Commit c416ddf5 authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Ingo Molnar

x86: Unspaghettize do_trap()

Cleanup the label maze in this function. Having a
seperate function to first handle the traps that don't
generate a signal makes it easier to convert into
more readable conditional paths.
Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1348577479-2564-1-git-send-email-fweisbec@gmail.com
[ Fixed 32-bit build failure. ]
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 1b2b23d8
...@@ -107,30 +107,45 @@ static inline void preempt_conditional_cli(struct pt_regs *regs) ...@@ -107,30 +107,45 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
dec_preempt_count(); dec_preempt_count();
} }
static void __kprobes static int __kprobes
do_trap(int trapnr, int signr, char *str, struct pt_regs *regs, do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
long error_code, siginfo_t *info) struct pt_regs *regs, long error_code)
{ {
struct task_struct *tsk = current;
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
if (regs->flags & X86_VM_MASK) { if (regs->flags & X86_VM_MASK) {
/* /*
* traps 0, 1, 3, 4, and 5 should be forwarded to vm86. * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
* On nmi (interrupt 2), do_trap should not be called. * On nmi (interrupt 2), do_trap should not be called.
*/ */
if (trapnr < X86_TRAP_UD) if (trapnr < X86_TRAP_UD) {
goto vm86_trap; if (!handle_vm86_trap((struct kernel_vm86_regs *) regs,
goto trap_signal; error_code, trapnr))
return 0;
}
return -1;
} }
#endif #endif
if (!user_mode(regs)) {
if (!fixup_exception(regs)) {
tsk->thread.error_code = error_code;
tsk->thread.trap_nr = trapnr;
die(str, regs, error_code);
}
return 0;
}
if (!user_mode(regs)) return -1;
goto kernel_trap; }
#ifdef CONFIG_X86_32 static void __kprobes
trap_signal: do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
#endif long error_code, siginfo_t *info)
{
struct task_struct *tsk = current;
if (!do_trap_no_signal(tsk, trapnr, str, regs, error_code))
return;
/* /*
* We want error_code and trap_nr set for userspace faults and * We want error_code and trap_nr set for userspace faults and
* kernelspace faults which result in die(), but not * kernelspace faults which result in die(), but not
...@@ -158,23 +173,6 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs, ...@@ -158,23 +173,6 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
force_sig_info(signr, info, tsk); force_sig_info(signr, info, tsk);
else else
force_sig(signr, tsk); force_sig(signr, tsk);
return;
kernel_trap:
if (!fixup_exception(regs)) {
tsk->thread.error_code = error_code;
tsk->thread.trap_nr = trapnr;
die(str, regs, error_code);
}
return;
#ifdef CONFIG_X86_32
vm86_trap:
if (handle_vm86_trap((struct kernel_vm86_regs *) regs,
error_code, trapnr))
goto trap_signal;
return;
#endif
} }
#define DO_ERROR(trapnr, signr, str, name) \ #define DO_ERROR(trapnr, signr, str, name) \
......
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