aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/traps_32.c
diff options
context:
space:
mode:
authorAlexander van Heukelum <heukelum@fastmail.fm>2008-09-09 15:55:56 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-13 04:20:04 -0400
commit61aef7d24909b95f9eddaa78d78902fbea1d7059 (patch)
tree7accab8128d3f791b48614a334fa70e2b54e74bd /arch/x86/kernel/traps_32.c
parent762db4347060c5d23e9675846e02f7d95d7f944f (diff)
i386: prepare to convert exceptions to interrupts
There is some macro magic in traps_32.c to construct standard exception dispatch functions. This patch renames the DO_ERROR- like macros to DO_TRAP, and introduces new DO_ERROR ones that conditionally reenable interrupts explicitly, like x86_64. No code changes. Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm> 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.c76
1 files changed, 65 insertions, 11 deletions
diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 203b863ac2a8..fe6dd972068d 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -528,6 +528,56 @@ vm86_trap:
528 return; 528 return;
529} 529}
530 530
531#define DO_TRAP(trapnr, signr, str, name) \
532void do_##name(struct pt_regs *regs, long error_code) \
533{ \
534 trace_hardirqs_fixup(); \
535 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
536 == NOTIFY_STOP) \
537 return; \
538 do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \
539}
540
541#define DO_TRAP_INFO(trapnr, signr, str, name, sicode, siaddr, irq) \
542void do_##name(struct pt_regs *regs, long error_code) \
543{ \
544 siginfo_t info; \
545 if (irq) \
546 local_irq_enable(); \
547 info.si_signo = signr; \
548 info.si_errno = 0; \
549 info.si_code = sicode; \
550 info.si_addr = (void __user *)siaddr; \
551 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
552 == NOTIFY_STOP) \
553 return; \
554 do_trap(trapnr, signr, str, 0, regs, error_code, &info); \
555}
556
557#define DO_VM86_TRAP(trapnr, signr, str, name) \
558void do_##name(struct pt_regs *regs, long error_code) \
559{ \
560 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
561 == NOTIFY_STOP) \
562 return; \
563 do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \
564}
565
566#define DO_VM86_TRAP_INFO(trapnr, signr, str, name, sicode, siaddr) \
567void do_##name(struct pt_regs *regs, long error_code) \
568{ \
569 siginfo_t info; \
570 info.si_signo = signr; \
571 info.si_errno = 0; \
572 info.si_code = sicode; \
573 info.si_addr = (void __user *)siaddr; \
574 trace_hardirqs_fixup(); \
575 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
576 == NOTIFY_STOP) \
577 return; \
578 do_trap(trapnr, signr, str, 1, regs, error_code, &info); \
579}
580
531#define DO_ERROR(trapnr, signr, str, name) \ 581#define DO_ERROR(trapnr, signr, str, name) \
532void do_##name(struct pt_regs *regs, long error_code) \ 582void do_##name(struct pt_regs *regs, long error_code) \
533{ \ 583{ \
@@ -535,6 +585,7 @@ void do_##name(struct pt_regs *regs, long error_code) \
535 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \ 585 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
536 == NOTIFY_STOP) \ 586 == NOTIFY_STOP) \
537 return; \ 587 return; \
588 conditional_sti(regs); \
538 do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \ 589 do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \
539} 590}
540 591
@@ -551,6 +602,7 @@ void do_##name(struct pt_regs *regs, long error_code) \
551 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \ 602 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
552 == NOTIFY_STOP) \ 603 == NOTIFY_STOP) \
553 return; \ 604 return; \
605 conditional_sti(regs); \
554 do_trap(trapnr, signr, str, 0, regs, error_code, &info); \ 606 do_trap(trapnr, signr, str, 0, regs, error_code, &info); \
555} 607}
556 608
@@ -560,6 +612,7 @@ void do_##name(struct pt_regs *regs, long error_code) \
560 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \ 612 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
561 == NOTIFY_STOP) \ 613 == NOTIFY_STOP) \
562 return; \ 614 return; \
615 conditional_sti(regs); \
563 do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \ 616 do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \
564} 617}
565 618
@@ -575,22 +628,23 @@ void do_##name(struct pt_regs *regs, long error_code) \
575 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \ 628 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
576 == NOTIFY_STOP) \ 629 == NOTIFY_STOP) \
577 return; \ 630 return; \
631 conditional_sti(regs); \
578 do_trap(trapnr, signr, str, 1, regs, error_code, &info); \ 632 do_trap(trapnr, signr, str, 1, regs, error_code, &info); \
579} 633}
580 634
581DO_VM86_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip) 635DO_VM86_TRAP_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
582#ifndef CONFIG_KPROBES 636#ifndef CONFIG_KPROBES
583DO_VM86_ERROR(3, SIGTRAP, "int3", int3) 637DO_VM86_TRAP(3, SIGTRAP, "int3", int3)
584#endif 638#endif
585DO_VM86_ERROR(4, SIGSEGV, "overflow", overflow) 639DO_VM86_TRAP(4, SIGSEGV, "overflow", overflow)
586DO_VM86_ERROR(5, SIGSEGV, "bounds", bounds) 640DO_VM86_TRAP(5, SIGSEGV, "bounds", bounds)
587DO_ERROR_INFO(6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->ip, 0) 641DO_TRAP_INFO(6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->ip, 0)
588DO_ERROR(9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun) 642DO_TRAP(9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
589DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS) 643DO_TRAP(10, SIGSEGV, "invalid TSS", invalid_TSS)
590DO_ERROR(11, SIGBUS, "segment not present", segment_not_present) 644DO_TRAP(11, SIGBUS, "segment not present", segment_not_present)
591DO_ERROR(12, SIGBUS, "stack segment", stack_segment) 645DO_TRAP(12, SIGBUS, "stack segment", stack_segment)
592DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0, 0) 646DO_TRAP_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0, 0)
593DO_ERROR_INFO(32, SIGILL, "iret exception", iret_error, ILL_BADSTK, 0, 1) 647DO_TRAP_INFO(32, SIGILL, "iret exception", iret_error, ILL_BADSTK, 0, 1)
594 648
595void __kprobes 649void __kprobes
596do_general_protection(struct pt_regs *regs, long error_code) 650do_general_protection(struct pt_regs *regs, long error_code)