diff --git a/LoongArch-Load-vmlinux.efi-to-the-link-address.patch b/LoongArch-Load-vmlinux.efi-to-the-link-address.patch new file mode 100644 index 0000000000000000000000000000000000000000..1724d7c2f92ca37eaf177f42728f7bf636a17db4 --- /dev/null +++ b/LoongArch-Load-vmlinux.efi-to-the-link-address.patch @@ -0,0 +1,78 @@ +From 549466430ae68f7df6cfa65088fe55d4ef926d8e Mon Sep 17 00:00:00 2001 +From: WANG Rui +Date: Sat, 25 Nov 2023 14:52:32 +0800 +Subject: [PATCH] LoongArch: Load vmlinux.efi to the link address + +Currently, kexec loads vmlinux.efi to address 0 instead of the link +address. This causes kexec to fail to boot the new vmlinux.efi on qemu. + + pei_loongarch_load: kernel_segment: 0000000000000000 + pei_loongarch_load: kernel_entry: 00000000013f1000 + pei_loongarch_load: image_size: 0000000001ca0000 + pei_loongarch_load: text_offset: 0000000000200000 + pei_loongarch_load: phys_offset: 0000000000000000 + pei_loongarch_load: PE format: yes + loongarch_load_other_segments:333: command_line: kexec console=ttyS0,115200 + kexec_load: entry = 0x13f1000 flags = 0x1020000 + nr_segments = 2 + segment[0].buf = 0x7fffeea38010 + segment[0].bufsz = 0x1b55200 + segment[0].mem = (nil) + segment[0].memsz = 0x1ca0000 + segment[1].buf = 0x5555570940b0 + segment[1].bufsz = 0x200 + segment[1].mem = 0x1ca0000 + segment[1].memsz = 0x4000 + +This patch constrains the range of the kernel segment by `hole_min` +and `hole_max` to place vmlinux.efi exactly at the link address. + + pei_loongarch_load: kernel_segment: 0000000000200000 + pei_loongarch_load: kernel_entry: 00000000013f1000 + pei_loongarch_load: image_size: 0000000001ca0000 + pei_loongarch_load: text_offset: 0000000000200000 + pei_loongarch_load: phys_offset: 0000000000000000 + pei_loongarch_load: PE format: yes + loongarch_load_other_segments:339: command_line: kexec console=ttyS0,115200 + kexec_load: entry = 0x13f1000 flags = 0x1020000 + nr_segments = 2 + segment[0].buf = 0x7ffff2028010 + segment[0].bufsz = 0x1b55200 + segment[0].mem = 0x200000 + segment[0].memsz = 0x1ca0000 + segment[1].buf = 0x555557498098 + segment[1].bufsz = 0x200 + segment[1].mem = 0x1ea0000 + segment[1].memsz = 0x4000 + +Signed-off-by: WANG Rui +Reviewed-by: Huacai Chen +Signed-off-by: Simon Horman +--- + kexec/arch/loongarch/kexec-loongarch.c | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/kexec/arch/loongarch/kexec-loongarch.c b/kexec/arch/loongarch/kexec-loongarch.c +index 62ff8fd..32a42d2 100644 +--- a/kexec/arch/loongarch/kexec-loongarch.c ++++ b/kexec/arch/loongarch/kexec-loongarch.c +@@ -265,9 +265,13 @@ unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) + hole = ULONG_MAX; + } + } else { +- hole = locate_hole(info, +- loongarch_mem.text_offset + loongarch_mem.image_size, +- MiB(16), 0, ULONG_MAX, 1); ++ unsigned long hole_min; ++ unsigned long hole_max; ++ ++ hole_min = loongarch_mem.text_offset; ++ hole_max = hole_min + loongarch_mem.image_size; ++ hole = locate_hole(info, loongarch_mem.image_size, ++ MiB(1), hole_min, hole_max, 1); + + if (hole == ULONG_MAX) + dbgprintf("%s: locate_hole failed\n", __func__); +-- +2.41.0 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 80d6b8712c763d4c24fefa839e9a9a579d351682..4520f21ad27c2ff56695025cff7ca6b98569cec7 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.26 -Release: 11 +Release: 12 License: GPLv2 Summary: The kexec/kdump userspace component URL: https://www.kernel.org/ @@ -88,6 +88,7 @@ Patch0007: kexec-tools-fix-riscv-support.patch Patch0008: Add-loongarch-iomem.h.patch Patch0009: Fix-incorrect-page-exclusion-in-exclude_nodata_pages.patch Patch0010: loongarch64-fix-kernel-image-size-error.patch +Patch0012: LoongArch-Load-vmlinux.efi-to-the-link-address.patch %endif Patch0011: Before-adding-to-usablemem_rgns-check-if-the-memory-.patch @@ -298,6 +299,9 @@ done %endif %changelog +* Tue May 20 2025 Ming Wang - 2.0.26-12 +- Backport upstream patch to fix KVM kexec issue. + * Mon Feb 10 2025 chenhaixiang - 2.0.26-11 - Before adding to usablemem_rgns, check if the memory range is already included.