target-i386: Allow execute from user mode when SMEP is enabled.
authorRicky Zhou <ricky@rzhou.org>
Mon, 14 Jul 2014 20:54:47 +0000 (13:54 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 15 Jul 2014 16:43:14 +0000 (18:43 +0200)
Previously, execute would be disabled for all pages with SMEP enabled,
regardless of what mode the access took place in.

Signed-off-by: Ricky Zhou <ricky@rzhou.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target-i386/helper.c

index 11ca864..47b982b 100644 (file)
@@ -750,7 +750,8 @@ do_check_protect_pse36:
     /* the page can be put in the TLB */
     prot = PAGE_READ;
     if (!(ptep & PG_NX_MASK) &&
-        !((env->cr[4] & CR4_SMEP_MASK) && (ptep & PG_USER_MASK))) {
+        (mmu_idx == MMU_USER_IDX ||
+         !((env->cr[4] & CR4_SMEP_MASK) && (ptep & PG_USER_MASK)))) {
         prot |= PAGE_EXEC;
     }
     if (pte & PG_DIRTY_MASK) {