[PATCH v3 03/44] arm64: Clarify initial unmasking of DAIF bits
Vladimir Murzin
vladimir.murzin at arm.com
Mon Nov 30 07:54:25 PST 2026
The exception masking state is built differently for the boot and
secondary CPUs.
For the boot CPU, the exception masking state is built step by step:
* Start with DAIF masked
* Unmask DA in setup_arch()
* Later, in smp_prepare_boot_cpu(), once the relevant boot CPU
features are discovered, update PMR if pseudo-NMI is supported
* Finally, in init_IRQ(), re-synchronize the state, allowing
pseudo-NMIs (again, if supported)
For secondary CPUs:
* Start with DAIF masked
* secondary_start_kernel() updates PMR if supported and unmasks DAIF
Both flows use the same local_daif_restore() helper to manipulate the
exception masking state. However, although there is no functional
issue, local_daif_restore() behaves differently depending on the
context in which it is invoked: part of its functionality depends on
CPU feature discovery. On the boot CPU, the relevant CPU features are
discovered in smp_prepare_boot_cpu() at the earliest, which means that
a call to local_daif_restore() prior to that, say in setup_arch(),
cannot do anything other than update DAIF. Although we end up with the
desired effect, this can still be confusing.
Clarify the initial unmasking of DAIF bits by:
* Replacing local_daif_restore() with a direct write to DAIF
* Updating the accompanying comment to explain that the exception
masking state is built step by step for the boot CPU
Signed-off-by: Vladimir Murzin <vladimir.murzin at arm.com>
---
arch/arm64/kernel/setup.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index a707deba6ae7..56c40575b39b 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -308,10 +308,14 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p)
* threads, and we want to unmask SError as soon as possible after
* initializing earlycon so that we can report any SErrors immediately.
*
- * IRQ and FIQ will be unmasked after the root irqchip has been
- * detected and initialized.
+ * Note, that exception state can depend on supported CPU features, yet
+ * those are discovered later on during primary CPU boot.
+ *
+ * IRQ and FIQ (and any form of supported NMI) will be unmasked after
+ * the root irqchip has been detected and initialized.
*/
- local_daif_restore(DAIF_PROCCTX_NOIRQ);
+ write_sysreg(DAIF_PROCCTX_NOIRQ, daif);
+ trace_hardirqs_off();
/*
* TTBR0 is only used for the identity mapping at this stage. Make it
--
2.34.1
More information about the linux-arm-kernel
mailing list