From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=113.46.200.221 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796009719; b=lO/ZYYmw4UcQpCjSAZ5xpT1E0Tc/48phny9w00vBfAn/TYUvCFkx1AU6E31biQ8QZNw4 7lBTPRuIpOA6q2cc7qI28shaKY/G7ppSsD5VtmsNGRDsGB2k/Ee/Ug0XKj2pmvcbstRY0 lBbC1ZCoX+5Nb87vM7JB0PUXVjv3sFNDkpq+V7yhirabbJ27E3uzv2prTtT1SntRYHWZ4 sWdGdw4WpYUW5cFAj30BMTj1kTHdvGbKj5JsdCC5M8cLw+v4hFYjaZi88aDoYNWmzfySi 7GIhcT8aeLDDsk8QZNxfFM8YyClIW7cxALfnO3GgvljDDwRbPSocNr3PyCffyXXYoeQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796009719; h=DMARC-Filter:dkim-signature:Received:Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:CC:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding:X-Originating-IP: X-ClientProxiedBy; bh=s24QVB7qXncpXg+DDKWDbZ3KNq0jw7OEU2tcfRFtblQ=; b=V2MD8EFnefgCFHJDKMYq843JpBGCnRaLzcnw75CkqAfVlURhplCYtys3fE2iKY+c3EmU RLbtJA7SqLLkMznpLbNoyfiUjFwgBf/V6MXXg/nEGju31GE+fEWmx4BcYPPXsyF1wKyWx tea1SoqDlxUMPX5818bltQh2gZKtyk2NMTAulgtL8mxYPCEAxTIWxuaCvFnv32UmvV/51 jpT+PQhi+hDStRyfxHveXTFBT+JobaFVBMS7MY7lNiaeCuTq3t+4U+xWw2wzj7FVKzPTC OTRPZmtUfKO+DbJQmZQNNf52nZteG9v5Y+v7Uk8l2tke+AcfXJqOS8yzcl0OmIkemag== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=scXP8BDP; arc=none smtp.remote-ip=113.46.200.221 Received: from canpmsgout06.his.huawei.com (canpmsgout06.his.huawei.com [113.46.200.221]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2041606A31C; Mon, 30 Nov 2026 03:35:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F2041606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=scXP8BDP dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=s24QVB7qXncpXg+DDKWDbZ3KNq0jw7OEU2tcfRFtblQ=; b=scXP8BDPqlu/SpLg2RNbJjpiWlfX9FnbS1f1veAHkc5jm5N5GArOX9oVGshDJWWhte/iUQTEb Gd2RADqxpcmWOSWkC+c+SFyuOKxsM15hXBE405Pdi2ABhYLXMHDaf+1so9n4ec1dAd9VgGZQ6mg 6ZAdpp5BdTRUD83HxPrx4Ms= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout06.his.huawei.com (SkyGuard) with ESMTPS id 4jd8lw2crJzRhsR; Mon, 30 Nov 2026 11:34:52 +0800 (CST) Received: from kwepemk200008.china.huawei.com (unknown [7.202.194.74]) by mail.maildlp.com (Postfix) with ESMTPS id D1D7740561; Mon, 30 Nov 2026 11:35:13 +0800 (CST) Received: from [10.67.110.68] (10.67.110.68) by kwepemk200008.china.huawei.com (7.202.194.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Mon, 30 Nov 2026 11:35:12 +0800 Message-ID: Date: Mon, 30 Nov 2026 11:35:12 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/3] arm64: entry: sdei: save and restore PMR for pseudo-NMI To: Ada Couprie Diaz , CC: Will Deacon , Mark Rutland , Catalin Marinas , Vladimir Murzin , James Morse , Usama Arif , Marc Zyngier , Kiryl Shutsemau , Breno Leitao , Doug Anderson , Linus Walleij , Peter Zijlstra , Thomas Huth , Dawei Li , mrigendrachaubey , , , References: <20261123171557.140944-1-ada.coupriediaz@arm.com> <20261123171557.140944-3-ada.coupriediaz@arm.com> From: Jinjie Ruan In-Reply-To: <20261123171557.140944-3-ada.coupriediaz@arm.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemk200008.china.huawei.com (7.202.194.74) 在 2026/11/24 1:15, Ada Couprie Diaz 写道: > When using pseudo-NMIs, the PMR affects if IRQs are disabled > and is not updated by the CPU on exception entry/exit. It must be saved > and restored to/from pt_regs, as the DAIF bits are, so that > `regs_irqs_disabled()` can reliably work with pseudo-NMIs. > > We do so in the regular entry path, and set it to a known value > reflecting that DAIF is masking all interrupts. > Do the same for SDEI, as it can interrupt the kernel at any point > and does not mandate firmware to touch PMR, but does mandate masking DAIF. > > This makes `regs_irqs_disabled()` reliable in the SDEI handler with > pseudo-NMIs enabled, which is critical as the return path to the kernel > depends on if the interrupted task had IRQs disabled or not. > This also avoids returning to the interrupted task with a different PMR > and a possible DAIF/PMR mismatch, as expected by the rest of the kernel. > > Fixes: 133d05186325 ("arm64: Make PMR part of task context") > Cc: stable@vger.kernel.org > Signed-off-by: Ada Couprie Diaz > --- > arch/arm64/kernel/entry-common.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c > index cb122163a68d..91afd1a36ec6 100644 > --- a/arch/arm64/kernel/entry-common.c > +++ b/arch/arm64/kernel/entry-common.c > @@ -1067,6 +1067,16 @@ __sdei_handler(struct pt_regs *regs, struct sdei_registered_event *arg) > else if (cpu_has_pan()) > set_pstate_pan(0); > > + /* > + * Regular kernel entry saves and resets the PMR to align with DAIF, > + * but __sdei_asm_handler() does not ; do it now. > + */ > + if (system_uses_irq_prio_masking()) { > + regs->pmr = read_sysreg_s(SYS_ICC_PMR_EL1); > + write_sysreg_s(GIC_PRIO_IRQON | GIC_PRIO_PSR_I_SET, > + SYS_ICC_PMR_EL1); > + } Reviewed-by: Jinjie Ruan > + > /* > * Nothing saved the interrupted context's exception registers on the > * way in, and it may be in the middle of exception entry or return > @@ -1110,6 +1120,9 @@ __sdei_handler(struct pt_regs *regs, struct sdei_registered_event *arg) > write_sysreg(far, far_el1); > write_sysreg(vbar, vbar_el1); > > + if (system_uses_irq_prio_masking()) > + write_sysreg_s(regs->pmr, SYS_ICC_PMR_EL1); > + > return ret; > } > #endif /* CONFIG_ARM_SDE_INTERFACE */