Skip to contentSkip to conversation

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

PATCH In review Jim Mattson 2 participants 5 messages May 10, 2022 – May 17, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 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.]

---
v1 -> v2: Dropped changes to invvpid_error and invept_error. v2 -> v3: Changed printf format character from 'd' to 'u'

 arch/x86/kvm/vmx/vmx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx/vmx.c +4 -2
index 610355b9ccce..3a76730584cd 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=%u\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=%u\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

PATCH v3 2/2 KVM: VMX: Print VM-instruction error as unsigned

Change the printf format character from 'd' to 'u' for the VM-instruction error in vmwrite_error().

Fixes 6aa8b732ca01 ("[PATCH] kvm: userspace interface")
---
 arch/x86/kvm/vmx/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +1 -1
index 3a76730584cd..f558a14851f1 100644
@@ -386,7 +386,7 @@ asmlinkage void vmread_error(unsigned long field, bool fault)
 
 noinline void vmwrite_error(unsigned long field, unsigned long value)
 {
-	vmx_insn_failed("kvm: vmwrite failed: field=%lx val=%lx err=%d\n",
+	vmx_insn_failed("kvm: vmwrite failed: field=%lx val=%lx err=%u\n",
 			field, value, vmcs_read32(VM_INSTRUCTION_ERROR));
 }
 
Signature · 1 line
2.36.0.512.ge40c2bad7a-goog
#3 lore raw

Re: [PATCH v3 2/2] KVM: VMX: Print VM-instruction error as unsigned

Quoted 11 lines · Sean Christopherson
Quoted 7 lines · Jim Mattson

Change the printf format character from 'd' to 'u' for the VM-instruction error in vmwrite_error().

Fixes 6aa8b732ca01 ("[PATCH] kvm: userspace interface")

---

Paolo?

maintainer Reviewed-by on v3 1/2
#4 lore raw
In reply to Jim Mattson
Quoted 7 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.

Quoted 5 lines

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

---

I do think it'd be worthwhile to add the safe VMREAD variant, but I don't care enough to hold this up.