[kvm-devel] [PATCH 2/3] remove _eflags and use directly ctxt-eflags.
Remove _eflags and use directly ctxt-eflags. Caching eflags is not needed as it is restored to vcpu by kvm_main.c:emulate_instruction() from ctxt-eflags only if emulation doesn't fail. Signed-off-by: Laurent Vivier [EMAIL PROTECTED] --- drivers/kvm/x86_emulate.c | 121 ++--- 1 files changed, 59 insertions(+), 62 deletions(-) diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c index 64e8e03..d1dec3e 100644 --- a/drivers/kvm/x86_emulate.c +++ b/drivers/kvm/x86_emulate.c @@ -930,37 +930,37 @@ static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt, return 0; } -static inline void emulate_grp2(struct decode_cache *c, unsigned long *_eflags) +static inline void emulate_grp2(struct x86_emulate_ctxt *ctxt) { + struct decode_cache *c = ctxt-decode; switch (c-modrm_reg) { case 0: /* rol */ - emulate_2op_SrcB(rol, c-src, c-dst, *_eflags); + emulate_2op_SrcB(rol, c-src, c-dst, ctxt-eflags); break; case 1: /* ror */ - emulate_2op_SrcB(ror, c-src, c-dst, *_eflags); + emulate_2op_SrcB(ror, c-src, c-dst, ctxt-eflags); break; case 2: /* rcl */ - emulate_2op_SrcB(rcl, c-src, c-dst, *_eflags); + emulate_2op_SrcB(rcl, c-src, c-dst, ctxt-eflags); break; case 3: /* rcr */ - emulate_2op_SrcB(rcr, c-src, c-dst, *_eflags); + emulate_2op_SrcB(rcr, c-src, c-dst, ctxt-eflags); break; case 4: /* sal/shl */ case 6: /* sal/shl */ - emulate_2op_SrcB(sal, c-src, c-dst, *_eflags); + emulate_2op_SrcB(sal, c-src, c-dst, ctxt-eflags); break; case 5: /* shr */ - emulate_2op_SrcB(shr, c-src, c-dst, *_eflags); + emulate_2op_SrcB(shr, c-src, c-dst, ctxt-eflags); break; case 7: /* sar */ - emulate_2op_SrcB(sar, c-src, c-dst, *_eflags); + emulate_2op_SrcB(sar, c-src, c-dst, ctxt-eflags); break; } } static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt, - struct x86_emulate_ops *ops, - unsigned long *_eflags) + struct x86_emulate_ops *ops) { struct decode_cache *c = ctxt-decode; int rc = 0; @@ -987,13 +987,13 @@ static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt, c-src.val = insn_fetch(s32, 4, c-eip); break; } - emulate_2op_SrcV(test, c-src, c-dst, *_eflags); + emulate_2op_SrcV(test, c-src, c-dst, ctxt-eflags); break; case 2: /* not */ c-dst.val = ~c-dst.val; break; case 3: /* neg */ - emulate_1op(neg, c-dst, *_eflags); + emulate_1op(neg, c-dst, ctxt-eflags); break; default: DPRINTF(Cannot emulate %02x\n, c-b); @@ -1006,7 +1006,6 @@ done: static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops, - unsigned long *_eflags, int *no_wb) { struct decode_cache *c = ctxt-decode; @@ -1014,10 +1013,10 @@ static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, switch (c-modrm_reg) { case 0: /* inc */ - emulate_1op(inc, c-dst, *_eflags); + emulate_1op(inc, c-dst, ctxt-eflags); break; case 1: /* dec */ - emulate_1op(dec, c-dst, *_eflags); + emulate_1op(dec, c-dst, ctxt-eflags); break; case 4: /* jmp abs */ if (c-b == 0xff) @@ -1056,7 +1055,6 @@ static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, static inline int emulate_grp9(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops, - unsigned long *_eflags, unsigned long cr2) { struct decode_cache *c = ctxt-decode; @@ -1072,7 +1070,7 @@ static inline int emulate_grp9(struct x86_emulate_ctxt *ctxt, c-regs[VCPU_REGS_RAX] = (u32) (old 0); c-regs[VCPU_REGS_RDX] = (u32) (old 32); - *_eflags = ~EFLG_ZF; + ctxt-eflags = ~EFLG_ZF; } else { new = ((u64)c-regs[VCPU_REGS_RCX] 32) | @@ -1081,7 +1079,7 @@ static inline int emulate_grp9(struct x86_emulate_ctxt *ctxt, rc = ops-cmpxchg_emulated(cr2, old, new, 8, ctxt-vcpu); if (rc != 0) return rc; - *_eflags |= EFLG_ZF; + ctxt-eflags |= EFLG_ZF; } return 0; } @@ -1141,7 +1139,6 @@
[kvm-devel] [PATCH 2/3] remove _eflags and use directly ctxt-eflags.
Remove _eflags and use directly ctxt-eflags. Caching eflags is not needed as it is restored to vcpu by kvm_main.c:emulate_instruction() from ctxt-eflags only if emulation doesn't fail Signed-off-by: Laurent Vivier [EMAIL PROTECTED] --- drivers/kvm/x86_emulate.c | 120 ++--- 1 files changed, 58 insertions(+), 62 deletions(-) diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c index 67fe1e1..2f8cb16 100644 --- a/drivers/kvm/x86_emulate.c +++ b/drivers/kvm/x86_emulate.c @@ -929,37 +929,37 @@ static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt, struct x86_emulat return 0; } -static inline void emulate_grp2(struct decode_cache *c, unsigned long *_eflags) +static inline void emulate_grp2(struct x86_emulate_ctxt *ctxt) { + struct decode_cache *c = ctxt-decode; switch (c-modrm_reg) { case 0: /* rol */ - emulate_2op_SrcB(rol, c-src, c-dst, *_eflags); + emulate_2op_SrcB(rol, c-src, c-dst, ctxt-eflags); break; case 1: /* ror */ - emulate_2op_SrcB(ror, c-src, c-dst, *_eflags); + emulate_2op_SrcB(ror, c-src, c-dst, ctxt-eflags); break; case 2: /* rcl */ - emulate_2op_SrcB(rcl, c-src, c-dst, *_eflags); + emulate_2op_SrcB(rcl, c-src, c-dst, ctxt-eflags); break; case 3: /* rcr */ - emulate_2op_SrcB(rcr, c-src, c-dst, *_eflags); + emulate_2op_SrcB(rcr, c-src, c-dst, ctxt-eflags); break; case 4: /* sal/shl */ case 6: /* sal/shl */ - emulate_2op_SrcB(sal, c-src, c-dst, *_eflags); + emulate_2op_SrcB(sal, c-src, c-dst, ctxt-eflags); break; case 5: /* shr */ - emulate_2op_SrcB(shr, c-src, c-dst, *_eflags); + emulate_2op_SrcB(shr, c-src, c-dst, ctxt-eflags); break; case 7: /* sar */ - emulate_2op_SrcB(sar, c-src, c-dst, *_eflags); + emulate_2op_SrcB(sar, c-src, c-dst, ctxt-eflags); break; } } static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt, - struct x86_emulate_ops *ops, - unsigned long *_eflags) + struct x86_emulate_ops *ops) { struct decode_cache *c = ctxt-decode; int rc = 0; @@ -986,13 +986,13 @@ static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt, c-src.val = insn_fetch(s32, 4, c-eip); break; } - emulate_2op_SrcV(test, c-src, c-dst, *_eflags); + emulate_2op_SrcV(test, c-src, c-dst, ctxt-eflags); break; case 2: /* not */ c-dst.val = ~c-dst.val; break; case 3: /* neg */ - emulate_1op(neg, c-dst, *_eflags); + emulate_1op(neg, c-dst, ctxt-eflags); break; default: DPRINTF(Cannot emulate %02x\n, c-b); @@ -1005,7 +1005,6 @@ done: static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops, - unsigned long *_eflags, int *no_wb) { struct decode_cache *c = ctxt-decode; @@ -1013,10 +1012,10 @@ static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, switch (c-modrm_reg) { case 0: /* inc */ - emulate_1op(inc, c-dst, *_eflags); + emulate_1op(inc, c-dst, ctxt-eflags); break; case 1: /* dec */ - emulate_1op(dec, c-dst, *_eflags); + emulate_1op(dec, c-dst, ctxt-eflags); break; case 4: /* jmp abs */ if (c-b == 0xff) @@ -1055,7 +1054,6 @@ static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, static inline int emulate_grp9(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops, - unsigned long *_eflags, unsigned long cr2) { struct decode_cache *c = ctxt-decode; @@ -1071,7 +1069,7 @@ static inline int emulate_grp9(struct x86_emulate_ctxt *ctxt, c-regs[VCPU_REGS_RAX] = (u32) (old 0); c-regs[VCPU_REGS_RDX] = (u32) (old 32); - *_eflags = ~EFLG_ZF; + ctxt-eflags = ~EFLG_ZF; } else { new = ((u64)c-regs[VCPU_REGS_RCX] 32) | (u32) c-regs[VCPU_REGS_RBX]; @@ -1079,7 +1077,7 @@ static inline int emulate_grp9(struct x86_emulate_ctxt *ctxt, rc = ops-cmpxchg_emulated(cr2, old, new, 8, ctxt-vcpu); if (rc != 0) return rc; - *_eflags |= EFLG_ZF; + ctxt-eflags |= EFLG_ZF;