patch-1.3.53 linux/arch/ppc/mm/fault.c
Next file: linux/arch/ppc/mm/init.c
Previous file: linux/arch/ppc/mm/Makefile
Back to the patch index
Back to the overall index
- Lines: 255
- Date:
Sat Dec 30 15:48:22 1995
- Orig file:
v1.3.52/linux/arch/ppc/mm/fault.c
- Orig date:
Mon Nov 27 12:48:27 1995
diff -u --recursive --new-file v1.3.52/linux/arch/ppc/mm/fault.c linux/arch/ppc/mm/fault.c
@@ -1,3 +1,4 @@
+/* * Last edited: Nov 29 18:14 1995 (cort) */
/*
* ARCH/ppc/mm/fault.c
*
@@ -5,6 +6,9 @@
* Ported to PPC by Gary Thomas
*/
+/*#define NOISY_DATAFAULT*/
+/*#define NOISY_INSTRFAULT*/
+
#include <linux/config.h>
#include <linux/signal.h>
#include <linux/sched.h>
@@ -37,19 +41,24 @@
if (user_mode(regs)) mode |= 0x04;
if (regs->dsisr & 0x02000000) mode |= 0x02; /* Load/store */
if (regs->dsisr & 0x08000000) mode |= 0x01; /* Protection violation */
-#if 0
- /*#ifdef SHOW_FAULTS*/
- printk("Data Access Fault - Loc: %x, DSISR: %x, PC: %x", regs->dar, regs->dsisr, regs->nip);
- printk(" PR: %d\n", regs->msr &&(1<<14));
+#ifdef NOISY_DATAFAULT
+ printk("Data fault on %x\n",regs->dar);
#endif
if (mode & 0x01)
{
#if 0
printk("Write Protect Fault - Loc: %x, DSISR: %x, PC: %x\n", regs->dar, regs->dsisr, regs->nip);
#endif
+#ifdef NOISY_DATAFAULT
+ printk("Write Protect fault\n ");
+#endif
do_page_fault(regs, regs->dar, mode);
+#ifdef NOISY_DATAFAULT
+ printk("Write Protect fault handled\n");
+#endif
return;
}
+/* printk("trying\n"); */
for (tries = 0; tries < 1; tries++)
{
dir = pgd_offset(current->mm, regs->dar & PAGE_MASK);
@@ -72,7 +81,15 @@
{
printk("No PGD\n");
}
+#ifdef NOISY_DATAFAULT
+ printk("fall through page fault addr=%x; ip=%x\n",
+ regs->dar,regs->nip);
+ printk("beforefault: pgd[0] = %x[%x]\n",current->mm->pgd,*(current->mm->pgd));
+#endif
do_page_fault(regs, regs->dar, mode);
+#ifdef NOISY_DATAFAULT
+ printk("handled: pgd[0] = %x[%x]\n",current->mm->pgd,*(current->mm->pgd));
+#endif
}
}
@@ -83,43 +100,72 @@
pmd_t *pmd;
pte_t *pte;
int tries, mode = 0;
-#if 0
- panic("Instruction Access Fault - Loc: %x, DSISR: %x, PC: %x\n", regs->dar, regs->dsisr, regs->nip);
-#endif
+
+#if NOISY_INSTRFAULT
+ printk("Instr fault on %x\n",regs->dar);
+#endif
if (user_mode(regs)) mode |= 0x04;
if (regs->dsisr & 0x02000000) mode |= 0x02; /* Load/store */
if (regs->dsisr & 0x08000000) mode |= 0x01; /* Protection violation */
+
if (mode & 0x01)
{
- do_page_fault(regs, regs->dar, mode);
+ do_page_fault(regs, regs->dar, mode);
return;
}
for (tries = 0; tries < 1; tries++)
{
+ /* dir = pgd_offset(current->mm, regs->nip & PAGE_MASK); */
dir = pgd_offset(current->mm, regs->dar & PAGE_MASK);
+#ifdef NOISY_INSTRFAULT
+/* printk("regs->dar=%x current=%x current->mm=%x current->mm->pgd=%x current->tss.pg_tables=%x\n",
+ regs->dar,current,current->mm,current->mm->pgd,current->tss.pg_tables);*/
+#endif
if (dir)
{
- pmd = pmd_offset(dir, regs->dar & PAGE_MASK);
+ pmd = pmd_offset(dir, regs->dar & PAGE_MASK);
if (pmd && pmd_present(*pmd))
{
- pte = pte_offset(pmd, regs->dar & PAGE_MASK);
- if (pte && pte_present(*pte))
- {
+ pte = pte_offset(pmd, regs->dar & PAGE_MASK);
+
+#ifdef NOISY_INSTRFAULT
+/* printk("dir %x(%x) pmd %x(%x) pte %x\n",dir,*dir,pmd,*pmd,pte);*/
#if 0
- printk("Page mapped - PTE: %x[%x]\n", pte, *(long *)pte);
+ printk("pgd_offset mm=%x mm->pgd=%x dirshouldbe=%x\n",
+ current->mm, current->mm->pgd,
+ current->mm->pgd+((regs->dar&PAGE_MASK) >> PGDIR_SHIFT));
+ printk("dir is %x\n", dir);
+
+ /* printk("got pte\n"); */
+ if (pte) {
+ printk("pgd=%x; dir=%x->%x; pmd=%x->%x; pte=%x; \n",
+ current->mm->pgd,dir,*dir,pmd,*pmd,pte);
+ if (pte_present(*pte)) {
+ printk("pte present\n");
+ } else {
+ printk("pte not present\n");
+ }
+ } else {
+ printk("pte false\n");
+ }
#endif
- MMU_hash_page(¤t->tss, regs->dar & PAGE_MASK, pte);
+#endif
+ if (pte && pte_present(*pte))
+ {
+/* MMU_hash_page(¤t->tss, regs->nip & PAGE_MASK, pte); */
+ MMU_hash_page(¤t->tss, regs->dar & PAGE_MASK, pte);
return;
}
}
} else
{
-#if 1
- panic("No PGD Instruction Access Fault - Loc: %x, DSISR: %x, PC: %x\n", regs->dar, regs->dsisr, regs->nip);
-#endif
- printk("No PGD\n");
+#ifdef NOISY_INSTRFAULT
+ panic("No PGD Instruction Access Fault - Loc: %x, DSISR: %x, PC: %x current->mm\n",
+ regs->dar, regs->dsisr, regs->nip, current->mm);
+#endif
}
- do_page_fault(regs, regs->dar, mode);
+/* do_page_fault(regs, regs->nip, mode); */
+ do_page_fault(regs, regs->dar, mode);
}
}
@@ -138,24 +184,15 @@
{
struct vm_area_struct * vma;
unsigned long page;
-/* printk("\ndo_page_fault()\n");*/
+
+/* printk("In do_page_fault()\n"); */
#if 1
for (vma = current->mm->mmap ; ; vma = vma->vm_next)
{
if (!vma)
{
-#if 0 /* mfisk */
- { struct vm_area_struct * mmp;
-
- for(mmp=current->mm->mmap; mmp; mmp=mmp->vm_next) {
- printk("notinmap: current: %x; mm: %x; mmap: %x; vma: %x to %x flags: %x\n",
- current, current->mm, mmp, mmp->vm_start, mmp->vm_end, mmp->vm_flags);
- }
- }
-#endif
- panic("do_page_fault() !vma \n");
- panic("not in map: ip = %x; current=%x; mm=%x; mmap=%x; address = %x error_code = %x\n",
- regs->nip, current, current->mm, current->mm->mmap, address, error_code);
+ panic("!vma: ip = %x; current=%x[%d]; mm=%x; mmap=%x; address = %x error_code = %x\n",
+ regs->nip, current,current->pid,current->mm,current->mm->mmap, address, error_code);
goto bad_area;
}
if (vma->vm_end > address)
@@ -164,6 +201,8 @@
#else
vma = find_vma(current, address);
if (!vma)
+ {
+ }
goto bad_area;
#endif
if (vma->vm_start <= address){
@@ -171,13 +210,19 @@
}
if (!(vma->vm_flags & VM_GROWSDOWN))
{
+ printk("stack: gpr[1]=%x ip = %x; current=%x[%d]; mm=%x; mmap=%x; address = %x error_code = %x\n",regs->gpr[1],regs->nip, current,current->pid,current->mm,current->mm->mmap, address, error_code);
panic("stack\n");
goto bad_area;
}
if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur)
- { panic("stack 2\n");
+ {
+ printk("stack2: vma->vm_end-addres %x rlim %x\n", vma->vm_end - address,
+ current->rlim[RLIMIT_STACK].rlim_cur);
+ printk("stack2: vm_end %x address = %x\n", vma->vm_end,address);
+ printk("stack2: gpr[1]=%x ip = %x; current=%x[%d]; mm=%x; mmap=%x; address = %x error_code = %x\n",regs->gpr[1],regs->nip, current,current->pid,current->mm,current->mm->mmap, address, error_code);
+ panic("stack2\n");
goto bad_area;
- }
+ }
vma->vm_offset -= vma->vm_start - (address & PAGE_MASK);
vma->vm_start = (address & PAGE_MASK);
@@ -192,8 +237,8 @@
if (error_code & 2) {
if (!(vma->vm_flags & VM_WRITE))
{
- panic("\ndo_page_fault() write\n");
- panic("\ndo_page_fault() write! current: %x, address:%x, vm_flags: %x, mm: %x; vma(%x) %x to %x\n",
+ panic("do_page_fault() write\n");
+ panic("do_page_fault() write! current: %x, address:%x, vm_flags: %x, mm: %x; vma(%x) %x to %x\n",
current,address,vma->vm_flags,current->mm,vma,vma->vm_start,vma->vm_end);
goto bad_area;
}
@@ -224,7 +269,10 @@
goto bad_area;
}
}
+/* printk("premm: pgd[0] = %x[%x]\n",current->mm->pgd,*(current->mm->pgd)); */
handle_mm_fault(vma, address, error_code & 2);
+/* printk("handled fault for %x in %x to %x flags %x\n", */
+/* address,vma->vm_start,vma->vm_end,vma->vm_flags); */
return;
/*
@@ -233,16 +281,21 @@
*/
bad_area:
if (user_mode(regs)) {
- panic("Task: %x, PC: %x, bad area! - Addr: %x\n", current, regs->nip, address);
+ printk("Task: %x, PC: %x, bad area! - Addr: %x\n", current, regs->nip, address);
send_sig(SIGSEGV, current, 1);
return;
}
#if 0
- panic("\nKERNEL! Task: %x, PC: %x, bad area! - Addr: %x, PGDIR: %x\n",
+ panic("KERNEL! Task: %x, PC: %x, bad area! - Addr: %x, PGDIR: %x\n",
current, regs->nip, address, current->tss.pg_tables);
#else
- panic("\nKERNELmm! current: %x, address:%x, vm_flags: %x, mm: %x; vma(%x) %x to %x\n",
+ /* panic("KERNEL mm! current: %x, address:%x, vm_flags: %x, mm: %x; \nvma(%x) %x to %x swapper_pg_dir %x\n",
+ current,address,vma->vm_flags,current->mm,vma,vma->vm_start,vma->vm_end,
+ swapper_pg_dir);*/
+ printk("KERNEL mm! current: %x, address:%x, vm_flags: %x, mm: %x; vma(%x) %x to %x\n",
current,address,vma->vm_flags,current->mm,vma,vma->vm_start,vma->vm_end);
+ panic("Kernel access of bad area\n");
+
#endif
while (1) ;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov
with Sam's (original) version of this