Skip to contentSkip to conversation

vVMX: adjust VMPTRLD error handling

PATCH In review Jan Beulich 2 participants 2 messages Jun 2, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vVMX: adjust VMPTRLD error handling

There are two issues there: When hvm_map_guest_frame_rw() yields a r/o page mapping, we fail to indicate the failure to the guest, and we fall over the NULL pointer in nvcpu->nv_vvmcx when subsequently invoking nvmx_set_vmcs_pointer() (if no earlier VMPTRLD put in place a valid value).

Fixes 5dbbaa0fe121 ("x86/vvmx: fix I/O and MSR bitmaps mapping")
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1820,7 +1820,7 @@ static int nvmx_handle_vmptrld(struct cp
                 vvmcx = NULL;
             }
         }
-        else
+        if ( !vvmcx )
         {
             vmfail(regs, VMX_INSN_VMPTRLD_INVALID_PHYADDR);
             goto out;
#1 lore raw
Quoted 13 lines · Jan Beulich

There are two issues there: When hvm_map_guest_frame_rw() yields a r/o page mapping, we fail to indicate the failure to the guest, and we fall over the NULL pointer in nvcpu->nv_vvmcx when subsequently invoking nvmx_set_vmcs_pointer() (if no earlier VMPTRLD put in place a valid value).

Fixes 5dbbaa0fe121 ("x86/vvmx: fix I/O and MSR bitmaps mapping")

xen/arch/x86/hvm/vmx/vvmx.c static int nvmx_handle_vmptrld(struct cp · line 1826

Quoted 8 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1820,7 +1820,7 @@ static int nvmx_handle_vmptrld(struct cp
                 vvmcx = NULL;
             }
         }
-        else
+        if ( !vvmcx )
         {
             vmfail(regs, VMX_INSN_VMPTRLD_INVALID_PHYADDR);
             goto out;

To go back to one of Manuel's original questions, there is no such thing as a read-only page in real hardware (write ignore is the closest), but I'm certain that hardware will give us VMPTRLD_INVALID_PHYADDR for e.g. trying to overlay the APIC MMIO page, so I think it is a reasonable to use for this purpose.

But, please insert a blank line.  I've spent 5 minutes thinking this patch was broken and trying to figure out how you'd covered the r/o case before realising I was reading it wrong.

With that, Reviewed-By: Andrew Cooper <[email protected]>

~Andrew