aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2012-09-03 08:24:27 -0400
committerAvi Kivity <avi@redhat.com>2012-09-06 11:07:01 -0400
commit9d1b39a967871b7c69025dba7b7bdaee42871021 (patch)
treef3c163ddc441849b0dd350db2b7e1c1e32e75e45
parent716d51abff06f48425cef15d78ca6f36093f6dbf (diff)
KVM: emulator: make x86 emulation modes enum instead of defines
Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--arch/x86/include/asm/kvm_emulate.h22
-rw-r--r--arch/x86/kvm/emulate.c4
2 files changed, 13 insertions, 13 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h
index b5bb73aecc06..e9e5675c0dfb 100644
--- a/arch/x86/include/asm/kvm_emulate.h
+++ b/arch/x86/include/asm/kvm_emulate.h
@@ -249,6 +249,15 @@ struct read_cache {
249 unsigned long end; 249 unsigned long end;
250}; 250};
251 251
252/* Execution mode, passed to the emulator. */
253enum x86emul_mode {
254 X86EMUL_MODE_REAL, /* Real mode. */
255 X86EMUL_MODE_VM86, /* Virtual 8086 mode. */
256 X86EMUL_MODE_PROT16, /* 16-bit protected mode. */
257 X86EMUL_MODE_PROT32, /* 32-bit protected mode. */
258 X86EMUL_MODE_PROT64, /* 64-bit (long) mode. */
259};
260
252struct x86_emulate_ctxt { 261struct x86_emulate_ctxt {
253 const struct x86_emulate_ops *ops; 262 const struct x86_emulate_ops *ops;
254 263
@@ -256,7 +265,7 @@ struct x86_emulate_ctxt {
256 unsigned long eflags; 265 unsigned long eflags;
257 unsigned long eip; /* eip before instruction emulation */ 266 unsigned long eip; /* eip before instruction emulation */
258 /* Emulated execution mode, represented by an X86EMUL_MODE value. */ 267 /* Emulated execution mode, represented by an X86EMUL_MODE value. */
259 int mode; 268 enum x86emul_mode mode;
260 269
261 /* interruptibility state, as a result of execution of STI or MOV SS */ 270 /* interruptibility state, as a result of execution of STI or MOV SS */
262 int interruptibility; 271 int interruptibility;
@@ -308,17 +317,6 @@ struct x86_emulate_ctxt {
308#define REPE_PREFIX 0xf3 317#define REPE_PREFIX 0xf3
309#define REPNE_PREFIX 0xf2 318#define REPNE_PREFIX 0xf2
310 319
311/* Execution mode, passed to the emulator. */
312#define X86EMUL_MODE_REAL 0 /* Real mode. */
313#define X86EMUL_MODE_VM86 1 /* Virtual 8086 mode. */
314#define X86EMUL_MODE_PROT16 2 /* 16-bit protected mode. */
315#define X86EMUL_MODE_PROT32 4 /* 32-bit protected mode. */
316#define X86EMUL_MODE_PROT64 8 /* 64-bit (long) mode. */
317
318/* any protected mode */
319#define X86EMUL_MODE_PROT (X86EMUL_MODE_PROT16|X86EMUL_MODE_PROT32| \
320 X86EMUL_MODE_PROT64)
321
322/* CPUID vendors */ 320/* CPUID vendors */
323#define X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx 0x68747541 321#define X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx 0x68747541
324#define X86EMUL_CPUID_VENDOR_AuthenticAMD_ecx 0x444d4163 322#define X86EMUL_CPUID_VENDOR_AuthenticAMD_ecx 0x444d4163
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 663e95881bdb..5fe06a8fbebc 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2268,6 +2268,8 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt)
2268 if (msr_data == 0x0) 2268 if (msr_data == 0x0)
2269 return emulate_gp(ctxt, 0); 2269 return emulate_gp(ctxt, 0);
2270 break; 2270 break;
2271 default:
2272 break;
2271 } 2273 }
2272 2274
2273 ctxt->eflags &= ~(EFLG_VM | EFLG_IF | EFLG_RF); 2275 ctxt->eflags &= ~(EFLG_VM | EFLG_IF | EFLG_RF);
@@ -4400,7 +4402,7 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
4400 } 4402 }
4401 4403
4402 /* Instruction can only be executed in protected mode */ 4404 /* Instruction can only be executed in protected mode */
4403 if ((ctxt->d & Prot) && !(ctxt->mode & X86EMUL_MODE_PROT)) { 4405 if ((ctxt->d & Prot) && ctxt->mode < X86EMUL_MODE_PROT16) {
4404 rc = emulate_ud(ctxt); 4406 rc = emulate_ud(ctxt);
4405 goto done; 4407 goto done;
4406 } 4408 }