Skip to content

Commit 0ecc5be

Browse files
ytcoodeKAGA-KOKO
authored andcommitted
x86/apic: Make x2apic_disable() work correctly
x2apic_disable() clears x2apic_state and x2apic_mode unconditionally, even when the state is X2APIC_ON_LOCKED, which prevents the kernel to disable it thereby creating inconsistent state. Due to the early state check for X2APIC_ON, the code path which warns about a locked X2APIC cannot be reached. Test for state < X2APIC_ON instead and move the clearing of the state and mode variables to the place which actually disables X2APIC. [ tglx: Massaged change log. Added Fixes tag. Moved clearing so it's at the right place for back ports ] Fixes: a57e456 ("x86/apic: Fix fallout from x2apic cleanup") Signed-off-by: Yuntao Wang <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/all/[email protected]
1 parent 7c626ce commit 0ecc5be

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

arch/x86/kernel/apic/apic.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,12 +1775,9 @@ static __init void apic_set_fixmap(bool read_apic);
17751775

17761776
static __init void x2apic_disable(void)
17771777
{
1778-
u32 x2apic_id, state = x2apic_state;
1778+
u32 x2apic_id;
17791779

1780-
x2apic_mode = 0;
1781-
x2apic_state = X2APIC_DISABLED;
1782-
1783-
if (state != X2APIC_ON)
1780+
if (x2apic_state < X2APIC_ON)
17841781
return;
17851782

17861783
x2apic_id = read_apic_id();
@@ -1793,6 +1790,10 @@ static __init void x2apic_disable(void)
17931790
}
17941791

17951792
__x2apic_disable();
1793+
1794+
x2apic_mode = 0;
1795+
x2apic_state = X2APIC_DISABLED;
1796+
17961797
/*
17971798
* Don't reread the APIC ID as it was already done from
17981799
* check_x2apic() and the APIC driver still is a x2APIC variant,

0 commit comments

Comments
 (0)