fault.c 1.5 KB

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