fault.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * linux/arch/m68knommu/mm/fault.c
  3. *
  4. * Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>,
  5. * Copyright (C) 2000 Lineo, Inc. (www.lineo.com)
  6. *
  7. * Based on:
  8. *
  9. * linux/arch/m68k/mm/fault.c
  10. *
  11. * Copyright (C) 1995 Hamish Macdonald
  12. */
  13. #include <linux/mman.h>
  14. #include <linux/mm.h>
  15. #include <linux/kernel.h>
  16. #include <linux/ptrace.h>
  17. #include <asm/system.h>
  18. #include <asm/pgtable.h>
  19. extern void die_if_kernel(char *, struct pt_regs *, long);
  20. /*
  21. * This routine handles page faults. It determines the problem, and
  22. * then passes it off to one of the appropriate routines.
  23. *
  24. * error_code:
  25. * bit 0 == 0 means no page found, 1 means protection fault
  26. * bit 1 == 0 means read, 1 means write
  27. *
  28. * If this routine detects a bad access, it returns 1, otherwise it
  29. * returns 0.
  30. */
  31. asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address,
  32. unsigned long error_code)
  33. {
  34. #ifdef DEBUG
  35. printk (KERN_DEBUG "regs->sr=%#x, regs->pc=%#lx, address=%#lx, %ld\n",
  36. regs->sr, regs->pc, address, error_code);
  37. #endif
  38. /*
  39. * Oops. The kernel tried to access some bad page. We'll have to
  40. * terminate things with extreme prejudice.
  41. */
  42. if ((unsigned long) address < PAGE_SIZE) {
  43. printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
  44. } else
  45. printk(KERN_ALERT "Unable to handle kernel access");
  46. printk(KERN_ALERT " at virtual address %08lx\n",address);
  47. die_if_kernel("Oops", regs, error_code);
  48. do_exit(SIGKILL);
  49. return 1;
  50. }