Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 329903
b: refs/heads/master
c: 9d1b39a
h: refs/heads/master
i:
  329901: ffcfb53
  329899: c40ec2e
  329895: ef56bec
  329887: 09ce75b
v: v3
  • Loading branch information
Gleb Natapov authored and Avi Kivity committed Sep 6, 2012
1 parent 2315d3a commit 67501b2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 716d51abff06f48425cef15d78ca6f36093f6dbf
refs/heads/master: 9d1b39a967871b7c69025dba7b7bdaee42871021
22 changes: 10 additions & 12 deletions trunk/arch/x86/include/asm/kvm_emulate.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,23 @@ struct read_cache {
unsigned long end;
};

/* Execution mode, passed to the emulator. */
enum x86emul_mode {
X86EMUL_MODE_REAL, /* Real mode. */
X86EMUL_MODE_VM86, /* Virtual 8086 mode. */
X86EMUL_MODE_PROT16, /* 16-bit protected mode. */
X86EMUL_MODE_PROT32, /* 32-bit protected mode. */
X86EMUL_MODE_PROT64, /* 64-bit (long) mode. */
};

struct x86_emulate_ctxt {
const struct x86_emulate_ops *ops;

/* Register state before/after emulation. */
unsigned long eflags;
unsigned long eip; /* eip before instruction emulation */
/* Emulated execution mode, represented by an X86EMUL_MODE value. */
int mode;
enum x86emul_mode mode;

/* interruptibility state, as a result of execution of STI or MOV SS */
int interruptibility;
Expand Down Expand Up @@ -308,17 +317,6 @@ struct x86_emulate_ctxt {
#define REPE_PREFIX 0xf3
#define REPNE_PREFIX 0xf2

/* Execution mode, passed to the emulator. */
#define X86EMUL_MODE_REAL 0 /* Real mode. */
#define X86EMUL_MODE_VM86 1 /* Virtual 8086 mode. */
#define X86EMUL_MODE_PROT16 2 /* 16-bit protected mode. */
#define X86EMUL_MODE_PROT32 4 /* 32-bit protected mode. */
#define X86EMUL_MODE_PROT64 8 /* 64-bit (long) mode. */

/* any protected mode */
#define X86EMUL_MODE_PROT (X86EMUL_MODE_PROT16|X86EMUL_MODE_PROT32| \
X86EMUL_MODE_PROT64)

/* CPUID vendors */
#define X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx 0x68747541
#define X86EMUL_CPUID_VENDOR_AuthenticAMD_ecx 0x444d4163
Expand Down
4 changes: 3 additions & 1 deletion trunk/arch/x86/kvm/emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2268,6 +2268,8 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt)
if (msr_data == 0x0)
return emulate_gp(ctxt, 0);
break;
default:
break;
}

ctxt->eflags &= ~(EFLG_VM | EFLG_IF | EFLG_RF);
Expand Down Expand Up @@ -4400,7 +4402,7 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
}

/* Instruction can only be executed in protected mode */
if ((ctxt->d & Prot) && !(ctxt->mode & X86EMUL_MODE_PROT)) {
if ((ctxt->d & Prot) && ctxt->mode < X86EMUL_MODE_PROT16) {
rc = emulate_ud(ctxt);
goto done;
}
Expand Down

0 comments on commit 67501b2

Please sign in to comment.