Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5443251pxb; Wed, 26 Jan 2022 12:05:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNkSM9Rv/lLdiiNBoOGIZug1EXybzLG5JeDPsgpE42TVtDj20Ye/6KoyDSDq4mRc1fQC9I X-Received: by 2002:a17:90b:1a8a:: with SMTP id ng10mr525913pjb.151.1643227551895; Wed, 26 Jan 2022 12:05:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643227551; cv=none; d=google.com; s=arc-20160816; b=TNe1lEofwj4xssCg2L9RN9njPuTRDj8elp7eFkydW3zhimIAIZZoyVgNKRSlI9lsQH cIpAis/NZCUiEXiFatxKidwaR/ebU5BNGVA7rGp2rrO37OHFG1bmBsMVLecadLFQN4pa kjypcAemkPEMyo03ei789gIatNtAvzFpgV2zZ3l1UlHIdi6KYfZNgDEHG42k1SmawD3x bPiiiPPFzTvaz/BwzvCYm6jT14A4nbEHmtqhRPNUWbxipF1VBvcsj+5RQrkwg9A8r0uT 8NQpPMdpI8djCgQt3b18nLyzNPHrYTx8umw7cTknxlOdAQTDktMLe65t/JUIE3FysoUr nUEw== 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=UF2qpbrpB00ql4TtsfhNQvNuRxolvfsRxhWKsgUb0JV9NeWNccCN5S6dXrlkP3LTcs bFzW0OU11vdSySIlKXV3/vcAoBOdFPTs3reoKWvajPMjFXCooicjUsH7kdIXY8+T5lpQ f2KvpzT3eKBKNOMALmIwu4DnJLTqgSXqdrHINCWVFaCgaZE/qyNnFgPRdgas93XBGj4J WWBVaCBz8cz4dhTGMhuEL+3aP6fYOC5tHNvK2EJrdHXiaGtEebBOGPjy2xc70icbclog 52Tallzfvd1V3jTroz48E9Vwv/1BA0cN8MxqS0U86d5jmBhtVItv0evOnjRyG/jZhV9x YvHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=cs7Xjc9U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f4si214568pgj.488.2022.01.26.12.05.37; Wed, 26 Jan 2022 12:05:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=cs7Xjc9U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S236552AbiAZGdA (ORCPT + 99 others); Wed, 26 Jan 2022 01:33:00 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:48556 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235931AbiAZGcv (ORCPT ); Wed, 26 Jan 2022 01:32:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1643178771; x=1674714771; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=dHMURxnIsgonyHWuwt/5fkDXVTWfVe9P2gTB2bgBiiA=; b=cs7Xjc9U8ITEcqJxRSj2XPJ3/2K4gDAiAOPWOCh5HypmrRyFasj5sTlx R32ljRl4lQuV+b9/TPbNRfD/808ymLOyrRZHJnqbOCxcpiLG4UPmEwt/w pQ6WnWb9BxJimDt3LNKIV0ng2F1SLaWn+IazvGyJ54yluNiVXbHqXwWh1 k=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-02.qualcomm.com with ESMTP; 25 Jan 2022 22:32:50 -0800 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; 25 Jan 2022 22:32:47 -0800 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.922.19; Tue, 25 Jan 2022 22:32:47 -0800 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.922.19; Tue, 25 Jan 2022 22:32:44 -0800 From: Fenglin Wu To: , , CC: , , , , Subject: [PATCH v5 04/10] spmi: pmic-arb: check apid against limits before calling irq handler Date: Wed, 26 Jan 2022 14:31:46 +0800 Message-ID: <1643178713-17178-5-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1643178713-17178-1-git-send-email-quic_fenglinw@quicinc.com> References: <1643178713-17178-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: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) 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