Skip to content

Commit 8b909e3

Browse files
bauermannmpe
authored andcommitted
powerpc/kexec: Fix loading of kernel + initramfs with kexec_file_load()
Commit b6664ba ("s390, kexec_file: drop arch_kexec_mem_walk()") changed kexec_add_buffer() to skip searching for a memory location if kexec_buf.mem is already set, and use the address that is there. In powerpc code we reuse a kexec_buf variable for loading both the kernel and the initramfs by resetting some of the fields between those uses, but not mem. This causes kexec_add_buffer() to try to load the kernel at the same address where initramfs will be loaded, which is naturally rejected: # kexec -s -l --initrd initramfs vmlinuz kexec_file_load failed: Invalid argument Setting the mem field before every call to kexec_add_buffer() fixes this regression. Fixes: b6664ba ("s390, kexec_file: drop arch_kexec_mem_walk()") Cc: stable@vger.kernel.org # v5.0+ Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com> Reviewed-by: Dave Young <dyoung@redhat.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 3202e35 commit 8b909e3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

arch/powerpc/kernel/kexec_elf_64.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ static int elf_exec_load(struct kimage *image, struct elfhdr *ehdr,
547547
kbuf.memsz = phdr->p_memsz;
548548
kbuf.buf_align = phdr->p_align;
549549
kbuf.buf_min = phdr->p_paddr + base;
550+
kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
550551
ret = kexec_add_buffer(&kbuf);
551552
if (ret)
552553
goto out;
@@ -581,7 +582,8 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
581582
struct kexec_buf kbuf = { .image = image, .buf_min = 0,
582583
.buf_max = ppc64_rma_size };
583584
struct kexec_buf pbuf = { .image = image, .buf_min = 0,
584-
.buf_max = ppc64_rma_size, .top_down = true };
585+
.buf_max = ppc64_rma_size, .top_down = true,
586+
.mem = KEXEC_BUF_MEM_UNKNOWN };
585587

586588
ret = build_elf_exec_info(kernel_buf, kernel_len, &ehdr, &elf_info);
587589
if (ret)
@@ -606,6 +608,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
606608
kbuf.bufsz = kbuf.memsz = initrd_len;
607609
kbuf.buf_align = PAGE_SIZE;
608610
kbuf.top_down = false;
611+
kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
609612
ret = kexec_add_buffer(&kbuf);
610613
if (ret)
611614
goto out;
@@ -638,6 +641,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
638641
kbuf.bufsz = kbuf.memsz = fdt_size;
639642
kbuf.buf_align = PAGE_SIZE;
640643
kbuf.top_down = true;
644+
kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
641645
ret = kexec_add_buffer(&kbuf);
642646
if (ret)
643647
goto out;

0 commit comments

Comments
 (0)