Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4712532ybb; Tue, 24 Mar 2020 04:02:12 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuRFY1NoJIiKFQrVLhAbsmUIHbqXBa+ZFb69ovYbGVJIdw57hgP2qpBJqMsSLU6vusFBnwK X-Received: by 2002:a05:6808:90f:: with SMTP id w15mr3029917oih.0.1585047732409; Tue, 24 Mar 2020 04:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585047732; cv=none; d=google.com; s=arc-20160816; b=vzDoUokEr3V76GLk2fK0j7n23B/Pop92cRy13FK4fCVZADeNh+gbUr1nUdNnnf0P+W V+xgdQbbaJM1QTOc06D5OG8bO7l0xpV6iJ1CRIephcsmCldaaOQaj0vwqmvUKQ1xKYuu zisBIufVla0LcgRVO2YmQlTwEisuYsYKfd4SbIZb9iTIq7hInb4Hj44rbrGegnawpPlr 5ZYV+0stx1iErb31IDvb8jHCrMKtL7ESLoLFfWNOgf+pEWFWU7w8HRW6/4081PdyJ+LY 0btzTwZhaZGA5XMYPt1Ki9ypVKUnRq0Q/qmXWKOOhrysvKK/e0mCBGfYfKWtGrbS6Y5y 9/2w== 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=QMfgAm5QiuFVNQHvhtM8pgpbog8JhJ3gy4qHQT2LAPo=; b=SWIvESBegSyDYMMJXHC/Kzr7KIuNtdHqvyhjQvgl9FFxG91Q3UnoRtp6yUfLVrpVkl nUCY7FHSfsArYw5AfjL6q66+/IxbT3hODJH6rhqKlwW+U+3HNlZlJkY9MPQDZ6TKN3T4 2FgNuMQAumHstre3RqUc4QNwDzZlEjh7IgaAREEsFSZ0BmHpT27BwjCUcWS3yvL9CDOt IMgzj9Hr10AE4PeJm0N93pgVy3ZWvSkmKZTGyltzTIzQl8ejhB+iGFVtyGUs0I4xL2T3 B7lGdVPMw0lv1n1OVc1O8H2BFbi9UZ9wPM3IExTM0/kbUsMUna8m46UDwNw/uvCZYGVh hxpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=hV9H0uOh; 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 r6si4374631otc.12.2020.03.24.04.01.59; Tue, 24 Mar 2020 04:02:12 -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=hV9H0uOh; 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 S1727416AbgCXLBT (ORCPT + 99 others); Tue, 24 Mar 2020 07:01:19 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:56544 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727384AbgCXLBR (ORCPT ); Tue, 24 Mar 2020 07:01:17 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 02OB1GmT123999; Tue, 24 Mar 2020 06:01:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1585047676; bh=QMfgAm5QiuFVNQHvhtM8pgpbog8JhJ3gy4qHQT2LAPo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=hV9H0uOhRJqXKTWCZTp5+dA0C2JSqTPxc07ZvGlZ4YbbG/F+PwbgrckTazhXG2hja 4SmAb4lRZf5HWpyPXEstPl7fm1rKjNgFsTB5TuNnUHn+MZrlxQyrJkPHqGKL9iYFM8 v/8VeTVge4mBj68kvsAK4Chqu5abRFYEZ/z1+fO8= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 02OB1GJG109451; Tue, 24 Mar 2020 06:01:16 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 24 Mar 2020 06:01:15 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE111.ent.ti.com (10.64.6.32) 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; Tue, 24 Mar 2020 06:01:15 -0500 Received: from sokoban.bb.dnainternet.fi (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 02OB0rAt008648; Tue, 24 Mar 2020 06:01:13 -0500 From: Tero Kristo To: , , CC: , , , , Tero Kristo Subject: [PATCHv9 09/15] remoteproc/omap: Check for undefined mailbox messages Date: Tue, 24 Mar 2020 13:00:29 +0200 Message-ID: <20200324110035.29907-10-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200324110035.29907-1-t-kristo@ti.com> References: <20200324110035.29907-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 --- v9: * no changes 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 604499275896..5bccb5840a02 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