#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)
+
 enum x86_intercept_stage {
        X86_ICPT_PRE_EXCEPT,
        X86_ICPT_POST_EXCEPT,
 
 #define Prefix      (1<<16)     /* Instruction varies with 66/f2/f3 prefix */
 #define Sse         (1<<17)     /* SSE Vector instruction */
 /* Misc flags */
+#define Prot        (1<<21) /* instruction generates #UD if not in prot-mode */
 #define VendorSpecific (1<<22) /* Vendor specific instruction */
 #define NoAccess    (1<<23) /* Don't access memory (lea/invlpg/verr etc) */
 #define Op3264      (1<<24) /* Operand is 64b in long mode, 32b otherwise */
                goto done;
        }
 
+       /* Instruction can only be executed in protected mode */
+       if ((c->d & Prot) && !(ctxt->mode & X86EMUL_MODE_PROT)) {
+               rc = emulate_ud(ctxt);
+               goto done;
+       }
+
        /* Do instruction specific permission checks */
        if (c->check_perm) {
                rc = c->check_perm(ctxt);