Skip to content

Commit

Permalink
target-i386: fix protection bits in the TLB for SMEP
Browse files Browse the repository at this point in the history
User pages must be marked as non-executable when running under SMEP;
otherwise, fetching the page first and then calling it will fail.

With this patch, all SMEP testcases in kvm-unit-tests now pass.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Jun 5, 2014
1 parent de431a6 commit b09481d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion target-i386/helper.c
Expand Up @@ -749,8 +749,10 @@ int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr,

/* the page can be put in the TLB */
prot = PAGE_READ;
if (!(ptep & PG_NX_MASK))
if (!(ptep & PG_NX_MASK) &&
!((env->cr[4] & CR4_SMEP_MASK) && (ptep & PG_USER_MASK))) {
prot |= PAGE_EXEC;
}
if (pte & PG_DIRTY_MASK) {
/* only set write access if already dirty... otherwise wait
for dirty access */
Expand Down

0 comments on commit b09481d

Please sign in to comment.