[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240201153811.1793120-1-stefan.wiehler@nokia.com>
Date: Thu, 1 Feb 2024 16:38:11 +0100
From: Stefan Wiehler <stefan.wiehler@...ia.com>
To: Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>
Cc: linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
Stefan Wiehler <stefan.wiehler@...ia.com>
Subject: [PATCH] arm64: Print provenance information for addresses in registers
Like commit 5aa6b70ed182 ("arm: print alloc free paths for address in
registers") already does for 32-bit ARM, print available provenance information
for addresses in registers in case of internal error as a debugging aid:
Unable to handle kernel write to read-only memory at virtual address ffffffc00117cd5c
...
x2 : 0000000000001b98 x1 : 0000000000000000 x0 : ffffffc00117cd5c
...
Register x0 information: 14-page vmalloc region starting at 0xffffffc00117a000 allocated at load_module+0x15c4/0x2bc0
Register x1 information: NULL pointer
Register x2 information: non-paged memory
...
Signed-off-by: Stefan Wiehler <stefan.wiehler@...ia.com>
---
arch/arm64/include/asm/system_misc.h | 1 +
arch/arm64/kernel/process.c | 11 +++++++++++
arch/arm64/kernel/traps.c | 1 +
3 files changed, 13 insertions(+)
diff --git a/arch/arm64/include/asm/system_misc.h b/arch/arm64/include/asm/system_misc.h
index c34344256762..5b9b02fee988 100644
--- a/arch/arm64/include/asm/system_misc.h
+++ b/arch/arm64/include/asm/system_misc.h
@@ -31,6 +31,7 @@ void hook_debug_fault_code(int nr, int (*fn)(unsigned long, unsigned long,
struct mm_struct;
extern void __show_regs(struct pt_regs *);
+extern void __show_regs_alloc_free(struct pt_regs *);
#endif /* __ASSEMBLY__ */
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 7387b68c745b..b6fc2ac6e007 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -197,6 +197,17 @@ static void print_pstate(struct pt_regs *regs)
}
}
+void __show_regs_alloc_free(struct pt_regs *regs)
+{
+ int i;
+
+ /* check for x0 - x29 only */
+ for (i = 0; i < 30; i++) {
+ pr_alert("Register x%d information:", i);
+ mem_dump_obj((void *)regs->regs[i]);
+ }
+}
+
void __show_regs(struct pt_regs *regs)
{
int i, top_reg;
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 215e6d7f2df8..b7bf22f1b33f 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -197,6 +197,7 @@ static int __die(const char *str, long err, struct pt_regs *regs)
print_modules();
show_regs(regs);
+ __show_regs_alloc_free(regs);
dump_kernel_instr(KERN_EMERG, regs);
--
2.42.0
Powered by blists - more mailing lists