Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp127198pxb; Mon, 18 Oct 2021 22:32:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdJjTWuE7f1ABrAPwvZMV3z51R2Gm9+3pQ841YSM8RV9593mlsZszzqwnllS15sF7agdI9 X-Received: by 2002:aa7:db85:: with SMTP id u5mr51009880edt.234.1634621550357; Mon, 18 Oct 2021 22:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634621550; cv=none; d=google.com; s=arc-20160816; b=Hym/9lmJAtfW9iSUUVaB5Rna5XgPoEd0HDGC2F8s6eaz05/VNU/LSMqsB5OBaFywox pOmo0V4wOwK3EQSLzcsOaspwEQsCOTLjP1I2jYm5swjxDkUIcQeBAzwM9q+cAahYA3v4 RSfQLkrAj6kmUCGO+bMdWqfnnY3UCxpiTChZqNUNRnQqTafNq5mPPh1AMw/CBa3E8ucl XGHM9sgp2WuuAxSKxY4w44s4bbP3W3SFc6dxOtyDfEC3pGHNHaOkQsTGAW+2W87XZxef ec3j74ypGCiiG6CWYx4fs5At24rirdZpQ88Gj4c8OHJEi/OIeBIqwFI7b6ihuB72R0uH Ht1Q== 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=6IMGfTuF3BVQ6/1Vk5UOBnvjkDqjWlq1aGTwIYOXs9w=; b=t7W4CyobbosVUbiZNEh+fOa4vBsGqbyo27FkkhEhJUZCXcKELUdr8TpUZxBqUZhIdp b8DYkjCZvhQ0YPoQknyyTR40LGd2trm/pk3bUxTFQI917Uc/3WJzqnMUk6IQSBkctYxE ppzO+0PMW1RNdPE6MZHBYsNjle59jJZCt9IdaxG6DSlOyw/z9tWNeZmMgWFGDs3sriM8 rXDeQUA+elZjRgIbHote76PliU4WZnOAgD1TthtqvzPHaDCeAMDCSzvXfa401c8H2LqE bOXC0AP76Z7Kqt8Zwvla4WZCxc+hUhIz4o7inGcuhDCYrbjsjmQBDQnsYF7FM2HL3hOU 9HoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=QAfJ2xto; 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 dp16si41093149ejc.686.2021.10.18.22.32.06; Mon, 18 Oct 2021 22:32:30 -0700 (PDT) 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=QAfJ2xto; 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 S233353AbhJSFcR (ORCPT + 99 others); Tue, 19 Oct 2021 01:32:17 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:40351 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233342AbhJSFcP (ORCPT ); Tue, 19 Oct 2021 01:32:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1634621404; x=1666157404; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=6IMGfTuF3BVQ6/1Vk5UOBnvjkDqjWlq1aGTwIYOXs9w=; b=QAfJ2xtoaq5EXT8XnSCEoszqCMts5mQ+rPYnGv1jtl5zv4e33x8pDnPr qv/iMFGg/90zUnxUSJSg/EqspePPi7ntUMarn2+dMjzwSA5/bpvuKspt0 izYfwhxj3vCIDHbaG3PBK2Xu5uSV9zGd0iDIlfwJ7u3QbJmQtHtlwggG+ Q=; Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 18 Oct 2021 22:30:04 -0700 X-QCInternal: smtphost Received: from nalasex01c.na.qualcomm.com ([10.47.97.35]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2021 22:30:03 -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.922.7; Mon, 18 Oct 2021 22:30:01 -0700 From: Fenglin Wu To: , , CC: , , , , Subject: [PATCH v2 03/10] spmi: pmic-arb: check apid against limits before calling irq handler Date: Tue, 19 Oct 2021 13:29:14 +0800 Message-ID: <1634621361-17155-4-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1634621361-17155-1-git-send-email-quic_fenglinw@quicinc.com> References: <1634621361-17155-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) 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 ce7ae99..479f721 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -523,21 +523,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