aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Jung Bauermann <bauerman@linux.ibm.com>2019-05-22 18:01:58 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2019-05-23 00:00:32 -0400
commit8b909e3548706cbebc0a676067b81aadda57f47e (patch)
tree9f3ad256ddf708bad80add6f5275d1695c432bbb
parent3202e35ec1c8fc19cea24253ff83edf702a60a02 (diff)
powerpc/kexec: Fix loading of kernel + initramfs with kexec_file_load()
Commit b6664ba42f14 ("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: b6664ba42f14 ("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>
-rw-r--r--arch/powerpc/kernel/kexec_elf_64.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/arch/powerpc/kernel/kexec_elf_64.c b/arch/powerpc/kernel/kexec_elf_64.c
index ba4f18a43ee8..52a29fc73730 100644
--- a/arch/powerpc/kernel/kexec_elf_64.c
+++ b/arch/powerpc/kernel/kexec_elf_64.c
@@ -547,6 +547,7 @@ static int elf_exec_load(struct kimage *image, struct elfhdr *ehdr,
547 kbuf.memsz = phdr->p_memsz; 547 kbuf.memsz = phdr->p_memsz;
548 kbuf.buf_align = phdr->p_align; 548 kbuf.buf_align = phdr->p_align;
549 kbuf.buf_min = phdr->p_paddr + base; 549 kbuf.buf_min = phdr->p_paddr + base;
550 kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
550 ret = kexec_add_buffer(&kbuf); 551 ret = kexec_add_buffer(&kbuf);
551 if (ret) 552 if (ret)
552 goto out; 553 goto out;
@@ -581,7 +582,8 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
581 struct kexec_buf kbuf = { .image = image, .buf_min = 0, 582 struct kexec_buf kbuf = { .image = image, .buf_min = 0,
582 .buf_max = ppc64_rma_size }; 583 .buf_max = ppc64_rma_size };
583 struct kexec_buf pbuf = { .image = image, .buf_min = 0, 584 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 };
585 587
586 ret = build_elf_exec_info(kernel_buf, kernel_len, &ehdr, &elf_info); 588 ret = build_elf_exec_info(kernel_buf, kernel_len, &ehdr, &elf_info);
587 if (ret) 589 if (ret)
@@ -606,6 +608,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
606 kbuf.bufsz = kbuf.memsz = initrd_len; 608 kbuf.bufsz = kbuf.memsz = initrd_len;
607 kbuf.buf_align = PAGE_SIZE; 609 kbuf.buf_align = PAGE_SIZE;
608 kbuf.top_down = false; 610 kbuf.top_down = false;
611 kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
609 ret = kexec_add_buffer(&kbuf); 612 ret = kexec_add_buffer(&kbuf);
610 if (ret) 613 if (ret)
611 goto out; 614 goto out;
@@ -638,6 +641,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
638 kbuf.bufsz = kbuf.memsz = fdt_size; 641 kbuf.bufsz = kbuf.memsz = fdt_size;
639 kbuf.buf_align = PAGE_SIZE; 642 kbuf.buf_align = PAGE_SIZE;
640 kbuf.top_down = true; 643 kbuf.top_down = true;
644 kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
641 ret = kexec_add_buffer(&kbuf); 645 ret = kexec_add_buffer(&kbuf);
642 if (ret) 646 if (ret)
643 goto out; 647 goto out;