Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1451995ybh; Fri, 13 Mar 2020 01:19:05 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvAV9a3oTiwOFZX2TSWRqp7LRty+eFTYev1Wu+J8JHhT94rjdn3SClhcMVhbMQnbPCjEOFa X-Received: by 2002:a05:6830:60e:: with SMTP id w14mr3024942oti.22.1584087545318; Fri, 13 Mar 2020 01:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584087545; cv=none; d=google.com; s=arc-20160816; b=jqGStEBAeCaH9hXz63ON6YwyXw8FIc/DQINZm6bV75ySlZhXlnXBU1Gpfkgv/weWQq ArHXbzOwUgqgafBaIKoEL7twi+lMiITTfNs4Q63gRj2zXfpfPw6tjQujF4jIwwM9klfc qrMAKFyek0hwTbqQhK0uFK/zzFWnpBgb7M6c1hvbnBsIp7Y71UGW1ItTfB7725lAbGsC mEX8718oLHxug8j53GvylE5PR3K1ngSoekNPycqWBXjvetwvPybNtRxuxcaI0MeJPEEd 2wjzdm2e3k6f3LQXpWJ5jAPqUqb84MJ+ncBK1r1B2agHRmaoLl4Tkg3KxZxUIcHD7h0n MAMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=9W5vTN/5yldWwJ7WFO5+AkbjB0CXv7qyOvqx0nLoARI=; b=xLx+YMoYKaV5+Ce0N7unzUAk9eFtL8nbUdReE/gapBCHQPZZDMEzjWgf5x4a6odxD4 xwCBZX5VcmO8jr07qYk1OTd/k4q8DqetbD89lxOJHGXwPPX62OwqDENKinjlxUmmI9Kh QUHHDD9shs+WI6M8aD9m/8LASJesxE2e3awUwowgGMcMSs+uW8SiajTNIKzPtUtpUXip 7MSD0xqJmBexudrEqRuR44ejQkB8PeWniKjBRoVwbrrM0bynyOzzXI4gn62mz8wwq9Vy Q68YT9WlDBfDYrAm3Ee2GzqJBCfYpuC7Akr2/FC3iLdkk6GUbn47RSZEeXO4pc6Imv6C Kxow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=e5Dd9wVT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v24si4537273otn.69.2020.03.13.01.18.53; Fri, 13 Mar 2020 01:19:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=e5Dd9wVT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726709AbgCMIR4 (ORCPT + 99 others); Fri, 13 Mar 2020 04:17:56 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:39372 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726669AbgCMIRu (ORCPT ); Fri, 13 Mar 2020 04:17:50 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 02D8HnIF071937; Fri, 13 Mar 2020 03:17:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1584087469; bh=9W5vTN/5yldWwJ7WFO5+AkbjB0CXv7qyOvqx0nLoARI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=e5Dd9wVT5i3NrsjBo95eIttKA1ZazTkjRvHWCPsC0Ti45zAhKJ6XRLkSHsedAFrXt 09Tnz7+dvrnRwUi/45UTYukXKpB+Bu2nxohoBqGAyJ4adcJnXABObDid7Mu8DixIWZ HdDSZrgjhWSaRAOBwM2N3x8G7RUKZIcVsvZ2N7Sg= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 02D8Hna2047435 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 13 Mar 2020 03:17:49 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Fri, 13 Mar 2020 03:17:49 -0500 Received: from localhost.localdomain (10.64.41.19) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Fri, 13 Mar 2020 03:17:49 -0500 Received: from sokoban.bb.dnainternet.fi (ileax41-snat.itg.ti.com [10.172.224.153]) by localhost.localdomain (8.15.2/8.15.2) with ESMTP id 02D8HQlf097835; Fri, 13 Mar 2020 03:17:47 -0500 From: Tero Kristo To: , , CC: , , , , Tero Kristo Subject: [PATCHv8 09/15] remoteproc/omap: Check for undefined mailbox messages Date: Fri, 13 Mar 2020 10:17:12 +0200 Message-ID: <20200313081718.30612-10-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200313081718.30612-1-t-kristo@ti.com> References: <20200313081718.30612-1-t-kristo@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suman Anna Add some checks in the mailbox callback function to limit any processing in the mailbox callback function to only certain currently valid messages, and drop all the remaining messages. A debug message is added to print any such invalid messages when the appropriate trace control is enabled. Co-developed-by: Subramaniam Chanderashekarapuram Signed-off-by: Subramaniam Chanderashekarapuram Signed-off-by: Suman Anna Signed-off-by: Tero Kristo Reviewed-by: Bjorn Andersson Reviewed-by: Andrew F. Davis Acked-by: Mathieu Poirier --- drivers/remoteproc/omap_remoteproc.c | 6 ++++++ drivers/remoteproc/omap_remoteproc.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c index 09eae548a691..7717a514d41a 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -130,6 +130,12 @@ static void omap_rproc_mbox_callback(struct mbox_client *client, void *data) dev_info(dev, "received echo reply from %s\n", name); break; default: + if (msg >= RP_MBOX_READY && msg < RP_MBOX_END_MSG) + return; + if (msg > oproc->rproc->max_notifyid) { + dev_dbg(dev, "dropping unknown message 0x%x", msg); + return; + } /* msg contains the index of the triggered vring */ if (rproc_vq_interrupt(oproc->rproc, msg) == IRQ_NONE) dev_dbg(dev, "no message was found in vqid %d\n", msg); diff --git a/drivers/remoteproc/omap_remoteproc.h b/drivers/remoteproc/omap_remoteproc.h index f6d2036d383d..72f656c93caa 100644 --- a/drivers/remoteproc/omap_remoteproc.h +++ b/drivers/remoteproc/omap_remoteproc.h @@ -56,6 +56,12 @@ * * @RP_MBOX_ABORT_REQUEST: a "please crash" request, used for testing the * recovery mechanism (to some extent). + * + * Introduce new message definitions if any here. + * + * @RP_MBOX_END_MSG: Indicates end of known/defined messages from remote core + * This should be the last definition. + * */ enum omap_rp_mbox_messages { RP_MBOX_READY = 0xFFFFFF00, @@ -64,6 +70,7 @@ enum omap_rp_mbox_messages { RP_MBOX_ECHO_REQUEST = 0xFFFFFF03, RP_MBOX_ECHO_REPLY = 0xFFFFFF04, RP_MBOX_ABORT_REQUEST = 0xFFFFFF05, + RP_MBOX_END_MSG = 0xFFFFFF06, }; #endif /* _OMAP_RPMSG_H */ -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki