linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC/PATCH] i386: handle all exceptions with interrupts off initially
@ 2008-09-09 19:55 heukelum
  2008-09-09 19:55 ` [PATCH 1/24] i386: remove kprobes' restore_interrupts in favour of conditional_sti heukelum
  2008-09-10  3:27 ` [RFC/PATCH] i386: handle all exceptions with interrupts off initially H. Peter Anvin
  0 siblings, 2 replies; 35+ messages in thread
From: heukelum @ 2008-09-09 19:55 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

x86_64 handles all exceptions with interrupts off initially, this
bisectable patch set does the same for i386, in (very) small steps.
If this is acceptable, it would make further unification of traps_32.c
and traps_64.c a lot easier. If it is not... why?

Patches are against current -git.

Every step in the series runs fine in a simple system under qemu.

Greetings,
	Alexander

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH 1/24] i386: remove kprobes' restore_interrupts in favour of conditional_sti
  2008-09-09 19:55 [RFC/PATCH] i386: handle all exceptions with interrupts off initially heukelum
@ 2008-09-09 19:55 ` heukelum
  2008-09-09 19:55   ` [PATCH 2/24] i386: prepare to convert exceptions to interrupts heukelum
  2008-09-10  3:27 ` [RFC/PATCH] i386: handle all exceptions with interrupts off initially H. Peter Anvin
  1 sibling, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:55 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

x86_64 uses a helper function conditional_sti in traps_64.c which
is equal to restore_interrupts in kprobes.h. The only user of
restore_interrupts is in traps_32.c. Introduce conditional_sti
for i386 and remove restore_interrupts.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |    8 +++++++-
 include/asm-x86/kprobes.h  |    9 ---------
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 03df8e4..c8096f7 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -84,6 +84,12 @@ static unsigned int code_bytes = 64;
 static int ignore_nmis;
 static int die_counter;
 
+static inline void conditional_sti(struct pt_regs *regs)
+{
+	if (regs->flags & X86_EFLAGS_IF)
+		local_irq_enable();
+}
+
 void printk_address(unsigned long address, int reliable)
 {
 #ifdef CONFIG_KALLSYMS
@@ -859,7 +865,7 @@ void __kprobes do_int3(struct pt_regs *regs, long error_code)
 	 * This is an interrupt gate, because kprobes wants interrupts
 	 * disabled. Normal trap handlers don't.
 	 */
-	restore_interrupts(regs);
+	conditional_sti(regs);
 
 	do_trap(3, SIGTRAP, "int3", 1, regs, error_code, NULL);
 }
diff --git a/include/asm-x86/kprobes.h b/include/asm-x86/kprobes.h
index 54980b0..93a7f49 100644
--- a/include/asm-x86/kprobes.h
+++ b/include/asm-x86/kprobes.h
@@ -82,15 +82,6 @@ struct kprobe_ctlblk {
 	struct prev_kprobe prev_kprobe;
 };
 
-/* trap3/1 are intr gates for kprobes.  So, restore the status of IF,
- * if necessary, before executing the original int3/1 (trap) handler.
- */
-static inline void restore_interrupts(struct pt_regs *regs)
-{
-	if (regs->flags & X86_EFLAGS_IF)
-		local_irq_enable();
-}
-
 extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
 extern int kprobe_exceptions_notify(struct notifier_block *self,
 				    unsigned long val, void *data);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 2/24] i386: prepare to convert exceptions to interrupts
  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
  2008-09-09 19:55     ` [PATCH 3/24] i386: convert hardware exception 0 to an interrupt gate heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:55 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 3/24] i386: convert hardware exception 0 to an interrupt gate
  2008-09-09 19:55   ` [PATCH 2/24] i386: prepare to convert exceptions to interrupts heukelum
@ 2008-09-09 19:55     ` heukelum
  2008-09-09 19:55       ` [PATCH 4/24] i386: expand exception 3 DO_TRAP macro heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:55 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle divide error exception with interrupt initially off.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 9ac59e0..97d193c 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -632,7 +632,7 @@ void do_##name(struct pt_regs *regs, long error_code)			\
 	do_trap(trapnr, signr, str, 1, regs, error_code, &info);	\
 }
 
-DO_VM86_TRAP_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
+DO_VM86_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
 #ifndef CONFIG_KPROBES
 DO_VM86_TRAP(3, SIGTRAP, "int3", int3)
 #endif
@@ -1245,7 +1245,7 @@ void __init trap_init(void)
 	early_iounmap(p, 4);
 #endif
 
-	set_trap_gate(0, &divide_error);
+	set_intr_gate(0, &divide_error);
 	set_intr_gate(1, &debug);
 	set_intr_gate(2, &nmi);
 	set_system_intr_gate(3, &int3); /* int3 can be called from all */
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 4/24] i386: expand exception 3 DO_TRAP macro
  2008-09-09 19:55     ` [PATCH 3/24] i386: convert hardware exception 0 to an interrupt gate heukelum
@ 2008-09-09 19:55       ` heukelum
  2008-09-09 19:55         ` [PATCH 5/24] i386: convert hardware exception 4 to an interrupt gate heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:55 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

The int3 exception was already takes as an interrupt and
do_int3 does not fit in the new DO_ERROR macro. This patch
just expands the DO_TRAP macro and rearranges the code a
bit.

No functional changes intended.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 97d193c..944641a 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -633,9 +633,6 @@ void do_##name(struct pt_regs *regs, long error_code)			\
 }
 
 DO_VM86_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
-#ifndef CONFIG_KPROBES
-DO_VM86_TRAP(3, SIGTRAP, "int3", int3)
-#endif
 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)
@@ -907,9 +904,9 @@ void restart_nmi(void)
 	acpi_nmi_enable();
 }
 
-#ifdef CONFIG_KPROBES
 void __kprobes do_int3(struct pt_regs *regs, long error_code)
 {
+#ifdef CONFIG_KPROBES
 	trace_hardirqs_fixup();
 
 	if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
@@ -920,10 +917,14 @@ void __kprobes do_int3(struct pt_regs *regs, long error_code)
 	 * disabled. Normal trap handlers don't.
 	 */
 	conditional_sti(regs);
+#else
+	if (notify_die(DIE_TRAP, "int3", regs, error_code, 3, SIGTRAP)
+			== NOTIFY_STOP)
+		return;
+#endif
 
 	do_trap(3, SIGTRAP, "int3", 1, regs, error_code, NULL);
 }
-#endif
 
 /*
  * Our handling of the processor debug registers is non-trivial.
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 5/24] i386: convert hardware exception 4 to an interrupt gate
  2008-09-09 19:55       ` [PATCH 4/24] i386: expand exception 3 DO_TRAP macro heukelum
@ 2008-09-09 19:55         ` heukelum
  2008-09-09 19:56           ` [PATCH 6/24] i386: convert hardware exception 5 " heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:55 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle overflow exception with interrupt initially off.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 944641a..5d762a8 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -633,7 +633,7 @@ void do_##name(struct pt_regs *regs, long error_code)			\
 }
 
 DO_VM86_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
-DO_VM86_TRAP(4, SIGSEGV, "overflow", overflow)
+DO_VM86_ERROR(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)
@@ -1250,7 +1250,7 @@ void __init trap_init(void)
 	set_intr_gate(1, &debug);
 	set_intr_gate(2, &nmi);
 	set_system_intr_gate(3, &int3); /* int3 can be called from all */
-	set_system_gate(4, &overflow); /* int4 can be called from all */
+	set_system_intr_gate(4, &overflow); /* int4 can be called from all */
 	set_trap_gate(5, &bounds);
 	set_trap_gate(6, &invalid_op);
 	set_trap_gate(7, &device_not_available);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 6/24] i386: convert hardware exception 5 to an interrupt gate
  2008-09-09 19:55         ` [PATCH 5/24] i386: convert hardware exception 4 to an interrupt gate heukelum
@ 2008-09-09 19:56           ` heukelum
  2008-09-09 19:56             ` [PATCH 7/24] i386: convert hardware exception 6 " heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle bounds exception with interrupt initially off.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 5d762a8..becfc84 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -634,7 +634,7 @@ void do_##name(struct pt_regs *regs, long error_code)			\
 
 DO_VM86_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
 DO_VM86_ERROR(4, SIGSEGV, "overflow", overflow)
-DO_VM86_TRAP(5, SIGSEGV, "bounds", bounds)
+DO_VM86_ERROR(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)
@@ -1251,7 +1251,7 @@ void __init trap_init(void)
 	set_intr_gate(2, &nmi);
 	set_system_intr_gate(3, &int3); /* int3 can be called from all */
 	set_system_intr_gate(4, &overflow); /* int4 can be called from all */
-	set_trap_gate(5, &bounds);
+	set_intr_gate(5, &bounds);
 	set_trap_gate(6, &invalid_op);
 	set_trap_gate(7, &device_not_available);
 	set_task_gate(8, GDT_ENTRY_DOUBLEFAULT_TSS);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 7/24] i386: convert hardware exception 6 to an interrupt gate
  2008-09-09 19:56           ` [PATCH 6/24] i386: convert hardware exception 5 " heukelum
@ 2008-09-09 19:56             ` heukelum
  2008-09-09 19:56               ` [PATCH 8/24] i386: convert hardware exception 7 " heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle invalid opcode exception with interrupt initially off.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index becfc84..5d8d057 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -635,7 +635,7 @@ void do_##name(struct pt_regs *regs, long error_code)			\
 DO_VM86_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
 DO_VM86_ERROR(4, SIGSEGV, "overflow", overflow)
 DO_VM86_ERROR(5, SIGSEGV, "bounds", bounds)
-DO_TRAP_INFO(6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->ip, 0)
+DO_ERROR_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)
@@ -1252,7 +1252,7 @@ void __init trap_init(void)
 	set_system_intr_gate(3, &int3); /* int3 can be called from all */
 	set_system_intr_gate(4, &overflow); /* int4 can be called from all */
 	set_intr_gate(5, &bounds);
-	set_trap_gate(6, &invalid_op);
+	set_intr_gate(6, &invalid_op);
 	set_trap_gate(7, &device_not_available);
 	set_task_gate(8, GDT_ENTRY_DOUBLEFAULT_TSS);
 	set_trap_gate(9, &coprocessor_segment_overrun);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 8/24] i386: convert hardware exception 7 to an interrupt gate
  2008-09-09 19:56             ` [PATCH 7/24] i386: convert hardware exception 6 " heukelum
@ 2008-09-09 19:56               ` heukelum
  2008-09-09 19:56                 ` [PATCH 9/24] i386: convert hardware exception 9 " heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle no coprocessor exception with interrupt initially off.

device_not_available in entry_32.S calls either math_state_restore
or math_emulate. This patch adds an extra indirection to be
able to re-enable interrupts explicitly in traps_32.c

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/entry_32.S |   15 ++-------------
 arch/x86/kernel/traps_32.c |   14 +++++++++++++-
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 109792b..5a88585 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -760,20 +760,9 @@ ENTRY(device_not_available)
 	RING0_INT_FRAME
 	pushl $-1			# mark this as an int
 	CFI_ADJUST_CFA_OFFSET 4
-	SAVE_ALL
-	GET_CR0_INTO_EAX
-	testl $0x4, %eax		# EM (math emulation bit)
-	jne device_not_available_emulate
-	preempt_stop(CLBR_ANY)
-	call math_state_restore
-	jmp ret_from_exception
-device_not_available_emulate:
-	pushl $0			# temporary storage for ORIG_EIP
+	pushl $do_device_not_available
 	CFI_ADJUST_CFA_OFFSET 4
-	call math_emulate
-	addl $4, %esp
-	CFI_ADJUST_CFA_OFFSET -4
-	jmp ret_from_exception
+	jmp error_code
 	CFI_ENDPROC
 END(device_not_available)
 
diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 5d8d057..3ddd71b 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -46,6 +46,7 @@
 #include <linux/edac.h>
 #endif
 
+#include <asm/processor-flags.h>
 #include <asm/arch_hooks.h>
 #include <asm/stacktrace.h>
 #include <asm/processor.h>
@@ -1234,6 +1235,17 @@ asmlinkage void math_emulate(long arg)
 
 #endif /* CONFIG_MATH_EMULATION */
 
+void __kprobes do_device_not_available(struct pt_regs *regs, long error)
+{
+	if (read_cr0() & X86_CR0_EM) {
+		conditional_sti(regs);
+		math_emulate(0);
+	} else {
+		math_state_restore(); /* interrupts still off */
+		conditional_sti(regs);
+	}
+}
+
 void __init trap_init(void)
 {
 	int i;
@@ -1253,7 +1265,7 @@ void __init trap_init(void)
 	set_system_intr_gate(4, &overflow); /* int4 can be called from all */
 	set_intr_gate(5, &bounds);
 	set_intr_gate(6, &invalid_op);
-	set_trap_gate(7, &device_not_available);
+	set_intr_gate(7, &device_not_available);
 	set_task_gate(8, GDT_ENTRY_DOUBLEFAULT_TSS);
 	set_trap_gate(9, &coprocessor_segment_overrun);
 	set_trap_gate(10, &invalid_TSS);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 9/24] i386: convert hardware exception 9 to an interrupt gate
  2008-09-09 19:56               ` [PATCH 8/24] i386: convert hardware exception 7 " heukelum
@ 2008-09-09 19:56                 ` heukelum
  2008-09-09 19:56                   ` [PATCH 10/24] i386: convert hardware exception 10 " heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle coprocessor segment overrun exception with interrupt initially off.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 3ddd71b..477946a 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -637,7 +637,7 @@ DO_VM86_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip
 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_TRAP(9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
+DO_ERROR(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)
@@ -1267,7 +1267,7 @@ void __init trap_init(void)
 	set_intr_gate(6, &invalid_op);
 	set_intr_gate(7, &device_not_available);
 	set_task_gate(8, GDT_ENTRY_DOUBLEFAULT_TSS);
-	set_trap_gate(9, &coprocessor_segment_overrun);
+	set_intr_gate(9, &coprocessor_segment_overrun);
 	set_trap_gate(10, &invalid_TSS);
 	set_trap_gate(11, &segment_not_present);
 	set_trap_gate(12, &stack_segment);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 10/24] i386: convert hardware exception 10 to an interrupt gate
  2008-09-09 19:56                 ` [PATCH 9/24] i386: convert hardware exception 9 " heukelum
@ 2008-09-09 19:56                   ` heukelum
  2008-09-09 19:56                     ` [PATCH 11/24] i386: convert hardware exception 11 " heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle invalid TSS exception with interrupt initially off.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 477946a..8ace1e2 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -638,7 +638,7 @@ 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_TRAP(10, SIGSEGV, "invalid TSS", invalid_TSS)
+DO_ERROR(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)
@@ -1268,7 +1268,7 @@ void __init trap_init(void)
 	set_intr_gate(7, &device_not_available);
 	set_task_gate(8, GDT_ENTRY_DOUBLEFAULT_TSS);
 	set_intr_gate(9, &coprocessor_segment_overrun);
-	set_trap_gate(10, &invalid_TSS);
+	set_intr_gate(10, &invalid_TSS);
 	set_trap_gate(11, &segment_not_present);
 	set_trap_gate(12, &stack_segment);
 	set_trap_gate(13, &general_protection);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 11/24] i386: convert hardware exception 11 to an interrupt gate
  2008-09-09 19:56                   ` [PATCH 10/24] i386: convert hardware exception 10 " heukelum
@ 2008-09-09 19:56                     ` heukelum
  2008-09-09 19:56                       ` [PATCH 12/24] i386: convert hardware exception 12 " heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle segment not present exception with interrupt initially off.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 8ace1e2..572ea9f 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -639,7 +639,7 @@ 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_TRAP(11, SIGBUS, "segment not present", segment_not_present)
+DO_ERROR(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)
@@ -1269,7 +1269,7 @@ void __init trap_init(void)
 	set_task_gate(8, GDT_ENTRY_DOUBLEFAULT_TSS);
 	set_intr_gate(9, &coprocessor_segment_overrun);
 	set_intr_gate(10, &invalid_TSS);
-	set_trap_gate(11, &segment_not_present);
+	set_intr_gate(11, &segment_not_present);
 	set_trap_gate(12, &stack_segment);
 	set_trap_gate(13, &general_protection);
 	set_intr_gate(14, &page_fault);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 12/24] i386: convert hardware exception 12 to an interrupt gate
  2008-09-09 19:56                     ` [PATCH 11/24] i386: convert hardware exception 11 " heukelum
@ 2008-09-09 19:56                       ` heukelum
  2008-09-09 19:56                         ` [PATCH 13/24] i386: convert hardware exception 13 " heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle stack segment exception with interrupt initially off.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 572ea9f..e535324 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -640,7 +640,7 @@ 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_TRAP(12, SIGBUS, "stack segment", stack_segment)
+DO_ERROR(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)
 
@@ -1270,7 +1270,7 @@ void __init trap_init(void)
 	set_intr_gate(9, &coprocessor_segment_overrun);
 	set_intr_gate(10, &invalid_TSS);
 	set_intr_gate(11, &segment_not_present);
-	set_trap_gate(12, &stack_segment);
+	set_intr_gate(12, &stack_segment);
 	set_trap_gate(13, &general_protection);
 	set_intr_gate(14, &page_fault);
 	set_trap_gate(15, &spurious_interrupt_bug);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 13/24] i386: convert hardware exception 13 to an interrupt gate
  2008-09-09 19:56                       ` [PATCH 12/24] i386: convert hardware exception 12 " heukelum
@ 2008-09-09 19:56                         ` heukelum
  2008-09-09 19:56                           ` [PATCH 14/24] i386: convert hardware exception 15 " heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle general protection exception with interrupt initially off.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index e535324..c3b636e 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -652,6 +652,8 @@ do_general_protection(struct pt_regs *regs, long error_code)
 	struct tss_struct *tss;
 	int cpu;
 
+	conditional_sti(regs);
+
 	cpu = get_cpu();
 	tss = &per_cpu(init_tss, cpu);
 	thread = &current->thread;
@@ -1271,7 +1273,7 @@ void __init trap_init(void)
 	set_intr_gate(10, &invalid_TSS);
 	set_intr_gate(11, &segment_not_present);
 	set_intr_gate(12, &stack_segment);
-	set_trap_gate(13, &general_protection);
+	set_intr_gate(13, &general_protection);
 	set_intr_gate(14, &page_fault);
 	set_trap_gate(15, &spurious_interrupt_bug);
 	set_trap_gate(16, &coprocessor_error);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 14/24] i386: convert hardware exception 15 to an interrupt gate
  2008-09-09 19:56                         ` [PATCH 13/24] i386: convert hardware exception 13 " heukelum
@ 2008-09-09 19:56                           ` heukelum
  2008-09-09 19:56                             ` [PATCH 15/24] i386: convert hardware exception 16 " heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle exception 15 with interrupt initially off.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index c3b636e..ef934a2 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -1162,6 +1162,7 @@ void do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
 
 void do_spurious_interrupt_bug(struct pt_regs *regs, long error_code)
 {
+	conditional_sti(regs);
 #if 0
 	/* No need to warn about this any longer. */
 	printk(KERN_INFO "Ignoring P6 Local APIC Spurious Interrupt Bug...\n");
@@ -1275,7 +1276,7 @@ void __init trap_init(void)
 	set_intr_gate(12, &stack_segment);
 	set_intr_gate(13, &general_protection);
 	set_intr_gate(14, &page_fault);
-	set_trap_gate(15, &spurious_interrupt_bug);
+	set_intr_gate(15, &spurious_interrupt_bug);
 	set_trap_gate(16, &coprocessor_error);
 	set_trap_gate(17, &alignment_check);
 #ifdef CONFIG_X86_MCE
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 15/24] i386: convert hardware exception 16 to an interrupt gate
  2008-09-09 19:56                           ` [PATCH 14/24] i386: convert hardware exception 15 " heukelum
@ 2008-09-09 19:56                             ` heukelum
  2008-09-09 19:56                               ` [PATCH 16/24] i386: convert hardware exception 17 " heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle coprocessor error exception with interrupt initially off.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index ef934a2..733c0e3 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -1086,6 +1086,7 @@ void math_error(void __user *ip)
 
 void do_coprocessor_error(struct pt_regs *regs, long error_code)
 {
+	conditional_sti(regs);
 	ignore_fpu_irq = 1;
 	math_error((void __user *)regs->ip);
 }
@@ -1277,7 +1278,7 @@ void __init trap_init(void)
 	set_intr_gate(13, &general_protection);
 	set_intr_gate(14, &page_fault);
 	set_intr_gate(15, &spurious_interrupt_bug);
-	set_trap_gate(16, &coprocessor_error);
+	set_intr_gate(16, &coprocessor_error);
 	set_trap_gate(17, &alignment_check);
 #ifdef CONFIG_X86_MCE
 	set_trap_gate(18, &machine_check);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 16/24] i386: convert hardware exception 17 to an interrupt gate
  2008-09-09 19:56                             ` [PATCH 15/24] i386: convert hardware exception 16 " heukelum
@ 2008-09-09 19:56                               ` heukelum
  2008-09-09 19:56                                 ` [PATCH 17/24] i386: convert hardware exception 18 " heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle alignment check exception with interrupt initially off.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 733c0e3..bc8b21d 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -641,7 +641,7 @@ 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_TRAP_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0, 0)
+DO_ERROR_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
@@ -1279,7 +1279,7 @@ void __init trap_init(void)
 	set_intr_gate(14, &page_fault);
 	set_intr_gate(15, &spurious_interrupt_bug);
 	set_intr_gate(16, &coprocessor_error);
-	set_trap_gate(17, &alignment_check);
+	set_intr_gate(17, &alignment_check);
 #ifdef CONFIG_X86_MCE
 	set_trap_gate(18, &machine_check);
 #endif
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 17/24] i386: convert hardware exception 18 to an interrupt gate
  2008-09-09 19:56                               ` [PATCH 16/24] i386: convert hardware exception 17 " heukelum
@ 2008-09-09 19:56                                 ` heukelum
  2008-09-09 19:56                                   ` [PATCH 18/24] i386: convert hardware exception 19 " heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle machine check exception with interrupt initially off.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/entry_32.S |    2 +-
 arch/x86/kernel/traps_32.c |   11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 5a88585..c5fe01b 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1019,7 +1019,7 @@ ENTRY(machine_check)
 	RING0_INT_FRAME
 	pushl $0
 	CFI_ADJUST_CFA_OFFSET 4
-	pushl machine_check_vector
+	pushl $do_machine_check
 	CFI_ADJUST_CFA_OFFSET 4
 	jmp error_code
 	CFI_ENDPROC
diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index bc8b21d..f696914 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -62,6 +62,7 @@
 #include <asm/traps.h>
 
 #include "mach_traps.h"
+#include "cpu/mcheck/mce.h"
 
 DECLARE_BITMAP(used_vectors, NR_VECTORS);
 EXPORT_SYMBOL_GPL(used_vectors);
@@ -1250,6 +1251,14 @@ void __kprobes do_device_not_available(struct pt_regs *regs, long error)
 	}
 }
 
+#ifdef CONFIG_X86_MCE
+void __kprobes do_machine_check(struct pt_regs *regs, long error)
+{
+	conditional_sti(regs);
+	machine_check_vector(regs, error);
+}
+#endif
+
 void __init trap_init(void)
 {
 	int i;
@@ -1281,7 +1290,7 @@ void __init trap_init(void)
 	set_intr_gate(16, &coprocessor_error);
 	set_intr_gate(17, &alignment_check);
 #ifdef CONFIG_X86_MCE
-	set_trap_gate(18, &machine_check);
+	set_intr_gate(18, &machine_check);
 #endif
 	set_trap_gate(19, &simd_coprocessor_error);
 
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 18/24] i386: convert hardware exception 19 to an interrupt gate
  2008-09-09 19:56                                 ` [PATCH 17/24] i386: convert hardware exception 18 " heukelum
@ 2008-09-09 19:56                                   ` heukelum
  2008-09-09 19:56                                     ` [PATCH 19/24] i386: remove temporary DO_TRAP macros, expanding the last one used heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Handle SIMD coprocessor exception with interrupt initially off.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index f696914..1ad7697 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -1142,6 +1142,8 @@ static void simd_math_error(void __user *ip)
 
 void do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
 {
+	conditional_sti(regs);
+
 	if (cpu_has_xmm) {
 		/* Handle SIMD FPU exceptions on PIII+ processors. */
 		ignore_fpu_irq = 1;
@@ -1292,7 +1294,7 @@ void __init trap_init(void)
 #ifdef CONFIG_X86_MCE
 	set_intr_gate(18, &machine_check);
 #endif
-	set_trap_gate(19, &simd_coprocessor_error);
+	set_intr_gate(19, &simd_coprocessor_error);
 
 	if (cpu_has_fxsr) {
 		printk(KERN_INFO "Enabling fast FPU save and restore... ");
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 19/24] i386: remove temporary DO_TRAP macros, expanding the last one used
  2008-09-09 19:56                                   ` [PATCH 18/24] i386: convert hardware exception 19 " heukelum
@ 2008-09-09 19:56                                     ` heukelum
  2008-09-09 19:56                                       ` [PATCH 20/24] i386: add TRACE_IRQS_OFF to entry_32.S in 'error_code' heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Only one use of the DO_TRAP macros remains. Expand that one and
remove the macros now.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |   66 ++++++++++----------------------------------
 1 files changed, 15 insertions(+), 51 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 1ad7697..7047760 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -530,56 +530,6 @@ 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)			\
 {									\
@@ -643,7 +593,6 @@ 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_TRAP_INFO(32, SIGILL, "iret exception", iret_error, ILL_BADSTK, 0, 1)
 
 void __kprobes
 do_general_protection(struct pt_regs *regs, long error_code)
@@ -1261,6 +1210,21 @@ void __kprobes do_machine_check(struct pt_regs *regs, long error)
 }
 #endif
 
+void do_iret_error(struct pt_regs *regs, long error_code)
+{
+	siginfo_t info;
+	local_irq_enable();
+
+	info.si_signo = SIGILL;
+	info.si_errno = 0;
+	info.si_code = ILL_BADSTK;
+	info.si_addr = 0;
+	if (notify_die(DIE_TRAP, "iret exception",
+			regs, error_code, 32, SIGILL) == NOTIFY_STOP)
+		return;
+	do_trap(32, SIGILL, "iret exception", 0, regs, error_code, &info);
+}
+
 void __init trap_init(void)
 {
 	int i;
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 20/24] i386: add TRACE_IRQS_OFF to entry_32.S in 'error_code'
  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                                       ` heukelum
  2008-09-09 19:56                                         ` [PATCH 21/24] i386: add TRACE_IRQS_OFF for exception 1 (debug) heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

Many exceptions use the same code path via the label 'error_code'
in entry_32.S. At this point interrupts are off, so let's inform
the tracing code of that fact before calling into C.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/entry_32.S |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index c5fe01b..49438e5 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -730,6 +730,7 @@ error_code:
 	movl $(__USER_DS), %ecx
 	movl %ecx, %ds
 	movl %ecx, %es
+	TRACE_IRQS_OFF
 	movl %esp,%eax			# pt_regs pointer
 	call *%edi
 	jmp ret_from_exception
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 21/24] i386: add TRACE_IRQS_OFF for exception 1 (debug)
  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                                         ` heukelum
  2008-09-09 19:56                                           ` [PATCH 22/24] i386: add TRACE_IRQS_OFF for the nmi heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

At this point interrupts are off, so let's inform the tracing
code of that fact before calling into C.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/entry_32.S |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 49438e5..a278505 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -804,6 +804,7 @@ debug_stack_correct:
 	pushl $-1			# mark this as an int
 	CFI_ADJUST_CFA_OFFSET 4
 	SAVE_ALL
+	TRACE_IRQS_OFF
 	xorl %edx,%edx			# error code 0
 	movl %esp,%eax			# pt_regs pointer
 	call do_debug
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 22/24] i386: add TRACE_IRQS_OFF for the nmi
  2008-09-09 19:56                                         ` [PATCH 21/24] i386: add TRACE_IRQS_OFF for exception 1 (debug) heukelum
@ 2008-09-09 19:56                                           ` heukelum
  2008-09-09 19:56                                             ` [PATCH 23/24] i386: add TRACE_IRQS_OFF for the exception 3 (int3) heukelum
  2009-01-12 17:21                                             ` [PATCH 22/24] i386: add TRACE_IRQS_OFF for the nmi Peter Zijlstra
  0 siblings, 2 replies; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

At this point interrupts are off, so let's inform the tracing
code of that fact before calling into C.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/entry_32.S |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index a278505..2abdc9a 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -849,6 +849,7 @@ nmi_stack_correct:
 	pushl %eax
 	CFI_ADJUST_CFA_OFFSET 4
 	SAVE_ALL
+	TRACE_IRQS_OFF
 	xorl %edx,%edx		# zero error code
 	movl %esp,%eax		# pt_regs pointer
 	call do_nmi
@@ -889,6 +890,7 @@ nmi_espfix_stack:
 	pushl %eax
 	CFI_ADJUST_CFA_OFFSET 4
 	SAVE_ALL
+	TRACE_IRQS_OFF
 	FIXUP_ESPFIX_STACK		# %eax == %esp
 	xorl %edx,%edx			# zero error code
 	call do_nmi
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 23/24] i386: add TRACE_IRQS_OFF for the exception 3 (int3)
  2008-09-09 19:56                                           ` [PATCH 22/24] i386: add TRACE_IRQS_OFF for the nmi heukelum
@ 2008-09-09 19:56                                             ` 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
  1 sibling, 1 reply; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

At this point interrupts are off, so let's inform the tracing
code of that fact before calling into C.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/entry_32.S |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 2abdc9a..b21fbfa 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -921,6 +921,7 @@ KPROBE_ENTRY(int3)
 	pushl $-1			# mark this as an int
 	CFI_ADJUST_CFA_OFFSET 4
 	SAVE_ALL
+	TRACE_IRQS_OFF
 	xorl %edx,%edx		# zero error code
 	movl %esp,%eax		# pt_regs pointer
 	call do_int3
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 24/24] i386: trace_hardirqs_fixup should now not be necessary: irqs are off.
  2008-09-09 19:56                                             ` [PATCH 23/24] i386: add TRACE_IRQS_OFF for the exception 3 (int3) heukelum
@ 2008-09-09 19:56                                               ` heukelum
  0 siblings, 0 replies; 35+ messages in thread
From: heukelum @ 2008-09-09 19:56 UTC (permalink / raw)
  To: linux-kernel, mingo, ak; +Cc: Alexander van Heukelum

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

The exception handlers in entry_32.S should now all call
TRACE_IRQS_OFF before calling the C code. The calls to
trace_hardirqs_fixup should now be unnecessary. Remove them.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/traps_32.c |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 7047760..041a25e 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -533,7 +533,6 @@ vm86_trap:
 #define DO_ERROR(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;							\
@@ -576,7 +575,6 @@ void do_##name(struct pt_regs *regs, long error_code)			\
 	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;							\
@@ -860,15 +858,9 @@ void restart_nmi(void)
 void __kprobes do_int3(struct pt_regs *regs, long error_code)
 {
 #ifdef CONFIG_KPROBES
-	trace_hardirqs_fixup();
-
 	if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
 			== NOTIFY_STOP)
 		return;
-	/*
-	 * This is an interrupt gate, because kprobes wants interrupts
-	 * disabled. Normal trap handlers don't.
-	 */
 	conditional_sti(regs);
 #else
 	if (notify_die(DIE_TRAP, "int3", regs, error_code, 3, SIGTRAP)
@@ -906,8 +898,6 @@ void __kprobes do_debug(struct pt_regs *regs, long error_code)
 	struct task_struct *tsk = current;
 	unsigned int condition;
 
-	trace_hardirqs_fixup();
-
 	get_debugreg(condition, 6);
 
 	/*
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [RFC/PATCH] i386: handle all exceptions with interrupts off initially
  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-10  3:27 ` H. Peter Anvin
  2008-09-10  5:53   ` Ingo Molnar
  1 sibling, 1 reply; 35+ messages in thread
From: H. Peter Anvin @ 2008-09-10  3:27 UTC (permalink / raw)
  To: heukelum; +Cc: linux-kernel, mingo, ak

heukelum@fastmail.fm wrote:
> From: Alexander van Heukelum <heukelum@fastmail.fm>
> 
> x86_64 handles all exceptions with interrupts off initially, this
> bisectable patch set does the same for i386, in (very) small steps.
> If this is acceptable, it would make further unification of traps_32.c
> and traps_64.c a lot easier. If it is not... why?
> 

The only reason not to is that one generally doesn't want to disable 
interrupts unless necessary (bad for latency.)  On 64 bits there are 
stack switches which make disabling interrupts mandatory.  The only 
pitfall is if there is any code which is likely to take time, but I 
highly doubt it.

In other words, it's not something we want to do "just because", but to 
the extent that it provides real benefit, it makes sense.

	-hpa

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC/PATCH] i386: handle all exceptions with interrupts off initially
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Ingo Molnar @ 2008-09-10  5:53 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: heukelum, linux-kernel, ak


* H. Peter Anvin <hpa@zytor.com> wrote:

> heukelum@fastmail.fm wrote:
>> From: Alexander van Heukelum <heukelum@fastmail.fm>
>>
>> x86_64 handles all exceptions with interrupts off initially, this
>> bisectable patch set does the same for i386, in (very) small steps.
>> If this is acceptable, it would make further unification of traps_32.c
>> and traps_64.c a lot easier. If it is not... why?
>>
>
> The only reason not to is that one generally doesn't want to disable 
> interrupts unless necessary (bad for latency.) On 64 bits there are 
> stack switches which make disabling interrupts mandatory.  The only 
> pitfall is if there is any code which is likely to take time, but I 
> highly doubt it.

the entry paths here are really short (we enable irqs almost 
immediately) so it's a non-issue in terms of worst-case latencies.

> In other words, it's not something we want to do "just because", but 
> to the extent that it provides real benefit, it makes sense.

this is historically pretty fragile code so bringing the 32-bit and 
64-bit variants more in line sounds like a good reason to me. For 
example we had various long-living irq state annotation bugs (the 
combination of kprobes and lockdep, etc.) that remained unfixed partly 
due to this assymetry.

There will be details i'm sure, but the series looks quite bisectable.

	Ingo

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC/PATCH] i386: handle all exceptions with interrupts off initially
  2008-09-10  5:53   ` Ingo Molnar
@ 2008-09-10  5:59     ` H. Peter Anvin
  2008-09-10  7:00       ` Ingo Molnar
  0 siblings, 1 reply; 35+ messages in thread
From: H. Peter Anvin @ 2008-09-10  5:59 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: heukelum, linux-kernel, ak

Ingo Molnar wrote:
> 
> the entry paths here are really short (we enable irqs almost 
> immediately) so it's a non-issue in terms of worst-case latencies.
> 
>> In other words, it's not something we want to do "just because", but 
>> to the extent that it provides real benefit, it makes sense.
> 
> this is historically pretty fragile code so bringing the 32-bit and 
> 64-bit variants more in line sounds like a good reason to me. For 
> example we had various long-living irq state annotation bugs (the 
> combination of kprobes and lockdep, etc.) that remained unfixed partly 
> due to this assymetry.
> 

Agreed completely.  I certainly didn't mean to come across sounding 
negative.

	-hpa


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC/PATCH] i386: handle all exceptions with interrupts off initially
  2008-09-10  5:59     ` H. Peter Anvin
@ 2008-09-10  7:00       ` Ingo Molnar
  2008-09-10  7:24         ` Ingo Molnar
  0 siblings, 1 reply; 35+ messages in thread
From: Ingo Molnar @ 2008-09-10  7:00 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: heukelum, linux-kernel


* H. Peter Anvin <hpa@zytor.com> wrote:

> Ingo Molnar wrote:
>>
>> the entry paths here are really short (we enable irqs almost 
>> immediately) so it's a non-issue in terms of worst-case latencies.
>>
>>> In other words, it's not something we want to do "just because", but 
>>> to the extent that it provides real benefit, it makes sense.
>>
>> this is historically pretty fragile code so bringing the 32-bit and 
>> 64-bit variants more in line sounds like a good reason to me. For 
>> example we had various long-living irq state annotation bugs (the 
>> combination of kprobes and lockdep, etc.) that remained unfixed 
>> partly due to this assymetry.
>
> Agreed completely.  I certainly didn't mean to come across sounding 
> negative.

great - i'll check which topic this fits in best. I suspect it will get 
its own topic - but there could be interactions as traps*.c is a central 
(and hence popular) file - here are the currently pending changes in 
-tip:

db4b0f1: kmemcheck: implement REP MOVS/STOS emulation
48e2bd5: x86: coding style fixes to arch/x86/kernel/traps_64.c
c9c3ddd: x86_64: remove empty lines from stack traces/oopses
4df9e51: x86: coding style fixes to arch/x86/kernel/traps_64.c
b359e8a: x86, xsave: context switch support using xsave/xrstor
dc1e35c: x86, xsave: enable xsave/xrstor on cpus with xsave support
862849a: x86: add hooks for kmemcheck on x86_64
787ecfa: x86: add hooks for kmemcheck
afdb702: x86: __show_registers() and __show_regs() API unification
0d84b78: x86 NMI-safe INT3 and Page Fault

we'll see.

	Ingo

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC/PATCH] i386: handle all exceptions with interrupts off initially
  2008-09-10  7:00       ` Ingo Molnar
@ 2008-09-10  7:24         ` Ingo Molnar
  2008-09-10  9:36           ` Alexander van Heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: Ingo Molnar @ 2008-09-10  7:24 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: heukelum, linux-kernel


* Ingo Molnar <mingo@elte.hu> wrote:

> great - i'll check which topic this fits in best. I suspect it will 
> get its own topic - but there could be interactions as traps*.c is a 
> central (and hence popular) file [...]

i've put Alexander's patches into a new -git based topic: tip/x86/traps 
- and git sorted the merge into tip/master out automatically, so this 
will be ok logistically. The commits are below.

	Ingo

------------------------>
71d6990: i386: trace_hardirqs_fixup should now not be necessary: irqs are off.
0dbf58b: i386: add TRACE_IRQS_OFF for the exception 3 (int3)
340f725: i386: add TRACE_IRQS_OFF for the nmi
c320a17: i386: add TRACE_IRQS_OFF for exception 1 (debug)
b51f1c3: i386: add TRACE_IRQS_OFF to entry_32.S in 'error_code'
d7af1f9: i386: remove temporary DO_TRAP macros, expanding the last one used
8915399: i386: convert hardware exception 19 to an interrupt gate
cc0302d: i386: convert hardware exception 18 to an interrupt gate
ed530ad: i386: convert hardware exception 17 to an interrupt gate
97082d7: i386: convert hardware exception 16 to an interrupt gate
d2ac8fa: i386: convert hardware exception 15 to an interrupt gate
0fdfcc7: i386: convert hardware exception 13 to an interrupt gate
f490c71: i386: convert hardware exception 12 to an interrupt gate
c4781f3: i386: convert hardware exception 11 to an interrupt gate
22d09d5: i386: convert hardware exception 10 to an interrupt gate
00f28ef: i386: convert hardware exception 9 to an interrupt gate
3a08e35: i386: convert hardware exception 7 to an interrupt gate
1fb2f60: i386: convert hardware exception 6 to an interrupt gate
4b00f5f: i386: convert hardware exception 5 to an interrupt gate
118ab1a: i386: convert hardware exception 4 to an interrupt gate
376de73: i386: expand exception 3 DO_TRAP macro
bec6f72: i386: convert hardware exception 0 to an interrupt gate
d72fa10: i386: prepare to convert exceptions to interrupts
b5721fe9: i386: remove kprobes' restore_interrupts in favour of conditional_sti

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC/PATCH] i386: handle all exceptions with interrupts off initially
  2008-09-10  7:24         ` Ingo Molnar
@ 2008-09-10  9:36           ` Alexander van Heukelum
  0 siblings, 0 replies; 35+ messages in thread
From: Alexander van Heukelum @ 2008-09-10  9:36 UTC (permalink / raw)
  To: Ingo Molnar, H. Peter Anvin; +Cc: linux-kernel

On Wed, 10 Sep 2008 09:24:55 +0200, "Ingo Molnar" <mingo@elte.hu> said:
> * Ingo Molnar <mingo@elte.hu> wrote:
> 
> > great - i'll check which topic this fits in best. I suspect it will 
> > get its own topic - but there could be interactions as traps*.c is a 
> > central (and hence popular) file [...]
> 
> i've put Alexander's patches into a new -git based topic: tip/x86/traps 
> - and git sorted the merge into tip/master out automatically, so this 
> will be ok logistically. The commits are below.

Great! Let's see if it works out.

Thanks,
    Alexander

> 	Ingo
-- 
  Alexander van Heukelum
  heukelum@fastmail.fm

-- 
http://www.fastmail.fm - Does exactly what it says on the tin


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 22/24] i386: add TRACE_IRQS_OFF for the nmi
  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
@ 2009-01-12 17:21                                             ` Peter Zijlstra
  2009-01-12 18:39                                               ` Ingo Molnar
  1 sibling, 1 reply; 35+ messages in thread
From: Peter Zijlstra @ 2009-01-12 17:21 UTC (permalink / raw)
  To: heukelum; +Cc: linux-kernel, mingo, ak, Dhaval Giani

On Tue, 2008-09-09 at 21:56 +0200, heukelum@fastmail.fm wrote:
> From: Alexander van Heukelum <heukelum@fastmail.fm>
> 
> At this point interrupts are off, so let's inform the tracing
> code of that fact before calling into C.

Sorry but this is an obvious dud, lockdep (and thus the irq state
tracer) aren't nmi safe.

Ingo, please revert, as people are already seeing lockdep warnings due
to this.

> Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
> ---
>  arch/x86/kernel/entry_32.S |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
> index a278505..2abdc9a 100644
> --- a/arch/x86/kernel/entry_32.S
> +++ b/arch/x86/kernel/entry_32.S
> @@ -849,6 +849,7 @@ nmi_stack_correct:
>  	pushl %eax
>  	CFI_ADJUST_CFA_OFFSET 4
>  	SAVE_ALL
> +	TRACE_IRQS_OFF
>  	xorl %edx,%edx		# zero error code
>  	movl %esp,%eax		# pt_regs pointer
>  	call do_nmi
> @@ -889,6 +890,7 @@ nmi_espfix_stack:
>  	pushl %eax
>  	CFI_ADJUST_CFA_OFFSET 4
>  	SAVE_ALL
> +	TRACE_IRQS_OFF
>  	FIXUP_ESPFIX_STACK		# %eax == %esp
>  	xorl %edx,%edx			# zero error code
>  	call do_nmi


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 22/24] i386: add TRACE_IRQS_OFF for the nmi
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Ingo Molnar @ 2009-01-12 18:39 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: heukelum, linux-kernel, ak, Dhaval Giani


* Peter Zijlstra <peterz@infradead.org> wrote:

> On Tue, 2008-09-09 at 21:56 +0200, heukelum@fastmail.fm wrote:
> > From: Alexander van Heukelum <heukelum@fastmail.fm>
> > 
> > At this point interrupts are off, so let's inform the tracing
> > code of that fact before calling into C.
> 
> Sorry but this is an obvious dud, lockdep (and thus the irq state
> tracer) aren't nmi safe.
> 
> Ingo, please revert, as people are already seeing lockdep warnings due
> to this.

done - reverted it in tip/x86/urgent, see the commit below. Is that all 
that we need, wasnt there a 64-bit side done too?

	Ingo

--------------->
>From e8cea892dff8e3ebed42954c46730309b617196f Mon Sep 17 00:00:00 2001
From: Ingo Molnar <mingo@elte.hu>
Date: Mon, 12 Jan 2009 19:36:59 +0100
Subject: [PATCH] Revert "i386: add TRACE_IRQS_OFF for the nmi"

This reverts commit e0c7317557c8fc8eacf611e30c2a80f4e24e47a3.

This patch was wrong, as lockdep (and thus the irq state tracer)
aren't nmi safe. People are already seeing lockdep warnings due
to this.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/kernel/entry_32.S |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index d6f0490..4646902 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1203,7 +1203,6 @@ nmi_stack_correct:
 	pushl %eax
 	CFI_ADJUST_CFA_OFFSET 4
 	SAVE_ALL
-	TRACE_IRQS_OFF
 	xorl %edx,%edx		# zero error code
 	movl %esp,%eax		# pt_regs pointer
 	call do_nmi
@@ -1244,7 +1243,6 @@ nmi_espfix_stack:
 	pushl %eax
 	CFI_ADJUST_CFA_OFFSET 4
 	SAVE_ALL
-	TRACE_IRQS_OFF
 	FIXUP_ESPFIX_STACK		# %eax == %esp
 	xorl %edx,%edx			# zero error code
 	call do_nmi

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH 22/24] i386: add TRACE_IRQS_OFF for the nmi
  2009-01-12 18:39                                               ` Ingo Molnar
@ 2009-01-12 18:43                                                 ` Peter Zijlstra
  2009-01-12 20:50                                                   ` Alexander van Heukelum
  0 siblings, 1 reply; 35+ messages in thread
From: Peter Zijlstra @ 2009-01-12 18:43 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: heukelum, linux-kernel, ak, Dhaval Giani

On Mon, 2009-01-12 at 19:39 +0100, Ingo Molnar wrote:
> * Peter Zijlstra <peterz@infradead.org> wrote:
> 
> > On Tue, 2008-09-09 at 21:56 +0200, heukelum@fastmail.fm wrote:
> > > From: Alexander van Heukelum <heukelum@fastmail.fm>
> > > 
> > > At this point interrupts are off, so let's inform the tracing
> > > code of that fact before calling into C.
> > 
> > Sorry but this is an obvious dud, lockdep (and thus the irq state
> > tracer) aren't nmi safe.
> > 
> > Ingo, please revert, as people are already seeing lockdep warnings due
> > to this.
> 
> done - reverted it in tip/x86/urgent, see the commit below. Is that all 
> that we need, wasnt there a 64-bit side done too?

I had a _very_ quick peek but couldn't fine one, Alexander, does your
memory go back that far? :-)



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 22/24] i386: add TRACE_IRQS_OFF for the nmi
  2009-01-12 18:43                                                 ` Peter Zijlstra
@ 2009-01-12 20:50                                                   ` Alexander van Heukelum
  0 siblings, 0 replies; 35+ messages in thread
From: Alexander van Heukelum @ 2009-01-12 20:50 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar; +Cc: linux-kernel, Andi Kleen, Dhaval Giani


On Mon, 12 Jan 2009 19:43:35 +0100, "Peter Zijlstra"
<peterz@infradead.org> said:
> On Mon, 2009-01-12 at 19:39 +0100, Ingo Molnar wrote:
> > * Peter Zijlstra <peterz@infradead.org> wrote:
> > 
> > > On Tue, 2008-09-09 at 21:56 +0200, heukelum@fastmail.fm wrote:
> > > > From: Alexander van Heukelum <heukelum@fastmail.fm>
> > > > 
> > > > At this point interrupts are off, so let's inform the tracing
> > > > code of that fact before calling into C.
> > > 
> > > Sorry but this is an obvious dud, lockdep (and thus the irq state
> > > tracer) aren't nmi safe.
> > > 
> > > Ingo, please revert, as people are already seeing lockdep warnings due
> > > to this.
> > 
> > done - reverted it in tip/x86/urgent, see the commit below. Is that all 
> > that we need, wasnt there a 64-bit side done too?
> 
> I had a _very_ quick peek but couldn't fine one, Alexander, does your
> memory go back that far? :-)

Git helped a bit, I must admit. The 64-bit version does not include
TRACE_IRQS_ON/TRACE_IRQS_OFF in the nmi handler. The comment above
"ENTRY(paranoid_exit)" in entry_64.S should be updated, though. That
code is not used for NMIs.

The revert is obviously the correct thing to do, but a comment would
not hurt here either.

Greetings,
    Alexander
-- 
  Alexander van Heukelum
  heukelum@fastmail.fm

-- 
http://www.fastmail.fm - Access your email from home and the web


^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2009-01-12 20:51 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [PATCH 2/24] i386: prepare to convert exceptions to interrupts heukelum
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).