[PW_SID:1100959] riscv: kexec: Fix VCPU crash on kexec/kdump under KVM#2018
[PW_SID:1100959] riscv: kexec: Fix VCPU crash on kexec/kdump under KVM#2018linux-riscv-bot wants to merge 7 commits into
Conversation
When CONFIG_KEXEC_CORE is enabled, add a dedicated .kexec.tramp.text area to the RISC-V kernel linker script. This introduces a KEXEC_TRAMP_TEXT linker snippet in image-vars.h and uses it from vmlinux.lds.S to: - align both the start and the end to PAGE_SIZE - define __kexec_tramp_text_start/__kexec_tramp_text_end - KEEP all .kexec.tramp.text* input sections - ASSERT the trampoline text fits within one page The end-of-section page alignment guarantees that the trampoline page, which is later identity-mapped as PAGE_KERNEL_EXEC, contains nothing but the trampoline code and padding (no shared neighbour data). When kexec is disabled, KEXEC_TRAMP_TEXT expands to nothing. Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Move riscv_kexec_norelocate out of the generic .text section and into a dedicated executable trampoline section, .kexec.tramp.text. Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Crash kexec uses riscv_kexec_norelocate as a trampoline to jump into the crashkernel. Add a small helper to build dedicated 4KB page tables that map the trampoline page as executable. Two mappings are installed: - VA(__kexec_tramp_text_start) -> PA(__kexec_tramp_text_start) - PA(__kexec_tramp_text_start) -> PA(__kexec_tramp_text_start) This allows the trampoline to run regardless of whether it is entered via its linked virtual address or its physical address. Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Make riscv_kexec_norelocate a two-pass trampoline so it can drop the kernel page tables while still executing from a mapped address. On the first entry, t3 is initialized to 0 by machine_kexec(). Loads the physical address of riscv_kexec_norelocate and the trampoline SATP value, switches to the trampoline page table, and jumps to the trampoline VA(=PA). On the second entry, t3 contains the physical address of riscv_kexec_norelocate, so the PC comparison matches and execution continues under trampoline VA(=PA). Since the trampoline page table is already active, replace the previous stvec-based handoff with a direct jump to the target entry (jr a2). Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 <fangyu.yu@linux.alibaba.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add riscv_kexec_relocate_entry to .kexec.tramp.text and the two asm-visible globals (riscv_kexec_relocate_entry_pa and riscv_kexec_cc_buffer_pa) that the wrapper consumes. The wrapper performs the same two-step transition used by the crash path: switch to the trampoline pgd, jump to the PA of self, then drop the MMU with PC already on a PA. It finally jumps to the PA of control_code_buffer. machine_kexec_prepare() publishes the wrapper PA and the control_code_buffer PA via WRITE_ONCE for non-crash images. Nothing routes to the wrapper yet; the switchover happens in the follow-up patch. Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
riscv_kexec_relocate (copied into control_code_buffer) uses an stvec trick to drop the MMU and land on the PA of the next loop label. Under VS-mode KVM cannot emulate this single-step transition and the VCPU dies with "kvm run failed Operation not supported". Route normal kexec through riscv_kexec_relocate_entry, the trampoline wrapper added in the previous patch. It drops SATP with PC already on a PA, then hands off to control_code_buffer where the relocate body runs with SATP=0. Drop the stvec trick from the relocate body and pass first_ind_entry as a physical address since the body now starts with SATP=0. The ".align 2" plus filler "nop" that ensured the PA of the loop top was 4-byte aligned -- required because the legacy stvec trick wrote that PA into stvec.BASE, whose low two bits are MODE and are discarded by the hardware -- is no longer load-bearing and is removed as well. Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[v2,1/7] riscv: Add kexec trampoline text section to vmlinux.lds.S" |
|
Patch 1: "[v2,1/7] riscv: Add kexec trampoline text section to vmlinux.lds.S" |
|
Patch 1: "[v2,1/7] riscv: Add kexec trampoline text section to vmlinux.lds.S" |
|
Patch 1: "[v2,1/7] riscv: Add kexec trampoline text section to vmlinux.lds.S" |
|
Patch 1: "[v2,1/7] riscv: Add kexec trampoline text section to vmlinux.lds.S" |
|
Patch 1: "[v2,1/7] riscv: Add kexec trampoline text section to vmlinux.lds.S" |
|
Patch 1: "[v2,1/7] riscv: Add kexec trampoline text section to vmlinux.lds.S" |
|
Patch 1: "[v2,1/7] riscv: Add kexec trampoline text section to vmlinux.lds.S" |
|
Patch 1: "[v2,1/7] riscv: Add kexec trampoline text section to vmlinux.lds.S" |
|
Patch 1: "[v2,1/7] riscv: Add kexec trampoline text section to vmlinux.lds.S" |
|
Patch 1: "[v2,1/7] riscv: Add kexec trampoline text section to vmlinux.lds.S" |
|
Patch 1: "[v2,1/7] riscv: Add kexec trampoline text section to vmlinux.lds.S" |
|
Patch 2: "[v2,2/7] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text" |
|
Patch 2: "[v2,2/7] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text" |
|
Patch 2: "[v2,2/7] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text" |
|
Patch 2: "[v2,2/7] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text" |
|
Patch 2: "[v2,2/7] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text" |
|
Patch 2: "[v2,2/7] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text" |
|
Patch 2: "[v2,2/7] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text" |
|
Patch 2: "[v2,2/7] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text" |
|
Patch 2: "[v2,2/7] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text" |
|
Patch 2: "[v2,2/7] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text" |
|
Patch 2: "[v2,2/7] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text" |
|
Patch 5: "[v2,5/7] riscv: kexec: Always build the trampoline page table" |
|
Patch 5: "[v2,5/7] riscv: kexec: Always build the trampoline page table" |
|
Patch 5: "[v2,5/7] riscv: kexec: Always build the trampoline page table" |
|
Patch 5: "[v2,5/7] riscv: kexec: Always build the trampoline page table" |
|
Patch 5: "[v2,5/7] riscv: kexec: Always build the trampoline page table" |
|
Patch 5: "[v2,5/7] riscv: kexec: Always build the trampoline page table" |
|
Patch 6: "[v2,6/7] riscv: kexec: Add the relocate-trampoline wrapper" |
|
Patch 6: "[v2,6/7] riscv: kexec: Add the relocate-trampoline wrapper" |
|
Patch 6: "[v2,6/7] riscv: kexec: Add the relocate-trampoline wrapper" |
|
Patch 6: "[v2,6/7] riscv: kexec: Add the relocate-trampoline wrapper" |
|
Patch 6: "[v2,6/7] riscv: kexec: Add the relocate-trampoline wrapper" |
|
Patch 6: "[v2,6/7] riscv: kexec: Add the relocate-trampoline wrapper" |
|
Patch 6: "[v2,6/7] riscv: kexec: Add the relocate-trampoline wrapper" |
|
Patch 6: "[v2,6/7] riscv: kexec: Add the relocate-trampoline wrapper" |
|
Patch 6: "[v2,6/7] riscv: kexec: Add the relocate-trampoline wrapper" |
|
Patch 6: "[v2,6/7] riscv: kexec: Add the relocate-trampoline wrapper" |
|
Patch 6: "[v2,6/7] riscv: kexec: Add the relocate-trampoline wrapper" |
|
Patch 6: "[v2,6/7] riscv: kexec: Add the relocate-trampoline wrapper" |
|
Patch 7: "[v2,7/7] riscv: kexec: Route normal kexec through the trampoline page table" |
|
Patch 7: "[v2,7/7] riscv: kexec: Route normal kexec through the trampoline page table" |
|
Patch 7: "[v2,7/7] riscv: kexec: Route normal kexec through the trampoline page table" |
|
Patch 7: "[v2,7/7] riscv: kexec: Route normal kexec through the trampoline page table" |
|
Patch 7: "[v2,7/7] riscv: kexec: Route normal kexec through the trampoline page table" |
|
Patch 7: "[v2,7/7] riscv: kexec: Route normal kexec through the trampoline page table" |
|
Patch 7: "[v2,7/7] riscv: kexec: Route normal kexec through the trampoline page table" |
|
Patch 7: "[v2,7/7] riscv: kexec: Route normal kexec through the trampoline page table" |
|
Patch 7: "[v2,7/7] riscv: kexec: Route normal kexec through the trampoline page table" |
|
Patch 7: "[v2,7/7] riscv: kexec: Route normal kexec through the trampoline page table" |
|
Patch 7: "[v2,7/7] riscv: kexec: Route normal kexec through the trampoline page table" |
|
Patch 7: "[v2,7/7] riscv: kexec: Route normal kexec through the trampoline page table" |
PR for series 1100959 applied to workflow__riscv__fixes
Name: riscv: kexec: Fix VCPU crash on kexec/kdump under KVM
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1100959
Version: 2