Skip to content

Commit 053d229

Browse files
sean-jcbonzini
authored andcommitted
KVM: VMX: Exit to userspace if vCPU has injected exception and invalid state
Exit to userspace with an emulation error if KVM encounters an injected exception with invalid guest state, in addition to the existing check of bailing if there's a pending exception (KVM doesn't support emulating exceptions except when emulating real mode via vm86). In theory, KVM should never get to such a situation as KVM is supposed to exit to userspace before injecting an exception with invalid guest state. But in practice, userspace can intervene and manually inject an exception and/or stuff registers to force invalid guest state while a previously injected exception is awaiting reinjection. Fixes: fc4fad7 ("KVM: VMX: Reject KVM_RUN if emulation is required with pending exception") Reported-by: syzbot+cfafed3bb76d3e37581b@syzkaller.appspotmail.com Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20220502221850.131873-1-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 0c2c7c0 commit 053d229

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/x86/kvm/vmx/vmx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5472,7 +5472,7 @@ static bool vmx_emulation_required_with_pending_exception(struct kvm_vcpu *vcpu)
54725472
struct vcpu_vmx *vmx = to_vmx(vcpu);
54735473

54745474
return vmx->emulation_required && !vmx->rmode.vm86_active &&
5475-
vcpu->arch.exception.pending;
5475+
(vcpu->arch.exception.pending || vcpu->arch.exception.injected);
54765476
}
54775477

54785478
static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)