[PATCH] Treat ISI faults as read faults on classic 32-bit PowerPC

Paul Mackerras paulus at samba.org
Thu Jul 19 10:00:20 EST 2007


Segher Boessenkool writes:

> Some old software on ppc32 executes from pages it hasn't marked
> executable.  Since "classic" hardware doesn't distinguish between
> execute and read accesses, the do_page_fault() code shouldn't
> either.  This makes glibc-2.2 work again on such hardware.
> 
> Signed-off-by: Segher Boessenkool <segher at kernel.crashing.org>
> Cc: Scott Wood <scottwood at freescale.com>
> Cc: Johannes Berg <johannes at sipsolutions.net>
> ---
> [Resend again, ozlabs' greylisting doesn't like me at all.]
> 
> Tested by Scott on 32-bit, glibc-2.2.5 and glibc-2.3.3 (no new
> failures and problem solved), and by Johannes on his glibc-2.4
> "---p" testcase.  Could use testing on ppc64 and BookE too, for
> good measure.

Hmmm.  The dangling else clauses are pretty gross, and in fact we have
the same problem on POWER3 and RS64 processors (to be fair, we had
the problem before and didn't notice, but we should still fix it).

How about this instead?  Could people test it please?  (Note that
CPU_FTR_NOEXECUTE is 0 in 32-bit kernels.)

Paul.

diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index 0ece513..99c3093 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -283,7 +283,13 @@ good_area:
 		/* protection fault */
 		if (error_code & DSISR_PROTFAULT)
 			goto bad_area;
-		if (!(vma->vm_flags & VM_EXEC))
+		/*
+		 * Allow execution from readable areas if the MMU does not
+		 * provide separate controls over reading and executing.
+		 */
+		if (!(vma->vm_flags & VM_EXEC) &&
+		    (cpu_has_feature(CPU_FTR_NOEXECUTE) ||
+		     !(vma->vm_flags & (VM_READ | VM_WRITE))))
 			goto bad_area;
 #else
 		pte_t *ptep;



More information about the Linuxppc-dev mailing list