x86/smp: Cure stop_other_cpus() and kexec() troubles
Status from this message: The following commit has been merged into the x86/core branch of tip:
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest7 patches 23 repliesApplied
- v28 patches 7 repliesSuperseded
Changes in v3 from the cover letter
- Use a CPU mask instead of an atomic counter and send the NMI only to CPUs which did not report that they reached HLT. That's still not race free vs. a late handling of the reboot vector, but that's not fixable.
Patches in v3 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/7 | x86/smp: Make stop_other_cpus() more robustarch/ arch/ arch/ | +73 | 8 replies | |
| 2/7 | x86/smp: Dont access non-existing CPUID leafarch/ | +3 | 3 replies | |
| 3/7 | x86/smp: Remove pointless wmb()s from native_stop_other_cpus()arch/ | +0 | 1 reply | |
| 4/7 | x86/smp: Use dedicated cache-line for mwait_play_dead()arch/ | +14 | 1 reply | |
| 5/7 | x86/smp: Cure kexec() vs. mwait_play_dead() breakagearch/ arch/ arch/ | +66 | 2 replies | |
| 6/7 | x86/smp: Split sending INIT IPI out into a helper functionarch/ | +20 | 2 replies | |
| 7/7 | x86/smp: Put CPUs into INIT on shutdown if possiblearch/ arch/ arch/ | +53 | 6 replies |
Reviews trailers per patch
All 7 patches have a Reviewed-by or Acked-by.
| Patch | Ashok Raj | Tony Battersby | Mario Limonciello | Borislav Petkov (AMD) | Baokun Li |
|---|---|---|---|---|---|
| 1/7 | R-b | T-b | R-b | ||
| 2/7 | R-b | R-b | |||
| 3/7 | R-b | ||||
| 4/7 | R-b | R-b | |||
| 5/7 | T-b R-b | ||||
| 6/7 | R-b | ||||
| 7/7 | R-b | R-b | Reported-and-tested-by |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.
Cover letter [patch v3 0/7] x86/smp: Cure stop_other_cpus() and kexec() troubles
This is the third version of the stop_other_cpus() / kexec() vs. mwait_play_dead() series. Version 2 can be found here:
https://lore.kernel.org/r/[email protected]
The two issues addressed are:
1) stop_other_cpus() continues after observing num_online_cpus() == 1.
This is problematic because the to be stopped CPUs clear their online bit first and then invoke eventually WBINVD, which can take a long time. There seems to be an interaction between the WBINVD and the reboot mechanics as this intermittendly results in hangs.
2) kexec() kernel can overwrite the memory locations which "offline" CPUs are monitoring. This write brings them out of MWAIT and they resume execution on overwritten text, page tables, data and stacks resulting in triple faults.
Cure them by:
#1 Synchronizing stop_other_cpus() with a CPU mask which is updated in
stop_this_cpu() _after_ WBINVD completes.
#2 Bringing offline CPUs out of MWAIT and move them into HLT before
starting the kexec() kernel. Optionaly send them an INIT IPI so they go back into wait for startup state.
Changes vs. V2:
- Use a CPU mask instead of an atomic counter and send the NMI only to CPUs which did not report that they reached HLT. That's still not race free vs. a late handling of the reboot vector, but that's not fixable.
Interestingly enough testing the NMI mechanics unearthed that after soft disabling the local APIC the CPU is _not_ handling the NMI despite the SDM claiming:
"The operation and response of a local APIC while in this software-disabled
state is as follows:
* The local APIC will respond normally to INIT, NMI, SMI, and SIPI messages."
I validated that even without handling the NMI, the CPU is kicked out of HLT reliably.
It's unclear whether that's X2APIC specific and I neither verified that behaviour on AMD. Nor is it clear what "respond normally" actually means.
The AMD APM is not helpful either:
"SMI, NMI, INIT, Startup, and Remote Read interrupts may be accepted"
Oh well.
The series is also available from git:
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git x86/kexec
Thanks,
tglx
--- include/asm/cpu.h | 2 include/asm/smp.h | 4 + kernel/process.c | 25 +++++++-- kernel/smp.c | 111 +++++++++++++++++++++++++++++----------- kernel/smpboot.c | 149 ++++++++++++++++++++++++++++++++++++++++-------------- 5 files changed, 220 insertions(+), 71 deletions(-)