aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2011-04-04 06:39:26 -0400
committerAvi Kivity <avi@redhat.com>2011-05-11 07:57:01 -0400
commit8ea7d6aef84e278fcb121acff1bd4c3edaa95b8b (patch)
treeee61ee7da7bd83b1df8f02dcf67648a1617e7888 /arch
parentd09beabd7cd4cf70d982ff54656dc6431df80fa4 (diff)
KVM: x86 emulator: Add flag to check for protected mode instructions
This patch adds a flag for the opcoded to tag instruction which are only recognized in protected mode. The necessary check is added too. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/kvm_emulate.h4
-rw-r--r--arch/x86/kvm/emulate.c7
2 files changed, 11 insertions, 0 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h
index 460c2d8964b7..cab841a034f9 100644
--- a/arch/x86/include/asm/kvm_emulate.h
+++ b/arch/x86/include/asm/kvm_emulate.h
@@ -274,6 +274,10 @@ struct x86_emulate_ctxt {
274#define X86EMUL_MODE_PROT32 4 /* 32-bit protected mode. */ 274#define X86EMUL_MODE_PROT32 4 /* 32-bit protected mode. */
275#define X86EMUL_MODE_PROT64 8 /* 64-bit (long) mode. */ 275#define X86EMUL_MODE_PROT64 8 /* 64-bit (long) mode. */
276 276
277/* any protected mode */
278#define X86EMUL_MODE_PROT (X86EMUL_MODE_PROT16|X86EMUL_MODE_PROT32| \
279 X86EMUL_MODE_PROT64)
280
277enum x86_intercept_stage { 281enum x86_intercept_stage {
278 X86_ICPT_PRE_EXCEPT, 282 X86_ICPT_PRE_EXCEPT,
279 X86_ICPT_POST_EXCEPT, 283 X86_ICPT_POST_EXCEPT,
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 4822824b608b..3f32a6699fbd 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -78,6 +78,7 @@
78#define Prefix (1<<16) /* Instruction varies with 66/f2/f3 prefix */ 78#define Prefix (1<<16) /* Instruction varies with 66/f2/f3 prefix */
79#define Sse (1<<17) /* SSE Vector instruction */ 79#define Sse (1<<17) /* SSE Vector instruction */
80/* Misc flags */ 80/* Misc flags */
81#define Prot (1<<21) /* instruction generates #UD if not in prot-mode */
81#define VendorSpecific (1<<22) /* Vendor specific instruction */ 82#define VendorSpecific (1<<22) /* Vendor specific instruction */
82#define NoAccess (1<<23) /* Don't access memory (lea/invlpg/verr etc) */ 83#define NoAccess (1<<23) /* Don't access memory (lea/invlpg/verr etc) */
83#define Op3264 (1<<24) /* Operand is 64b in long mode, 32b otherwise */ 84#define Op3264 (1<<24) /* Operand is 64b in long mode, 32b otherwise */
@@ -3143,6 +3144,12 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
3143 goto done; 3144 goto done;
3144 } 3145 }
3145 3146
3147 /* Instruction can only be executed in protected mode */
3148 if ((c->d & Prot) && !(ctxt->mode & X86EMUL_MODE_PROT)) {
3149 rc = emulate_ud(ctxt);
3150 goto done;
3151 }
3152
3146 /* Do instruction specific permission checks */ 3153 /* Do instruction specific permission checks */
3147 if (c->check_perm) { 3154 if (c->check_perm) {
3148 rc = c->check_perm(ctxt); 3155 rc = c->check_perm(ctxt);