KVM: x86: Ensure all logical CPUs have consistent reserved cr4 bits
authorSean Christopherson <sean.j.christopherson@intel.com>
Tue, 10 Dec 2019 22:44:14 +0000 (14:44 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 21 Jan 2020 12:58:05 +0000 (13:58 +0100)
Check the current CPU's reserved cr4 bits against the mask calculated
for the boot CPU to ensure consistent behavior across all CPUs.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c

index 8a907cd7b1e182c3d7c7c2f37e59beefad55a3a1..960b886e1e436090bff3589c1111535f22702c67 100644 (file)
@@ -9461,6 +9461,13 @@ void kvm_arch_hardware_unsetup(void)
 
 int kvm_arch_check_processor_compat(void)
 {
+       struct cpuinfo_x86 *c = &cpu_data(smp_processor_id());
+
+       WARN_ON(!irqs_disabled());
+
+       if (kvm_host_cr4_reserved_bits(c) != cr4_reserved_bits)
+               return -EIO;
+
        return kvm_x86_ops->check_processor_compatibility();
 }