riscv: Don't use va_pa_offset on kdump
authorNick Kossifidis <mick@ics.forth.gr>
Fri, 26 Nov 2021 18:04:09 +0000 (20:04 +0200)
committerPalmer Dabbelt <palmer@rivosinc.com>
Sun, 9 Jan 2022 18:38:06 +0000 (10:38 -0800)
commita11c07f032a0e9a562a32ece73af96b0e754c4b3
tree18165c38852c0f6bfaec1d39c7856f768d2a5c1b
parent893eae9ac7e4c23c70874c3981fdcf3311655874
riscv: Don't use va_pa_offset on kdump

On kdump instead of using an intermediate step to relocate the kernel,
that lives in a "control buffer" outside the current kernel's mapping,
we jump to the crash kernel directly by calling riscv_kexec_norelocate().
The current implementation uses va_pa_offset while switching to physical
addressing, however since we moved the kernel outside the linear mapping
this won't work anymore since riscv_kexec_norelocate() is part of the
kernel mapping and we should use kernel_map.va_kernel_pa_offset, and also
take XIP kernel into account.

We don't really need to use va_pa_offset on riscv_kexec_norelocate, we
can just set STVEC to the physical address of the new kernel instead and
let the hart jump to the new kernel on the next instruction after setting
SATP to zero. This fixes kdump and is also simpler/cleaner.

I tested this on the latest qemu and HiFive Unmatched and works as
expected.

Fixes: 2bfc6cd81bd1 ("riscv: Move kernel mapping outside of linear mapping")
Signed-off-by: Nick Kossifidis <mick@ics.forth.gr>
Reviewed-by: Alexandre Ghiti <alex@ghiti.fr>
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/kernel/kexec_relocate.S