kexec_file: print out debugging message if required

JIRA: https://issues.redhat.com/browse/RHEL-477

Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

Conflict: There's conflict in kernel/crash_core.c because memory/cpu
          hotplug support on crash hasn't been back ported to rhel9. So
          skip that hunk for now.

commit a85ee18c7900f001f42082d2fabce4eaf57e655f
Author: Baoquan He <bhe@redhat.com>
Date:   Wed Dec 13 13:57:42 2023 +0800

    kexec_file: print out debugging message if required

    Then when specifying '-d' for kexec_file_load interface, loaded locations
    of kernel/initrd/cmdline etc can be printed out to help debug.

    Here replace pr_debug() with the newly added kexec_dprintk() in kexec_file
    loading related codes.

    And also print out type/start/head of kimage and flags to help debug.

    Link: https://lkml.kernel.org/r/20231213055747.61826-3-bhe@redhat.com
    Signed-off-by: Baoquan He <bhe@redhat.com>
    Cc: Conor Dooley <conor@kernel.org>
    Cc: Joe Perches <joe@perches.com>
    Cc: Nathan Chancellor <nathan@kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Baoquan He <bhe@redhat.com>
This commit is contained in:
Baoquan He 2024-04-28 21:54:45 +08:00
parent ba5f45be9a
commit f44db8de6a
2 changed files with 10 additions and 5 deletions

View File

@ -204,6 +204,8 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd,
if (ret < 0)
return ret;
image->kernel_buf_len = ret;
kexec_dprintk("kernel: %p kernel_size: %#lx\n",
image->kernel_buf, image->kernel_buf_len);
/* Call arch image probe handlers */
ret = arch_kexec_kernel_image_probe(image, image->kernel_buf,
@ -384,13 +386,14 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd,
if (ret)
goto out;
kexec_dprintk("nr_segments = %lu\n", image->nr_segments);
for (i = 0; i < image->nr_segments; i++) {
struct kexec_segment *ksegment;
ksegment = &image->segment[i];
pr_debug("Loading segment %d: buf=0x%p bufsz=0x%zx mem=0x%lx memsz=0x%zx\n",
i, ksegment->buf, ksegment->bufsz, ksegment->mem,
ksegment->memsz);
kexec_dprintk("segment[%d]: buf=0x%p bufsz=0x%zx mem=0x%lx memsz=0x%zx\n",
i, ksegment->buf, ksegment->bufsz, ksegment->mem,
ksegment->memsz);
ret = kimage_load_segment(image, &image->segment[i]);
if (ret)
@ -403,6 +406,8 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd,
if (ret)
goto out;
kexec_dprintk("kexec_file_load: type:%u, start:0x%lx head:0x%lx flags:0x%lx\n",
image->type, image->start, image->head, flags);
/*
* Free up any temporary buffers allocated which are not needed
* after image has been loaded

View File

@ -129,8 +129,8 @@ void ima_add_kexec_buffer(struct kimage *image)
image->ima_buffer_size = kexec_segment_size;
image->ima_buffer = kexec_buffer;
pr_debug("kexec measurement buffer for the loaded kernel at 0x%lx.\n",
kbuf.mem);
kexec_dprintk("kexec measurement buffer for the loaded kernel at 0x%lx.\n",
kbuf.mem);
}
#endif /* IMA_KEXEC */