|
|
Log in / Subscribe / Register

Add crashdump support in guest kernel

From:  fangyu.yu-AT-linux.alibaba.com
To:  pjw-AT-kernel.org, palmer-AT-dabbelt.com, aou-AT-eecs.berkeley.edu, alex-AT-ghiti.fr, songshuaishuai-AT-tinylab.org, bjorn-AT-rivosinc.com, ardb-AT-kernel.org, arnd-AT-arndb.de, bhelgaas-AT-google.com, richard.lyu-AT-suse.com, tzimmermann-AT-suse.de, nathan-AT-kernel.org
Subject:  [PATCH 0/4] Add crashdump support in guest kernel
Date:  Tue, 24 Mar 2026 19:45:23 +0800
Message-ID:  <20260324114527.91494-1-fangyu.yu@linux.alibaba.com>
Cc:  guoren-AT-kernel.org, kvm-riscv-AT-lists.infradead.org, linux-riscv-AT-lists.infradead.org, linux-kernel-AT-vger.kernel.org, Fangyu Yu <fangyu.yu-AT-linux.alibaba.com>
Archive-link:  Article

From: Fangyu Yu <fangyu.yu@linux.alibaba.com>

In a RISC-V kernel, crashdump needs to hand off execution to the crash
kernel after tearing down the current kernel address space. However,
under virtualization the guest uses two-stage address translation, PC
does not jump to stvec after setting satp to zero.

This patch set introduces a dedicated kexec trampoline text section and
builds a minimal trampoline page table for it. The crash handoff is then
reworked into a two-pass trampoline:

    1. First enter via the kernel VA, install the trampoline page table,
       and jump to the trampoline VA(=PA) of the norelocate code;
    2. Continue execution with trampoline VA(=PA) and directly jump to the
       crash kernel entry point with jr, instead of depending on a stvec
       redirection.

With this, crashdump in RISC-V guests becomes robust against the
two-stage translation.

Fangyu Yu (4):
  riscv: Add kexec trampoline text section to vmlinux.lds.S
  riscv: kexec: Place norelocate trampoline into .kexec.tramp.text
  riscv: kexec: Build trampoline page tables for crash kernel entry
  riscv: kexec: Switch to trampoline page table before norelocate

 arch/riscv/include/asm/kexec.h     |   9 +++
 arch/riscv/kernel/image-vars.h     |  13 ++++
 arch/riscv/kernel/kexec_relocate.S |  34 +++++++--
 arch/riscv/kernel/machine_kexec.c  | 116 ++++++++++++++++++++++++++++-
 arch/riscv/kernel/vmlinux.lds.S    |   1 +
 5 files changed, 166 insertions(+), 7 deletions(-)

-- 
2.50.1




Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds