Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp879843iol; Sat, 11 Jun 2022 23:11:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwULFLdRJmvr3wMTpyLBuMkl5oEGVJVR1akMAkvxlCB3Mlhm4TnsivDfjyDUCIkz95y71KL X-Received: by 2002:a05:6402:1f0e:b0:42d:e38a:51f7 with SMTP id b14-20020a0564021f0e00b0042de38a51f7mr60358340edb.68.1655014312194; Sat, 11 Jun 2022 23:11:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655014312; cv=none; d=google.com; s=arc-20160816; b=rQQoRGaspECdW9AdCpsdHlXKnPgn42DVdkV08cu5nVVqG83qJgFq1C/vioB5wNrWy3 S8PK/bCjIhWiRLHNxQ8Qow0UIDf0fZVEPBFF2/6GdlpgmLo+NNyNEfdOg94+IfO1mEQJ IzlDpvCt2l4ONMLvcW0k9avZE3JN/Xk/8nCY2S2ELcz0zxDf0udEk4vUTmT3t11E0QTp Y2Y1izus0BCDOr+kNtHbih7tk0lXSuPdatVbGbYy+hbCaCPK/r3WA7CFXI9PHwqQmOgl JyCx0I4jEgxJ6PWl6ebQoIRlmqBnbbCH0ldfV19fZus1qNWu/cLE2TFoo1NS2/ysajqy cF8Q== 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=usT4/buVx7PGd19cz44/ikxt/9hbuWQPQBDZLcJeGN5aSfoR2WLenCO8blSygTgkGq VBQxNBeyr/PMC4/c4uX6+Sdssn0Ew7FosGIScTTlg8H0lwtPtplXjgPxmXVedp0Xzu0Y HmzVBdvA187kXfwazbIgf6J++p2WyUtw4pyyIWpmDhhmBcm7QYH/TJaBr23sb6Tgg6QY OxDQdt/k8wOS4VE2atecP4XsXNE79xGRftp6g82Pu8Ngarr4Sffv5LUr2BcVHjCEs3CP 7PQniocUYoZ+D2c1Rc/Cb7CVK7+MaeNOLVDP0Bycnh4hFXN+VOpIq/PzeMWxh3pQeFYN b1eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=YJ52NowK; 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 j25-20020a50ed19000000b0042ac84c9a4esi4098012eds.445.2022.06.11.23.11.26; Sat, 11 Jun 2022 23:11:52 -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=YJ52NowK; 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 S234014AbiFLDZg (ORCPT + 99 others); Sat, 11 Jun 2022 23:25:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233797AbiFLDZY (ORCPT ); Sat, 11 Jun 2022 23:25:24 -0400 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBC2666C9C; Sat, 11 Jun 2022 20:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1655004322; x=1686540322; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=dHMURxnIsgonyHWuwt/5fkDXVTWfVe9P2gTB2bgBiiA=; b=YJ52NowKYKBPL7bLAF4/1cULgD5IaZkCnd1NkbErzGZKn22TeD3vOwbH xsoZ5+Yr1PwVqNuYon8T+qZbi1amssScS+sW7F1ciRrMSek2posCzC1wp gpuBCIwlXZG0Kb46JdUCBmjZkWCWXa0eiDXSxCTr+k4P7yO0mR+fsI5WJ A=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-02.qualcomm.com with ESMTP; 11 Jun 2022 20:25:22 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2022 20:25:22 -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; Sat, 11 Jun 2022 20:25:22 -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; Sat, 11 Jun 2022 20:25:19 -0700 From: Fenglin Wu To: , , CC: , , , , , "David Collins" Subject: [RESEND PATCH v6 04/10] spmi: pmic-arb: check apid against limits before calling irq handler Date: Sun, 12 Jun 2022 11:24:40 +0800 Message-ID: <1655004286-11493-5-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1655004286-11493-1-git-send-email-quic_fenglinw@quicinc.com> References: <1655004286-11493-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