diff options
author | Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> | 2011-05-24 22:06:16 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-07-12 04:45:08 -0400 |
commit | adf52235b4082e67f31bf1fba36f1dce312633d6 (patch) | |
tree | a1bb9e64f46b7f6ae993c875e99dcc0a9776e4c0 /arch/x86/kvm | |
parent | d780592b99d7d8a5ff905f6bacca519d4a342c76 (diff) |
KVM: x86 emulator: Clean up init_emulate_ctxt()
Use a local pointer to the emulate_ctxt for simplicity. Then, arrange
the hard-to-read mode selection lines neatly.
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/x86.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index aaa3735004b..ae2353c5020 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -4508,7 +4508,8 @@ static void inject_emulated_exception(struct kvm_vcpu *vcpu) | |||
4508 | 4508 | ||
4509 | static void init_emulate_ctxt(struct kvm_vcpu *vcpu) | 4509 | static void init_emulate_ctxt(struct kvm_vcpu *vcpu) |
4510 | { | 4510 | { |
4511 | struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode; | 4511 | struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt; |
4512 | struct decode_cache *c = &ctxt->decode; | ||
4512 | int cs_db, cs_l; | 4513 | int cs_db, cs_l; |
4513 | 4514 | ||
4514 | /* | 4515 | /* |
@@ -4521,15 +4522,15 @@ static void init_emulate_ctxt(struct kvm_vcpu *vcpu) | |||
4521 | 4522 | ||
4522 | kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l); | 4523 | kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l); |
4523 | 4524 | ||
4524 | vcpu->arch.emulate_ctxt.eflags = kvm_get_rflags(vcpu); | 4525 | ctxt->eflags = kvm_get_rflags(vcpu); |
4525 | vcpu->arch.emulate_ctxt.eip = kvm_rip_read(vcpu); | 4526 | ctxt->eip = kvm_rip_read(vcpu); |
4526 | vcpu->arch.emulate_ctxt.mode = | 4527 | ctxt->mode = (!is_protmode(vcpu)) ? X86EMUL_MODE_REAL : |
4527 | (!is_protmode(vcpu)) ? X86EMUL_MODE_REAL : | 4528 | (ctxt->eflags & X86_EFLAGS_VM) ? X86EMUL_MODE_VM86 : |
4528 | (vcpu->arch.emulate_ctxt.eflags & X86_EFLAGS_VM) | 4529 | cs_l ? X86EMUL_MODE_PROT64 : |
4529 | ? X86EMUL_MODE_VM86 : cs_l | 4530 | cs_db ? X86EMUL_MODE_PROT32 : |
4530 | ? X86EMUL_MODE_PROT64 : cs_db | 4531 | X86EMUL_MODE_PROT16; |
4531 | ? X86EMUL_MODE_PROT32 : X86EMUL_MODE_PROT16; | 4532 | ctxt->guest_mode = is_guest_mode(vcpu); |
4532 | vcpu->arch.emulate_ctxt.guest_mode = is_guest_mode(vcpu); | 4533 | |
4533 | memset(c, 0, sizeof(struct decode_cache)); | 4534 | memset(c, 0, sizeof(struct decode_cache)); |
4534 | memcpy(c->regs, vcpu->arch.regs, sizeof c->regs); | 4535 | memcpy(c->regs, vcpu->arch.regs, sizeof c->regs); |
4535 | vcpu->arch.emulate_regs_need_sync_from_vcpu = false; | 4536 | vcpu->arch.emulate_regs_need_sync_from_vcpu = false; |