Skip to content

Commit

Permalink
x86: Merge kernel_math_error() into math_error()
Browse files Browse the repository at this point in the history
Clean up the kernel exception handling and make it more similar to
the other traps.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
LKML-Reference: <1269176446-2489-4-git-send-email-brgerst@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
  • Loading branch information
Brian Gerst authored and H. Peter Anvin committed May 3, 2010
1 parent 9b6dba9 commit e2e75c9
Showing 1 changed file with 16 additions and 28 deletions.
44 changes: 16 additions & 28 deletions arch/x86/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,35 +576,35 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
return;
}

#ifdef CONFIG_X86_64
static int kernel_math_error(struct pt_regs *regs, const char *str, int trapnr)
{
if (fixup_exception(regs))
return 1;

notify_die(DIE_GPF, str, regs, 0, trapnr, SIGFPE);
/* Illegal floating point operation in the kernel */
current->thread.trap_no = trapnr;
die(str, regs, 0);
return 0;
}
#endif

/*
* Note that we play around with the 'TS' bit in an attempt to get
* the correct behaviour even in the presence of the asynchronous
* IRQ13 behaviour
*/
void math_error(struct pt_regs *regs, int error_code, int trapnr)
{
struct task_struct *task;
struct task_struct *task = current;
siginfo_t info;
unsigned short err;
char *str = (trapnr == 16) ? "fpu exception" : "simd exception";

if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, SIGFPE) == NOTIFY_STOP)
return;
conditional_sti(regs);

if (!user_mode_vm(regs))
{
if (!fixup_exception(regs)) {
task->thread.error_code = error_code;
task->thread.trap_no = trapnr;
die(str, regs, error_code);
}
return;
}

/*
* Save the info for the exception handler and clear the error.
*/
task = current;
save_init_fpu(task);
task->thread.trap_no = trapnr;
task->thread.error_code = error_code;
Expand Down Expand Up @@ -665,14 +665,8 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)

dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code)
{
conditional_sti(regs);

#ifdef CONFIG_X86_32
ignore_fpu_irq = 1;
#else
if (!user_mode(regs) &&
kernel_math_error(regs, "kernel x87 math error", 16))
return;
#endif

math_error(regs, error_code, 16);
Expand All @@ -681,14 +675,8 @@ dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code)
dotraplinkage void
do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
{
conditional_sti(regs);

#ifdef CONFIG_X86_32
ignore_fpu_irq = 1;
#else
if (!user_mode(regs) &&
kernel_math_error(regs, "kernel simd math error", 19))
return;
#endif

math_error(regs, error_code, 19);
Expand Down

0 comments on commit e2e75c9

Please sign in to comment.