From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F3D1606A32F for ; Mon, 30 Nov 2026 11:15:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=vlWT2SRe; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=CrlYbOdo DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:References:Cc:To:From:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=8QXyvYyG8m/sEWBHJKj0JW7/DBMArbvjeK5ggI8eRhE=; b=vlWT2SRetSQISe gmy0WY/T0mufI4bWktkxdHevpo7zV30JB64TWtue4hB9FdX4lbpEs09g7MTDl5x4ZohTK5zd1KC4c Z692f7DwEB2Nl0EUMmIH4ICg/JDdpsMOhVxASskE97kDmQ/NbhB5I878h5wwrUy6Dq/hrMNso5kKi WAotCPQDKEOI7iZLaIvzyGxFCCjvJm7Gqp1DBEGb8NfUsV45kFi3fynr7zLgwrV/K77JsBCkIBFc3 ZfegTJpHbBP+WZup8f/0xOv++L/3eaHuF8GsWTrMb15SWqLdaD//DGT0svnQPTwMtCOcTA6Sfa3Ot xuXO3Y0lTj3RoF+IZ+yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXzLb-00000004HwT-3UQi; Mon, 30 Nov 2026 11:15:03 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXzLU-00000004Huf-15tR for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2026 11:15:02 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AAC081570; Mon, 30 Nov 2026 03:14:49 -0800 (PST) Received: from [10.0.154.42] (e121487-lin.cambridge.arm.com [10.0.154.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D89D33F86F; Mon, 30 Nov 2026 03:14:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796037292; bh=GbOH9lNmHp7gos+/GXwJOhwuGCTzVhOb36dZN2599W4=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=CrlYbOdoyUEz94mCMW4ye20U0e2czOI9YThtNEkYRvikGjGGLKoayo+xMKWfdkxig N+RL2GvZRggcCoYfw04TqK9m4nmYwOADdYwqUDYS6sH6YVljByibkmeyAKMeSaM4I2 XPca3Udl1PGPppyrrxuJPoKqbzGr++IMxgbvYLsk= Message-ID: Date: Mon, 30 Nov 2026 11:14:49 +0000 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 08/39] arm64: interrupts: introduce a helper for GIC priority initialization From: Vladimir Murzin To: linux-arm-kernel@lists.infradead.org Cc: mark.rutland@arm.com, catalin.marinas@arm.com, lpieralisi@kernel.org, liaochang1@huawei.com, ashok.raj@oss.qualcomm.com, maz@kernel.org, will@kernel.org, ruanjinjie@huawei.com References: <20261112132042.129062-1-vladimir.murzin@arm.com> <20261112132042.129062-9-vladimir.murzin@arm.com> Content-Language: en-GB In-Reply-To: <20261112132042.129062-9-vladimir.murzin@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261130_031456_388106_A032A1A9 X-CRM114-Status: GOOD ( 28.01 ) X-Spam-Score: -4.4 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On 11/12/26 13:20, Vladimir Murzin wrote: > From: Ada Couprie Diaz > > Arm64's `init_IRQ()` calls `local_daif_restore()` to synchronize > interrupt masking via DAIF and switch to masking via PMR. This > depends on a very specific behaviour of `local_daif_restore()` which > will clear DAIF if masking interrupts via PMR, which will get removed > in the future. > > As `setup_arch()` cleared DA only earlier, introduce a dedicated > helper that explicitly initializes the PMR to mask interrupts and > clears DAIF, switching to IRQ priority masking. > > Given it is a dedicated helper, add a lockdep assertion as > `setup_arch()` should always have called `trace_hardirqs_off()` when > clearing DA, otherwise something bad happened. > > Signed-off-by: Ada Couprie Diaz > Signed-off-by: Vladimir Murzin > Reviewed-by: Jinjie Ruan > Tested-by: Jinjie Ruan > --- > arch/arm64/include/asm/interrupts/masking.h | 19 +++++++++++++++++++ > arch/arm64/kernel/irq.c | 14 +++++--------- > 2 files changed, 24 insertions(+), 9 deletions(-) > > diff --git a/arch/arm64/include/asm/interrupts/masking.h b/arch/arm64/include/asm/interrupts/masking.h > index db3439853b64..9e589bf11ec8 100644 > --- a/arch/arm64/include/asm/interrupts/masking.h > +++ b/arch/arm64/include/asm/interrupts/masking.h > @@ -5,6 +5,8 @@ > #ifndef __ASM_INTERRUPTS_MASKING_H > #define __ASM_INTERRUPTS_MASKING_H > > +#include > + > #include > #include > #include > @@ -89,4 +91,21 @@ static inline void local_exceptions_final_mask(void) > __local_exceptions_final_mask(); > } > #endif /* CONFIG_DEBUG_IRQFLAGS */ > + > +/* > + * During early boot, we unmask PSR.DA before the GIC has been set up. > + * If we use IRQ priority masking, the PMR and PSR will be out of sync > + * after the GIC is enabled : sync them up. > + */ > +static inline void local_interrupt_priority_init(void) > +{ > + if (!system_uses_irq_prio_masking()) > + return; > + > + WARN_ON(read_sysreg(daif) & PSR_A_BIT); > + lockdep_assert_irqs_disabled(); > + > + arm64_update_exc_context(NOIRQ_CONTEXT); > +} > + > #endif /* __ASM_INTERRUPTS_MASKING_H */ > diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c > index 58b778083576..a3d9128ba195 100644 > --- a/arch/arm64/kernel/irq.c > +++ b/arch/arm64/kernel/irq.c > @@ -21,7 +21,6 @@ > #include > #include > #include > -#include > #include > #include > #include > @@ -131,14 +130,11 @@ void __init init_IRQ(void) > > irqchip_init(); > > - if (system_uses_irq_prio_masking()) { > - /* > - * Now that we have a stack for our IRQ handler, set > - * the PMR/PSR pair to a consistent state. > - */ > - WARN_ON(read_sysreg(daif) & PSR_A_BIT); > - local_daif_restore(DAIF_PROCCTX_NOIRQ); > - } > + /* > + * Now that we have a stack for our IRQ handler, > + * let's mask interrupts via the PMR. > + */ > + local_interrupt_priority_init(); Having a go over boot CPU path made me think we do not need this helper: - by this point we have arm64_debug_exc_context() helper, so DAIF check can be replaced with arm64_debug_exc_context(NONMI_CONTEXT) which better reflects expected exception state. - we have just introduced local_exceptions_cpu_init_mask(), but next patch uses it only in secondary CPU path which brings unnecessary asymmetry. There is no reasons we cannot use local_exceptions_cpu_init_mask() here: CPU features are discovered and helper would do right thing for both pseudo-NMI and (later) for FEAT_NMI. So I'm inclined to drop this patch and update the next one with: @@ -131,14 +130,8 @@ void __init init_IRQ(void) irqchip_init(); - if (system_uses_irq_prio_masking()) { - /* - * Now that we have a stack for our IRQ handler, set - * the PMR/PSR pair to a consistent state. - */ - WARN_ON(read_sysreg(daif) & PSR_A_BIT); - local_daif_restore(DAIF_PROCCTX_NOIRQ); - } + arm64_debug_exc_context(NONMI_CONTEXT); + local_exceptions_cpu_init_mask(NOIRQ_CONTEXT); } Cheers Vladimir > } > > #ifdef CONFIG_DEBUG_IRQFLAGS > -- 2.34.1 >