aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>2011-05-29 08:53:48 -0400
committerAvi Kivity <avi@redhat.com>2011-07-12 06:15:57 -0400
commit9d74191ab1ea857d1cc27e439316eebf8ae46d19 (patch)
treeaed0f1486f410231366c96047a8cc8267b5e4468 /arch/x86/kvm/x86.c
parent55399a02e90fdc6cd45165b2df5dd97b7c3f018f (diff)
KVM: x86 emulator: Use the pointers ctxt and c consistently
We should use the local variables ctxt and c when the emulate_ctxt and decode appears many times. At least, we need to be consistent about how we use these in a function. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index de262a086863..39d8b043580f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4552,24 +4552,24 @@ static void init_emulate_ctxt(struct kvm_vcpu *vcpu)
4552 4552
4553int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip) 4553int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip)
4554{ 4554{
4555 struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode; 4555 struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt;
4556 struct decode_cache *c = &ctxt->decode;
4556 int ret; 4557 int ret;
4557 4558
4558 init_emulate_ctxt(vcpu); 4559 init_emulate_ctxt(vcpu);
4559 4560
4560 vcpu->arch.emulate_ctxt.decode.op_bytes = 2; 4561 c->op_bytes = 2;
4561 vcpu->arch.emulate_ctxt.decode.ad_bytes = 2; 4562 c->ad_bytes = 2;
4562 vcpu->arch.emulate_ctxt.decode.eip = vcpu->arch.emulate_ctxt.eip + 4563 c->eip = ctxt->eip + inc_eip;
4563 inc_eip; 4564 ret = emulate_int_real(ctxt, irq);
4564 ret = emulate_int_real(&vcpu->arch.emulate_ctxt, irq);
4565 4565
4566 if (ret != X86EMUL_CONTINUE) 4566 if (ret != X86EMUL_CONTINUE)
4567 return EMULATE_FAIL; 4567 return EMULATE_FAIL;
4568 4568
4569 vcpu->arch.emulate_ctxt.eip = c->eip; 4569 ctxt->eip = c->eip;
4570 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs); 4570 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
4571 kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip); 4571 kvm_rip_write(vcpu, ctxt->eip);
4572 kvm_set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags); 4572 kvm_set_rflags(vcpu, ctxt->eflags);
4573 4573
4574 if (irq == NMI_VECTOR) 4574 if (irq == NMI_VECTOR)
4575 vcpu->arch.nmi_pending = false; 4575 vcpu->arch.nmi_pending = false;
@@ -4630,21 +4630,22 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,
4630 int insn_len) 4630 int insn_len)
4631{ 4631{
4632 int r; 4632 int r;
4633 struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode; 4633 struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt;
4634 struct decode_cache *c = &ctxt->decode;
4634 bool writeback = true; 4635 bool writeback = true;
4635 4636
4636 kvm_clear_exception_queue(vcpu); 4637 kvm_clear_exception_queue(vcpu);
4637 4638
4638 if (!(emulation_type & EMULTYPE_NO_DECODE)) { 4639 if (!(emulation_type & EMULTYPE_NO_DECODE)) {
4639 init_emulate_ctxt(vcpu); 4640 init_emulate_ctxt(vcpu);
4640 vcpu->arch.emulate_ctxt.interruptibility = 0; 4641 ctxt->interruptibility = 0;
4641 vcpu->arch.emulate_ctxt.have_exception = false; 4642 ctxt->have_exception = false;
4642 vcpu->arch.emulate_ctxt.perm_ok = false; 4643 ctxt->perm_ok = false;
4643 4644
4644 vcpu->arch.emulate_ctxt.only_vendor_specific_insn 4645 ctxt->only_vendor_specific_insn
4645 = emulation_type & EMULTYPE_TRAP_UD; 4646 = emulation_type & EMULTYPE_TRAP_UD;
4646 4647
4647 r = x86_decode_insn(&vcpu->arch.emulate_ctxt, insn, insn_len); 4648 r = x86_decode_insn(ctxt, insn, insn_len);
4648 4649
4649 trace_kvm_emulate_insn_start(vcpu); 4650 trace_kvm_emulate_insn_start(vcpu);
4650 ++vcpu->stat.insn_emulation; 4651 ++vcpu->stat.insn_emulation;
@@ -4660,7 +4661,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,
4660 } 4661 }
4661 4662
4662 if (emulation_type & EMULTYPE_SKIP) { 4663 if (emulation_type & EMULTYPE_SKIP) {
4663 kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.decode.eip); 4664 kvm_rip_write(vcpu, c->eip);
4664 return EMULATE_DONE; 4665 return EMULATE_DONE;
4665 } 4666 }
4666 4667
@@ -4672,7 +4673,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,
4672 } 4673 }
4673 4674
4674restart: 4675restart:
4675 r = x86_emulate_insn(&vcpu->arch.emulate_ctxt); 4676 r = x86_emulate_insn(ctxt);
4676 4677
4677 if (r == EMULATION_INTERCEPTED) 4678 if (r == EMULATION_INTERCEPTED)
4678 return EMULATE_DONE; 4679 return EMULATE_DONE;
@@ -4684,7 +4685,7 @@ restart:
4684 return handle_emulation_failure(vcpu); 4685 return handle_emulation_failure(vcpu);
4685 } 4686 }
4686 4687
4687 if (vcpu->arch.emulate_ctxt.have_exception) { 4688 if (ctxt->have_exception) {
4688 inject_emulated_exception(vcpu); 4689 inject_emulated_exception(vcpu);
4689 r = EMULATE_DONE; 4690 r = EMULATE_DONE;
4690 } else if (vcpu->arch.pio.count) { 4691 } else if (vcpu->arch.pio.count) {
@@ -4703,13 +4704,12 @@ restart:
4703 r = EMULATE_DONE; 4704 r = EMULATE_DONE;
4704 4705
4705 if (writeback) { 4706 if (writeback) {
4706 toggle_interruptibility(vcpu, 4707 toggle_interruptibility(vcpu, ctxt->interruptibility);
4707 vcpu->arch.emulate_ctxt.interruptibility); 4708 kvm_set_rflags(vcpu, ctxt->eflags);
4708 kvm_set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
4709 kvm_make_request(KVM_REQ_EVENT, vcpu); 4709 kvm_make_request(KVM_REQ_EVENT, vcpu);
4710 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs); 4710 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
4711 vcpu->arch.emulate_regs_need_sync_to_vcpu = false; 4711 vcpu->arch.emulate_regs_need_sync_to_vcpu = false;
4712 kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip); 4712 kvm_rip_write(vcpu, ctxt->eip);
4713 } else 4713 } else
4714 vcpu->arch.emulate_regs_need_sync_to_vcpu = true; 4714 vcpu->arch.emulate_regs_need_sync_to_vcpu = true;
4715 4715
@@ -5130,8 +5130,7 @@ int emulator_fix_hypercall(struct x86_emulate_ctxt *ctxt)
5130 5130
5131 kvm_x86_ops->patch_hypercall(vcpu, instruction); 5131 kvm_x86_ops->patch_hypercall(vcpu, instruction);
5132 5132
5133 return emulator_write_emulated(&vcpu->arch.emulate_ctxt, 5133 return emulator_write_emulated(ctxt, rip, instruction, 3, NULL);
5134 rip, instruction, 3, NULL);
5135} 5134}
5136 5135
5137static int move_to_next_stateful_cpuid_entry(struct kvm_vcpu *vcpu, int i) 5136static int move_to_next_stateful_cpuid_entry(struct kvm_vcpu *vcpu, int i)
@@ -5849,21 +5848,21 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
5849int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason, 5848int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason,
5850 bool has_error_code, u32 error_code) 5849 bool has_error_code, u32 error_code)
5851{ 5850{
5852 struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode; 5851 struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt;
5852 struct decode_cache *c = &ctxt->decode;
5853 int ret; 5853 int ret;
5854 5854
5855 init_emulate_ctxt(vcpu); 5855 init_emulate_ctxt(vcpu);
5856 5856
5857 ret = emulator_task_switch(&vcpu->arch.emulate_ctxt, 5857 ret = emulator_task_switch(ctxt, tss_selector, reason,
5858 tss_selector, reason, has_error_code, 5858 has_error_code, error_code);
5859 error_code);
5860 5859
5861 if (ret) 5860 if (ret)
5862 return EMULATE_FAIL; 5861 return EMULATE_FAIL;
5863 5862
5864 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs); 5863 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
5865 kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip); 5864 kvm_rip_write(vcpu, ctxt->eip);
5866 kvm_set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags); 5865 kvm_set_rflags(vcpu, ctxt->eflags);
5867 kvm_make_request(KVM_REQ_EVENT, vcpu); 5866 kvm_make_request(KVM_REQ_EVENT, vcpu);
5868 return EMULATE_DONE; 5867 return EMULATE_DONE;
5869} 5868}