aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorNadav Amit <namit@cs.technion.ac.il>2014-06-18 10:19:35 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-07-11 03:14:05 -0400
commit68efa764f3429f2bd71f431e91c04b0bcb7d34f1 (patch)
treebc0a388fb542ff2c634722863dfa72a521b6dd7d /arch/x86/kvm
parent10e38fc7cabc668738e6a7b7b57cbcddb2234440 (diff)
KVM: x86: Emulator support for #UD on CPL>0
Certain instructions (e.g., mwait and monitor) cause a #UD exception when they are executed in user mode. This is in contrast to the regular privileged instructions which cause #GP. In order not to mess with SVM interception of mwait and monitor which assumes privilege level assertions take place before interception, a flag has been added. Signed-off-by: Nadav Amit <namit@cs.technion.ac.il> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/emulate.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index b61ffe9d86a7..dd074106d0c9 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -165,6 +165,7 @@
165#define Intercept ((u64)1 << 48) /* Has valid intercept field */ 165#define Intercept ((u64)1 << 48) /* Has valid intercept field */
166#define CheckPerm ((u64)1 << 49) /* Has valid check_perm field */ 166#define CheckPerm ((u64)1 << 49) /* Has valid check_perm field */
167#define NoBigReal ((u64)1 << 50) /* No big real mode */ 167#define NoBigReal ((u64)1 << 50) /* No big real mode */
168#define PrivUD ((u64)1 << 51) /* #UD instead of #GP on CPL > 0 */
168 169
169#define DstXacc (DstAccLo | SrcAccHi | SrcWrite) 170#define DstXacc (DstAccLo | SrcAccHi | SrcWrite)
170 171
@@ -4608,7 +4609,10 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
4608 4609
4609 /* Privileged instruction can be executed only in CPL=0 */ 4610 /* Privileged instruction can be executed only in CPL=0 */
4610 if ((ctxt->d & Priv) && ops->cpl(ctxt)) { 4611 if ((ctxt->d & Priv) && ops->cpl(ctxt)) {
4611 rc = emulate_gp(ctxt, 0); 4612 if (ctxt->d & PrivUD)
4613 rc = emulate_ud(ctxt);
4614 else
4615 rc = emulate_gp(ctxt, 0);
4612 goto done; 4616 goto done;
4613 } 4617 }
4614 4618