diff mbox

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

Message ID 1405371287-12189-1-git-send-email-ricky@rzhou.org
State New
Headers show

Commit Message

Ricky Zhou July 14, 2014, 8:54 p.m. UTC
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>
---
 target-i386/helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini July 15, 2014, 7:32 a.m. UTC | #1
Il 14/07/2014 22:54, Ricky Zhou ha scritto:
> 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>
> ---
>  target-i386/helper.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/target-i386/helper.c b/target-i386/helper.c
> index 11ca864..47b982b 100644
> --- a/target-i386/helper.c
> +++ b/target-i386/helper.c
> @@ -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
diff mbox

Patch

diff --git a/target-i386/helper.c b/target-i386/helper.c
index 11ca864..47b982b 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -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) {