In lapic_resume, ensure x2apic is actually disabled when the kernel expects it to be disabled, i.e. when x2apic_mode = 0. x2apic_mode is set to 0 and x2apic is disabled on boot if the kernel doesn't support irq remapping or for other reasons. On resume from s2ram (/sys/power/mem_sleep = deep), firmware can re-enable x2apic, but the kernel continues using the xapic interface because it didn't check to see if someone enabled x2apic behind its back, which causes hangs. This situation happens on defconfig + bare metal + s2ram, on which this fix has been tested. Fixes: 6e1cb38a2aef ("x64, x2apic/intr-remap: add x2apic support, including enabling interrupt-remapping") Cc: stable@vger.kernel.org Co-developed-by: Rahul Bukte Signed-off-by: Rahul Bukte Signed-off-by: Shashank Balaji --- arch/x86/kernel/apic/apic.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index d93f87f29d03..cc64d61f82cf 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2456,6 +2456,12 @@ static void lapic_resume(void *data) if (x2apic_mode) { __x2apic_enable(); } else { + /* + * x2apic may have been re-enabled by the + * firmware on resuming from s2ram + */ + __x2apic_disable(); + /* * Make sure the APICBASE points to the right address * -- 2.43.0