fault.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. /*
  20. * This routine handles page faults. It determines the problem, and
  21. * then passes it off to one of the appropriate routines.
  22. *
  23. * error_code:
  24. * bit 0 == 0 means no page found, 1 means protection fault
  25. * bit 1 == 0 means read, 1 means write
  26. *
  27. * If this routine detects a bad access, it returns 1, otherwise it
  28. * returns 0.
  29. */
  30. asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address,
  31. unsigned long error_code)
  32. {
  33. #ifdef DEBUG
  34. printk ("regs->sr=%#x, regs->pc=%#lx, address=%#lx, %ld\n",
  35. regs->sr, regs->pc, address, error_code);
  36. #endif
  37. /*
  38. * Oops. The kernel tried to access some bad page. We'll have to
  39. * terminate things with extreme prejudice.
  40. */
  41. if ((unsigned long) address < PAGE_SIZE) {
  42. printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
  43. } else
  44. printk(KERN_ALERT "Unable to handle kernel access");
  45. printk(" at virtual address %08lx\n",address);
  46. if (!user_mode(regs))
  47. die("Oops", regs, error_code);
  48. do_exit(SIGKILL);
  49. return 1;
  50. }