Skip to contentSkip to conversation

KVM: nVMX: Fix consistency check on injected exception error code

PATCH Applied Sean Christopherson 3 participants 3 messages Oct 1, 2019 – Oct 3, 2019

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

PATCH 1/1 KVM: nVMX: Fix consistency check on injected exception error code

Current versions of Intel's SDM incorrectly state that "bits 31:15 of the VM-Entry exception error-code field" must be zero. In reality, bits 31:16 must be zero, i.e. error codes are 16-bit values.

The bogus error code check manifests as an unexpected VM-Entry failure due to an invalid code field (error number 7) in L1, e.g. when injecting a #GP with error_code=0x9f00.

Nadav previously reported the bug[*], both to KVM and Intel, and fixed the associated kvm-unit-test.

[*] https://patchwork.kernel.org/patch/11124749/

---
 arch/x86/kvm/vmx/nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/vmx/nested.c +1 -1
index 41abc62c9a8a..e76eb4f07f6c 100644
@@ -2610,7 +2610,7 @@ static int nested_check_vm_entry_controls(struct kvm_vcpu *vcpu,
 
 		/* VM-entry exception error code */
 		if (CC(has_error_code &&
-		       vmcs12->vm_entry_exception_error_code & GENMASK(31, 15)))
+		       vmcs12->vm_entry_exception_error_code & GENMASK(31, 16)))
 			return -EINVAL;
 
 		/* VM-entry interruption-info field: reserved bits */
Signature · 1 line
2.22.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Sean Christopherson

Current versions of Intel's SDM incorrectly state that "bits 31:15 of the VM-Entry exception error-code field" must be zero. In reality, bits 31:16 must be zero, i.e. error codes are 16-bit values.

The bogus error code check manifests as an unexpected VM-Entry failure due to an invalid code field (error number 7) in L1, e.g. when injecting a #GP with error_code=0x9f00.

Quoted 8 lines

Nadav previously reported the bug[*], both to KVM and Intel, and fixed the associated kvm-unit-test.

[*] https://patchwork.kernel.org/patch/11124749/