1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#include <linux/mman.h>
17#include <linux/mm.h>
18#include <linux/kernel.h>
19#include <linux/ptrace.h>
20
21
22void die(const char *str, struct pt_regs *fp, unsigned long err);
23
24
25
26
27
28
29
30
31
32
33
34
35asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address,
36 unsigned long error_code)
37{
38#ifdef DEBUG
39 pr_debug("regs->sr=%#x, regs->pc=%#lx, address=%#lx, %ld\n",
40 regs->sr, regs->pc, address, error_code);
41#endif
42
43
44
45
46
47 if ((unsigned long) address < PAGE_SIZE)
48 pr_alert("Unable to handle kernel NULL pointer dereference");
49 else
50 pr_alert("Unable to handle kernel access");
51 printk(" at virtual address %08lx\n", address);
52 if (!user_mode(regs))
53 die("Oops", regs, error_code);
54 do_exit(SIGKILL);
55
56 return 1;
57}
58