mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Nicholas Piggin <npiggin@gmail.com>,
	linux-arch@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>
Subject: [RFC PATCH 2/3] init: Require archs call start_kernel with arch irqs disabled
Date: Tue,  9 May 2023 21:07:38 +1000	[thread overview]
Message-ID: <20230509110739.241735-3-npiggin@gmail.com> (raw)
In-Reply-To: <20230509110739.241735-1-npiggin@gmail.com>

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 <npiggin@gmail.com>
---
 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


  parent reply	other threads:[~2023-05-09 11:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-09 11:07 [RFC PATCH 0/3] Prohibit irq disable when disabled or enable when enabled Nicholas Piggin
2023-05-09 11:07 ` [RFC PATCH 1/3] hrtimer: balance irq save/restore Nicholas Piggin
2023-05-09 11:07 ` Nicholas Piggin [this message]
2023-05-09 11:07 ` [RFC PATCH 3/3] irqflags: Warn on irq disable when disabled and enable when enabled Nicholas Piggin
2023-05-22  8:25   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230509110739.241735-3-npiggin@gmail.com \
    --to=npiggin@gmail.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®