Skip to contentSkip to conversation

KVM: VMX: Print VM-instruction error when it may be helpful

PATCH Superseded Jim Mattson 2 participants 3 messages May 8, 2022 – May 10, 2022

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 KVM: VMX: Print VM-instruction error when it may be helpful

From: David Matlack <[email protected]>

Include the value of the "VM-instruction error" field from the current VMCS (if any) in the error message for VMCLEAR and VMPTRLD, since each of these instructions may result in more than one VM-instruction error. Previously, this field was only reported for VMWRITE errors.

[Rebased and refactored code; dropped the error number for INVVPID and INVEPT; reworded commit message.]

---
 arch/x86/kvm/vmx/vmx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx/vmx.c +4 -2
index d58b763df855..a25da991da07 100644
@@ -392,12 +392,14 @@ noinline void vmwrite_error(unsigned long field, unsigned long value)
 
 noinline void vmclear_error(struct vmcs *vmcs, u64 phys_addr)
 {
-	vmx_insn_failed("kvm: vmclear failed: %p/%llx\n", vmcs, phys_addr);
+	vmx_insn_failed("kvm: vmclear failed: %p/%llx err=%d\n",
+			vmcs, phys_addr, vmcs_read32(VM_INSTRUCTION_ERROR));
 }
 
 noinline void vmptrld_error(struct vmcs *vmcs, u64 phys_addr)
 {
-	vmx_insn_failed("kvm: vmptrld failed: %p/%llx\n", vmcs, phys_addr);
+	vmx_insn_failed("kvm: vmptrld failed: %p/%llx err=%d\n",
+			vmcs, phys_addr, vmcs_read32(VM_INSTRUCTION_ERROR));
 }
 
 noinline void invvpid_error(unsigned long ext, u16 vpid, gva_t gva)
Signature · 1 line
2.36.0.512.ge40c2bad7a-goog
#1 lore raw
Quoted 20 lines · Jim Mattson

From: David Matlack <[email protected]>

Include the value of the "VM-instruction error" field from the current VMCS (if any) in the error message for VMCLEAR and VMPTRLD, since each of these instructions may result in more than one VM-instruction error. Previously, this field was only reported for VMWRITE errors.

[Rebased and refactored code; dropped the error number for INVVPID and INVEPT; reworded commit message.]

---
 arch/x86/kvm/vmx/vmx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx/vmx.c +0 -0
index d58b763df855..a25da991da07 100644

arch/x86/kvm/vmx/vmx.c noinline void vmwrite_error(unsigned long field, unsigned long value) · line 395

Quoted 5 lines
arch/x86/kvm/vmx/vmx.c +1 -1
@@ -392,12 +392,14 @@ noinline void vmwrite_error(unsigned long field, unsigned long value)
 
 noinline void vmclear_error(struct vmcs *vmcs, u64 phys_addr)
 {
-	vmx_insn_failed("kvm: vmclear failed: %p/%llx\n", vmcs, phys_addr);
+	vmx_insn_failed("kvm: vmclear failed: %p/%llx err=%d\n",

I highly doubt it will ever matter, but arguably this should be %u, not %d.

Quoted 14 lines
arch/x86/kvm/vmx/vmx.c +3 -1
+			vmcs, phys_addr, vmcs_read32(VM_INSTRUCTION_ERROR));
 }
 
 noinline void vmptrld_error(struct vmcs *vmcs, u64 phys_addr)
 {
-	vmx_insn_failed("kvm: vmptrld failed: %p/%llx\n", vmcs, phys_addr);
+	vmx_insn_failed("kvm: vmptrld failed: %p/%llx err=%d\n",
+			vmcs, phys_addr, vmcs_read32(VM_INSTRUCTION_ERROR));
 }
 
 noinline void invvpid_error(unsigned long ext, u16 vpid, gva_t gva)
Signature · 1 line
2.36.0.512.ge40c2bad7a-goog
#2 lore raw
Quoted 7 lines · Sean Christopherson

arch/x86/kvm/vmx/vmx.c noinline void vmwrite_error(unsigned long field, unsigned long value) · line 395

Quoted 4 lines

noinline void vmclear_error(struct vmcs *vmcs, u64 phys_addr) {

arch/x86/kvm/vmx/vmx.c +1 -1
-     vmx_insn_failed("kvm: vmclear failed: %p/%llx\n", vmcs, phys_addr);
+     vmx_insn_failed("kvm: vmclear failed: %p/%llx err=%d\n",

I highly doubt it will ever matter, but arguably this should be %u, not %d.

:-@

Okay; I will send out a V3, along with a separate patch to fix VMWRITE.