[2/4] KVM: x86: Ensure all logical CPUs have consistent reserved cr4 bits
diff mbox series

Message ID 20191210224416.10757-3-sean.j.christopherson@intel.com
State New
Headers show
  • KVM: x86: Add checks on host-reserved cr4 bits
Related show

Commit Message

Sean Christopherson Dec. 10, 2019, 10:44 p.m. UTC
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>

I'm on the fence as to whether this is gratuitous or useful, which is
why it's a separate patch and not tagged for stable.

 arch/x86/kvm/x86.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff mbox series

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 321eecb4cffd..ab3a4104febf 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -9415,6 +9415,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();