From 0834b222c9fd9c3e2b054b81581d2d03ad9dfbc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Sat, 8 Jul 2023 20:17:59 +0300 Subject: [PATCH] cpu/x86/lapic: Fix regression with X2APIC_LATE_WORKAROUND MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes the boot hang due to commit 053a45bcdb3ccf8 ("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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/76384 Reviewed-by: Subrata Banik Tested-by: build bot (Jenkins) --- src/cpu/x86/lapic/lapic.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cpu/x86/lapic/lapic.c b/src/cpu/x86/lapic/lapic.c index 24d2e37d47..8e0449a5fe 100644 --- a/src/cpu/x86/lapic/lapic.c +++ b/src/cpu/x86/lapic/lapic.c @@ -9,6 +9,8 @@ #include #include +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); }