[PATCH v2 1/5] kho: Do not translate the handover FDT address in is_kho_boot()
Chen Pei
cp0613 at linux.alibaba.com
Tue Nov 3 00:09:22 PST 2026
is_kho_boot() only has to say whether a handover FDT was recorded, but
it asks kho_get_fdt() for one and so converts kho_in.fdt_phys with
phys_to_virt() just to throw the pointer away. Both callers use it as a
boolean and never dereference the result.
On riscv64 that conversion is not valid yet when efi_init() reaches it:
setup_vm() leaves kernel_map.va_pa_offset at 0 and setup_bootmem()
assigns it later, so a handover boot that came through UEFI panics in
linear_mapping_pa_to_va(). Only debug builds fail -- without
CONFIG_DEBUG_VIRTUAL __va() degenerates to "phys + 0" and the boolean
stays correct -- but the panic also goes unnoticed without an earlycon.
Check the physical address instead. Nothing needs the translation, and
architectures stay free to bring their linear mapping up whenever they
like.
Fixes: d6d511639185 ("kexec: introduce is_kho_boot()")
Signed-off-by: Chen Pei <cp0613 at linux.alibaba.com>
---
Tested on qemu-system-riscv64 (virt, -cpu max, TCG): edk2
RISCV_VIRT_CODE.fd/VARS.fd on pflash with OpenSBI fw_dynamic.bin below
it, and a GPT disk holding an ESP with grub plus the kernel and an ext4
partition as rootfs. Kernel config is riscv defconfig plus
DEBUG_KERNEL, DEBUG_VIRTUAL, KEXEC_FILE, KEXEC_HANDOVER and the kho
selftest fragment; the outgoing kernel gets "kho=on" and the kho
selftest init does kexec_file_load() followed by reboot(RB_KEXEC).
Before, the first handover panics. earlycon= is needed to see it: the
BUG precedes console registration, so without an earlycon the machine
goes silent right after kexec.
KHO: found kexec handover data.
efi: EFI v2.7 by EDK II
kernel BUG at arch/riscv/mm/physaddr.c:47!
epc : linear_mapping_pa_to_va+0x1c/0x1e
ra : is_kho_boot+0x18/0x28
After, the same setup keeps handing over until the window closes, 29
consecutive boots and no BUG.
KHO: found kexec handover data.
KHO: exec from: 7.4.0-rc1-next-20261102-00005-gfca49e548231 (count 29)
kernel/liveupdate/kexec_handover.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index 6f1f55fe3181..6ab181de345c 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -1643,7 +1643,7 @@ EXPORT_SYMBOL_GPL(kho_restore_free);
*/
bool is_kho_boot(void)
{
- return !!kho_get_fdt();
+ return kho_in.fdt_phys != 0;
}
EXPORT_SYMBOL_GPL(is_kho_boot);
--
2.50.1
More information about the linux-riscv
mailing list