Skip to contentSkip to conversation

target-i386: Allow execute from user mode when SMEP is enabled.

PATCH In review Ricky Zhou 2 participants 2 messages Jul 14, 2014 – Jul 15, 2014

lore
Share & tools
lore

Ricky Zhou

author
#0 lore raw

PATCH 1/1 target-i386: Allow execute from user mode when SMEP is enabled.

Previously, execute would be disabled for all pages with SMEP enabled, regardless of what mode the access took place in.

---
 target-i386/helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target-i386/helper.c +2 -1
index 11ca864..47b982b 100644
@@ -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) {
Signature · 1 line
1.9.3
#1 lore raw

Il 14/07/2014 22:54, Ricky Zhou ha scritto:

Quoted 14 lines

Previously, execute would be disabled for all pages with SMEP enabled, regardless of what mode the access took place in.

---
 target-i386/helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target-i386/helper.c +0 -0
index 11ca864..47b982b 100644

target-i386/helper.c do_check_protect_pse36: · line 757

Quoted 9 lines
target-i386/helper.c +2 -1
@@ -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) {

Thanks, queued for 2.1.

Paolo