Skip to contentSkip to conversation

sparc32: drop hardcoding trap_level in kgdb_trap

PATCH In review Sam Ravnborg 1 participant 1 message Apr 22, 2016 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 sparc32: drop hardcoding trap_level in kgdb_trap

Fix this so we pass the trap_level from the actual trap code like we do in sparc64.
Add use on ENTRY(), ENDPROC() in the assembler function too.

This fixes a bug where the hardcoded value for trap_level was the sparc64 value.

As the generic code does not use the trap_level argument (for sparc32) - this patch does not have any functional impact.

---
 arch/sparc/include/asm/head_32.h |  8 ++++----
 arch/sparc/include/asm/kgdb.h    |  2 +-
 arch/sparc/kernel/entry.S        | 10 ++++------
 arch/sparc/kernel/kgdb_32.c      |  6 +++---
 4 files changed, 12 insertions(+), 14 deletions(-)
arch/sparc/include/asm/head_32.h +4 -4
index 5f1dbe3..6fc60fd 100644
@@ -43,10 +43,10 @@
 	nop;
 
 #ifdef CONFIG_KGDB
-#define KGDB_TRAP(num) \
-	b kgdb_trap_low; \
-	rd %psr,%l0; \
-	nop; \
+#define KGDB_TRAP(num)                  \
+	mov num, %l7;                   \
+	b kgdb_trap_low;                \
+	rd %psr,%l0;                    \
 	nop;
 #else
 #define KGDB_TRAP(num) \
arch/sparc/include/asm/kgdb.h +1 -1
index 47366af..a6ad7bf 100644
@@ -28,10 +28,10 @@ enum regnames {
 #define NUMREGBYTES		((GDB_CSR + 1) * 4)
 #else
 #define NUMREGBYTES		((GDB_Y + 1) * 8)
+#endif
 
 struct pt_regs;
 asmlinkage void kgdb_trap(unsigned long trap_level, struct pt_regs *regs);
-#endif
 
 void arch_kgdb_breakpoint(void);
 
arch/sparc/kernel/entry.S +4 -6
index a83707c..6ece718 100644
@@ -1225,20 +1225,18 @@ breakpoint_trap:
 	RESTORE_ALL
 
 #ifdef CONFIG_KGDB
-	.align	4
-	.globl	kgdb_trap_low
-	.type	kgdb_trap_low,#function
-kgdb_trap_low:
+	ENTRY(kgdb_trap_low)
 	rd	%wim,%l3
 	SAVE_ALL
 	wr 	%l0, PSR_ET, %psr
 	WRITE_PAUSE
 
+	mov	%l7, %o0		! trap_level
 	call	kgdb_trap
-	 add	%sp, STACKFRAME_SZ, %o0
+	 add	%sp, STACKFRAME_SZ, %o1	! struct pt_regs *regs
 
 	RESTORE_ALL
-	.size	kgdb_trap_low,.-kgdb_trap_low
+	ENDPROC(kgdb_trap_low)
 #endif
 
 	.align	4
arch/sparc/kernel/kgdb_32.c +3 -3
index dcf2108..5d0a323 100644
@@ -135,19 +135,19 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
 
 extern void do_hw_interrupt(struct pt_regs *regs, unsigned long type);
 
-asmlinkage void kgdb_trap(struct pt_regs *regs)
+asmlinkage void kgdb_trap(unsigned long trap_level, struct pt_regs *regs)
 {
 	unsigned long flags;
 
 	if (user_mode(regs)) {
-		do_hw_interrupt(regs, 0xfd);
+		do_hw_interrupt(regs, trap_level);
 		return;
 	}
 
 	flushw_all();
 
 	local_irq_save(flags);
-	kgdb_handle_exception(0x172, SIGTRAP, 0, regs);
+	kgdb_handle_exception(trap_level, SIGTRAP, 0, regs);
 	local_irq_restore(flags);
 }
 
Signature · 1 line
2.5.0