2023-05-09 11:14:14

by Nicholas Piggin

[permalink] [raw]
Subject: [RFC PATCH 2/3] init: Require archs call start_kernel with arch irqs disabled

Let's require start_kernel() is called with arch_irqs_disabled. For now,
just correct that condition and print a warning if CONFIG_DEBUG_IRQFLAGS
is set.

This prevents core code from disabling irqs when they are already
disabled, in aid of eventually adding a debug check to catch that
condition.

Signed-off-by: Nicholas Piggin <[email protected]>
---
init/main.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/init/main.c b/init/main.c
index af50044deed5..f3979628943e 100644
--- a/init/main.c
+++ b/init/main.c
@@ -889,7 +889,11 @@ asmlinkage __visible void __init __no_sanitize_address __noreturn start_kernel(v

cgroup_init_early();

- local_irq_disable();
+ if (!raw_irqs_disabled()) {
+ raw_local_irq_disable();
+ if (IS_ENABLED(CONFIG_DEBUG_IRQFLAGS))
+ WARN_ONCE(1, "arch should call start_kernel with arch_irqs_disabled\n");
+ }
early_boot_irqs_disabled = true;

/*
--
2.40.1