Skip to content

Commit 720a22f

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
x86/apic: Don't access the APIC when disabling x2APIC
With 'iommu=off' on the kernel command line and x2APIC enabled by the BIOS the code which disables the x2APIC triggers an unchecked MSR access error: RDMSR from 0x802 at rIP: 0xffffffff94079992 (native_apic_msr_read+0x12/0x50) This is happens because default_acpi_madt_oem_check() selects an x2APIC driver before the x2APIC is disabled. When the x2APIC is disabled because interrupt remapping cannot be enabled due to 'iommu=off' on the command line, x2apic_disable() invokes apic_set_fixmap() which in turn tries to read the APIC ID. This triggers the MSR warning because x2APIC is disabled, but the APIC driver is still x2APIC based. Prevent that by adding an argument to apic_set_fixmap() which makes the APIC ID read out conditional and set it to false from the x2APIC disable path. That's correct as the APIC ID has already been read out during early discovery. Fixes: d10a904 ("x86/apic: Consolidate boot_cpu_physical_apicid initialization sites") Reported-by: Adrian Huang <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Tested-by: Adrian Huang <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/875xw5t6r7.ffs@tglx
1 parent 400fea4 commit 720a22f

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

arch/x86/kernel/apic/apic.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ void x2apic_setup(void)
17711771
__x2apic_enable();
17721772
}
17731773

1774-
static __init void apic_set_fixmap(void);
1774+
static __init void apic_set_fixmap(bool read_apic);
17751775

17761776
static __init void x2apic_disable(void)
17771777
{
@@ -1793,7 +1793,12 @@ static __init void x2apic_disable(void)
17931793
}
17941794

17951795
__x2apic_disable();
1796-
apic_set_fixmap();
1796+
/*
1797+
* Don't reread the APIC ID as it was already done from
1798+
* check_x2apic() and the APIC driver still is a x2APIC variant,
1799+
* which fails to do the read after x2APIC was disabled.
1800+
*/
1801+
apic_set_fixmap(false);
17971802
}
17981803

17991804
static __init void x2apic_enable(void)
@@ -2057,13 +2062,14 @@ void __init init_apic_mappings(void)
20572062
}
20582063
}
20592064

2060-
static __init void apic_set_fixmap(void)
2065+
static __init void apic_set_fixmap(bool read_apic)
20612066
{
20622067
set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
20632068
apic_mmio_base = APIC_BASE;
20642069
apic_printk(APIC_VERBOSE, "mapped APIC to %16lx (%16lx)\n",
20652070
apic_mmio_base, mp_lapic_addr);
2066-
apic_read_boot_cpu_id(false);
2071+
if (read_apic)
2072+
apic_read_boot_cpu_id(false);
20672073
}
20682074

20692075
void __init register_lapic_address(unsigned long address)
@@ -2073,7 +2079,7 @@ void __init register_lapic_address(unsigned long address)
20732079
mp_lapic_addr = address;
20742080

20752081
if (!x2apic_mode)
2076-
apic_set_fixmap();
2082+
apic_set_fixmap(true);
20772083
}
20782084

20792085
/*

0 commit comments

Comments
 (0)