[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <ea7c01b7c969ddc269a8f94cc9646fc48b7ff790.1584352425.git.zong.li@sifive.com>
Date: Tue, 24 Mar 2020 15:30:53 +0800
From: Zong Li <zong.li@...ive.com>
To: palmer@...belt.com, paul.walmsley@...ive.com, alex@...ti.fr,
linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc: Zong Li <zong.li@...ive.com>
Subject: [PATCH RFC 8/8] riscv/kaslr: dump out kernel offset information on panic
Dump out the kernel offset when panic to help debug kernel.
Signed-off-by: Zong Li <zong.li@...ive.com>
---
arch/riscv/kernel/setup.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index 913d25e4b9fa..3ce50bf628ba 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -85,3 +85,26 @@ void __init setup_arch(char **cmdline_p)
riscv_fill_hwcap();
}
+
+static int dump_kernel_offset(struct notifier_block *self, unsigned long v,
+ void *p)
+{
+ pr_emerg("Kernel Offset: 0x%lx from 0x%lx\n",
+ get_kaslr_offset(), PAGE_OFFSET);
+
+ 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) && get_kaslr_offset() > 0)
+ atomic_notifier_chain_register(&panic_notifier_list,
+ &kernel_offset_notifier);
+
+ return 0;
+}
+__initcall(register_kernel_offset_dumper);
--
2.25.1
Powered by blists - more mailing lists