Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp985171pxp; Wed, 16 Mar 2022 23:30:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+Z2I3cv+3hBsZjjod2yb0tSK+fDvbQCNiwZL9CE7xgmiL5/IhJByDNUjzIZvw8TgpZfrq X-Received: by 2002:a05:6402:50ce:b0:416:798c:b167 with SMTP id h14-20020a05640250ce00b00416798cb167mr2813857edb.136.1647498654466; Wed, 16 Mar 2022 23:30:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647498654; cv=none; d=google.com; s=arc-20160816; b=KbtEdbhgePsl1WQeO0S5YaSTmrcfkY5nuQ/P2p92ShuUJp3RGPPSYa0bpk26J7kDUZ 8WllXD+HCX1pk0HGQifsP4Q/U7JaZtD8ECKucNArCp4OQdtAwJu0PXaEqIhLxKslmKmd /zlsC+K3blyCADuGXug0USxZjwXdjApuoxXvcLT1qRnJww+ZTVk1STczArE13vNKAvki ajaq4uRnhPPV6hrBJJ3liL/8dAaaG66yUskqRA2DEeGHqgjxL4DkLVfccimgm4b5Z7Wj y2yo+ZknzCzR/zC3uogXDWOsxWVZDf/fIpDoETQYbVfaiuMcqtQne+GCXJn7J9QwlxVi nQMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dHMURxnIsgonyHWuwt/5fkDXVTWfVe9P2gTB2bgBiiA=; b=eYjRlf/sphluusRDAhLvBfgobBe8zUDfzGxSHKFy3dZYqZsXjF0Y0R7Kl40pUFUzGU pEbp09auUCKF+mpB5ObsjqQt7O64h2lOp8RSt7mti6+VK/R+f1nxuaX64RM10HuVTEVK u10l3YqZT0gBg7V7ipI2iuxWV8PptwXFBvgjyfrP2Kfym62oldy3m5DCDk7/tpk9EmBI Gq1jU9Aba6DrOEcXgw6jbVpqz1KyXWaeMOnsWdSFU30fIKhkgKrfMRVIEgLrrncR+aKo YAr0DkISK8be44QomQHh80atpBDy6T/kVgL7Uhy42A1zg3z665lpfGGYovkFYOenOdde i6BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=eWWCc5OC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p20-20020a170906615400b006cfbb200709si2411226ejl.900.2022.03.16.23.30.29; Wed, 16 Mar 2022 23:30:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=eWWCc5OC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230037AbiCQGXn (ORCPT + 99 others); Thu, 17 Mar 2022 02:23:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230003AbiCQGWj (ORCPT ); Thu, 17 Mar 2022 02:22:39 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77E6911CF59; Wed, 16 Mar 2022 23:12:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1647497571; x=1679033571; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=dHMURxnIsgonyHWuwt/5fkDXVTWfVe9P2gTB2bgBiiA=; b=eWWCc5OCg1uGBX8dn20wREk2RL2dgZLsEhwu28bmxMCO+jhGvMGMD4Hw 6mYPS1da9NjYDBq52NHXXtT5KvbBuc2uQQrqIOBz4vNse0vYnGWALNYy/ eBHcaL6AW3aZRYpFYGPZ9ENaarOry743w0nv+yzj7RIVzYazq+6pxnc0F c=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-01.qualcomm.com with ESMTP; 16 Mar 2022 23:12:51 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2022 23:12:51 -0700 Received: from nalasex01c.na.qualcomm.com (10.47.97.35) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 16 Mar 2022 23:12:50 -0700 Received: from fenglinw-gv.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 16 Mar 2022 23:12:48 -0700 From: Fenglin Wu To: , , CC: , , , , Subject: [PATCH v6 04/10] spmi: pmic-arb: check apid against limits before calling irq handler Date: Thu, 17 Mar 2022 14:12:09 +0800 Message-ID: <1647497535-32151-5-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1647497535-32151-1-git-send-email-quic_fenglinw@quicinc.com> References: <1647497535-32151-1-git-send-email-quic_fenglinw@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Collins Check that the apid for an SPMI interrupt falls between the min_apid and max_apid that can be handled by the APPS processor before invoking the per-apid interrupt handler: periph_interrupt(). This avoids an access violation in rare cases where the status bit is set for an interrupt that is not owned by the APPS processor. Signed-off-by: David Collins Signed-off-by: Fenglin Wu --- drivers/spmi/spmi-pmic-arb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c index 2bc3b88..e19eaec 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -625,21 +625,26 @@ static void pmic_arb_chained_irq(struct irq_desc *desc) struct spmi_pmic_arb *pmic_arb = irq_desc_get_handler_data(desc); const struct pmic_arb_ver_ops *ver_ops = pmic_arb->ver_ops; struct irq_chip *chip = irq_desc_get_chip(desc); - int first = pmic_arb->min_apid >> 5; - int last = pmic_arb->max_apid >> 5; + int first = pmic_arb->min_apid; + int last = pmic_arb->max_apid; u8 ee = pmic_arb->ee; u32 status, enable, handled = 0; int i, id, apid; chained_irq_enter(chip, desc); - for (i = first; i <= last; ++i) { + for (i = first >> 5; i <= last >> 5; ++i) { status = readl_relaxed( ver_ops->owner_acc_status(pmic_arb, ee, i)); while (status) { id = ffs(status) - 1; status &= ~BIT(id); apid = id + i * 32; + if (apid < first || apid > last) { + WARN_ONCE(true, "spurious spmi irq received for apid=%d\n", + apid); + continue; + } enable = readl_relaxed( ver_ops->acc_enable(pmic_arb, apid)); if (enable & SPMI_PIC_ACC_ENABLE_BIT) -- 2.7.4