Skip to content

Commit 80962ec

Browse files
sean-jcbonzini
authored andcommitted
KVM: nVMX: Do not report error code when synthesizing VM-Exit from Real Mode
Don't report an error code to L1 when synthesizing a nested VM-Exit and L2 is in Real Mode. Per Intel's SDM, regarding the error code valid bit: This bit is always 0 if the VM exit occurred while the logical processor was in real-address mode (CR0.PE=0). The bug was introduced by a recent fix for AMD's Paged Real Mode, which moved the error code suppression from the common "queue exception" path to the "inject exception" path, but missed VMX's "synthesize VM-Exit" path. Fixes: b97f074 ("KVM: x86: determine if an exception has an error code only when injecting it.") Cc: [email protected] Cc: Maxim Levitsky <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 6c41468 commit 80962ec

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arch/x86/kvm/vmx/nested.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3868,7 +3868,12 @@ static void nested_vmx_inject_exception_vmexit(struct kvm_vcpu *vcpu)
38683868
exit_qual = 0;
38693869
}
38703870

3871-
if (ex->has_error_code) {
3871+
/*
3872+
* Unlike AMD's Paged Real Mode, which reports an error code on #PF
3873+
* VM-Exits even if the CPU is in Real Mode, Intel VMX never sets the
3874+
* "has error code" flags on VM-Exit if the CPU is in Real Mode.
3875+
*/
3876+
if (ex->has_error_code && is_protmode(vcpu)) {
38723877
/*
38733878
* Intel CPUs do not generate error codes with bits 31:16 set,
38743879
* and more importantly VMX disallows setting bits 31:16 in the

0 commit comments

Comments
 (0)