Skip to content

Commit

Permalink
KVM: VMX: When emulating on invalid vmx state, don't return to usersp…
Browse files Browse the repository at this point in the history
…ace unnecessarily

If we aren't doing mmio there's no need to exit to userspace (which will
just be confused).

Signed-off-by: Avi Kivity <avi@redhat.com>
  • Loading branch information
Avi Kivity committed Mar 24, 2009
1 parent 350f69d commit 8b3079a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arch/x86/kvm/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ struct vcpu_vmx {
} rmode;
int vpid;
bool emulation_required;
enum emulation_result invalid_state_emulation_result;

/* Support for vnmi-less CPUs */
int soft_vnmi_blocked;
Expand Down Expand Up @@ -3130,7 +3131,8 @@ static int handle_nmi_window(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
static void handle_invalid_guest_state(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run)
{
int err;
struct vcpu_vmx *vmx = to_vmx(vcpu);
enum emulation_result err = EMULATE_DONE;

preempt_enable();
local_irq_enable();
Expand All @@ -3154,6 +3156,8 @@ static void handle_invalid_guest_state(struct kvm_vcpu *vcpu,

local_irq_disable();
preempt_disable();

vmx->invalid_state_emulation_result = err;
}

/*
Expand Down Expand Up @@ -3205,7 +3209,7 @@ static int kvm_handle_exit(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
if (vmx->emulation_required && emulate_invalid_guest_state) {
if (guest_state_valid(vcpu))
vmx->emulation_required = 0;
return 0;
return vmx->invalid_state_emulation_result != EMULATE_DO_MMIO;
}

/* Access CR3 don't cause VMExit in paging mode, so we need
Expand Down

0 comments on commit 8b3079a

Please sign in to comment.