summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cpu/x86/smm/smm_stub.S19
-rw-r--r--src/include/cpu/x86/lapic.h2
2 files changed, 13 insertions, 8 deletions
diff --git a/src/cpu/x86/smm/smm_stub.S b/src/cpu/x86/smm/smm_stub.S
index 25a35aabbeed..c83839cc0131 100644
--- a/src/cpu/x86/smm/smm_stub.S
+++ b/src/cpu/x86/smm/smm_stub.S
@@ -101,25 +101,30 @@ smm_trampoline32:
* the OS can manipulate the APIC id use the non-changing cpuid result
* for APIC id (eax). A table is used to handle a discontiguous
* APIC id space. */
+apic_id:
+ mov $LAPIC_BASE_MSR, %ecx
+ rdmsr
+ and $LAPIC_BASE_X2APIC_ENABLED, %eax
+ cmp $LAPIC_BASE_X2APIC_ENABLED, %eax
+ jne xapic
- mov $0, %eax
- cpuid
- cmp $0xb, %eax
- jc 1f
+x2apic:
mov $0xb, %eax
mov $0, %ecx
cpuid
mov %edx, %eax
- jmp 2f
-1:
+ jmp apicid_end
+
+xapic:
mov $1, %eax
cpuid
mov %ebx, %eax
shr $24, %eax
-2:
+apicid_end:
mov $(apic_to_cpu_num), %ebx
xor %ecx, %ecx
+
1:
cmp (%ebx, %ecx, 2), %ax
je 1f
diff --git a/src/include/cpu/x86/lapic.h b/src/include/cpu/x86/lapic.h
index 7006dbce1cf7..c509e61b0818 100644
--- a/src/include/cpu/x86/lapic.h
+++ b/src/include/cpu/x86/lapic.h
@@ -126,7 +126,7 @@ static __always_inline int lapic_busy(void)
static __always_inline unsigned int initial_lapicid(void)
{
uint32_t lapicid;
- if (cpuid_get_max_func() >= 0xb)
+ if (is_x2apic_mode() && cpuid_get_max_func() >= 0xb)
lapicid = cpuid_ext(0xb, 0).edx;
else
lapicid = cpuid_ebx(1) >> 24;