Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 68efa764 authored by Nadav Amit's avatar Nadav Amit Committed by Paolo Bonzini
Browse files

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: default avatarNadav Amit <namit@cs.technion.ac.il>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 10e38fc7
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@
#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,6 +4609,9 @@ 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)) {
			if (ctxt->d & PrivUD)
				rc = emulate_ud(ctxt);
			else
				rc = emulate_gp(ctxt, 0);
			goto done;
		}