diff options
author | Gleb Natapov <gleb@redhat.com> | 2010-04-28 12:15:38 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-08-01 03:35:34 -0400 |
commit | 3457e4192e367fd4e0da5e9f46f9df85fa99cd11 (patch) | |
tree | 357625d4f4ffb8619f8d7df79323b9a447d4498d /arch | |
parent | 8fe681e984b6505d4d12125c0776399304803ec7 (diff) |
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/x86.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 51402d8a46fa..9e5a833f3392 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -3924,22 +3924,6 @@ int emulate_instruction(struct kvm_vcpu *vcpu, | |||
3924 | 3924 | ||
3925 | restart: | 3925 | restart: |
3926 | r = x86_emulate_insn(&vcpu->arch.emulate_ctxt, &emulate_ops); | 3926 | r = x86_emulate_insn(&vcpu->arch.emulate_ctxt, &emulate_ops); |
3927 | shadow_mask = vcpu->arch.emulate_ctxt.interruptibility; | ||
3928 | |||
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 | 3927 | ||
3944 | if (r) { /* emulation failed */ | 3928 | if (r) { /* emulation failed */ |
3945 | /* | 3929 | /* |
@@ -3955,6 +3939,21 @@ restart: | |||
3955 | return EMULATE_FAIL; | 3939 | return EMULATE_FAIL; |
3956 | } | 3940 | } |
3957 | 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; | ||
3955 | } | ||
3956 | |||
3958 | if (vcpu->arch.exception.pending) | 3957 | if (vcpu->arch.exception.pending) |
3959 | vcpu->arch.emulate_ctxt.restart = false; | 3958 | vcpu->arch.emulate_ctxt.restart = false; |
3960 | 3959 | ||