[kvm-devel] [PATCH 3/3] Remove no_wb, use dst.type = OP_NONE instead, idea stollen from xen-3.1
Remove no_wb, use dst.type = OP_NONE instead, idea stollen from xen-3.1 Signed-off-by: Laurent Vivier [EMAIL PROTECTED] --- drivers/kvm/x86_emulate.c | 76 ++-- drivers/kvm/x86_emulate.h |2 +- 2 files changed, 25 insertions(+), 53 deletions(-) diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c index d1dec3e..14160f0 100644 --- a/drivers/kvm/x86_emulate.c +++ b/drivers/kvm/x86_emulate.c @@ -1005,8 +1005,7 @@ done: } static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, - struct x86_emulate_ops *ops, - int *no_wb) + struct x86_emulate_ops *ops) { struct decode_cache *c = ctxt-decode; int rc; @@ -1044,7 +1043,7 @@ static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, c-dst.bytes, ctxt-vcpu); if (rc != 0) return rc; - *no_wb = 1; + c-dst.type = OP_NONE; break; default: DPRINTF(Cannot emulate %02x\n, c-b); @@ -1126,6 +1125,10 @@ static inline int writeback(struct x86_emulate_ctxt *ctxt, ctxt-vcpu); if (rc != 0) return rc; + break; + case OP_NONE: + /* no writeback */ + break; default: break; } @@ -1136,7 +1139,6 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) { unsigned long cr2 = ctxt-cr2; - int no_wb = 0; u64 msr_data; unsigned long saved_rcx = 0, saved_eip = 0; struct decode_cache *c = ctxt-decode; @@ -1330,18 +1332,16 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) goto done; break; case 0xfe ... 0xff: /* Grp4/Grp5 */ - rc = emulate_grp45(ctxt, ops, no_wb); + rc = emulate_grp45(ctxt, ops); if (rc != 0) goto done; break; } writeback: - if (!no_wb) { - rc = writeback(ctxt, ops); - if (rc != 0) - goto done; - } + rc = writeback(ctxt, ops); + if (rc != 0) + goto done; /* Commit shadow register state. */ memcpy(ctxt-vcpu-regs, c-regs, sizeof c-regs); @@ -1382,7 +1382,7 @@ special_insn: register_address_increment(c-regs[VCPU_REGS_RSP], c-op_bytes); - no_wb = 1; /* Disable writeback. */ + c-dst.type = OP_NONE; /* Disable writeback. */ break; case 0x6c: /* insb */ case 0x6d: /* insw/insd */ @@ -1527,7 +1527,7 @@ special_insn: case 0xe9: /* jmp rel */ case 0xeb: /* jmp rel short */ JMP_REL(c-src.val); - no_wb = 1; /* Disable writeback. */ + c-dst.type = OP_NONE; /* Disable writeback. */ break; @@ -1537,8 +1537,6 @@ special_insn: twobyte_insn: switch (c-b) { case 0x01: /* lgdt, lidt, lmsw */ - /* Disable writeback. */ - no_wb = 1; switch (c-modrm_reg) { u16 size; unsigned long address; @@ -1593,56 +1591,30 @@ twobyte_insn: default: goto cannot_emulate; } + /* Disable writeback. */ + c-dst.type = OP_NONE; break; case 0x21: /* mov from dr to reg */ - no_wb = 1; if (c-modrm_mod != 3) goto cannot_emulate; rc = emulator_get_dr(ctxt, c-modrm_reg, c-regs[c-modrm_rm]); + if (rc) + goto cannot_emulate; + c-dst.type = OP_NONE; /* no writeback */ break; case 0x23: /* mov from reg to dr */ - no_wb = 1; if (c-modrm_mod != 3) goto cannot_emulate; rc = emulator_set_dr(ctxt, c-modrm_reg, c-regs[c-modrm_rm]); + if (rc) + goto cannot_emulate; + c-dst.type = OP_NONE; /* no writeback */ break; case 0x40 ... 0x4f: /* cmov */ c-dst.val = c-dst.orig_val = c-src.val; - no_wb = 1; - /* -* First, assume we're decoding an even cmov opcode -* (lsb == 0). -*/ - switch ((c-b 15) 1) { - case 0: /* cmovo */ - no_wb = (ctxt-eflags EFLG_OF) ? 0 : 1; - break; - case 1:
[kvm-devel] [PATCH 3/3] remove no_wb
Remove no_wb, use dst.type = OP_NONE instead, idea stollen from xen-3.1 Signed-off-by: Laurent Vivier [EMAIL PROTECTED] --- drivers/kvm/x86_emulate.c | 76 ++-- drivers/kvm/x86_emulate.h |2 +- 2 files changed, 25 insertions(+), 53 deletions(-) diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c index 2f8cb16..c614f96 100644 --- a/drivers/kvm/x86_emulate.c +++ b/drivers/kvm/x86_emulate.c @@ -1004,8 +1004,7 @@ done: } static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, - struct x86_emulate_ops *ops, - int *no_wb) + struct x86_emulate_ops *ops) { struct decode_cache *c = ctxt-decode; int rc; @@ -1043,7 +1042,7 @@ static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, c-dst.bytes, ctxt-vcpu); if (rc != 0) return rc; - *no_wb = 1; + c-dst.type = OP_NONE; break; default: DPRINTF(Cannot emulate %02x\n, c-b); @@ -1124,6 +1123,10 @@ static inline int writeback(struct x86_emulate_ctxt *ctxt, ctxt-vcpu); if (rc != 0) return rc; + break; + case OP_NONE: + /* no writeback */ + break; default: break; } @@ -1134,7 +1137,6 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) { unsigned long cr2 = ctxt-cr2; - int no_wb = 0; u64 msr_data; unsigned long saved_rcx = 0, saved_eip = 0; struct decode_cache *c = ctxt-decode; @@ -1346,7 +1348,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) case 0xe9: /* jmp rel */ case 0xeb: /* jmp rel short */ JMP_REL(c-src.val); - no_wb = 1; /* Disable writeback. */ + c-dst.type = OP_NONE; /* Disable writeback. */ break; case 0xf6 ... 0xf7: /* Grp3 */ rc = emulate_grp3(ctxt, ops); @@ -1354,18 +1356,16 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) goto done; break; case 0xfe ... 0xff: /* Grp4/Grp5 */ - rc = emulate_grp45(ctxt, ops, no_wb); + rc = emulate_grp45(ctxt, ops); if (rc != 0) goto done; break; } writeback: - if (!no_wb) { - rc = writeback(ctxt, ops); - if (rc != 0) - goto done; - } + rc = writeback(ctxt, ops); + if (rc != 0) + goto done; /* Commit shadow register state. */ memcpy(ctxt-vcpu-regs, c-regs, sizeof c-regs); @@ -1406,7 +1406,7 @@ special_insn: register_address_increment(c-regs[VCPU_REGS_RSP], c-op_bytes); - no_wb = 1; /* Disable writeback. */ + c-dst.type = OP_NONE; /* Disable writeback. */ break; case 0x6c: /* insb */ case 0x6d: /* insw/insd */ @@ -1534,8 +1534,6 @@ special_insn: twobyte_insn: switch (c-b) { case 0x01: /* lgdt, lidt, lmsw */ - /* Disable writeback. */ - no_wb = 1; switch (c-modrm_reg) { u16 size; unsigned long address; @@ -1589,56 +1587,30 @@ twobyte_insn: default: goto cannot_emulate; } + /* Disable writeback. */ + c-dst.type = OP_NONE; break; case 0x21: /* mov from dr to reg */ - no_wb = 1; if (c-modrm_mod != 3) goto cannot_emulate; rc = emulator_get_dr(ctxt, c-modrm_reg, c-regs[c-modrm_rm]); + if (rc) + goto cannot_emulate; + c-dst.type = OP_NONE; /* no writeback */ break; case 0x23: /* mov from reg to dr */ - no_wb = 1; if (c-modrm_mod != 3) goto cannot_emulate; rc = emulator_set_dr(ctxt, c-modrm_reg, c-regs[c-modrm_rm]); + if (rc) + goto cannot_emulate; + c-dst.type = OP_NONE; /* no writeback */ break; case 0x40 ... 0x4f: /* cmov */ c-dst.val = c-dst.orig_val = c-src.val; - no_wb = 1; - /* -* First, assume we're decoding an even cmov opcode -* (lsb == 0). -*/ - switch ((c-b 15) 1) { -