From 176c8877ce8820ecc4f74748c83ab993b938eac6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Sat, 29 May 2021 20:33:22 +0300 Subject: [PATCH] cpu/x86/lapic: Add Kconfig choice LAPIC_ACCESS_MODE MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Allows compile-time optimisation on platforms that do not wish to enable runtime checking of X2APIC. Legacy lapic_cpu_init() is incompatible so there is dependency on PARALLEL_MP. Also stop_this_cpu() is incompatible, so there is dependency on !AP_IN_SIPI_WAIT. Since the code actually lacks enablement of X2APIC (apparently assuming the blob has done it) and the other small flaws pointed out in earlier reviews, X2APIC_RUNTIME is not selected per default on any platform yet. Change-Id: I8269f9639ee3e89a2c2b4178d266ba2dac46db3f Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/55073 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans Reviewed-by: Angel Pons Reviewed-by: Wonkyu Kim --- src/cpu/x86/Kconfig | 22 ++++++++++++++++++++++ src/cpu/x86/lapic/lapic.c | 4 ++++ src/include/cpu/x86/lapic.h | 6 ++++++ 3 files changed, 32 insertions(+) diff --git a/src/cpu/x86/Kconfig b/src/cpu/x86/Kconfig index 7aba5c4658..d7057ad861 100644 --- a/src/cpu/x86/Kconfig +++ b/src/cpu/x86/Kconfig @@ -17,6 +17,28 @@ config PARALLEL_MP_AP_WORK config LEGACY_SMP_INIT bool +choice LAPIC_ACCESS_MODE + prompt "APIC operation mode" + default XAPIC_ONLY + +config XAPIC_ONLY + prompt "Set XAPIC mode" + bool + +config X2APIC_ONLY + prompt "Set X2APIC mode" + bool + depends on PARALLEL_MP + depends on !AP_IN_SIPI_WAIT + +config X2APIC_RUNTIME + prompt "Support both XAPIC and X2APIC" + bool + depends on PARALLEL_MP + depends on !AP_IN_SIPI_WAIT + +endchoice + config UDELAY_LAPIC bool default n diff --git a/src/cpu/x86/lapic/lapic.c b/src/cpu/x86/lapic/lapic.c index a5b4cd5047..09dd00397e 100644 --- a/src/cpu/x86/lapic/lapic.c +++ b/src/cpu/x86/lapic/lapic.c @@ -3,6 +3,10 @@ #include #include +#if !CONFIG(XAPIC_ONLY) +#error "BUG: lapic_write_around() needs to be fixed for X2APIC." +#endif + void lapic_virtual_wire_mode_init(void) { /* this is so interrupts work. This is very limited scope -- diff --git a/src/include/cpu/x86/lapic.h b/src/include/cpu/x86/lapic.h index ab2843f69a..2de5dd57df 100644 --- a/src/include/cpu/x86/lapic.h +++ b/src/include/cpu/x86/lapic.h @@ -10,6 +10,12 @@ static inline bool is_x2apic_mode(void) { + if (CONFIG(XAPIC_ONLY)) + return false; + + if (CONFIG(X2APIC_ONLY)) + return true; + msr_t msr; msr = rdmsr(LAPIC_BASE_MSR); return ((msr.lo & LAPIC_BASE_X2APIC_ENABLED) == LAPIC_BASE_X2APIC_ENABLED); -- 2.11.4.GIT