From: Fangyu Yu <[email protected]> The trampoline page table and the kexec_tramp_satp value are currently built only on the crash path. A follow-up patch needs the same infrastructure for the normal kexec path.
Pull the trampoline build and the WRITE_ONCE() that publishes the SATP value out of the crash-only else branch in machine_kexec_prepare(). The crash path keeps recording its own riscv_kexec_norelocate_pa; the normal path keeps its existing control_code_buffer copy. No functional change. Signed-off-by: Fangyu Yu <[email protected]> --- arch/riscv/kernel/machine_kexec.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/arch/riscv/kernel/machine_kexec.c b/arch/riscv/kernel/machine_kexec.c index 72817bba5d3b..d82f45fb44b6 100644 --- a/arch/riscv/kernel/machine_kexec.c +++ b/arch/riscv/kernel/machine_kexec.c @@ -139,6 +139,16 @@ machine_kexec_prepare(struct kimage *image) return -EINVAL; } + /* + * Build the trampoline page table and capture its SATP value. + * The crash path consumes it today; the non-crash kexec path + * will use the same setup as well. + */ + riscv_kexec_build_tramp((unsigned long)__kexec_tramp_text_start, + __pa_symbol(__kexec_tramp_text_start)); + WRITE_ONCE(kexec_tramp_satp, + PFN_DOWN(__pa_symbol(kexec_tramp_pgd)) | satp_mode); + /* Copy the assembler code for relocation to the control page */ if (image->type != KEXEC_TYPE_CRASH) { control_code_buffer = page_address(image->control_code_page); @@ -155,19 +165,8 @@ machine_kexec_prepare(struct kimage *image) /* Mark the control page executable */ set_memory_x((unsigned long) control_code_buffer, 1); } else { - /* - * Crash kexec uses riscv_kexec_norelocate as a trampoline. - * Pre-build the trampoline page tables and capture the - * trampoline SATP value plus the physical address of - * riscv_kexec_norelocate so that the panic path only has - * to switch satp and jump. - */ - riscv_kexec_build_tramp((unsigned long)__kexec_tramp_text_start, - __pa_symbol(__kexec_tramp_text_start)); WRITE_ONCE(riscv_kexec_norelocate_pa, __pa_symbol(&riscv_kexec_norelocate)); - WRITE_ONCE(kexec_tramp_satp, - PFN_DOWN(__pa_symbol(kexec_tramp_pgd)) | satp_mode); } return 0; -- 2.50.1
