KVM: x86: Emulator support for #UD on CPL>0
authorNadav Amit <namit@cs.technion.ac.il>
Wed, 18 Jun 2014 14:19:35 +0000 (17:19 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 11 Jul 2014 07:14:05 +0000 (09:14 +0200)
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>
arch/x86/kvm/emulate.c

index b61ffe9d86a7a335282465e1dbda023dce5dcaf2..dd074106d0c9bee26f3a603278c77f2d9361b53c 100644 (file)
 #define Intercept   ((u64)1 << 48)  /* Has valid intercept field */
 #define CheckPerm   ((u64)1 << 49)  /* Has valid check_perm field */
 #define NoBigReal   ((u64)1 << 50)  /* No big real mode */
+#define PrivUD      ((u64)1 << 51)  /* #UD instead of #GP on CPL > 0 */
 
 #define DstXacc     (DstAccLo | SrcAccHi | SrcWrite)
 
@@ -4608,7 +4609,10 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
 
                /* Privileged instruction can be executed only in CPL=0 */
                if ((ctxt->d & Priv) && ops->cpl(ctxt)) {
-                       rc = emulate_gp(ctxt, 0);
+                       if (ctxt->d & PrivUD)
+                               rc = emulate_ud(ctxt);
+                       else
+                               rc = emulate_gp(ctxt, 0);
                        goto done;
                }
 
This page took 0.027263 seconds and 5 git commands to generate.