cpu/x86/lapic: Fix regression with X2APIC_LATE_WORKAROUND

This patch fixes the boot hang due to commit 053a45bcdb ("cpu/x86/lapic: Fix X2APIC_ONLY regression") on platform which selects X2APIC_LATE_WORKAROUND config.

 [EMERG]  Switching from X2APIC to XAPIC mode is not implemented.

Without this patch: Boot gets stuck inside at BS_WRITE_TABLES when enable_lapic() gets called after X2APIC mode has been enabled. The fix is to change enable_lapic() to track when late enablement for X2APIC mode happens with X2APIC_LATE_WORKAROUND.

TEST=Able to build and boot google/rex to chromeos.

Change-Id: I41e72380e9cfb59721d0df607ad875d7b6546974
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/76384
Reviewed-by: Subrata Banik <subratabanik@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Kyösti Mälkki 2023-07-08 20:17:59 +03:00 committed by Subrata Banik
parent 3c1b7b485b
commit 0834b222c9
1 changed files with 7 additions and 1 deletions

View File

@ -9,6 +9,8 @@
#include <smp/node.h>
#include <types.h>
static bool quirk_x2apic_allowed;
void enable_lapic_mode(bool try_set_x2apic)
{
uintptr_t apic_base;
@ -46,14 +48,18 @@ void enable_lapic_mode(bool try_set_x2apic)
die("Switching from X2APIC to XAPIC mode is not implemented.");
}
if (CONFIG(X2APIC_LATE_WORKAROUND) && use_x2apic)
quirk_x2apic_allowed = true;
}
void enable_lapic(void)
{
bool try_set_x2apic = true;
if (CONFIG(XAPIC_ONLY) || CONFIG(X2APIC_LATE_WORKAROUND))
if (CONFIG(XAPIC_ONLY))
try_set_x2apic = false;
else if (CONFIG(X2APIC_LATE_WORKAROUND))
try_set_x2apic = quirk_x2apic_allowed;
enable_lapic_mode(try_set_x2apic);
}