Commit 3457e4192e367fd4e0da5e9f46f9df85fa99cd11

Authored by Gleb Natapov
Committed by Avi Kivity
1 parent 8fe681e984

KVM: handle emulation failure case first

If emulation failed return immediately.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>

Showing 1 changed file with 15 additions and 16 deletions Side-by-side Diff

... ... @@ -3924,23 +3924,7 @@
3924 3924  
3925 3925 restart:
3926 3926 r = x86_emulate_insn(&vcpu->arch.emulate_ctxt, &emulate_ops);
3927   - shadow_mask = vcpu->arch.emulate_ctxt.interruptibility;
3928 3927  
3929   - if (r == 0)
3930   - kvm_x86_ops->set_interrupt_shadow(vcpu, shadow_mask);
3931   -
3932   - if (vcpu->arch.pio.count) {
3933   - if (!vcpu->arch.pio.in)
3934   - vcpu->arch.pio.count = 0;
3935   - return EMULATE_DO_MMIO;
3936   - }
3937   -
3938   - if (vcpu->mmio_needed) {
3939   - if (vcpu->mmio_is_write)
3940   - vcpu->mmio_needed = 0;
3941   - return EMULATE_DO_MMIO;
3942   - }
3943   -
3944 3928 if (r) { /* emulation failed */
3945 3929 /*
3946 3930 * if emulation was due to access to shadowed page table
... ... @@ -3953,6 +3937,21 @@
3953 3937 trace_kvm_emulate_insn_failed(vcpu);
3954 3938 kvm_report_emulation_failure(vcpu, "mmio");
3955 3939 return EMULATE_FAIL;
  3940 + }
  3941 +
  3942 + shadow_mask = vcpu->arch.emulate_ctxt.interruptibility;
  3943 + kvm_x86_ops->set_interrupt_shadow(vcpu, shadow_mask);
  3944 +
  3945 + if (vcpu->arch.pio.count) {
  3946 + if (!vcpu->arch.pio.in)
  3947 + vcpu->arch.pio.count = 0;
  3948 + return EMULATE_DO_MMIO;
  3949 + }
  3950 +
  3951 + if (vcpu->mmio_needed) {
  3952 + if (vcpu->mmio_is_write)
  3953 + vcpu->mmio_needed = 0;
  3954 + return EMULATE_DO_MMIO;
3956 3955 }
3957 3956  
3958 3957 if (vcpu->arch.exception.pending)