11 #include <linux/module.h>
12 #include <linux/signal.h>
19 #include <linux/sched.h>
21 #include <linux/perf_event.h>
23 #include <asm/exception.h>
24 #include <asm/pgtable.h>
25 #include <asm/system_misc.h>
27 #include <asm/tlbflush.h>
34 static inline int notify_page_fault(
struct pt_regs *
regs,
unsigned int fsr)
49 static inline int notify_page_fault(
struct pt_regs *regs,
unsigned int fsr)
69 addr, (
long long)
pgd_val(*pgd));
114 #ifndef CONFIG_ARM_LPAE
132 __do_kernel_fault(
struct mm_struct *mm,
unsigned long addr,
unsigned int fsr,
146 "Unable to handle kernel %s at virtual address %08lx\n",
147 (addr <
PAGE_SIZE) ?
"NULL pointer dereference" :
148 "paging request", addr);
151 die(
"Oops", regs, fsr);
161 __do_user_fault(
struct task_struct *tsk,
unsigned long addr,
162 unsigned int fsr,
unsigned int sig,
int code,
167 #ifdef CONFIG_DEBUG_USER
170 printk(
KERN_DEBUG "%s: unhandled page fault (%d) at 0x%08lx, code 0x%03x\n",
171 tsk->
comm, sig, addr, fsr);
178 tsk->
thread.error_code = fsr;
183 si.si_addr = (
void __user *)addr;
199 __do_kernel_fault(mm, addr, fsr, regs);
203 #define VM_FAULT_BADMAP 0x010000
204 #define VM_FAULT_BADACCESS 0x020000
211 static inline bool access_error(
unsigned int fsr,
struct vm_area_struct *vma)
213 unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
220 return vma->
vm_flags & mask ?
false :
true;
224 __do_page_fault(
struct mm_struct *mm,
unsigned long addr,
unsigned int fsr,
242 if (access_error(fsr, vma)) {
265 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
266 (write ? FAULT_FLAG_WRITE : 0);
268 if (notify_page_fault(regs, fsr))
302 #ifdef CONFIG_DEBUG_VM
309 fault = __do_page_fault(mm, addr, fsr, flags, tsk);
315 if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(
current))
325 if (!(fault & VM_FAULT_ERROR) && flags & FAULT_FLAG_ALLOW_RETRY) {
326 if (fault & VM_FAULT_MAJOR) {
335 if (fault & VM_FAULT_RETRY) {
338 flags &= ~FAULT_FLAG_ALLOW_RETRY;
339 flags |= FAULT_FLAG_TRIED;
352 if (fault & VM_FAULT_OOM) {
369 if (fault & VM_FAULT_SIGBUS) {
386 __do_user_fault(tsk, addr, fsr, sig, code, regs);
390 __do_kernel_fault(mm, addr, fsr, regs);
420 do_translation_fault(
unsigned long addr,
unsigned int fsr,
436 pgd = cpu_get_pgd() +
index;
455 #ifdef CONFIG_ARM_LPAE
483 do_translation_fault(
unsigned long addr,
unsigned int fsr,
495 do_sect_fault(
unsigned long addr,
unsigned int fsr,
struct pt_regs *regs)
505 do_bad(
unsigned long addr,
unsigned int fsr,
struct pt_regs *regs)
518 #ifdef CONFIG_ARM_LPAE
526 int sig,
int code,
const char *
name)
550 inf->
name, fsr, addr);
555 info.si_addr = (
void __user *)addr;
561 int sig,
int code,
const char *
name)
582 inf->
name, ifsr, addr);
587 info.si_addr = (
void __user *)addr;
591 #ifndef CONFIG_ARM_LPAE
592 static int __init exceptions_init(
void)
596 "I-cache maintenance fault");
605 "section access flag fault");
607 "section access flag fault");