Skip to content

Commit 993a110

Browse files
daveyoungsuryasaimadhu
authored andcommitted
x86/kexec: Fix a kexec_file_load() failure
Commit b6664ba ("s390, kexec_file: drop arch_kexec_mem_walk()") changed the behavior of kexec_locate_mem_hole(): it will try to allocate free memory only when kbuf.mem is initialized to zero. However, x86's kexec_file_load() implementation reuses a struct kexec_buf allocated on the stack and its kbuf.mem member gets set by each kexec_add_buffer() invocation. The second kexec_add_buffer() will reuse the same kbuf but not reinitialize kbuf.mem. Therefore, explictily reset kbuf.mem each time in order for kexec_locate_mem_hole() to locate a free memory region each time. [ bp: massage commit message. ] Fixes: b6664ba ("s390, kexec_file: drop arch_kexec_mem_walk()") Signed-off-by: Dave Young <dyoung@redhat.com> Signed-off-by: Borislav Petkov <bp@suse.de> Acked-by: Baoquan He <bhe@redhat.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: AKASHI Takahiro <takahiro.akashi@linaro.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Philipp Rudo <prudo@linux.vnet.ibm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Yannik Sembritzki <yannik@sembritzki.me> Cc: Yi Wang <wang.yi59@zte.com.cn> Cc: kexec@lists.infradead.org Cc: x86-ml <x86@kernel.org> Link: https://lkml.kernel.org/r/20181228011247.GA9999@dhcp-128-65.nay.redhat.com
1 parent bf7d28c commit 993a110

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

arch/x86/kernel/crash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ int crash_load_segments(struct kimage *image)
470470

471471
kbuf.memsz = kbuf.bufsz;
472472
kbuf.buf_align = ELF_CORE_HEADER_ALIGN;
473+
kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
473474
ret = kexec_add_buffer(&kbuf);
474475
if (ret) {
475476
vfree((void *)image->arch.elf_headers);

arch/x86/kernel/kexec-bzimage64.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ static void *bzImage64_load(struct kimage *image, char *kernel,
434434
kbuf.memsz = PAGE_ALIGN(header->init_size);
435435
kbuf.buf_align = header->kernel_alignment;
436436
kbuf.buf_min = MIN_KERNEL_LOAD_ADDR;
437+
kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
437438
ret = kexec_add_buffer(&kbuf);
438439
if (ret)
439440
goto out_free_params;
@@ -448,6 +449,7 @@ static void *bzImage64_load(struct kimage *image, char *kernel,
448449
kbuf.bufsz = kbuf.memsz = initrd_len;
449450
kbuf.buf_align = PAGE_SIZE;
450451
kbuf.buf_min = MIN_INITRD_LOAD_ADDR;
452+
kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
451453
ret = kexec_add_buffer(&kbuf);
452454
if (ret)
453455
goto out_free_params;

0 commit comments

Comments
 (0)