Commit 54a519e6 authored by Alexandre Ghiti's avatar Alexandre Ghiti Committed by Palmer Dabbelt

riscv: Dump out kernel offset information on panic

Dump out the KASLR virtual kernel offset when panic to help debug kernel.
Signed-off-by: default avatarZong Li <zong.li@sifive.com>
Signed-off-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
Tested-by: default avatarConor Dooley <conor.dooley@microchip.com>
Tested-by: default avatarSong Shuai <songshuaishuai@tinylab.org>
Reviewed-by: default avatarSami Tolvanen <samitolvanen@google.com>
Tested-by: default avatarSami Tolvanen <samitolvanen@google.com>
Link: https://lore.kernel.org/r/20230722123850.634544-3-alexghiti@rivosinc.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent 84fe419d
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/efi.h> #include <linux/efi.h>
#include <linux/crash_dump.h> #include <linux/crash_dump.h>
#include <linux/panic_notifier.h>
#include <asm/acpi.h> #include <asm/acpi.h>
#include <asm/alternative.h> #include <asm/alternative.h>
...@@ -341,3 +342,27 @@ void free_initmem(void) ...@@ -341,3 +342,27 @@ void free_initmem(void)
free_initmem_default(POISON_FREE_INITMEM); free_initmem_default(POISON_FREE_INITMEM);
} }
static int dump_kernel_offset(struct notifier_block *self,
unsigned long v, void *p)
{
pr_emerg("Kernel Offset: 0x%lx from 0x%lx\n",
kernel_map.virt_offset,
KERNEL_LINK_ADDR);
return 0;
}
static struct notifier_block kernel_offset_notifier = {
.notifier_call = dump_kernel_offset
};
static int __init register_kernel_offset_dumper(void)
{
if (IS_ENABLED(CONFIG_RANDOMIZE_BASE))
atomic_notifier_chain_register(&panic_notifier_list,
&kernel_offset_notifier);
return 0;
}
device_initcall(register_kernel_offset_dumper);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment