[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260125014224.249901-7-chang.seok.bae@intel.com>
Date: Sun, 25 Jan 2026 01:42:21 +0000
From: "Chang S. Bae" <chang.seok.bae@...el.com>
To: linux-kernel@...r.kernel.org
Cc: x86@...nel.org,
tglx@...utronix.de,
mingo@...hat.com,
bp@...en8.de,
dave.hansen@...ux.intel.com,
peterz@...radead.org,
david.kaplan@....com,
chang.seok.bae@...el.com
Subject: [PATCH 6/7] x86/nmi: Reference stop-machine static key for offline microcode handler
The microcode loader now uses stop-machine facility for NMI-based
loading. During the rendezvous, the stop-machine static key is enabled
and can be queried via stop_machine_nmi_handler_enabled(). Reference this
on the offline handling path.
Previously, the microcode-specific static key helper returned false when
CONFIG_MICROCODE_LATE_LOADING=n. Since the offline handler is also built
only with that option, the helper effectively acted as a guard to avoid
referencing the handler symbol when it was not present. With the removal,
to avoid build issues, introduce a one-line helper.
Signed-off-by: Chang S. Bae <chang.seok.bae@...el.com>
---
Note on an alternative option:
Rather than keeping this loader-specific handler, stop-machine facility
could be extended further to call-back to handle offline cases. Then, the
microcode loader however will be the only user of that. Instead, just
switching to check the stop-machine helper looks to be simple enough.
---
arch/x86/include/asm/microcode.h | 5 +++--
arch/x86/kernel/nmi.c | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h
index 946b0cebed87..a4e4ea8acf99 100644
--- a/arch/x86/include/asm/microcode.h
+++ b/arch/x86/include/asm/microcode.h
@@ -77,15 +77,16 @@ static inline u32 intel_get_microcode_revision(void)
}
#endif /* !CONFIG_CPU_SUP_INTEL */
-void microcode_offline_nmi_handler(void);
-
#ifdef CONFIG_MICROCODE_LATE_LOADING
+void microcode_offline_nmi_handler(void);
+
DECLARE_STATIC_KEY_FALSE(microcode_nmi_handler_enable);
static __always_inline bool microcode_nmi_handler_enabled(void)
{
return static_branch_unlikely(µcode_nmi_handler_enable);
}
#else
+static __always_inline void microcode_offline_nmi_handler(void) { }
static __always_inline bool microcode_nmi_handler_enabled(void) { return false; }
#endif
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 642469f3be80..52bc844354de 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -548,7 +548,7 @@ DEFINE_IDTENTRY_RAW(exc_nmi)
raw_atomic_long_inc(&nsp->idt_calls);
if (arch_cpu_is_offline(smp_processor_id())) {
- if (microcode_nmi_handler_enabled())
+ if (stop_machine_nmi_handler_enabled())
microcode_offline_nmi_handler();
return;
}
@@ -711,7 +711,7 @@ DEFINE_FREDENTRY_NMI(exc_nmi)
irqentry_state_t irq_state;
if (arch_cpu_is_offline(smp_processor_id())) {
- if (microcode_nmi_handler_enabled())
+ if (stop_machine_nmi_handler_enabled())
microcode_offline_nmi_handler();
return;
}
--
2.51.0
Powered by blists - more mailing lists