Skip to content

Commit e99f050

Browse files
aprzywaravikivity
authored andcommitted
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: Andre Przywara <[email protected]> Signed-off-by: Amit Shah <[email protected]> Signed-off-by: Christoph Egger <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
1 parent b1d8614 commit e99f050

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

arch/x86/kvm/x86_emulate.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include <linux/module.h>
3333
#include <asm/kvm_x86_emulate.h>
3434

35+
#include "mmu.h" /* for is_long_mode() */
36+
3537
/*
3638
* Opcode effective-address decode tables.
3739
* Note that we only emulate instructions that have at least one memory
@@ -209,15 +211,17 @@ static u32 opcode_table[256] = {
209211

210212
static u32 twobyte_table[256] = {
211213
/* 0x00 - 0x0F */
212-
0, Group | GroupDual | Group7, 0, 0, 0, 0, ImplicitOps, 0,
214+
0, Group | GroupDual | Group7, 0, 0, 0, ImplicitOps, ImplicitOps, 0,
213215
ImplicitOps, ImplicitOps, 0, 0, 0, ImplicitOps | ModRM, 0, 0,
214216
/* 0x10 - 0x1F */
215217
0, 0, 0, 0, 0, 0, 0, 0, ImplicitOps | ModRM, 0, 0, 0, 0, 0, 0, 0,
216218
/* 0x20 - 0x2F */
217219
ModRM | ImplicitOps, ModRM, ModRM | ImplicitOps, ModRM, 0, 0, 0, 0,
218220
0, 0, 0, 0, 0, 0, 0, 0,
219221
/* 0x30 - 0x3F */
220-
ImplicitOps, 0, ImplicitOps, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
222+
ImplicitOps, 0, ImplicitOps, 0,
223+
ImplicitOps, ImplicitOps, 0, 0,
224+
0, 0, 0, 0, 0, 0, 0, 0,
221225
/* 0x40 - 0x47 */
222226
DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
223227
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)
19881992
goto cannot_emulate;
19891993
}
19901994
break;
1995+
case 0x05: /* syscall */
1996+
goto cannot_emulate;
1997+
break;
19911998
case 0x06:
19921999
emulate_clts(ctxt->vcpu);
19932000
c->dst.type = OP_NONE;
@@ -2054,6 +2061,12 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
20542061
rc = X86EMUL_CONTINUE;
20552062
c->dst.type = OP_NONE;
20562063
break;
2064+
case 0x34: /* sysenter */
2065+
goto cannot_emulate;
2066+
break;
2067+
case 0x35: /* sysexit */
2068+
goto cannot_emulate;
2069+
break;
20572070
case 0x40 ... 0x4f: /* cmov */
20582071
c->dst.val = c->dst.orig_val = c->src.val;
20592072
if (!test_cc(c->b, ctxt->eflags))

0 commit comments

Comments
 (0)