x86/vvmx: Correct the INVALID_PADDR checks for VMPTRLD/VMCLEAR
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 1 Nov 2018 17:37:48 +0000 (17:37 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 23 Nov 2018 13:46:59 +0000 (13:46 +0000)
The referenced addresses also need checking against MAXPHYSADDR.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
xen/arch/x86/hvm/vmx/vvmx.c

index c296660e38126113475177988f007c305de2ad00..5daab82dc05391e91da04c48040769c0ac36d52e 100644 (file)
@@ -1672,7 +1672,7 @@ static int nvmx_handle_vmptrld(struct cpu_user_regs *regs)
     if ( rc != X86EMUL_OKAY )
         return rc;
 
-    if ( gpa & 0xfff )
+    if ( (gpa & ~PAGE_MASK) || !gfn_valid(v->domain, gaddr_to_gfn(gpa)) )
     {
         vmfail(regs, VMX_INSN_VMPTRLD_INVALID_PHYADDR);
         goto out;
@@ -1780,7 +1780,7 @@ static int nvmx_handle_vmclear(struct cpu_user_regs *regs)
         goto out;
     }
 
-    if ( gpa & 0xfff )
+    if ( (gpa & ~PAGE_MASK) || !gfn_valid(v->domain, gaddr_to_gfn(gpa)) )
     {
         vmfail(regs, VMX_INSN_VMCLEAR_INVALID_PHYADDR);
         goto out;