Skip to content

Commit 558682b

Browse files
whitebrandyKAGA-KOKO
authored andcommitted
x86/apic: Include the LDR when clearing out APIC registers
Although APIC initialization will typically clear out the LDR before setting it, the APIC cleanup code should reset the LDR. This was discovered with a 32-bit KVM guest jumping into a kdump kernel. The stale bits in the LDR triggered a bug in the KVM APIC implementation which caused the destination mapping for VCPUs to be corrupted. Note that this isn't intended to paper over the KVM APIC bug. The kernel has to clear the LDR when resetting the APIC registers except when X2APIC is enabled. This lacks a Fixes tag because missing to clear LDR goes way back into pre git history. [ tglx: Made x2apic_enabled a function call as required ] Signed-off-by: Bandan Das <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent bae3a8d commit 558682b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/x86/kernel/apic/apic.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,10 @@ void clear_local_APIC(void)
11791179
apic_write(APIC_LVT0, v | APIC_LVT_MASKED);
11801180
v = apic_read(APIC_LVT1);
11811181
apic_write(APIC_LVT1, v | APIC_LVT_MASKED);
1182+
if (!x2apic_enabled()) {
1183+
v = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
1184+
apic_write(APIC_LDR, v);
1185+
}
11821186
if (maxlvt >= 4) {
11831187
v = apic_read(APIC_LVTPC);
11841188
apic_write(APIC_LVTPC, v | APIC_LVT_MASKED);

0 commit comments

Comments
 (0)