PPC405 support in later 2.4.x kernels
Quoted 2 lines · Trevor Woerner
I grabbed 2.4.22-pre8 and found the ppc4xx code back, but the strangest thing is now happening: I've lost my user-space.
I had the same problem with 2.4.22. I diffed 2.4.21-pre7 with 2.4.22 and found some 405-specific code to be missing in the fault handler. The attached patch fixes the problem.
arch/ppc/mm/fault.c +24 -0
@@ -26,6 +26,7 @@#include <linux/mman.h> #include <linux/mm.h> #include <linux/interrupt.h> +#include <linux/highmem.h> #include <asm/page.h> #include <asm/pgtable.h>
@@ -51,6 +52,7 @@ unsigned int probingmem;extern void die_if_kernel (char *,struct pt_regs *,long );void bad_page_fault (struct pt_regs *,unsigned long ,int sig);void do_page_fault (struct pt_regs *,unsigned long ,unsigned long ); +extern int get_pteptr (struct mm_struct *mm,unsigned long addr,pte_t **ptep);/* * Check whether the instruction at regs->nip is a store using
@@ -202,6 +204,28 @@ good_area:if (is_write) {if (!(vma->vm_flags &VM_WRITE )) goto bad_area; +#if defined(CONFIG_4xx) + /* an exec - 4xx/BookE allows for per-page execute permission */ + }else if (regs->trap ==0x400 ) { +pte_t *ptep; + + +/* Since 4xx supports per-page execute permission, +* we lazily flush dcache to icache. */ +if (get_pteptr (mm, address, &ptep) &&pte_present (*ptep)) { +struct page *page =pte_page (*ptep); + +if (!test_bit (PG_arch_1, &page->flags)) { +__flush_dcache_icache (kmap (page)); +kunmap (page); +set_bit (PG_arch_1, &page->flags); + } +pte_update (ptep,0 , _PAGE_HWEXEC); +_tlbie (address); +up_read (&mm->mmap_sem); +return ; + } +#endif /* a read */ }else {/* protection fault */
Quoted 7 lines · Wouter Cloetens
Quoted 2 lines · Trevor Woerner
I grabbed 2.4.22-pre8 and found the ppc4xx code back, but the strangest thing is now happening: I've lost my user-space.
I had the same problem with 2.4.22. I diffed 2.4.21-pre7 with 2.4.22 and found some 405-specific code to be missing in the fault handler. The attached patch fixes the problem.
The patch is half of an optimization. We have ended up with code which never sets execute permission on the PTEs (my fault). We should either just add code (in the TLB miss handler or elsewhere) to set execute permission on all pages, or else do the full lazy-flush optimization, which involves the change in do_page_fault plus another change to flush_icache_page to make it turn off hardware execute permission rather than flushing the page. (The latter half doesn't seem to be in linuxppc-2.4 or linuxppc_2_4_devel, which is interesting.)
I'll check in a proper fix in the next day or so. In the meantime the patch to do_page_fault will fix the problem.
Paul.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/