Skip to contentSkip to conversation

riscv: export kaslr offset and satp in VMCOREINFO ELF notes

PATCH In review Austin Kim 2 participants 2 messages Feb 11 – Feb 13 RISC-V

lore
Share & tools
lore

Austin Kim

author
#0 lore raw

PATCH 2/2 riscv: export kaslr offset and satp in VMCOREINFO ELF notes

From: Austin Kim <[email protected]>

The following options are required by the kdump crash utility for RISC-V based vmcore file:

- kaslr: If the vmcore is generated from a KASLR-enabled Linux kernel, the KASLR offset is required for the crash utility to load the vmcore. Without the proper kaslr option, the crash utility fails to load the vmcore file.
- satp: The exact root page table address helps determine the correct base PGD address.

With this patch, RISC-V VMCOREINFO ELF notes now include both kaslr and satp information.

---
 arch/riscv/kernel/vmcore_info.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/riscv/kernel/vmcore_info.c +7 -0
index d5e448aa9..682ba423c 100644
@@ -3,6 +3,11 @@
 #include <linux/vmcore_info.h>
 #include <linux/pagemap.h>
 
+static inline u64 get_satp_value(void)
+{
+	return csr_read(CSR_SATP);
+}
+
 void arch_crash_save_vmcoreinfo(void)
 {
 	VMCOREINFO_NUMBER(phys_ram_base);
@@ -27,5 +32,7 @@ void arch_crash_save_vmcoreinfo(void)
 #else
 	vmcoreinfo_append_str("NUMBER(va_kernel_pa_offset)=0x%lx\n",
 						kernel_map.va_kernel_pa_offset);
+	vmcoreinfo_append_str("KERNELOFFSET=%lx\n", kaslr_offset());
+	vmcoreinfo_append_str("NUMBER(satp)=0x%llx\n", get_satp_value());
 #endif
 }
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 12 lines · Austin Kim

From: Austin Kim <[email protected]>

The following options are required by the kdump crash utility for RISC-V based vmcore file:

- kaslr: If the vmcore is generated from a KASLR-enabled Linux kernel, the KASLR offset is required for the crash utility to load the vmcore. Without the proper kaslr option, the crash utility fails to load the vmcore file.
- satp: The exact root page table address helps determine the correct base PGD address.

Quoted 4 lines

With this patch, RISC-V VMCOREINFO ELF notes now include both kaslr and satp information.

Thanks, queued for v7.0-rc.

- Paul