Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds KASLR support for Crash to analyze KASLR-ed vmcore since RISC-V Linux is already sufficiently prepared for KASLR [1]. With this patch, even if the Crash '--kaslr' option is not set or Linux CONFIG_RANDOMIZE_BASE is not configured, the 'derive_kaslr_offset()' function will always work to calculate 'kt->relocate' which serves to update the kernel virtual address. Testing in Qemu rv64 virt, kernel log outputed the kernel offset: [ 121.214447] SMP: stopping secondary CPUs [ 121.215445] Kernel Offset: 0x37c00000 from 0xffffffff80000000 [ 121.216312] Starting crashdump kernel... [ 121.216585] Will call new kernel at 94800000 from hart id 0 [ 121.216834] FDT image at 9c7fd000 [ 121.216982] Bye... Running crash with '-d 1' option and without '--kaslr' option, we get the right 'kt->relocate' and kernel link addr: $ ../crash/crash -d 1 vmlinux vmcore_kaslr_0815 ... KASLR: _stext from vmlinux: ffffffff80002000 _stext from vmcoreinfo: ffffffffb7c02000 relocate: 37c00000 (892MB) vmemmap : 0xff1c000000000000 - 0xff20000000000000 vmalloc : 0xff20000000000000 - 0xff60000000000000 mudules : 0xffffffff3952f000 - 0xffffffffb7c00000 lowmem : 0xff60000000000000 - kernel link addr : 0xffffffffb7c00000 ... KERNEL: /home/song/9_linux/linux/00_rv_kaslr/vmlinux DUMPFILE: /tmp/hello/vmcore_kaslr_0815 CPUS: 2 DATE: Tue Aug 15 16:36:15 CST 2023 UPTIME: 00:02:01 LOAD AVERAGE: 0.40, 0.23, 0.09 TASKS: 63 NODENAME: stage4.fedoraproject.org RELEASE: 6.5.0-rc3-00008-gad18dee423ac VERSION: #17 SMP Tue Aug 15 14:41:12 CST 2023 MACHINE: riscv64 (unknown Mhz) MEMORY: 511.8 MB PANIC: "Kernel panic - not syncing: sysrq triggered crash" PID: 160 COMMAND: "bash" TASK: ff6000000152bac0 [THREAD_INFO: ff6000000152bac0] CPU: 1 STATE: TASK_RUNNING (PANIC) crash> [1]: https://lore.kernel.org/linux-riscv/[email protected]/ Signed-off-by: Song Shuai <[email protected]> Reviewed-by: Guo Ren <[email protected]>
- Loading branch information