lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 20 Aug 2020 17:42:03 -0700
From:   Ashok Raj <>
To:, Thomas Gleixner <>
Cc:     Ashok Raj <>,
        Sukumar Ghorai <>,
        Srikanth Nandamuri <>,
        Evan Green <>,
        Mathias Nyman <>,
        Bjorn Helgaas <>,
Subject: [PATCH v2] x86/hotplug: Silence APIC only after all irq's are migrated

When offlining CPUs, fixup_irqs() migrates all interrupts away from the
outgoing CPU to an online CPU. It's always possible the device sent an
interrupt to the previous CPU destination. Pending interrupt bit in IRR in
LAPIC identifies such interrupts. apic_soft_disable() will not capture any
new interrupts in IRR. This causes interrupts from device to be lost during
CPU offline. The issue was found when explicitly setting MSI affinity to a
CPU and immediately offlining it. It was simple to recreate with a USB
ethernet device and doing I/O to it while the CPU is offlined. Lost
interrupts happen even when Interrupt Remapping is enabled.

Current code does apic_soft_disable() before migrating interrupts.

	  --> fixup_irqs(); // Too late to capture anything in IRR.

Just flipping the above call sequence seems to hit the IRR checks
and the lost interrupt is fixed for both legacy MSI and when
interrupt remapping is enabled.

Fixes: 60dcaad5736f ("x86/hotplug: Silence APIC and NMI when CPU is dead")
Reported-by: Evan Green <>
Tested-by: Mathias Nyman <>
Tested-by: Evan Green <>
Reviewed-by: Evan Green <>
Signed-off-by: Ashok Raj <>
- Typos and fixes suggested by Randy Dunlap

To: Thomas Gleixner <>
Cc: Sukumar Ghorai <>
Cc: Srikanth Nandamuri <>
Cc: Evan Green <>
Cc: Mathias Nyman <>
Cc: Bjorn Helgaas <>
 arch/x86/kernel/smpboot.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 27aa04a95702..3016c3b627ce 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1594,13 +1594,20 @@ int native_cpu_disable(void)
 	if (ret)
 		return ret;
+	cpu_disable_common();
 	 * Disable the local APIC. Otherwise IPI broadcasts will reach
 	 * it. It still responds normally to INIT, NMI, SMI, and SIPI
-	 * messages.
+	 * messages. It's important to do apic_soft_disable() after
+	 * fixup_irqs(), because fixup_irqs() called from cpu_disable_common()
+	 * depends on IRR being set. After apic_soft_disable() CPU preserves
+	 * currently set IRR/ISR but new interrupts will not set IRR.
+	 * This causes interrupts sent to outgoing CPU before completion
+	 * of IRQ migration to be lost. Check SDM Vol 3 " Local
+	 * APIC State after It Has been Software Disabled" section for more
+	 * details.
-	cpu_disable_common();
 	return 0;

Powered by blists - more mailing lists