mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: heukelum@fastmail.fm
To: linux-kernel@vger.kernel.org, mingo@elte.hu, ak@suse.de
Cc: Alexander van Heukelum <heukelum@fastmail.fm>
Subject: [PATCH 2/24] i386: prepare to convert exceptions to interrupts
Date: Tue,  9 Sep 2008 21:55:56 +0200	[thread overview]
Message-ID: <1220990178-29773-3-git-send-email-heukelum@fastmail.fm> (raw)
In-Reply-To: <1220990178-29773-2-git-send-email-heukelum@fastmail.fm>

From: Alexander van Heukelum <heukelum@fastmail.fm>

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>
---
 arch/x86/kernel/traps_32.c |   76 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 65 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index c8096f7..9ac59e0 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -528,6 +528,56 @@ vm86_trap:
 	return;
 }
 
+#define DO_TRAP(trapnr, signr, str, name)				\
+void do_##name(struct pt_regs *regs, long error_code)			\
+{									\
+	trace_hardirqs_fixup();						\
+	if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr)	\
+							== NOTIFY_STOP)	\
+		return;							\
+	do_trap(trapnr, signr, str, 0, regs, error_code, NULL);		\
+}
+
+#define DO_TRAP_INFO(trapnr, signr, str, name, sicode, siaddr, irq)	\
+void do_##name(struct pt_regs *regs, long error_code)			\
+{									\
+	siginfo_t info;							\
+	if (irq)							\
+		local_irq_enable();					\
+	info.si_signo = signr;						\
+	info.si_errno = 0;						\
+	info.si_code = sicode;						\
+	info.si_addr = (void __user *)siaddr;				\
+	if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr)	\
+							== NOTIFY_STOP)	\
+		return;							\
+	do_trap(trapnr, signr, str, 0, regs, error_code, &info);	\
+}
+
+#define DO_VM86_TRAP(trapnr, signr, str, name)				\
+void do_##name(struct pt_regs *regs, long error_code)			\
+{									\
+	if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr)	\
+							== NOTIFY_STOP)	\
+		return;							\
+	do_trap(trapnr, signr, str, 1, regs, error_code, NULL);		\
+}
+
+#define DO_VM86_TRAP_INFO(trapnr, signr, str, name, sicode, siaddr)	\
+void do_##name(struct pt_regs *regs, long error_code)			\
+{									\
+	siginfo_t info;							\
+	info.si_signo = signr;						\
+	info.si_errno = 0;						\
+	info.si_code = sicode;						\
+	info.si_addr = (void __user *)siaddr;				\
+	trace_hardirqs_fixup();						\
+	if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr)	\
+							== NOTIFY_STOP)	\
+		return;							\
+	do_trap(trapnr, signr, str, 1, regs, error_code, &info);	\
+}
+
 #define DO_ERROR(trapnr, signr, str, name)				\
 void do_##name(struct pt_regs *regs, long error_code)			\
 {									\
@@ -535,6 +585,7 @@ void do_##name(struct pt_regs *regs, long error_code)			\
 	if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr)	\
 							== NOTIFY_STOP)	\
 		return;							\
+	conditional_sti(regs);						\
 	do_trap(trapnr, signr, str, 0, regs, error_code, NULL);		\
 }
 
@@ -551,6 +602,7 @@ void do_##name(struct pt_regs *regs, long error_code)			\
 	if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr)	\
 							== NOTIFY_STOP)	\
 		return;							\
+	conditional_sti(regs);						\
 	do_trap(trapnr, signr, str, 0, regs, error_code, &info);	\
 }
 
@@ -560,6 +612,7 @@ void do_##name(struct pt_regs *regs, long error_code)			\
 	if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr)	\
 							== NOTIFY_STOP)	\
 		return;							\
+	conditional_sti(regs);						\
 	do_trap(trapnr, signr, str, 1, regs, error_code, NULL);		\
 }
 
@@ -575,22 +628,23 @@ void do_##name(struct pt_regs *regs, long error_code)			\
 	if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr)	\
 							== NOTIFY_STOP)	\
 		return;							\
+	conditional_sti(regs);						\
 	do_trap(trapnr, signr, str, 1, regs, error_code, &info);	\
 }
 
-DO_VM86_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
+DO_VM86_TRAP_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
 #ifndef CONFIG_KPROBES
-DO_VM86_ERROR(3, SIGTRAP, "int3", int3)
+DO_VM86_TRAP(3, SIGTRAP, "int3", int3)
 #endif
-DO_VM86_ERROR(4, SIGSEGV, "overflow", overflow)
-DO_VM86_ERROR(5, SIGSEGV, "bounds", bounds)
-DO_ERROR_INFO(6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->ip, 0)
-DO_ERROR(9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
-DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
-DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
-DO_ERROR(12, SIGBUS, "stack segment", stack_segment)
-DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0, 0)
-DO_ERROR_INFO(32, SIGILL, "iret exception", iret_error, ILL_BADSTK, 0, 1)
+DO_VM86_TRAP(4, SIGSEGV, "overflow", overflow)
+DO_VM86_TRAP(5, SIGSEGV, "bounds", bounds)
+DO_TRAP_INFO(6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->ip, 0)
+DO_TRAP(9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
+DO_TRAP(10, SIGSEGV, "invalid TSS", invalid_TSS)
+DO_TRAP(11, SIGBUS, "segment not present", segment_not_present)
+DO_TRAP(12, SIGBUS, "stack segment", stack_segment)
+DO_TRAP_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0, 0)
+DO_TRAP_INFO(32, SIGILL, "iret exception", iret_error, ILL_BADSTK, 0, 1)
 
 void __kprobes
 do_general_protection(struct pt_regs *regs, long error_code)
-- 
1.5.4.3


  reply	other threads:[~2008-09-10  4:12 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-09 19:55 [RFC/PATCH] i386: handle all exceptions with interrupts off initially heukelum
2008-09-09 19:55 ` [PATCH 1/24] i386: remove kprobes' restore_interrupts in favour of conditional_sti heukelum
2008-09-09 19:55   ` heukelum [this message]
2008-09-09 19:55     ` [PATCH 3/24] i386: convert hardware exception 0 to an interrupt gate heukelum
2008-09-09 19:55       ` [PATCH 4/24] i386: expand exception 3 DO_TRAP macro heukelum
2008-09-09 19:55         ` [PATCH 5/24] i386: convert hardware exception 4 to an interrupt gate heukelum
2008-09-09 19:56           ` [PATCH 6/24] i386: convert hardware exception 5 " heukelum
2008-09-09 19:56             ` [PATCH 7/24] i386: convert hardware exception 6 " heukelum
2008-09-09 19:56               ` [PATCH 8/24] i386: convert hardware exception 7 " heukelum
2008-09-09 19:56                 ` [PATCH 9/24] i386: convert hardware exception 9 " heukelum
2008-09-09 19:56                   ` [PATCH 10/24] i386: convert hardware exception 10 " heukelum
2008-09-09 19:56                     ` [PATCH 11/24] i386: convert hardware exception 11 " heukelum
2008-09-09 19:56                       ` [PATCH 12/24] i386: convert hardware exception 12 " heukelum
2008-09-09 19:56                         ` [PATCH 13/24] i386: convert hardware exception 13 " heukelum
2008-09-09 19:56                           ` [PATCH 14/24] i386: convert hardware exception 15 " heukelum
2008-09-09 19:56                             ` [PATCH 15/24] i386: convert hardware exception 16 " heukelum
2008-09-09 19:56                               ` [PATCH 16/24] i386: convert hardware exception 17 " heukelum
2008-09-09 19:56                                 ` [PATCH 17/24] i386: convert hardware exception 18 " heukelum
2008-09-09 19:56                                   ` [PATCH 18/24] i386: convert hardware exception 19 " heukelum
2008-09-09 19:56                                     ` [PATCH 19/24] i386: remove temporary DO_TRAP macros, expanding the last one used heukelum
2008-09-09 19:56                                       ` [PATCH 20/24] i386: add TRACE_IRQS_OFF to entry_32.S in 'error_code' heukelum
2008-09-09 19:56                                         ` [PATCH 21/24] i386: add TRACE_IRQS_OFF for exception 1 (debug) heukelum
2008-09-09 19:56                                           ` [PATCH 22/24] i386: add TRACE_IRQS_OFF for the nmi heukelum
2008-09-09 19:56                                             ` [PATCH 23/24] i386: add TRACE_IRQS_OFF for the exception 3 (int3) heukelum
2008-09-09 19:56                                               ` [PATCH 24/24] i386: trace_hardirqs_fixup should now not be necessary: irqs are off heukelum
2009-01-12 17:21                                             ` [PATCH 22/24] i386: add TRACE_IRQS_OFF for the nmi Peter Zijlstra
2009-01-12 18:39                                               ` Ingo Molnar
2009-01-12 18:43                                                 ` Peter Zijlstra
2009-01-12 20:50                                                   ` Alexander van Heukelum
2008-09-10  3:27 ` [RFC/PATCH] i386: handle all exceptions with interrupts off initially H. Peter Anvin
2008-09-10  5:53   ` Ingo Molnar
2008-09-10  5:59     ` H. Peter Anvin
2008-09-10  7:00       ` Ingo Molnar
2008-09-10  7:24         ` Ingo Molnar
2008-09-10  9:36           ` Alexander van Heukelum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1220990178-29773-3-git-send-email-heukelum@fastmail.fm \
    --to=heukelum@fastmail.fm \
    --cc=ak@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®