[Devel] [PATCH RHEL7 COMMIT] ms/kvm: x86: CPUID.01H:EDX.APIC[bit 9] should mirror IA32_APIC_BASE[11]

Konstantin Khorenko khorenko at virtuozzo.com
Tue Jun 27 19:35:22 MSK 2017


The commit is pushed to "branch-rh7-3.10.0-514.16.1.vz7.32.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.16.1.vz7.32.11
------>
commit 225fa8d744054d649199bbfe4544ec0f9c5bc180
Author: Jim Mattson <jmattson at google.com>
Date:   Tue Jun 27 20:35:22 2017 +0400

    ms/kvm: x86: CPUID.01H:EDX.APIC[bit 9] should mirror IA32_APIC_BASE[11]
    
    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 <jmattson at google.com>
    [Changed subject tag from nVMX to x86.]
    Signed-off-by: Radim Krčmář <rkrcmar at redhat.com>
    
    (cherry picked from commit c7dd15b33707e99c2b66da44a2a280638b4cd14f)
    https://jira.sw.ru/browse/PSBM-63209
    
    Signed-off-by: Denis Plotnikov <dplotnikov at virtuozzo.com>
---
 arch/x86/kvm/cpuid.c |  4 ++++
 arch/x86/kvm/lapic.c | 11 +++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 7f642df..e245bf66 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -82,6 +82,10 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu)
 			best->ecx |= F(OSXSAVE);
 	}
 
+	best->edx &= ~F(APIC);
+	if (vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE)
+		best->edx |= F(APIC);
+
 	if (apic) {
 		if (best->ecx & F(TSC_DEADLINE_TIMER))
 			apic->lapic_timer.timer_mode_mask = 3 << 17;
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 374a21b..cac46a5 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1688,14 +1688,17 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value)
 	u64 old_value = vcpu->arch.apic_base;
 	struct kvm_lapic *apic = vcpu->arch.apic;
 
-	if (!apic) {
+	if (!apic)
 		value |= MSR_IA32_APICBASE_BSP;
-		vcpu->arch.apic_base = value;
-		return;
-	}
 
 	vcpu->arch.apic_base = value;
 
+	if ((old_value ^ value) & MSR_IA32_APICBASE_ENABLE)
+		kvm_update_cpuid(vcpu);
+
+	if (!apic)
+		return;
+
 	/* update jump label if enable bit changes */
 	if ((old_value ^ value) & MSR_IA32_APICBASE_ENABLE) {
 		if (value & MSR_IA32_APICBASE_ENABLE) {


More information about the Devel mailing list