Commit e99f0507 authored by Andre Przywara's avatar Andre Przywara Committed by Avi Kivity

KVM: x86 emulator: Prepare for emulation of syscall instructions

Add the flags needed for syscall, sysenter and sysexit to the opcode table.
Catch (but for now ignore) the opcodes in the emulation switch/case.
Signed-off-by: default avatarAndre Przywara <andre.przywara@amd.com>
Signed-off-by: default avatarAmit Shah <amit.shah@redhat.com>
Signed-off-by: default avatarChristoph Egger <christoph.egger@amd.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent b1d86143
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#include <linux/module.h> #include <linux/module.h>
#include <asm/kvm_x86_emulate.h> #include <asm/kvm_x86_emulate.h>
#include "mmu.h" /* for is_long_mode() */
/* /*
* Opcode effective-address decode tables. * Opcode effective-address decode tables.
* Note that we only emulate instructions that have at least one memory * Note that we only emulate instructions that have at least one memory
...@@ -209,7 +211,7 @@ static u32 opcode_table[256] = { ...@@ -209,7 +211,7 @@ static u32 opcode_table[256] = {
static u32 twobyte_table[256] = { static u32 twobyte_table[256] = {
/* 0x00 - 0x0F */ /* 0x00 - 0x0F */
0, Group | GroupDual | Group7, 0, 0, 0, 0, ImplicitOps, 0, 0, Group | GroupDual | Group7, 0, 0, 0, ImplicitOps, ImplicitOps, 0,
ImplicitOps, ImplicitOps, 0, 0, 0, ImplicitOps | ModRM, 0, 0, ImplicitOps, ImplicitOps, 0, 0, 0, ImplicitOps | ModRM, 0, 0,
/* 0x10 - 0x1F */ /* 0x10 - 0x1F */
0, 0, 0, 0, 0, 0, 0, 0, ImplicitOps | ModRM, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ImplicitOps | ModRM, 0, 0, 0, 0, 0, 0, 0,
...@@ -217,7 +219,9 @@ static u32 twobyte_table[256] = { ...@@ -217,7 +219,9 @@ static u32 twobyte_table[256] = {
ModRM | ImplicitOps, ModRM, ModRM | ImplicitOps, ModRM, 0, 0, 0, 0, ModRM | ImplicitOps, ModRM, ModRM | ImplicitOps, ModRM, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x30 - 0x3F */ /* 0x30 - 0x3F */
ImplicitOps, 0, ImplicitOps, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ImplicitOps, 0, ImplicitOps, 0,
ImplicitOps, ImplicitOps, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
/* 0x40 - 0x47 */ /* 0x40 - 0x47 */
DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
...@@ -1988,6 +1992,9 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) ...@@ -1988,6 +1992,9 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
goto cannot_emulate; goto cannot_emulate;
} }
break; break;
case 0x05: /* syscall */
goto cannot_emulate;
break;
case 0x06: case 0x06:
emulate_clts(ctxt->vcpu); emulate_clts(ctxt->vcpu);
c->dst.type = OP_NONE; c->dst.type = OP_NONE;
...@@ -2054,6 +2061,12 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) ...@@ -2054,6 +2061,12 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
rc = X86EMUL_CONTINUE; rc = X86EMUL_CONTINUE;
c->dst.type = OP_NONE; c->dst.type = OP_NONE;
break; break;
case 0x34: /* sysenter */
goto cannot_emulate;
break;
case 0x35: /* sysexit */
goto cannot_emulate;
break;
case 0x40 ... 0x4f: /* cmov */ case 0x40 ... 0x4f: /* cmov */
c->dst.val = c->dst.orig_val = c->src.val; c->dst.val = c->dst.orig_val = c->src.val;
if (!test_cc(c->b, ctxt->eflags)) if (!test_cc(c->b, ctxt->eflags))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment