cpu/x86/lapic: Add Kconfig choice LAPIC_ACCESS_MODE
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 <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55073
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Wonkyu Kim <wonkyu.kim@intel.com>
diff --git a/src/cpu/x86/Kconfig b/src/cpu/x86/Kconfig
index 7aba5c4..d7057ad 100644
--- a/src/cpu/x86/Kconfig
+++ b/src/cpu/x86/Kconfig
@@ -17,6 +17,28 @@
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 a5b4cd5..09dd003 100644
--- a/src/cpu/x86/lapic/lapic.c
+++ b/src/cpu/x86/lapic/lapic.c
@@ -3,6 +3,10 @@
#include <cpu/x86/lapic.h>
#include <console/console.h>
+#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 --