Skip to content

Commit c7dd15b

Browse files
jsmattsonjrrkrcmar
authored andcommitted
kvm: x86: CPUID.01H:EDX.APIC[bit 9] should mirror IA32_APIC_BASE[11]
From the Intel SDM, volume 3, section 10.4.3, "Enabling or Disabling the Local APIC," When IA32_APIC_BASE[11] is 0, the processor is functionally equivalent to an IA-32 processor without an on-chip APIC. The CPUID feature flag for the APIC (see Section 10.4.2, "Presence of the Local APIC") is also set to 0. Signed-off-by: Jim Mattson <[email protected]> [Changed subject tag from nVMX to x86.] Signed-off-by: Radim Krčmář <[email protected]>
1 parent 4504b5c commit c7dd15b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

arch/x86/kvm/cpuid.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu)
8787
best->ecx |= F(OSXSAVE);
8888
}
8989

90+
best->edx &= ~F(APIC);
91+
if (vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE)
92+
best->edx |= F(APIC);
93+
9094
if (apic) {
9195
if (best->ecx & F(TSC_DEADLINE_TIMER))
9296
apic->lapic_timer.timer_mode_mask = 3 << 17;

arch/x86/kvm/lapic.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,14 +1806,17 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value)
18061806
u64 old_value = vcpu->arch.apic_base;
18071807
struct kvm_lapic *apic = vcpu->arch.apic;
18081808

1809-
if (!apic) {
1809+
if (!apic)
18101810
value |= MSR_IA32_APICBASE_BSP;
1811-
vcpu->arch.apic_base = value;
1812-
return;
1813-
}
18141811

18151812
vcpu->arch.apic_base = value;
18161813

1814+
if ((old_value ^ value) & MSR_IA32_APICBASE_ENABLE)
1815+
kvm_update_cpuid(vcpu);
1816+
1817+
if (!apic)
1818+
return;
1819+
18171820
/* update jump label if enable bit changes */
18181821
if ((old_value ^ value) & MSR_IA32_APICBASE_ENABLE) {
18191822
if (value & MSR_IA32_APICBASE_ENABLE) {

0 commit comments

Comments
 (0)