From 04718f4c309298213f9ce957d70186472a632099 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Thu, 29 Jul 2010 15:11:51 +0300 Subject: [PATCH] --- yaml --- r: 215647 b: refs/heads/master c: ef65c88912cafe56de2737c440aefc764fd8f202 h: refs/heads/master i: 215645: 482b32662a680da1c5f5a08aca766dc1b53e728a 215643: 1ed6f106b521815bfe2e3df4bf6c1944d27ab5e4 215639: 28244bd0c3ddf578af319221e0042a62fd10c108 215631: 9a3103906c3414e3d3fedde4ad084c4dba617b91 215615: 2d15f91a2d09ffcda1e216b445bede9211297adb v: v3 --- [refs] | 2 +- trunk/arch/x86/include/asm/kvm_emulate.h | 1 + trunk/arch/x86/kvm/emulate.c | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 4906ff872040..25d9d9a5ef75 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 9aabc88fc8687ba3a520e2ec459821d05f72474e +refs/heads/master: ef65c88912cafe56de2737c440aefc764fd8f202 diff --git a/trunk/arch/x86/include/asm/kvm_emulate.h b/trunk/arch/x86/include/asm/kvm_emulate.h index 9ddfa5ed2289..0f901c16cf1c 100644 --- a/trunk/arch/x86/include/asm/kvm_emulate.h +++ b/trunk/arch/x86/include/asm/kvm_emulate.h @@ -190,6 +190,7 @@ struct decode_cache { bool has_seg_override; u8 seg_override; unsigned int d; + int (*execute)(struct x86_emulate_ctxt *ctxt); unsigned long regs[NR_VCPU_REGS]; unsigned long eip; /* modrm */ diff --git a/trunk/arch/x86/kvm/emulate.c b/trunk/arch/x86/kvm/emulate.c index 3689f34a303a..799e895fb08e 100644 --- a/trunk/arch/x86/kvm/emulate.c +++ b/trunk/arch/x86/kvm/emulate.c @@ -106,6 +106,7 @@ struct opcode { u32 flags; union { + int (*execute)(struct x86_emulate_ctxt *ctxt); struct opcode *group; struct group_dual *gdual; } u; @@ -120,6 +121,7 @@ struct group_dual { #define N D(0) #define G(_f, _g) { .flags = ((_f) | Group), .u.group = (_g) } #define GD(_f, _g) { .flags = ((_f) | Group | GroupDual), .u.gdual = (_g) } +#define I(_f, _e) { .flags = (_f), .u.execute = (_e) } static struct opcode group1[] = { X7(D(Lock)), N @@ -349,6 +351,7 @@ static struct opcode twobyte_table[256] = { #undef N #undef G #undef GD +#undef I /* EFLAGS bit definitions. */ #define EFLG_ID (1<<21) @@ -1070,6 +1073,8 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt) c->d |= opcode.flags; } + c->execute = opcode.u.execute; + /* Unrecognised? */ if (c->d == 0 || (c->d & Undefined)) { DPRINTF("Cannot emulate %02x\n", c->b); @@ -2705,6 +2710,13 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt) special_insn: + if (c->execute) { + rc = c->execute(ctxt); + if (rc != X86EMUL_CONTINUE) + goto done; + goto writeback; + } + if (c->twobyte) goto twobyte_insn;