fault.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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/pgtable.h>
  19. void die(const char *str, struct pt_regs *fp, unsigned long err);
  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. pr_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. pr_alert("Unable to handle kernel NULL pointer dereference");
  44. else
  45. pr_alert("Unable to handle kernel access");
  46. printk(" at virtual address %08lx\n", address);
  47. if (!user_mode(regs))
  48. die("Oops", regs, error_code);
  49. do_exit(SIGKILL);
  50. return 1;
  51. }