diff options
author | Alexander van Heukelum <heukelum@mailshack.com> | 2008-07-01 19:32:04 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-09 02:18:07 -0400 |
commit | 13485ab55bc77f02024e80bcca0374950b0becb3 (patch) | |
tree | 3f959112d6c70827319a61a415f70e34f79cbbf1 /arch/x86/kernel/traps_32.c | |
parent | a7bbb0ce1d1f956c8491b925c74767adf654f373 (diff) |
x86: traps_xx: restructure do_general_protection()
- if (cond) block -> if (!cond) goto end_of_block
- local caching of current
Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/traps_32.c')
-rw-r--r-- | arch/x86/kernel/traps_32.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c index 5afd94a01b98..c9a0120e510c 100644 --- a/arch/x86/kernel/traps_32.c +++ b/arch/x86/kernel/traps_32.c | |||
@@ -598,8 +598,10 @@ DO_ERROR(12, SIGBUS, "stack segment", stack_segment) | |||
598 | DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0, 0) | 598 | DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0, 0) |
599 | DO_ERROR_INFO(32, SIGILL, "iret exception", iret_error, ILL_BADSTK, 0, 1) | 599 | DO_ERROR_INFO(32, SIGILL, "iret exception", iret_error, ILL_BADSTK, 0, 1) |
600 | 600 | ||
601 | void __kprobes do_general_protection(struct pt_regs *regs, long error_code) | 601 | void __kprobes |
602 | do_general_protection(struct pt_regs *regs, long error_code) | ||
602 | { | 603 | { |
604 | struct task_struct *tsk; | ||
603 | struct thread_struct *thread; | 605 | struct thread_struct *thread; |
604 | struct tss_struct *tss; | 606 | struct tss_struct *tss; |
605 | int cpu; | 607 | int cpu; |
@@ -640,23 +642,24 @@ void __kprobes do_general_protection(struct pt_regs *regs, long error_code) | |||
640 | if (regs->flags & X86_VM_MASK) | 642 | if (regs->flags & X86_VM_MASK) |
641 | goto gp_in_vm86; | 643 | goto gp_in_vm86; |
642 | 644 | ||
645 | tsk = current; | ||
643 | if (!user_mode(regs)) | 646 | if (!user_mode(regs)) |
644 | goto gp_in_kernel; | 647 | goto gp_in_kernel; |
645 | 648 | ||
646 | current->thread.error_code = error_code; | 649 | tsk->thread.error_code = error_code; |
647 | current->thread.trap_no = 13; | 650 | tsk->thread.trap_no = 13; |
648 | 651 | ||
649 | if (show_unhandled_signals && unhandled_signal(current, SIGSEGV) && | 652 | if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) && |
650 | printk_ratelimit()) { | 653 | printk_ratelimit()) { |
651 | printk(KERN_INFO | 654 | printk(KERN_INFO |
652 | "%s[%d] general protection ip:%lx sp:%lx error:%lx", | 655 | "%s[%d] general protection ip:%lx sp:%lx error:%lx", |
653 | current->comm, task_pid_nr(current), | 656 | tsk->comm, task_pid_nr(tsk), |
654 | regs->ip, regs->sp, error_code); | 657 | regs->ip, regs->sp, error_code); |
655 | print_vma_addr(" in ", regs->ip); | 658 | print_vma_addr(" in ", regs->ip); |
656 | printk("\n"); | 659 | printk("\n"); |
657 | } | 660 | } |
658 | 661 | ||
659 | force_sig(SIGSEGV, current); | 662 | force_sig(SIGSEGV, tsk); |
660 | return; | 663 | return; |
661 | 664 | ||
662 | gp_in_vm86: | 665 | gp_in_vm86: |
@@ -665,14 +668,15 @@ gp_in_vm86: | |||
665 | return; | 668 | return; |
666 | 669 | ||
667 | gp_in_kernel: | 670 | gp_in_kernel: |
668 | if (!fixup_exception(regs)) { | 671 | if (fixup_exception(regs)) |
669 | current->thread.error_code = error_code; | 672 | return; |
670 | current->thread.trap_no = 13; | 673 | |
671 | if (notify_die(DIE_GPF, "general protection fault", regs, | 674 | tsk->thread.error_code = error_code; |
675 | tsk->thread.trap_no = 13; | ||
676 | if (notify_die(DIE_GPF, "general protection fault", regs, | ||
672 | error_code, 13, SIGSEGV) == NOTIFY_STOP) | 677 | error_code, 13, SIGSEGV) == NOTIFY_STOP) |
673 | return; | 678 | return; |
674 | die("general protection fault", regs, error_code); | 679 | die("general protection fault", regs, error_code); |
675 | } | ||
676 | } | 680 | } |
677 | 681 | ||
678 | static notrace __kprobes void | 682 | static notrace __kprobes void |