Skip to contentSkip to conversation

traps: x86: more unification

PATCH Applied Alexander van Heukelum 4 participants 12 messages Sep 30, 2008 – Oct 1, 2008 x86

lore
Share & tools
lore
#0 lore raw

cover traps: x86: more unification

Hi Ingo,

Here are some more unification patches for traps_xx.c. They are against the current x86/traps branch in the tip tree and work fine for my miniconfigs.

The branch does not at the moment compile a defconfig kernel, due to a missing PCI_DEVICE_ID_AMD_10H_NB_MISC define, however.

Moreover, a defconfig won't run :-/ (on qemu-system-x86_64). Bisection pointed to commit 10a434fcb "x86: remove cpu_vendor_dev". The kernel crashes early with a general protection fault in a call to strnlen. I have no idea what goes wrong, yet.

Greetings,
Alexander

#1 lore raw

PATCH 1/4 traps: x86_64: split out math_error and simd_math_error

Split out math_error from do_coprocessor_error and simd_math_error from do_simd_coprocessor_error, like on i386. While at it, add the "error_code" parameter to do_coprocessor_error, do_simd_coprocessor_error and do_spurious_interrupt_bug. This does not change the generated code, but brings the declarations in line with all the other trap handlers.

---
 arch/x86/kernel/traps_64.c |   36 +++++++++++++++++++++---------------
 include/asm-x86/traps.h    |    6 +++---
 2 files changed, 24 insertions(+), 18 deletions(-)
arch/x86/kernel/traps_64.c +21 -15
index 8ab8f81..201f98d 100644
@@ -457,18 +457,12 @@ static int kernel_math_error(struct pt_regs *regs, const char *str, int trapnr)
  * the correct behaviour even in the presence of the asynchronous
  * IRQ13 behaviour
  */
-asmlinkage void do_coprocessor_error(struct pt_regs *regs)
+void math_error(void __user *ip)
 {
-	void __user *ip = (void __user *)(regs->ip);
 	struct task_struct *task;
 	siginfo_t info;
 	unsigned short cwd, swd;
 
-	conditional_sti(regs);
-	if (!user_mode(regs) &&
-	    kernel_math_error(regs, "kernel x87 math error", 16))
-		return;
-
 	/*
 	 * Save the info for the exception handler and clear the error.
 	 */
@@ -521,23 +515,26 @@ asmlinkage void do_coprocessor_error(struct pt_regs *regs)
 	force_sig_info(SIGFPE, &info, task);
 }
 
+asmlinkage void do_coprocessor_error(struct pt_regs *regs, long error_code)
+{
+	conditional_sti(regs);
+	if (!user_mode(regs) &&
+	    kernel_math_error(regs, "kernel x87 math error", 16))
+		return;
+	math_error((void __user *)regs->ip);
+}
+
 asmlinkage void bad_intr(void)
 {
 	printk("bad interrupt");
 }
 
-asmlinkage void do_simd_coprocessor_error(struct pt_regs *regs)
+static void simd_math_error(void __user *ip)
 {
-	void __user *ip = (void __user *)(regs->ip);
 	struct task_struct *task;
 	siginfo_t info;
 	unsigned short mxcsr;
 
-	conditional_sti(regs);
-	if (!user_mode(regs) &&
-			kernel_math_error(regs, "kernel simd math error", 19))
-		return;
-
 	/*
 	 * Save the info for the exception handler and clear the error.
 	 */
@@ -580,7 +577,16 @@ asmlinkage void do_simd_coprocessor_error(struct pt_regs *regs)
 	force_sig_info(SIGFPE, &info, task);
 }
 
-asmlinkage void do_spurious_interrupt_bug(struct pt_regs *regs)
+asmlinkage void do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
+{
+	conditional_sti(regs);
+	if (!user_mode(regs) &&
+			kernel_math_error(regs, "kernel simd math error", 19))
+		return;
+	simd_math_error((void __user *)regs->ip);
+}
+
+asmlinkage void do_spurious_interrupt_bug(struct pt_regs *regs, long error_code)
 {
 }
 
include/asm-x86/traps.h +3 -3
index 7a692ba..c82c39c 100644
@@ -72,9 +72,9 @@ asmlinkage void double_fault(void);
 asmlinkage void do_int3(struct pt_regs *, long);
 asmlinkage void do_stack_segment(struct pt_regs *, long);
 asmlinkage void do_debug(struct pt_regs *, unsigned long);
-asmlinkage void do_coprocessor_error(struct pt_regs *);
-asmlinkage void do_simd_coprocessor_error(struct pt_regs *);
-asmlinkage void do_spurious_interrupt_bug(struct pt_regs *);
+asmlinkage void do_coprocessor_error(struct pt_regs *, long);
+asmlinkage void do_simd_coprocessor_error(struct pt_regs *, long);
+asmlinkage void do_spurious_interrupt_bug(struct pt_regs *, long);
 
 asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code);
 
Signature · 1 line
1.5.4.3
#2 lore raw

PATCH 2/4 traps: i386: factor out lazy io-bitmap copy

x86_64 does not do the lazy io-bitmap dance. Putting it in its own function makes i386's do_general_protection look much more like x86_64's.

---
 arch/x86/kernel/traps_32.c |   76 +++++++++++++++++++++++++-------------------
 1 files changed, 43 insertions(+), 33 deletions(-)
arch/x86/kernel/traps_32.c +43 -33
index dd183a2..78113d3 100644
@@ -96,6 +96,47 @@ die_if_kernel(const char *str, struct pt_regs *regs, long err)
 		die(str, regs, err);
 }
 
+/*
+ * Perform the lazy TSS's I/O bitmap copy. If the TSS has an
+ * invalid offset set (the LAZY one) and the faulting thread has
+ * a valid I/O bitmap pointer, we copy the I/O bitmap in the TSS,
+ * we set the offset field correctly and return 1.
+ */
+static int lazy_iobitmap_copy(void)
+{
+	struct thread_struct *thread;
+	struct tss_struct *tss;
+	int cpu;
+
+	cpu = get_cpu();
+	tss = &per_cpu(init_tss, cpu);
+	thread = &current->thread;
+
+	if (tss->x86_tss.io_bitmap_base == INVALID_IO_BITMAP_OFFSET_LAZY &&
+	    thread->io_bitmap_ptr) {
+		memcpy(tss->io_bitmap, thread->io_bitmap_ptr,
+		       thread->io_bitmap_max);
+		/*
+		 * If the previously set map was extending to higher ports
+		 * than the current one, pad extra space with 0xff (no access).
+		 */
+		if (thread->io_bitmap_max < tss->io_bitmap_max) {
+			memset((char *) tss->io_bitmap +
+				thread->io_bitmap_max, 0xff,
+				tss->io_bitmap_max - thread->io_bitmap_max);
+		}
+		tss->io_bitmap_max = thread->io_bitmap_max;
+		tss->x86_tss.io_bitmap_base = IO_BITMAP_OFFSET;
+		tss->io_bitmap_owner = thread;
+		put_cpu();
+
+		return 1;
+	}
+	put_cpu();
+
+	return 0;
+}
+
 static void __kprobes
 do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
 	long error_code, siginfo_t *info)
@@ -188,44 +229,13 @@ void __kprobes
 do_general_protection(struct pt_regs *regs, long error_code)
 {
 	struct task_struct *tsk;
-	struct thread_struct *thread;
-	struct tss_struct *tss;
-	int cpu;
 
 	conditional_sti(regs);
 
-	cpu = get_cpu();
-	tss = &per_cpu(init_tss, cpu);
-	thread = &current->thread;
-
-	/*
-	 * Perform the lazy TSS's I/O bitmap copy. If the TSS has an
-	 * invalid offset set (the LAZY one) and the faulting thread has
-	 * a valid I/O bitmap pointer, we copy the I/O bitmap in the TSS
-	 * and we set the offset field correctly. Then we let the CPU to
-	 * restart the faulting instruction.
-	 */
-	if (tss->x86_tss.io_bitmap_base == INVALID_IO_BITMAP_OFFSET_LAZY &&
-	    thread->io_bitmap_ptr) {
-		memcpy(tss->io_bitmap, thread->io_bitmap_ptr,
-		       thread->io_bitmap_max);
-		/*
-		 * If the previously set map was extending to higher ports
-		 * than the current one, pad extra space with 0xff (no access).
-		 */
-		if (thread->io_bitmap_max < tss->io_bitmap_max) {
-			memset((char *) tss->io_bitmap +
-				thread->io_bitmap_max, 0xff,
-				tss->io_bitmap_max - thread->io_bitmap_max);
-		}
-		tss->io_bitmap_max = thread->io_bitmap_max;
-		tss->x86_tss.io_bitmap_base = IO_BITMAP_OFFSET;
-		tss->io_bitmap_owner = thread;
-		put_cpu();
-
+	if (lazy_iobitmap_copy()) {
+		/* restart the faulting instruction */
 		return;
 	}
-	put_cpu();
 
 	if (regs->flags & X86_VM_MASK)
 		goto gp_in_vm86;
Signature · 1 line
1.5.4.3
#3 lore raw

PATCH 3/4 traps: x86: introduce dotraplinkage

Mark the exception handlers with "dotraplinkage" to hide the calling convention differences between i386 and x86_64.

---
 arch/x86/kernel/entry_64.S |    2 +-
 arch/x86/kernel/traps_32.c |   28 +++++++++-------
 arch/x86/kernel/traps_64.c |   31 +++++++++++-------
 include/asm-x86/traps.h    |   73 +++++++++++++++++++++----------------------
 4 files changed, 72 insertions(+), 62 deletions(-)
arch/x86/kernel/entry_64.S +1 -1
index 1924659..291dd21 100644
@@ -1266,7 +1266,7 @@ ENTRY(simd_coprocessor_error)
 END(simd_coprocessor_error)
 
 ENTRY(device_not_available)
-	zeroentry math_state_restore
+	zeroentry do_device_not_available
 END(device_not_available)
 
 	/* runs on exception stack */
arch/x86/kernel/traps_32.c +16 -12
index 78113d3..6ecc1b7 100644
@@ -191,7 +191,7 @@ vm86_trap:
 }
 
 #define DO_ERROR(trapnr, signr, str, name)				\
-void do_##name(struct pt_regs *regs, long error_code)			\
+dotraplinkage void do_##name(struct pt_regs *regs, long error_code)	\
 {									\
 	if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr)	\
 							== NOTIFY_STOP)	\
@@ -201,7 +201,7 @@ void do_##name(struct pt_regs *regs, long error_code)			\
 }
 
 #define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr)		\
-void do_##name(struct pt_regs *regs, long error_code)			\
+dotraplinkage void do_##name(struct pt_regs *regs, long error_code)	\
 {									\
 	siginfo_t info;							\
 	info.si_signo = signr;						\
@@ -225,7 +225,7 @@ 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)
 
-void __kprobes
+dotraplinkage void __kprobes
 do_general_protection(struct pt_regs *regs, long error_code)
 {
 	struct task_struct *tsk;
@@ -429,7 +429,8 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs)
 	reassert_nmi();
 }
 
-notrace __kprobes void do_nmi(struct pt_regs *regs, long error_code)
+dotraplinkage notrace __kprobes void
+do_nmi(struct pt_regs *regs, long error_code)
 {
 	int cpu;
 
@@ -457,7 +458,7 @@ void restart_nmi(void)
 	acpi_nmi_enable();
 }
 
-void __kprobes do_int3(struct pt_regs *regs, long error_code)
+dotraplinkage void __kprobes do_int3(struct pt_regs *regs, long error_code)
 {
 #ifdef CONFIG_KPROBES
 	if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
@@ -495,7 +496,7 @@ void __kprobes do_int3(struct pt_regs *regs, long error_code)
  * find every occurrence of the TF bit that could be saved away even
  * by user code)
  */
-void __kprobes do_debug(struct pt_regs *regs, long error_code)
+dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
 {
 	struct task_struct *tsk = current;
 	unsigned int condition;
@@ -632,7 +633,7 @@ void math_error(void __user *ip)
 	force_sig_info(SIGFPE, &info, task);
 }
 
-void do_coprocessor_error(struct pt_regs *regs, long error_code)
+dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code)
 {
 	conditional_sti(regs);
 	ignore_fpu_irq = 1;
@@ -687,7 +688,8 @@ static void simd_math_error(void __user *ip)
 	force_sig_info(SIGFPE, &info, task);
 }
 
-void do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
+dotraplinkage void
+do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
 {
 	conditional_sti(regs);
 
@@ -711,7 +713,8 @@ void do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
 	force_sig(SIGSEGV, current);
 }
 
-void do_spurious_interrupt_bug(struct pt_regs *regs, long error_code)
+dotraplinkage void
+do_spurious_interrupt_bug(struct pt_regs *regs, long error_code)
 {
 	conditional_sti(regs);
 #if 0
@@ -789,7 +792,8 @@ asmlinkage void math_emulate(long arg)
 
 #endif /* CONFIG_MATH_EMULATION */
 
-void __kprobes do_device_not_available(struct pt_regs *regs, long error)
+dotraplinkage void __kprobes
+do_device_not_available(struct pt_regs *regs, long error)
 {
 	if (read_cr0() & X86_CR0_EM) {
 		conditional_sti(regs);
@@ -801,14 +805,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)
+dotraplinkage void __kprobes do_machine_check(struct pt_regs *regs, long error)
 {
 	conditional_sti(regs);
 	machine_check_vector(regs, error);
 }
 #endif
 
-void do_iret_error(struct pt_regs *regs, long error_code)
+dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code)
 {
 	siginfo_t info;
 	local_irq_enable();
arch/x86/kernel/traps_64.c +19 -12
index 201f98d..d4e02c1 100644
@@ -126,7 +126,7 @@ kernel_trap:
 }
 
 #define DO_ERROR(trapnr, signr, str, name)				\
-asmlinkage void do_##name(struct pt_regs *regs, long error_code)	\
+dotraplinkage void do_##name(struct pt_regs *regs, long error_code)	\
 {									\
 	if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr)	\
 							== NOTIFY_STOP)	\
@@ -136,7 +136,7 @@ asmlinkage void do_##name(struct pt_regs *regs, long error_code)	\
 }
 
 #define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr)		\
-asmlinkage void do_##name(struct pt_regs *regs, long error_code)	\
+dotraplinkage void do_##name(struct pt_regs *regs, long error_code)	\
 {									\
 	siginfo_t info;							\
 	info.si_signo = signr;						\
@@ -160,7 +160,7 @@ DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
 DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
 
 /* Runs on IST stack */
-asmlinkage void do_stack_segment(struct pt_regs *regs, long error_code)
+dotraplinkage void do_stack_segment(struct pt_regs *regs, long error_code)
 {
 	if (notify_die(DIE_TRAP, "stack segment", regs, error_code,
 			12, SIGBUS) == NOTIFY_STOP)
@@ -170,7 +170,7 @@ asmlinkage void do_stack_segment(struct pt_regs *regs, long error_code)
 	preempt_conditional_cli(regs);
 }
 
-asmlinkage void do_double_fault(struct pt_regs *regs, long error_code)
+dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
 {
 	static const char str[] = "double fault";
 	struct task_struct *tsk = current;
@@ -187,7 +187,7 @@ asmlinkage void do_double_fault(struct pt_regs *regs, long error_code)
 		die(str, regs, error_code);
 }
 
-asmlinkage void __kprobes
+dotraplinkage void __kprobes
 do_general_protection(struct pt_regs *regs, long error_code)
 {
 	struct task_struct *tsk;
@@ -318,7 +318,7 @@ asmlinkage notrace __kprobes void default_do_nmi(struct pt_regs *regs)
 		io_check_error(reason, regs);
 }
 
-asmlinkage notrace __kprobes void
+dotraplinkage notrace __kprobes void
 do_nmi(struct pt_regs *regs, long error_code)
 {
 	nmi_enter();
@@ -344,7 +344,7 @@ void restart_nmi(void)
 }
 
 /* runs on IST stack. */
-asmlinkage void __kprobes do_int3(struct pt_regs *regs, long error_code)
+dotraplinkage void __kprobes do_int3(struct pt_regs *regs, long error_code)
 {
 	if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
 			== NOTIFY_STOP)
@@ -377,8 +377,7 @@ asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *eregs)
 }
 
 /* runs on IST stack. */
-asmlinkage void __kprobes do_debug(struct pt_regs *regs,
-				   unsigned long error_code)
+dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
 {
 	struct task_struct *tsk = current;
 	unsigned long condition;
@@ -515,7 +514,7 @@ void math_error(void __user *ip)
 	force_sig_info(SIGFPE, &info, task);
 }
 
-asmlinkage void do_coprocessor_error(struct pt_regs *regs, long error_code)
+dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code)
 {
 	conditional_sti(regs);
 	if (!user_mode(regs) &&
@@ -577,7 +576,8 @@ static void simd_math_error(void __user *ip)
 	force_sig_info(SIGFPE, &info, task);
 }
 
-asmlinkage void do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
+dotraplinkage void
+do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
 {
 	conditional_sti(regs);
 	if (!user_mode(regs) &&
@@ -586,7 +586,8 @@ asmlinkage void do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
 	simd_math_error((void __user *)regs->ip);
 }
 
-asmlinkage void do_spurious_interrupt_bug(struct pt_regs *regs, long error_code)
+dotraplinkage void
+do_spurious_interrupt_bug(struct pt_regs *regs, long error_code)
 {
 }
 
@@ -638,6 +639,12 @@ asmlinkage void math_state_restore(void)
 }
 EXPORT_SYMBOL_GPL(math_state_restore);
 
+dotraplinkage void __kprobes
+do_device_not_available(struct pt_regs *regs, long error)
+{
+	math_state_restore();
+}
+
 void __init trap_init(void)
 {
 	set_intr_gate(0, &divide_error);
include/asm-x86/traps.h +36 -37

105 lines not on this page · raw message

Signature · 1 line
1.5.4.3
#4 lore raw

PATCH 4/4 traps: x86: converge do_debug handlers

Make the x86_64-version and the i386-version of do_debug more similar.

- introduce preempt_conditional_sti/cli to i386. The preempt-count is now elevated during the trap handler, like on x86_64. It does not run on a separate stack, however.
- replace an open-coded "send_sigtrap"
- copy some comments

---
 arch/x86/kernel/traps_32.c |   30 +++++++++++++++++++++---------
 arch/x86/kernel/traps_64.c |   17 +++++++++--------
 include/asm-x86/ptrace.h   |    4 ----
 3 files changed, 30 insertions(+), 21 deletions(-)
arch/x86/kernel/traps_32.c +21 -9
index 6ecc1b7..da97cd2 100644
@@ -89,6 +89,20 @@ static inline void conditional_sti(struct pt_regs *regs)
 		local_irq_enable();
 }
 
+static inline void preempt_conditional_sti(struct pt_regs *regs)
+{
+	inc_preempt_count();
+	if (regs->flags & X86_EFLAGS_IF)
+		local_irq_enable();
+}
+
+static inline void preempt_conditional_cli(struct pt_regs *regs)
+{
+	if (regs->flags & X86_EFLAGS_IF)
+		local_irq_disable();
+	dec_preempt_count();
+}
+
 static inline void
 die_if_kernel(const char *str, struct pt_regs *regs, long err)
 {
@@ -499,7 +513,7 @@ dotraplinkage void __kprobes do_int3(struct pt_regs *regs, long error_code)
 dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
 {
 	struct task_struct *tsk = current;
-	unsigned int condition;
+	unsigned long condition;
 	int si_code;
 
 	get_debugreg(condition, 6);
@@ -517,9 +531,9 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
 	if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
 						SIGTRAP) == NOTIFY_STOP)
 		return;
+
 	/* It's safe to allow irq's after DR6 has been saved */
-	if (regs->flags & X86_EFLAGS_IF)
-		local_irq_enable();
+	preempt_conditional_sti(regs);
 
 	/* Mask out spurious debug traps due to lazy DR7 setting */
 	if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) {
@@ -538,16 +552,11 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
 	 * kernel space (but re-enable TF when returning to user mode).
 	 */
 	if (condition & DR_STEP) {
-		/*
-		 * We already checked v86 mode above, so we can
-		 * check for kernel mode by just checking the CPL
-		 * of CS.
-		 */
 		if (!user_mode(regs))
 			goto clear_TF_reenable;
 	}
 
-	si_code = get_si_code((unsigned long)condition);
+	si_code = get_si_code(condition);
 	/* Ok, finally something we can handle */
 	send_sigtrap(tsk, regs, error_code, si_code);
 
@@ -557,15 +566,18 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
 	 */
 clear_dr7:
 	set_debugreg(0, 7);
+	preempt_conditional_cli(regs);
 	return;
 
 debug_vm86:
 	handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code, 1);
+	preempt_conditional_cli(regs);
 	return;
 
 clear_TF_reenable:
 	set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
 	regs->flags &= ~X86_EFLAGS_TF;
+	preempt_conditional_cli(regs);
 	return;
 }
 
arch/x86/kernel/traps_64.c +9 -8
index d4e02c1..80dbbc7 100644
@@ -381,7 +381,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
 {
 	struct task_struct *tsk = current;
 	unsigned long condition;
-	siginfo_t info;
+	int si_code;
 
 	get_debugreg(condition, 6);
 
@@ -399,6 +399,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
 						SIGTRAP) == NOTIFY_STOP)
 		return;
 
+	/* It's safe to allow irq's after DR6 has been saved */
 	preempt_conditional_sti(regs);
 
 	/* Mask out spurious debug traps due to lazy DR7 setting */
@@ -407,6 +408,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
 			goto clear_dr7;
 	}
 
+	/* Save debug status register where ptrace can see it */
 	tsk->thread.debugreg6 = condition;
 
 	/*
@@ -418,15 +420,14 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
 			goto clear_TF_reenable;
 	}
 
+	si_code = get_si_code(condition);
 	/* Ok, finally something we can handle */
-	tsk->thread.trap_no = 1;
-	tsk->thread.error_code = error_code;
-	info.si_signo = SIGTRAP;
-	info.si_errno = 0;
-	info.si_code = get_si_code(condition);
-	info.si_addr = user_mode(regs) ? (void __user *)regs->ip : NULL;
-	force_sig_info(SIGTRAP, &info, tsk);
+	send_sigtrap(tsk, regs, error_code, si_code);
 
+	/*
+	 * Disable additional traps. They'll be re-enabled when
+	 * the signal is delivered.
+	 */
 clear_dr7:
 	set_debugreg(0, 7);
 	preempt_conditional_cli(regs);
include/asm-x86/ptrace.h +0 -4
index ac578f1..a202552 100644
@@ -174,12 +174,8 @@ extern unsigned long profile_pc(struct pt_regs *regs);
 
 extern unsigned long
 convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs);
-
-#ifdef CONFIG_X86_32
 extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
 			 int error_code, int si_code);
-#endif
-
 void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
 
 extern long syscall_trace_enter(struct pt_regs *);
Signature · 1 line
1.5.4.3
#5 lore raw

PATCH 1/1 fix: x86: remove cpu_vendor_dev

In reply to Alexander van Heukelum

x86_64-kernels after commit 10a434fcb "x86: remove cpu_vendor_dev" crashed on qemu-system-x86_64 due to a typo in vmlinux_64.lds.S.

---

Quoted 4 lines · Alexander van Heukelum

Moreover, a defconfig won't run :-/ (on qemu-system-x86_64). Bisection pointed to commit 10a434fcb "x86: remove cpu_vendor_dev". The kernel crashes early with a general protection fault in a call to strnlen. I have no idea what goes wrong, yet.

It took quite some time, but I found the problem... I'll leave the other one to you ;).

Greetings,
Alexander

 arch/x86/kernel/vmlinux_64.lds.S |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/vmlinux_64.lds.S +1 -1
index 201e81a..46e0544 100644
@@ -172,8 +172,8 @@ SECTIONS
   .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
 	*(.x86_cpu_dev.init)
   }
-  SECURITY_INIT
   __x86_cpu_dev_end = .;
+  SECURITY_INIT
 
   . = ALIGN(8);
   .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
#6 lore raw

Re: [PATCH] fix: x86: remove cpu_vendor_dev

Quoted 28 lines · Alexander van Heukelum

x86_64-kernels after commit 10a434fcb "x86: remove cpu_vendor_dev" crashed on qemu-system-x86_64 due to a typo in vmlinux_64.lds.S.

---

Quoted 4 lines · Alexander van Heukelum

Moreover, a defconfig won't run :-/ (on qemu-system-x86_64). Bisection pointed to commit 10a434fcb "x86: remove cpu_vendor_dev". The kernel crashes early with a general protection fault in a call to strnlen. I have no idea what goes wrong, yet.

It took quite some time, but I found the problem... I'll leave the other one to you ;).

Greetings,
Alexander

 arch/x86/kernel/vmlinux_64.lds.S |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/vmlinux_64.lds.S +0 -0
index 201e81a..46e0544 100644

arch/x86/kernel/vmlinux_64.lds.S SECTIONS · line 179

Quoted 9 lines
arch/x86/kernel/vmlinux_64.lds.S +1 -1
@@ -172,8 +172,8 @@ SECTIONS
  .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
       *(.x86_cpu_dev.init)
  }
-  SECURITY_INIT
  __x86_cpu_dev_end = .;
+  SECURITY_INIT
 
  . = ALIGN(8);
  .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {

that is merging problem, Ingo should fix that already...

YH

#7 lore raw

Re: [PATCH] fix: x86: remove cpu_vendor_dev

Quoted 36 lines · Yinghai Lu
Quoted 34 lines · Alexander van Heukelum

x86_64-kernels after commit 10a434fcb "x86: remove cpu_vendor_dev" crashed on qemu-system-x86_64 due to a typo in vmlinux_64.lds.S.

---

Quoted 4 lines · Alexander van Heukelum

Moreover, a defconfig won't run :-/ (on qemu-system-x86_64). Bisection pointed to commit 10a434fcb "x86: remove cpu_vendor_dev". The kernel crashes early with a general protection fault in a call to strnlen. I have no idea what goes wrong, yet.

It took quite some time, but I found the problem... I'll leave the other one to you ;).

Greetings,
Alexander

 arch/x86/kernel/vmlinux_64.lds.S |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/vmlinux_64.lds.S +1 -1
index 201e81a..46e0544 100644
@@ -172,8 +172,8 @@ SECTIONS
  .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
       *(.x86_cpu_dev.init)
  }
-  SECURITY_INIT
  __x86_cpu_dev_end = .;
+  SECURITY_INIT
 
Quoted 5 lines

arch/x86/kernel/vmlinux_64.lds.S SECTIONS · line 179

Quoted 3 lines
arch/x86/kernel/vmlinux_64.lds.S +0 -0
  . = ALIGN(8);
  .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {

that is merging problem, Ingo should fix that already...

indeed. I've fixed it in tip/x86/traps by applying Alexander's patch.

Ingo

#8 lore raw

Re: [PATCH] fix: x86: remove cpu_vendor_dev

Quoted 39 lines · Ingo Molnar
Quoted 36 lines · Yinghai Lu
Quoted 34 lines · Alexander van Heukelum

x86_64-kernels after commit 10a434fcb "x86: remove cpu_vendor_dev" crashed on qemu-system-x86_64 due to a typo in vmlinux_64.lds.S.

---

Quoted 4 lines · Alexander van Heukelum

Moreover, a defconfig won't run :-/ (on qemu-system-x86_64). Bisection pointed to commit 10a434fcb "x86: remove cpu_vendor_dev". The kernel crashes early with a general protection fault in a call to strnlen. I have no idea what goes wrong, yet.

It took quite some time, but I found the problem... I'll leave the other one to you ;).

Greetings,
Alexander

 arch/x86/kernel/vmlinux_64.lds.S |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/vmlinux_64.lds.S +1 -1
index 201e81a..46e0544 100644
@@ -172,8 +172,8 @@ SECTIONS
  .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
       *(.x86_cpu_dev.init)
  }
-  SECURITY_INIT
  __x86_cpu_dev_end = .;
+  SECURITY_INIT
 
Quoted 8 lines
Quoted 5 lines

arch/x86/kernel/vmlinux_64.lds.S SECTIONS · line 179

Quoted 3 lines
arch/x86/kernel/vmlinux_64.lds.S +0 -0
  . = ALIGN(8);
  .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {

that is merging problem, Ingo should fix that already...

indeed. I've fixed it in tip/x86/traps by applying Alexander's patch.

still have merging problem... in tip/master we have

  __x86_cpu_dev_start = .;
  .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
        *(.x86_cpu_dev.init)
  }
  __x86_cpu_dev_end = .;
  SECURITY_INIT

DYN_ARRAY_INIT(8)

SECURITY_INIT

there is two copy of SECURITY_INIT

YH

#9 lore raw

Re: [PATCH] fix: x86: remove cpu_vendor_dev

Quoted 58 lines · Yinghai Lu
Quoted 39 lines · Ingo Molnar
Quoted 36 lines · Yinghai Lu
Quoted 34 lines · Alexander van Heukelum

x86_64-kernels after commit 10a434fcb "x86: remove cpu_vendor_dev" crashed on qemu-system-x86_64 due to a typo in vmlinux_64.lds.S.

---

Quoted 4 lines · Alexander van Heukelum

Moreover, a defconfig won't run :-/ (on qemu-system-x86_64). Bisection pointed to commit 10a434fcb "x86: remove cpu_vendor_dev". The kernel crashes early with a general protection fault in a call to strnlen. I have no idea what goes wrong, yet.

It took quite some time, but I found the problem... I'll leave the other one to you ;).

Greetings,
Alexander

 arch/x86/kernel/vmlinux_64.lds.S |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/vmlinux_64.lds.S +1 -1
index 201e81a..46e0544 100644
@@ -172,8 +172,8 @@ SECTIONS
  .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
       *(.x86_cpu_dev.init)
  }
-  SECURITY_INIT
  __x86_cpu_dev_end = .;
+  SECURITY_INIT
 
Quoted 8 lines
Quoted 5 lines

arch/x86/kernel/vmlinux_64.lds.S SECTIONS · line 179

Quoted 3 lines
arch/x86/kernel/vmlinux_64.lds.S +0 -0
  . = ALIGN(8);
  .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {

that is merging problem, Ingo should fix that already...

indeed. I've fixed it in tip/x86/traps by applying Alexander's patch.

still have merging problem... in tip/master we have

  __x86_cpu_dev_start = .;
  .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
        *(.x86_cpu_dev.init)
  }
  __x86_cpu_dev_end = .;
  SECURITY_INIT
Quoted 5 lines

DYN_ARRAY_INIT(8)

SECURITY_INIT

there is two copy of SECURITY_INIT

indeed. I fixed this up now.

interestingly, this seems to be one of the rare cases where Git auto-merge does the wrong thing - tt should have detected a conflict.

Ingo

#10 lore raw

Re: [PATCH] fix: x86: remove cpu_vendor_dev

Quoted 8 lines · Ingo Molnar
Quoted 2 lines

there is two copy of SECURITY_INIT

indeed. I fixed this up now.

interestingly, this seems to be one of the rare cases where Git auto-merge does the wrong thing - tt should have detected a conflict.

should let git guys know that.

YH

Applied
#11 lore raw
In reply to Alexander van Heukelum
Quoted 5 lines · Alexander van Heukelum

Hi Ingo,

Here are some more unification patches for traps_xx.c. They are against the current x86/traps branch in the tip tree and work fine for my miniconfigs.

applied to tip/x86/traps, thanks Alexander!

Quoted 2 lines

The branch does not at the moment compile a defconfig kernel, due to a missing PCI_DEVICE_ID_AMD_10H_NB_MISC define, however.

hm, commit 021f8b7 was missing, cf16970 got detached from that commit. I fixed it all up in tip/x86/traps.

Ingo