aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2011-02-01 09:32:03 -0500
committerMarcelo Tosatti <mtosatti@redhat.com>2011-03-17 12:08:28 -0400
commitd867162c6d1028d16358f4d2383d1833a849c74d (patch)
tree17486fbf7cf2ca38893baf704415586c1d6f5f43 /arch
parent3e90943907ff84cf0379a57c01c296a9b33c903e (diff)
KVM: x86 emulator: vendor specific instructions
Mark some instructions as vendor specific, and allow the caller to request emulation only of vendor specific instructions. This is useful in some circumstances (responding to a #UD fault). Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/kvm_emulate.h1
-rw-r--r--arch/x86/kvm/emulate.c12
2 files changed, 10 insertions, 3 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h
index 8e37deb1eb38..50ebc327a368 100644
--- a/arch/x86/include/asm/kvm_emulate.h
+++ b/arch/x86/include/asm/kvm_emulate.h
@@ -239,6 +239,7 @@ struct x86_emulate_ctxt {
239 int interruptibility; 239 int interruptibility;
240 240
241 bool perm_ok; /* do not check permissions if true */ 241 bool perm_ok; /* do not check permissions if true */
242 bool only_vendor_specific_insn;
242 243
243 bool have_exception; 244 bool have_exception;
244 struct x86_exception exception; 245 struct x86_exception exception;
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index caf966781d25..a90d7e033304 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -76,6 +76,7 @@
76#define Group (1<<14) /* Bits 3:5 of modrm byte extend opcode */ 76#define Group (1<<14) /* Bits 3:5 of modrm byte extend opcode */
77#define GroupDual (1<<15) /* Alternate decoding of mod == 3 */ 77#define GroupDual (1<<15) /* Alternate decoding of mod == 3 */
78/* Misc flags */ 78/* Misc flags */
79#define VendorSpecific (1<<22) /* Vendor specific instruction */
79#define NoAccess (1<<23) /* Don't access memory (lea/invlpg/verr etc) */ 80#define NoAccess (1<<23) /* Don't access memory (lea/invlpg/verr etc) */
80#define Op3264 (1<<24) /* Operand is 64b in long mode, 32b otherwise */ 81#define Op3264 (1<<24) /* Operand is 64b in long mode, 32b otherwise */
81#define Undefined (1<<25) /* No Such Instruction */ 82#define Undefined (1<<25) /* No Such Instruction */
@@ -2365,7 +2366,8 @@ static struct group_dual group7 = { {
2365 D(SrcMem16 | ModRM | Mov | Priv), 2366 D(SrcMem16 | ModRM | Mov | Priv),
2366 D(SrcMem | ModRM | ByteOp | Priv | NoAccess), 2367 D(SrcMem | ModRM | ByteOp | Priv | NoAccess),
2367}, { 2368}, {
2368 D(SrcNone | ModRM | Priv), N, N, D(SrcNone | ModRM | Priv), 2369 D(SrcNone | ModRM | Priv | VendorSpecific), N,
2370 N, D(SrcNone | ModRM | Priv | VendorSpecific),
2369 D(SrcNone | ModRM | DstMem | Mov), N, 2371 D(SrcNone | ModRM | DstMem | Mov), N,
2370 D(SrcMem16 | ModRM | Mov | Priv), N, 2372 D(SrcMem16 | ModRM | Mov | Priv), N,
2371} }; 2373} };
@@ -2489,7 +2491,7 @@ static struct opcode opcode_table[256] = {
2489static struct opcode twobyte_table[256] = { 2491static struct opcode twobyte_table[256] = {
2490 /* 0x00 - 0x0F */ 2492 /* 0x00 - 0x0F */
2491 N, GD(0, &group7), N, N, 2493 N, GD(0, &group7), N, N,
2492 N, D(ImplicitOps), D(ImplicitOps | Priv), N, 2494 N, D(ImplicitOps | VendorSpecific), D(ImplicitOps | Priv), N,
2493 D(ImplicitOps | Priv), D(ImplicitOps | Priv), N, N, 2495 D(ImplicitOps | Priv), D(ImplicitOps | Priv), N, N,
2494 N, D(ImplicitOps | ModRM), N, N, 2496 N, D(ImplicitOps | ModRM), N, N,
2495 /* 0x10 - 0x1F */ 2497 /* 0x10 - 0x1F */
@@ -2502,7 +2504,8 @@ static struct opcode twobyte_table[256] = {
2502 /* 0x30 - 0x3F */ 2504 /* 0x30 - 0x3F */
2503 D(ImplicitOps | Priv), I(ImplicitOps, em_rdtsc), 2505 D(ImplicitOps | Priv), I(ImplicitOps, em_rdtsc),
2504 D(ImplicitOps | Priv), N, 2506 D(ImplicitOps | Priv), N,
2505 D(ImplicitOps), D(ImplicitOps | Priv), N, N, 2507 D(ImplicitOps | VendorSpecific), D(ImplicitOps | Priv | VendorSpecific),
2508 N, N,
2506 N, N, N, N, N, N, N, N, 2509 N, N, N, N, N, N, N, N,
2507 /* 0x40 - 0x4F */ 2510 /* 0x40 - 0x4F */
2508 X16(D(DstReg | SrcMem | ModRM | Mov)), 2511 X16(D(DstReg | SrcMem | ModRM | Mov)),
@@ -2741,6 +2744,9 @@ done_prefixes:
2741 if (c->d == 0 || (c->d & Undefined)) 2744 if (c->d == 0 || (c->d & Undefined))
2742 return -1; 2745 return -1;
2743 2746
2747 if (!(c->d & VendorSpecific) && ctxt->only_vendor_specific_insn)
2748 return -1;
2749
2744 if (mode == X86EMUL_MODE_PROT64 && (c->d & Stack)) 2750 if (mode == X86EMUL_MODE_PROT64 && (c->d & Stack))
2745 c->op_bytes = 8; 2751 c->op_bytes = 8;
2746 2752