aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2010-11-22 10:53:21 -0500
committerAvi Kivity <avi@redhat.com>2011-01-12 04:29:53 -0500
commitda9cb575b1127f84984b8ad6d973dcc05ac036dd (patch)
treee0269a888731c630c9b64693b21d24b2821da362 /arch/x86/kvm/x86.c
parenta4ee1ca4a36e7857d90ae8c2b85f1bde9a042c10 (diff)
KVM: x86 emulator: introduce struct x86_exception to communicate faults
Introduce a structure that can contain an exception to be passed back to main kvm code. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 651cf9004fbe..0c908321e900 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4254,12 +4254,13 @@ static void toggle_interruptibility(struct kvm_vcpu *vcpu, u32 mask)
4254static void inject_emulated_exception(struct kvm_vcpu *vcpu) 4254static void inject_emulated_exception(struct kvm_vcpu *vcpu)
4255{ 4255{
4256 struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt; 4256 struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt;
4257 if (ctxt->exception == PF_VECTOR) 4257 if (ctxt->exception.vector == PF_VECTOR)
4258 kvm_propagate_fault(vcpu); 4258 kvm_propagate_fault(vcpu);
4259 else if (ctxt->error_code_valid) 4259 else if (ctxt->exception.error_code_valid)
4260 kvm_queue_exception_e(vcpu, ctxt->exception, ctxt->error_code); 4260 kvm_queue_exception_e(vcpu, ctxt->exception.vector,
4261 ctxt->exception.error_code);
4261 else 4262 else
4262 kvm_queue_exception(vcpu, ctxt->exception); 4263 kvm_queue_exception(vcpu, ctxt->exception.vector);
4263} 4264}
4264 4265
4265static void init_emulate_ctxt(struct kvm_vcpu *vcpu) 4266static void init_emulate_ctxt(struct kvm_vcpu *vcpu)
@@ -4371,7 +4372,7 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
4371 if (!(emulation_type & EMULTYPE_NO_DECODE)) { 4372 if (!(emulation_type & EMULTYPE_NO_DECODE)) {
4372 init_emulate_ctxt(vcpu); 4373 init_emulate_ctxt(vcpu);
4373 vcpu->arch.emulate_ctxt.interruptibility = 0; 4374 vcpu->arch.emulate_ctxt.interruptibility = 0;
4374 vcpu->arch.emulate_ctxt.exception = -1; 4375 vcpu->arch.emulate_ctxt.have_exception = false;
4375 vcpu->arch.emulate_ctxt.perm_ok = false; 4376 vcpu->arch.emulate_ctxt.perm_ok = false;
4376 4377
4377 r = x86_decode_insn(&vcpu->arch.emulate_ctxt); 4378 r = x86_decode_insn(&vcpu->arch.emulate_ctxt);
@@ -4437,7 +4438,7 @@ restart:
4437 } 4438 }
4438 4439
4439done: 4440done:
4440 if (vcpu->arch.emulate_ctxt.exception >= 0) { 4441 if (vcpu->arch.emulate_ctxt.have_exception) {
4441 inject_emulated_exception(vcpu); 4442 inject_emulated_exception(vcpu);
4442 r = EMULATE_DONE; 4443 r = EMULATE_DONE;
4443 } else if (vcpu->arch.pio.count) { 4444 } else if (vcpu->arch.pio.count) {