Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/55198 )
Change subject: [RFC,WIP] cpu/x86/lapic: Evaluate x2apic_mode just once ......................................................................
[RFC,WIP] cpu/x86/lapic: Evaluate x2apic_mode just once
TBD: Actually set and test.
Change-Id: Iff4f5dc50999f977eaf9b32e7caebf098a3600fe Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/cpu/x86/lapic/Makefile.inc M src/cpu/x86/lapic/lapic.c M src/include/cpu/x86/lapic.h 3 files changed, 9 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/55198/1
diff --git a/src/cpu/x86/lapic/Makefile.inc b/src/cpu/x86/lapic/Makefile.inc index 5ec234b..7d2f952 100644 --- a/src/cpu/x86/lapic/Makefile.inc +++ b/src/cpu/x86/lapic/Makefile.inc @@ -1,4 +1,4 @@ -ramstage-y += lapic.c +all-y += lapic.c ramstage-$(CONFIG_AP_IN_SIPI_WAIT) += lapic_cpu_stop.c ramstage-$(CONFIG_LEGACY_CPU_INIT) += lapic_cpu_init.c ramstage-$(CONFIG_LEGACY_CPU_INIT) += secondary.S diff --git a/src/cpu/x86/lapic/lapic.c b/src/cpu/x86/lapic/lapic.c index 3c0273e..dc61ea7 100644 --- a/src/cpu/x86/lapic/lapic.c +++ b/src/cpu/x86/lapic/lapic.c @@ -5,6 +5,8 @@ #include <console/console.h> #include <stdint.h>
+int x2apic_mode_enabled; + uintptr_t cpu_get_lapic_addr(void) { return LAPIC_DEFAULT_BASE; diff --git a/src/include/cpu/x86/lapic.h b/src/include/cpu/x86/lapic.h index 583d72a..3c860ab 100644 --- a/src/include/cpu/x86/lapic.h +++ b/src/include/cpu/x86/lapic.h @@ -7,6 +7,9 @@ #include <cpu/x86/msr.h> #include <halt.h> #include <stdint.h> +#include <smp/node.h> + +extern int x2apic_mode_enabled;
static __always_inline uint32_t xapic_read(unsigned int reg) { @@ -78,9 +81,7 @@ 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); + return x2apic_mode_enabled; }
static __always_inline uint32_t lapic_read(unsigned int reg) @@ -147,6 +148,8 @@ msr.lo &= ~LAPIC_BASE_MSR_X2APIC_MODE; if (CONFIG(X2APIC_ONLY)) msr.lo |= LAPIC_BASE_MSR_X2APIC_MODE; + if (CONFIG(X2APIC_RUNTIME) && boot_cpu()) + x2apic_mode_enabled = !!(msr.lo & LAPIC_BASE_MSR_X2APIC_MODE);
wrmsr(LAPIC_BASE_MSR, msr); }