Commit fd40d6e3 authored by Harvey Harrison's avatar Harvey Harrison Committed by Ingo Molnar

x86: shrink some ifdefs in fault.c

The change from current to tsk in do_page_fault is safe as
this is set at the very beginning of the function.

Removes a likely() annotation from the 64-bit version, this
could have instead been added to 32-bit.
Signed-off-by: default avatarHarvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 5b727a3b
...@@ -378,6 +378,7 @@ static void show_fault_oops(struct pt_regs *regs, unsigned long error_code, ...@@ -378,6 +378,7 @@ static void show_fault_oops(struct pt_regs *regs, unsigned long error_code,
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
if (!oops_may_print()) if (!oops_may_print())
return; return;
#endif
#ifdef CONFIG_X86_PAE #ifdef CONFIG_X86_PAE
if (error_code & PF_INSTR) { if (error_code & PF_INSTR) {
...@@ -390,28 +391,20 @@ static void show_fault_oops(struct pt_regs *regs, unsigned long error_code, ...@@ -390,28 +391,20 @@ static void show_fault_oops(struct pt_regs *regs, unsigned long error_code,
"(uid: %d)\n", current->uid); "(uid: %d)\n", current->uid);
} }
#endif #endif
printk(KERN_ALERT "BUG: unable to handle kernel ");
if (address < PAGE_SIZE)
printk(KERN_CONT "NULL pointer dereference");
else
printk(KERN_CONT "paging request");
printk(KERN_CONT " at %08lx\n", address);
printk(KERN_ALERT "IP:");
printk_address(regs->ip, 1);
dump_pagetable(address);
#else /* CONFIG_X86_64 */
printk(KERN_ALERT "BUG: unable to handle kernel "); printk(KERN_ALERT "BUG: unable to handle kernel ");
if (address < PAGE_SIZE) if (address < PAGE_SIZE)
printk(KERN_CONT "NULL pointer dereference"); printk(KERN_CONT "NULL pointer dereference");
else else
printk(KERN_CONT "paging request"); printk(KERN_CONT "paging request");
#ifdef CONFIG_X86_32
printk(KERN_CONT " at %08lx\n", address);
#else
printk(KERN_CONT " at %016lx\n", address); printk(KERN_CONT " at %016lx\n", address);
#endif
printk(KERN_ALERT "IP:"); printk(KERN_ALERT "IP:");
printk_address(regs->ip, 1); printk_address(regs->ip, 1);
dump_pagetable(address); dump_pagetable(address);
#endif
} }
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
...@@ -705,11 +698,7 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code) ...@@ -705,11 +698,7 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
vma = find_vma(mm, address); vma = find_vma(mm, address);
if (!vma) if (!vma)
goto bad_area; goto bad_area;
#ifdef CONFIG_X86_32
if (vma->vm_start <= address) if (vma->vm_start <= address)
#else
if (likely(vma->vm_start <= address))
#endif
goto good_area; goto good_area;
if (!(vma->vm_flags & VM_GROWSDOWN)) if (!(vma->vm_flags & VM_GROWSDOWN))
goto bad_area; goto bad_area;
...@@ -858,23 +847,21 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code) ...@@ -858,23 +847,21 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
*/ */
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
bust_spinlocks(1); bust_spinlocks(1);
#else
flags = oops_begin();
#endif
show_fault_oops(regs, error_code, address); show_fault_oops(regs, error_code, address);
tsk->thread.cr2 = address; tsk->thread.cr2 = address;
tsk->thread.trap_no = 14; tsk->thread.trap_no = 14;
tsk->thread.error_code = error_code; tsk->thread.error_code = error_code;
#ifdef CONFIG_X86_32
die("Oops", regs, error_code); die("Oops", regs, error_code);
bust_spinlocks(0); bust_spinlocks(0);
do_exit(SIGKILL); do_exit(SIGKILL);
#else /* CONFIG_X86_64 */ #else
flags = oops_begin();
show_fault_oops(regs, error_code, address);
tsk->thread.cr2 = address;
tsk->thread.trap_no = 14;
tsk->thread.error_code = error_code;
if (__die("Oops", regs, error_code)) if (__die("Oops", regs, error_code))
regs = NULL; regs = NULL;
/* Executive summary in case the body of the oops scrolled away */ /* Executive summary in case the body of the oops scrolled away */
...@@ -888,18 +875,16 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code) ...@@ -888,18 +875,16 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
*/ */
out_of_memory: out_of_memory:
up_read(&mm->mmap_sem); up_read(&mm->mmap_sem);
#ifdef CONFIG_X86_32
if (is_global_init(tsk)) { if (is_global_init(tsk)) {
yield(); yield();
#ifdef CONFIG_X86_32
down_read(&mm->mmap_sem); down_read(&mm->mmap_sem);
goto survive; goto survive;
}
#else #else
if (is_global_init(current)) {
yield();
goto again; goto again;
}
#endif #endif
}
printk("VM: killing process %s\n", tsk->comm); printk("VM: killing process %s\n", tsk->comm);
if (error_code & PF_USER) if (error_code & PF_USER)
do_group_exit(SIGKILL); do_group_exit(SIGKILL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment