[RFC PATCH 06/36] arm64: irq: introduce a helper for GIC priority initialization
Jinjie Ruan
ruanjinjie at huawei.com
Tue Jul 14 04:05:24 PDT 2026
On 7/14/2026 6:02 PM, Vladimir Murzin wrote:
> On 7/10/26 08:44, Jinjie Ruan wrote:
>>
>> On 7/9/2026 8:13 PM, Vladimir Murzin wrote:
>>> From: Ada Couprie Diaz <ada.coupriediaz at arm.com>
>>>
>>> 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 <ada.coupriediaz at arm.com>
>>> Signed-off-by: Vladimir Murzin <vladimir.murzin at arm.com>
>>> ---
>>> arch/arm64/include/asm/daifflags.h | 15 +++++++++++++++
>>> arch/arm64/kernel/irq.c | 7 +++----
>>> 2 files changed, 18 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/arch/arm64/include/asm/daifflags.h b/arch/arm64/include/asm/daifflags.h
>>> index 795b35128467..56341578e7e3 100644
>>> --- a/arch/arm64/include/asm/daifflags.h
>>> +++ b/arch/arm64/include/asm/daifflags.h
>>> @@ -141,4 +141,19 @@ static __always_inline void local_daif_inherit(struct pt_regs *regs)
>>> */
>>> write_sysreg(flags, daif);
>>> }
>>> +
>>> +/*
>>> + * 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)
>> Maybe switch_to_pmr_masking()?
>>
>
> I have no strong opinion on that, tbh.
>
> Having another look at the code made me think that this helper has
> only a single caller. Perhaps we should move the system_uses_irq_prio_masking()
> check from the caller into the helper, making it clear that the helper
> is specific to pNMI without having to inspect the call site.
I think it is fine to move system_uses_irq_prio_masking() check to the
helper.
>
> What do you reckon?
>
>>> +{
>>> + WARN_ON(read_sysreg(daif) & PSR_A_BIT);
>>> + lockdep_assert_irqs_disabled();
>>> +
>>> + gic_write_pmr(GIC_PRIO_IRQOFF);
>>> + write_sysreg(DAIF_PROCCTX, daif);
>> otherwise LGTM
>> Reviewed-by: Jinjie Ruan <ruanjinjie at huawei.com>
>>
>
> Thanks!
>
> Vladimir
>
>>> +}
>>> +
>>> #endif
>>> diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c
>>> index 9fafd826002b..c73faa30268d 100644
>>> --- a/arch/arm64/kernel/irq.c
>>> +++ b/arch/arm64/kernel/irq.c
>>> @@ -126,10 +126,9 @@ void __init init_IRQ(void)
>>>
>>> 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.
>>> + * Now that we have a stack for our IRQ handler,
>>> + * let's mask interrupts via the PMR.
>>> */
>>> - WARN_ON(read_sysreg(daif) & PSR_A_BIT);
>>> - local_daif_restore(DAIF_PROCCTX_NOIRQ);
>>> + local_interrupt_priority_init();
>>> }
>>> }
>>
>
>
More information about the linux-arm-kernel
mailing list