OSDN Git Service

KVM: nVMX: Check HOST_IA32_PERF_GLOBAL_CTRL on VM-Entry
authorOliver Upton <oupton@google.com>
Thu, 14 Nov 2019 00:17:17 +0000 (16:17 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 15 Nov 2019 10:44:14 +0000 (11:44 +0100)
Add a consistency check on nested vm-entry for host's
IA32_PERF_GLOBAL_CTRL from vmcs12. Per Intel's SDM Vol 3 26.2.2:

  If the "load IA32_PERF_GLOBAL_CTRL"
  VM-exit control is 1, bits reserved in the IA32_PERF_GLOBAL_CTRL
  MSR must be 0 in the field for that register"

Suggested-by: Jim Mattson <jmattson@google.com>
Co-developed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Signed-off-by: Oliver Upton <oupton@google.com>
Reviewed-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Peter Shier <pshier@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/nested.c

index 9190da3..ac896e9 100644 (file)
@@ -2676,6 +2676,11 @@ static int nested_vmx_check_host_state(struct kvm_vcpu *vcpu,
            CC(!kvm_pat_valid(vmcs12->host_ia32_pat)))
                return -EINVAL;
 
+       if ((vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL) &&
+           CC(!kvm_valid_perf_global_ctrl(vcpu_to_pmu(vcpu),
+                                          vmcs12->host_ia32_perf_global_ctrl)))
+               return -EINVAL;
+
 #ifdef CONFIG_X86_64
        ia32e = !!(vcpu->arch.efer & EFER_LMA);
 #else