diff mbox series

[1/2,v2] nVMX x86: Make nested_vmx_check_pml_controls() concise

Message ID 20180927182126.9846-2-krish.sadhukhan@oracle.com (mailing list archive)
State New, archived
Headers show
Series [1/2,v2] nVMX x86: Make nested_vmx_check_pml_controls() concise | expand

Commit Message

Krish Sadhukhan Sept. 27, 2018, 6:21 p.m. UTC
Suggested-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Reviewed-by: Mark Kanda <mark.kanda@oracle.com>
---
 arch/x86/kvm/vmx.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Jim Mattson Sept. 27, 2018, 6:59 p.m. UTC | #1
On Thu, Sep 27, 2018 at 11:21 AM, Krish Sadhukhan
<krish.sadhukhan@oracle.com> wrote:
> 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>
diff mbox series

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 533a327..2f8e0b9 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -11706,15 +11706,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;
 }