[PATCH] riscv: export kaslr offset and satp in VMCOREINFO ELF notes

Austin Kim posted 1 patch 1 week, 4 days ago
arch/riscv/kernel/vmcore_info.c | 7 +++++++
1 file changed, 7 insertions(+)
[PATCH] riscv: export kaslr offset and satp in VMCOREINFO ELF notes
Posted by Austin Kim 1 week, 4 days ago
From: Austin Kim <austin.kim@lge.com>

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.

Signed-off-by: Austin Kim <austin.kim@lge.com>
---
 arch/riscv/kernel/vmcore_info.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/riscv/kernel/vmcore_info.c b/arch/riscv/kernel/vmcore_info.c
index d5e448aa9..682ba423c 100644
--- a/arch/riscv/kernel/vmcore_info.c
+++ b/arch/riscv/kernel/vmcore_info.c
@@ -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
 }
-- 
2.34.1
Re: [PATCH] riscv: export kaslr offset and satp in VMCOREINFO ELF notes
Posted by kernel test robot 1 week, 3 days ago
Hi Austin,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.16-rc1 next-20260127]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Austin-Kim/riscv-export-kaslr-offset-and-satp-in-VMCOREINFO-ELF-notes/20260127-173528
base:   linus/master
patch link:    https://lore.kernel.org/r/aXiF55y5D49gcpUg%40adminpc-PowerEdge-R7525
patch subject: [PATCH] riscv: export kaslr offset and satp in VMCOREINFO ELF notes
config: riscv-allnoconfig-bpf (https://download.01.org/0day-ci/archive/20260127/202601272006.NUdRcAIi-lkp@intel.com/config)
compiler: riscv64-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260127/202601272006.NUdRcAIi-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601272006.NUdRcAIi-lkp@intel.com/

All errors (new ones prefixed by >>):

   riscv64-linux-ld: arch/riscv/kernel/vmcore_info.o: in function `arch_crash_save_vmcoreinfo':
>> arch/riscv/kernel/vmcore_info.c:23:(.text+0x240): undefined reference to `kaslr_offset'


vim +23 arch/riscv/kernel/vmcore_info.c

cfe94d456775a4 arch/riscv/kernel/vmcore_info.c Austin Kim      2026-01-27  10  
649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  11  void arch_crash_save_vmcoreinfo(void)
649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  12  {
649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  13  	VMCOREINFO_NUMBER(phys_ram_base);
649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  14  
649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  15  	vmcoreinfo_append_str("NUMBER(PAGE_OFFSET)=0x%lx\n", PAGE_OFFSET);
649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  16  	vmcoreinfo_append_str("NUMBER(VMALLOC_END)=0x%lx\n", VMALLOC_END);
c41bd2514184d7 arch/riscv/kernel/crash_core.c  Ignat Korchagin 2023-11-29  17  #ifdef CONFIG_MMU
c41bd2514184d7 arch/riscv/kernel/crash_core.c  Ignat Korchagin 2023-11-29  18  	VMCOREINFO_NUMBER(VA_BITS);
649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  19  	vmcoreinfo_append_str("NUMBER(VMEMMAP_START)=0x%lx\n", VMEMMAP_START);
649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  20  	vmcoreinfo_append_str("NUMBER(VMEMMAP_END)=0x%lx\n", VMEMMAP_END);
649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  21  #ifdef CONFIG_64BIT
649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  22  	vmcoreinfo_append_str("NUMBER(MODULES_VADDR)=0x%lx\n", MODULES_VADDR);
649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26 @23  	vmcoreinfo_append_str("NUMBER(MODULES_END)=0x%lx\n", MODULES_END);

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH] riscv: export kaslr offset and satp in VMCOREINFO ELF notes
Posted by Austin Kim 1 week, 3 days ago
Hello,

2026년 1월 28일 (수) AM 4:14, kernel test robot <lkp@intel.com>님이 작성:
>
> Hi Austin,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on linus/master]
> [also build test ERROR on v6.16-rc1 next-20260127]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Austin-Kim/riscv-export-kaslr-offset-and-satp-in-VMCOREINFO-ELF-notes/20260127-173528
> base:   linus/master
> patch link:    https://lore.kernel.org/r/aXiF55y5D49gcpUg%40adminpc-PowerEdge-R7525
> patch subject: [PATCH] riscv: export kaslr offset and satp in VMCOREINFO ELF notes
> config: riscv-allnoconfig-bpf (https://download.01.org/0day-ci/archive/20260127/202601272006.NUdRcAIi-lkp@intel.com/config)
> compiler: riscv64-linux-gcc (GCC) 15.1.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260127/202601272006.NUdRcAIi-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202601272006.NUdRcAIi-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
>    riscv64-linux-ld: arch/riscv/kernel/vmcore_info.o: in function `arch_crash_save_vmcoreinfo':
> >> arch/riscv/kernel/vmcore_info.c:23:(.text+0x240): undefined reference to `kaslr_offset'
>

First, I apologize for the inconvenience.

This link error occurs when CONFIG_RANDOMIZE_BASE is disabled.
In the RISC-V kernel, kaslr_offset() is only defined under
CONFIG_RANDOMIZE_BASE.

I will submit a new patch shortly to avoid this kind of error.

BR,
Austin Kim

>
> vim +23 arch/riscv/kernel/vmcore_info.c
>
> cfe94d456775a4 arch/riscv/kernel/vmcore_info.c Austin Kim      2026-01-27  10
> 649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  11  void arch_crash_save_vmcoreinfo(void)
> 649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  12  {
> 649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  13   VMCOREINFO_NUMBER(phys_ram_base);
> 649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  14
> 649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  15   vmcoreinfo_append_str("NUMBER(PAGE_OFFSET)=0x%lx\n", PAGE_OFFSET);
> 649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  16   vmcoreinfo_append_str("NUMBER(VMALLOC_END)=0x%lx\n", VMALLOC_END);
> c41bd2514184d7 arch/riscv/kernel/crash_core.c  Ignat Korchagin 2023-11-29  17  #ifdef CONFIG_MMU
> c41bd2514184d7 arch/riscv/kernel/crash_core.c  Ignat Korchagin 2023-11-29  18   VMCOREINFO_NUMBER(VA_BITS);
> 649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  19   vmcoreinfo_append_str("NUMBER(VMEMMAP_START)=0x%lx\n", VMEMMAP_START);
> 649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  20   vmcoreinfo_append_str("NUMBER(VMEMMAP_END)=0x%lx\n", VMEMMAP_END);
> 649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  21  #ifdef CONFIG_64BIT
> 649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26  22   vmcoreinfo_append_str("NUMBER(MODULES_VADDR)=0x%lx\n", MODULES_VADDR);
> 649d6b1019a2f2 arch/riscv/kernel/crash_core.c  Xianting Tian   2022-10-26 @23   vmcoreinfo_append_str("NUMBER(MODULES_END)=0x%lx\n", MODULES_END);
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki