]> git.karo-electronics.de Git - linux-beck.git/commitdiff
KVM: Provide current eip as part of emulator context.
authorGleb Natapov <gleb@redhat.com>
Thu, 18 Mar 2010 13:20:06 +0000 (15:20 +0200)
committerAvi Kivity <avi@redhat.com>
Mon, 17 May 2010 09:15:59 +0000 (12:15 +0300)
Eliminate the need to call back into KVM to get it from emulator.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/include/asm/kvm_emulate.h
arch/x86/kvm/emulate.c
arch/x86/kvm/x86.c

index b048fd21c54e637856363ba38cd9692e6123c38e..07657258af8f024801362bcaa8c388a017463918 100644 (file)
@@ -141,7 +141,7 @@ struct decode_cache {
        u8 seg_override;
        unsigned int d;
        unsigned long regs[NR_VCPU_REGS];
-       unsigned long eip, eip_orig;
+       unsigned long eip;
        /* modrm */
        u8 modrm;
        u8 modrm_mod;
@@ -160,6 +160,7 @@ struct x86_emulate_ctxt {
        struct kvm_vcpu *vcpu;
 
        unsigned long eflags;
+       unsigned long eip; /* eip before instruction emulation */
        /* Emulated execution mode, represented by an X86EMUL_MODE value. */
        int mode;
        u32 cs_base;
index 8bd05571672c6b6b913e637bf7f1a4ed75821c79..2c27aa466cf44498fc4683087980b4cc839352b2 100644 (file)
@@ -667,7 +667,7 @@ static int do_insn_fetch(struct x86_emulate_ctxt *ctxt,
        int rc;
 
        /* x86 instructions are limited to 15 bytes. */
-       if (eip + size - ctxt->decode.eip_orig > 15)
+       if (eip + size - ctxt->eip > 15)
                return X86EMUL_UNHANDLEABLE;
        eip += ctxt->cs_base;
        while (size--) {
@@ -927,7 +927,7 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
        /* Shadow copy of register state. Committed on successful emulation. */
 
        memset(c, 0, sizeof(struct decode_cache));
-       c->eip = c->eip_orig = kvm_rip_read(ctxt->vcpu);
+       c->eip = ctxt->eip;
        ctxt->cs_base = seg_base(ctxt, VCPU_SREG_CS);
        memcpy(c->regs, ctxt->vcpu->arch.regs, sizeof c->regs);
 
@@ -1878,7 +1878,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
                        }
                }
                register_address_increment(c, &c->regs[VCPU_REGS_RCX], -1);
-               c->eip = kvm_rip_read(ctxt->vcpu);
+               c->eip = ctxt->eip;
        }
 
        if (c->src.type == OP_MEM) {
@@ -2447,7 +2447,7 @@ twobyte_insn:
                                goto done;
 
                        /* Let the processor re-execute the fixed hypercall */
-                       c->eip = kvm_rip_read(ctxt->vcpu);
+                       c->eip = ctxt->eip;
                        /* Disable writeback. */
                        c->dst.type = OP_NONE;
                        break;
@@ -2551,7 +2551,7 @@ twobyte_insn:
                        | ((u64)c->regs[VCPU_REGS_RDX] << 32);
                if (kvm_set_msr(ctxt->vcpu, c->regs[VCPU_REGS_RCX], msr_data)) {
                        kvm_inject_gp(ctxt->vcpu, 0);
-                       c->eip = kvm_rip_read(ctxt->vcpu);
+                       c->eip = ctxt->eip;
                }
                rc = X86EMUL_CONTINUE;
                c->dst.type = OP_NONE;
@@ -2560,7 +2560,7 @@ twobyte_insn:
                /* rdmsr */
                if (kvm_get_msr(ctxt->vcpu, c->regs[VCPU_REGS_RCX], &msr_data)) {
                        kvm_inject_gp(ctxt->vcpu, 0);
-                       c->eip = kvm_rip_read(ctxt->vcpu);
+                       c->eip = ctxt->eip;
                } else {
                        c->regs[VCPU_REGS_RAX] = (u32)msr_data;
                        c->regs[VCPU_REGS_RDX] = msr_data >> 32;
index 9cb28a943c9ab78081f4cacd490979029052f99c..0ecd37ac9d399135ba19b4a5d763d028cc68a0f5 100644 (file)
@@ -3531,6 +3531,7 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
 
                vcpu->arch.emulate_ctxt.vcpu = vcpu;
                vcpu->arch.emulate_ctxt.eflags = kvm_x86_ops->get_rflags(vcpu);
+               vcpu->arch.emulate_ctxt.eip = kvm_rip_read(vcpu);
                vcpu->arch.emulate_ctxt.mode =
                        (!is_protmode(vcpu)) ? X86EMUL_MODE_REAL :
                        (vcpu->arch.emulate_ctxt.eflags & X86_EFLAGS_VM)