[PATCH 07/21] MIPS: print BadVAddr CP0 register on exception

Denis Orlov denorl2009 at gmail.com
Mon Jul 24 22:05:08 PDT 2023


This register contains the failing address on Address Error and some
TLB-related exceptions, and is useful for debugging purposes.

Signed-off-by: Denis Orlov <denorl2009 at gmail.com>
---
 arch/mips/include/asm/stackframe.h | 4 ++++
 arch/mips/lib/traps.c              | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/stackframe.h b/arch/mips/include/asm/stackframe.h
index 2295d7f02f..64ec37478a 100644
--- a/arch/mips/include/asm/stackframe.h
+++ b/arch/mips/include/asm/stackframe.h
@@ -89,8 +89,10 @@
 #endif
 		LONG_S	v1, PT_EPC(sp)
 		LONG_S	$25, PT_R25(sp)
+		MFC0	v1, CP0_BADVADDR
 		LONG_S	$28, PT_R28(sp)
 		LONG_S	$31, PT_R31(sp)
+		LONG_S	v1, PT_BVADDR(sp)
 		.set	pop
 		.endm
 
@@ -157,11 +159,13 @@
 		MTC0	v1, CP0_EPC
 		LONG_L	$31, PT_R31(sp)
 		LONG_L	$28, PT_R28(sp)
+		LONG_L	v1, PT_BVADDR(sp)
 		LONG_L	$25, PT_R25(sp)
 #ifdef CONFIG_64BIT
 		LONG_L	$8, PT_R8(sp)
 		LONG_L	$9, PT_R9(sp)
 #endif
+		MTC0	v0, CP0_BADVADDR
 		LONG_L	$7,  PT_R7(sp)
 		LONG_L	$6,  PT_R6(sp)
 		LONG_L	$5,  PT_R5(sp)
diff --git a/arch/mips/lib/traps.c b/arch/mips/lib/traps.c
index 45694fe7ef..638a511fee 100644
--- a/arch/mips/lib/traps.c
+++ b/arch/mips/lib/traps.c
@@ -153,7 +153,8 @@ static void show_regs(const struct pt_regs *regs)
 
 	printf("Status: %08x\n", (uint32_t)regs->cp0_status);
 	printf("Cause : %08x\n", (uint32_t)regs->cp0_cause);
-	printf("Config: %08x\n\n", read_c0_config());
+	printf("Config: %08x\n", read_c0_config());
+	printf("BadVA : %0*lx\n\n", field, regs->cp0_badvaddr);
 }
 
 void barebox_exc_handler(struct pt_regs *regs)
-- 
2.41.0




More information about the barebox mailing list