From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: linux-kernel@vger.kernel.org
Cc: x86@kernel.org, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, dave.hansen@linux.intel.com, peterz@infradead.org,
david.kaplan@amd.com, chang.seok.bae@intel.com
Subject: [PATCH 4/7] x86/microcode: Distinguish NMI control path on stop-machine callback
Date: Sun, 25 Jan 2026 01:42:19 +0000 [thread overview]
Message-ID: <20260125014224.249901-5-chang.seok.bae@intel.com> (raw)
In-Reply-To: <20260125014224.249901-1-chang.seok.bae@intel.com>
load_cpus_stopped() currently centralizes the stop_machine() callback for
both NMI and NMI-less rendezvous. microcode_update_handler() alone is
enough for the latter.
While the NMI-based rendezvous finally reaches the same update handler,
it requires additional logic to trigger and process NMIs. That machinery
will be replaced by stop_machine_nmi().
As preparation for that conversion, split the callback path to make
NMI-specific steps explicit and clear.
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
---
arch/x86/kernel/cpu/microcode/core.c | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index 68049f171860..28317176ae29 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -524,7 +524,7 @@ void noinstr microcode_offline_nmi_handler(void)
wait_for_ctrl();
}
-static noinstr bool microcode_update_handler(void)
+static noinstr int microcode_update_handler(void *unused)
{
unsigned int cpu = raw_smp_processor_id();
@@ -540,7 +540,7 @@ static noinstr bool microcode_update_handler(void)
touch_nmi_watchdog();
instrumentation_end();
- return true;
+ return 0;
}
/*
@@ -561,19 +561,15 @@ bool noinstr microcode_nmi_handler(void)
return false;
raw_cpu_write(ucode_ctrl.nmi_enabled, false);
- return microcode_update_handler();
+ return microcode_update_handler(NULL) == 0;
}
static int load_cpus_stopped(void *unused)
{
- if (microcode_ops->use_nmi) {
- /* Enable the NMI handler and raise NMI */
- this_cpu_write(ucode_ctrl.nmi_enabled, true);
- apic->send_IPI(smp_processor_id(), NMI_VECTOR);
- } else {
- /* Just invoke the handler directly */
- microcode_update_handler();
- }
+ /* Enable the NMI handler and raise NMI */
+ this_cpu_write(ucode_ctrl.nmi_enabled, true);
+ apic->send_IPI(smp_processor_id(), NMI_VECTOR);
+
return 0;
}
@@ -610,13 +606,13 @@ static int load_late_stop_cpus(bool is_safe)
*/
store_cpu_caps(&prev_info);
- if (microcode_ops->use_nmi)
+ if (microcode_ops->use_nmi) {
static_branch_enable_cpuslocked(µcode_nmi_handler_enable);
-
- stop_machine_cpuslocked(load_cpus_stopped, NULL, cpu_online_mask);
-
- if (microcode_ops->use_nmi)
+ stop_machine_cpuslocked(load_cpus_stopped, NULL, cpu_online_mask);
static_branch_disable_cpuslocked(µcode_nmi_handler_enable);
+ } else {
+ stop_machine_cpuslocked(microcode_update_handler, NULL, cpu_online_mask);
+ }
/* Analyze the results */
for_each_cpu_and(cpu, cpu_present_mask, &cpus_booted_once_mask) {
--
2.51.0
next prev parent reply other threads:[~2026-01-25 2:06 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-25 1:42 [PATCH 0/7] x86/microcode: Refactor NMI-based rendezvous mechanism to stop-machine Chang S. Bae
2026-01-25 1:42 ` [PATCH 1/7] stop_machine: Introduce stop_machine_nmi() Chang S. Bae
2026-01-26 11:51 ` kernel test robot
2026-01-27 14:49 ` Borislav Petkov
2026-01-27 19:15 ` Chang S. Bae
2026-01-27 15:49 ` Borislav Petkov
2026-01-27 16:00 ` Kaplan, David
2026-01-27 20:49 ` Borislav Petkov
2026-01-28 1:31 ` Kaplan, David
2026-01-28 16:35 ` Borislav Petkov
2026-01-29 12:17 ` Borislav Petkov
2026-01-29 15:47 ` Chang S. Bae
2026-02-02 10:54 ` Borislav Petkov
2026-02-06 2:14 ` Chang S. Bae
2026-03-04 16:33 ` Borislav Petkov
2026-01-28 8:02 ` Thomas Gleixner
2026-01-29 17:07 ` Chang S. Bae
2026-01-30 10:02 ` Thomas Gleixner
2026-01-25 1:42 ` [PATCH 2/7] x86/apic: Implement self-NMI support Chang S. Bae
2026-01-28 8:05 ` Thomas Gleixner
2026-01-29 16:32 ` Chang S. Bae
2026-01-25 1:42 ` [PATCH 3/7] x86/nmi: Support stop_machine_nmi() handler Chang S. Bae
2026-01-25 1:42 ` Chang S. Bae [this message]
2026-01-28 8:11 ` [PATCH 4/7] x86/microcode: Distinguish NMI control path on stop-machine callback Thomas Gleixner
2026-01-29 16:32 ` Chang S. Bae
2026-01-25 1:42 ` [PATCH 5/7] x86/microcode: Use stop-machine NMI facility Chang S. Bae
2026-01-25 1:42 ` [PATCH 6/7] x86/nmi: Reference stop-machine static key for offline microcode handler Chang S. Bae
2026-01-25 1:42 ` [PATCH 7/7] x86/microcode: Remove microcode_nmi_handler_enable Chang S. Bae
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=20260125014224.249901-5-chang.seok.bae@intel.com \
--to=chang.seok.bae@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=david.kaplan@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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®