[PATCH v8 07/11] powerpc: kexec_file: Use the common segment helpers
Jinjie Ruan
ruanjinjie at huawei.com
Thu Nov 12 05:34:14 PST 2026
load_elfcorehdr_segment() builds the elf core header from the powerpc
crash memory ranges and places it as a segment. The header needs
powerpc specific post processing, so keep building it here, but use
kexec_add_elf_core_header() to place it.
elf64_load() also loads the initrd by hand, use kexec_add_initrd()
for it.
Cc: Michael Ellerman <mpe at ellerman.id.au>
Cc: Nicholas Piggin <npiggin at gmail.com>
Cc: Christophe Leroy <chleroy at kernel.org>
Cc: Andrew Morton <akpm at linux-foundation.org>
Cc: Baoquan He <baoquan.he at linux.dev>
Cc: Mike Rapoport <rppt at kernel.org>
Signed-off-by: Jinjie Ruan <ruanjinjie at huawei.com>
---
arch/powerpc/kexec/elf_64.c | 9 ++-------
arch/powerpc/kexec/file_load_64.c | 14 ++++----------
2 files changed, 6 insertions(+), 17 deletions(-)
diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c
index d9a466cd602e..1ef444494641 100644
--- a/arch/powerpc/kexec/elf_64.c
+++ b/arch/powerpc/kexec/elf_64.c
@@ -96,18 +96,13 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
kexec_dprintk("Command line: %s", cmdline ? cmdline : "");
- if (initrd != NULL) {
- kbuf.buffer = initrd;
- kbuf.bufsz = kbuf.memsz = initrd_len;
+ if (initrd) {
kbuf.buf_align = PAGE_SIZE;
kbuf.top_down = false;
- kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
- ret = kexec_add_buffer(&kbuf);
+ ret = kexec_add_initrd(image, &kbuf);
if (ret)
goto out;
initrd_load_addr = kbuf.mem;
-
- kexec_dprintk("Loaded initrd at 0x%lx\n", initrd_load_addr);
}
ret = get_reserved_memory_ranges(&rmem);
diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
index 0cf03cee35a7..77652db7d1ca 100644
--- a/arch/powerpc/kexec/file_load_64.c
+++ b/arch/powerpc/kexec/file_load_64.c
@@ -416,9 +416,8 @@ static int load_elfcorehdr_segment(struct kimage *image, struct kexec_buf *kbuf)
/* Fix the offset for backup region in the ELF header */
sync_backup_region_phdr(image, headers, false);
- kbuf->buffer = headers;
- kbuf->mem = KEXEC_BUF_MEM_UNKNOWN;
- kbuf->bufsz = headers_sz;
+ image->elf_headers = headers;
+ image->elf_headers_sz = headers_sz;
/*
* Account for extra space required to accommodate additional memory
@@ -427,13 +426,9 @@ static int load_elfcorehdr_segment(struct kimage *image, struct kexec_buf *kbuf)
kbuf->memsz = headers_sz + kdump_extra_elfcorehdr_size(cmem);
kbuf->top_down = false;
- ret = kexec_add_buffer(kbuf);
- if (ret) {
- vfree(headers);
+ ret = kexec_add_elf_core_header(image, kbuf);
+ if (ret)
goto out;
- }
-
- image->elf_load_addr = kbuf->mem;
/*
* If CONFIG_CRASH_HOTPLUG is enabled, the elfcorehdr kexec segment
@@ -442,7 +437,6 @@ static int load_elfcorehdr_segment(struct kimage *image, struct kexec_buf *kbuf)
* memory in the FDT prepared for kdump.
*/
image->elf_headers_sz = kbuf->memsz;
- image->elf_headers = headers;
out:
kfree(cmem);
return ret;
--
2.34.1
More information about the linux-riscv
mailing list