Skip to contentSkip to conversation

sparc32: capture SuperSPARC data store error state

PATCH New Magnus Lindholm 1 participant 1 message Sep 24

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc32: capture SuperSPARC data store error state

SuperSPARC reports a failed buffered write with trap 0x2b. The store has retired by then, while the processor disables the store buffer and retains its entries for inspection.

MFSR is cleared when read. SAVE_ALL may spill a user window and read MFSR while checking that spill, so capture MFAR and MFSR first. Keep them in the trap window's output registers, which SAVE_ALL preserves.

Build pt_regs and set PSR.ET before entering C. The reporter can then inspect the frozen store buffer and, when present, the MXCC registers without running C or printk with traps disabled. Use the saved trap PSR for CPU identification, then continue through the existing bad-trap path.

This is diagnostic support, not error recovery: the handler neither retries the failed store nor re-enables the store buffer.

This follows SuperSPARC Family User's Manual sections 9.12.3.6, MFSR Timing and Operation, 10.6.5, Data Store Errors, 10.7, Store Buffer Diagnostic and Control Interfaces, 12.8.2, Data Store Error Trap, 16.5.4, MXCC Status Register, 16.5.6, MXCC MBus Port Register, and 16.8.4, MXCC Error Register.

---
Applies and builds standalone on v7.3-rc1; cross-built with the SPARCstation 20 configuration, no new warnings.

sparc32 does not boot on current mainline without the prerequisite series below, so this cannot be exercised on real hardware without them:

sparc32: relocatable kernel / phys_base + Viking fixes

    https://lore.kernel.org/sparclinux/[email protected]/T/#t
  sparc32: replace sp_banks with memblock (v3)
    https://lore.kernel.org/sparclinux/[email protected]/
  sparc32: SuperSPARC SMP synchronization fixes (v2)
    https://lore.kernel.org/sparclinux/[email protected]/

This and "sparc32: emulate UDIV/SDIV on illegal_instruction" both insert code immediately after do_hw_interrupt() in arch/sparc/kernel/traps_32.c. They are independent, adjacent insertions, no shared functionality, but whichever is applied second needs a trivial context rebase.

 arch/sparc/include/asm/mxcc.h   | 36 +++++++++++++++++++
 arch/sparc/include/asm/viking.h | 41 ++++++++++++++++++++++
 arch/sparc/kernel/entry.S       | 28 +++++++++++++++
 arch/sparc/kernel/entry.h       |  2 ++
 arch/sparc/kernel/traps_32.c    | 61 +++++++++++++++++++++++++++++++++
 arch/sparc/kernel/ttable_32.S   |  8 ++---
 6 files changed, 172 insertions(+), 4 deletions(-)
arch/sparc/include/asm/mxcc.h +36 -0
index bd6339dcf693..bbfeab004e3e 100644
@@ -126,6 +126,42 @@ static inline unsigned long mxcc_get_creg(void)
 	return mxcc_control;
 }
 
+static inline void mxcc_get_64bit_reg(unsigned long reg,
+				      unsigned long *high,
+				      unsigned long *low)
+{
+	unsigned long reg_high, reg_low;
+
+	__asm__ __volatile__("ldda [%2] %3, %%g2\n\t"
+			     "or %%g0, %%g2, %0\n\t"
+			     "or %%g0, %%g3, %1\n\t"
+			     : "=&r" (reg_high), "=&r" (reg_low)
+			     : "r" (reg), "i" (ASI_M_MXCC)
+			     : "g2", "g3");
+	*high = reg_high;
+	*low = reg_low;
+}
+
+static inline void mxcc_get_sreg(unsigned long *high, unsigned long *low)
+{
+	mxcc_get_64bit_reg(MXCC_SREG, high, low);
+}
+
+static inline void mxcc_get_ereg(unsigned long *high, unsigned long *low)
+{
+	mxcc_get_64bit_reg(MXCC_EREG, high, low);
+}
+
+static inline unsigned long mxcc_get_preg(void)
+{
+	unsigned long mxcc_port;
+
+	__asm__ __volatile__("lda [%1] %2, %0\n\t"
+			     : "=r" (mxcc_port)
+			     : "r" (MXCC_PREG), "i" (ASI_M_MXCC));
+	return mxcc_port;
+}
+
 static inline void mxcc_set_creg(unsigned long mxcc_control)
 {
 	__asm__ __volatile__("sta %0, [%1] %2\n\t" : :
arch/sparc/include/asm/viking.h +41 -0

53 lines not on this page · raw message

arch/sparc/kernel/entry.S +28 -0
index ea51ef52c952..0f07ec9082e7 100644
@@ -22,6 +22,7 @@
 #include <asm/psr.h>
 #include <asm/vaddrs.h>
 #include <asm/page.h>
+#include <asm/pgtsrmmu.h>
 #include <asm/winmacro.h>
 #include <asm/signal.h>
 #include <asm/obio.h>
@@ -205,6 +206,33 @@ bad_trap_handler:
 	 mov	%l7, %o1		! trap number
 
 	RESTORE_ALL
+
+	.align	4
+	.globl	data_store_error
+data_store_error:
+	/* SAVE_ALL preserves the trap window's output registers. */
+	mov	SRMMU_FAULT_ADDR, %l5
+	LEON_PI(lda	[%l5] ASI_LEON_MMUREGS, %o1)	! read MFAR first
+	SUN_PI_(lda	[%l5] ASI_M_MMUREGS, %o1)	! read MFAR first
+
+	mov	SRMMU_FAULT_STATUS, %l5
+	LEON_PI(lda	[%l5] ASI_LEON_MMUREGS, %o2)	! read MFSR last
+	SUN_PI_(lda	[%l5] ASI_M_MMUREGS, %o2)	! read MFSR last
+
+	SAVE_ALL
+
+	wr	%l0, PSR_ET, %psr
+	WRITE_PAUSE
+
+	add	%sp, STACKFRAME_SZ, %o0	! pt_regs
+	call	do_data_store_error
+	 nop
+
+	add	%sp, STACKFRAME_SZ, %o0	! pt_regs
+	call	do_hw_interrupt
+	 mov	0x2b, %o1
+
+	RESTORE_ALL
 	
 /* For now all IRQ's not registered get sent here. handler_irq() will
  * see if a routine is registered to handle this interrupt and if not
arch/sparc/kernel/entry.h +2 -0
index c746c0fd5d6b..b421705ab418 100644
@@ -12,6 +12,8 @@ void handler_irq(int irq, struct pt_regs *regs);
 #ifdef CONFIG_SPARC32
 /* traps */
 void do_hw_interrupt(struct pt_regs *regs, unsigned long type);
+void do_data_store_error(struct pt_regs *regs, unsigned long mfar,
+			 unsigned long mfsr);
 void do_illegal_instruction(struct pt_regs *regs, unsigned long pc,
                             unsigned long npc, unsigned long psr);
 
arch/sparc/kernel/traps_32.c +61 -0

73 lines not on this page · raw message

arch/sparc/kernel/ttable_32.S +4 -4
index e79fd786fbbb..ec6c885ddd33 100644
@@ -56,7 +56,7 @@ t_bad26:BAD_TRAP(0x26) BAD_TRAP(0x27)
 t_cpexc:TRAP_ENTRY(0x28, do_cp_exception)   /* Co-Processor Exception        */
 t_dacce:SRMMU_DFAULT                        /* Data Access Error             */
 t_hwdz:	TRAP_ENTRY(0x2a, do_hw_divzero)     /* Division by zero, you lose... */
-t_dserr:BAD_TRAP(0x2b)                      /* Data Store Error              */
+t_dserr:TRAP_ENTRY(0x2b, data_store_error)  /* Data Store Error              */
 t_daccm:BAD_TRAP(0x2c)                      /* Data Access MMU-Miss          */
 t_bad2d:BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
 t_bad32:BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
@@ -158,7 +158,7 @@ trapbase_cpu1:
 	TRAP_ENTRY(0x28, do_cp_exception)
 	SRMMU_DFAULT
 	TRAP_ENTRY(0x2a, do_hw_divzero)
-	BAD_TRAP(0x2b)
+	TRAP_ENTRY(0x2b, data_store_error)
 	BAD_TRAP(0x2c)
 	BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
 	BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
@@ -257,7 +257,7 @@ trapbase_cpu2:
 	TRAP_ENTRY(0x28, do_cp_exception)
 	SRMMU_DFAULT
 	TRAP_ENTRY(0x2a, do_hw_divzero)
-	BAD_TRAP(0x2b)
+	TRAP_ENTRY(0x2b, data_store_error)
 	BAD_TRAP(0x2c)
 	BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
 	BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
@@ -357,7 +357,7 @@ trapbase_cpu3:
 	TRAP_ENTRY(0x28, do_cp_exception)
 	SRMMU_DFAULT
 	TRAP_ENTRY(0x2a, do_hw_divzero)
-	BAD_TRAP(0x2b) BAD_TRAP(0x2c)
+	TRAP_ENTRY(0x2b, data_store_error) BAD_TRAP(0x2c)
 	BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
 	BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
 	BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)

base-commit: cee9395acd8043be0644b25c34bfa86623f2b935

Signature · 1 line
2.43.0