nVMX x86: Make nested_vmx_check_pml_controls() concise
authorKrish Sadhukhan <krish.sadhukhan@oracle.com>
Thu, 27 Sep 2018 18:33:27 +0000 (14:33 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 16 Oct 2018 22:29:41 +0000 (00:29 +0200)
Suggested-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Reviewed-by: Mark Kanda <mark.kanda@oracle.com>
Reviewed-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx.c

index 8efce8e..77ac8f5 100644 (file)
@@ -11779,15 +11779,12 @@ static int nested_vmx_check_msr_switch_controls(struct kvm_vcpu *vcpu,
 static int nested_vmx_check_pml_controls(struct kvm_vcpu *vcpu,
                                         struct vmcs12 *vmcs12)
 {
-       u64 address = vmcs12->pml_address;
-       int maxphyaddr = cpuid_maxphyaddr(vcpu);
+       if (!nested_cpu_has_pml(vmcs12))
+               return 0;
 
-       if (nested_cpu_has2(vmcs12, SECONDARY_EXEC_ENABLE_PML)) {
-               if (!nested_cpu_has_ept(vmcs12) ||
-                   !IS_ALIGNED(address, 4096)  ||
-                   address >> maxphyaddr)
-                       return -EINVAL;
-       }
+       if (!nested_cpu_has_ept(vmcs12) ||
+           !page_address_valid(vcpu, vmcs12->pml_address))
+               return -EINVAL;
 
        return 0;
 }