]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
kexec_file, x86: print out debugging message if required
authorBaoquan He <bhe@redhat.com>
Wed, 13 Dec 2023 05:57:43 +0000 (13:57 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 20 Dec 2023 23:02:57 +0000 (15:02 -0800)
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 e820 memmap passed to 2nd kernel just as kexec_load
interface has been doing.

Link: https://lkml.kernel.org/r/20231213055747.61826-4-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>
arch/x86/kernel/crash.c
arch/x86/kernel/kexec-bzimage64.c

index c92d88680dbf16ba25826fb7d26b48bcfb72c695..1715e5f06a59772a3915e1bfe8d67bee76cb1b19 100644 (file)
@@ -386,8 +386,8 @@ int crash_load_segments(struct kimage *image)
        if (ret)
                return ret;
        image->elf_load_addr = kbuf.mem;
-       pr_debug("Loaded ELF headers at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
-                image->elf_load_addr, kbuf.bufsz, kbuf.memsz);
+       kexec_dprintk("Loaded ELF headers at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
+                     image->elf_load_addr, kbuf.bufsz, kbuf.memsz);
 
        return ret;
 }
index a61c12c012709799ba0b2e1f11295b0861a96122..e9ae0eac6bf95246ce3d0729f0a3e4733baacbd1 100644 (file)
@@ -82,7 +82,7 @@ static int setup_cmdline(struct kimage *image, struct boot_params *params,
 
        cmdline_ptr[cmdline_len - 1] = '\0';
 
-       pr_debug("Final command line is: %s\n", cmdline_ptr);
+       kexec_dprintk("Final command line is: %s\n", cmdline_ptr);
        cmdline_ptr_phys = bootparams_load_addr + cmdline_offset;
        cmdline_low_32 = cmdline_ptr_phys & 0xffffffffUL;
        cmdline_ext_32 = cmdline_ptr_phys >> 32;
@@ -272,7 +272,12 @@ setup_boot_parameters(struct kimage *image, struct boot_params *params,
 
        nr_e820_entries = params->e820_entries;
 
+       kexec_dprintk("E820 memmap:\n");
        for (i = 0; i < nr_e820_entries; i++) {
+               kexec_dprintk("%016llx-%016llx (%d)\n",
+                             params->e820_table[i].addr,
+                             params->e820_table[i].addr + params->e820_table[i].size - 1,
+                             params->e820_table[i].type);
                if (params->e820_table[i].type != E820_TYPE_RAM)
                        continue;
                start = params->e820_table[i].addr;
@@ -424,7 +429,7 @@ static void *bzImage64_load(struct kimage *image, char *kernel,
         * command line. Make sure it does not overflow
         */
        if (cmdline_len + MAX_ELFCOREHDR_STR_LEN > header->cmdline_size) {
-               pr_debug("Appending elfcorehdr=<addr> to command line exceeds maximum allowed length\n");
+               kexec_dprintk("Appending elfcorehdr=<addr> to command line exceeds maximum allowed length\n");
                return ERR_PTR(-EINVAL);
        }
 
@@ -445,7 +450,7 @@ static void *bzImage64_load(struct kimage *image, char *kernel,
                return ERR_PTR(ret);
        }
 
-       pr_debug("Loaded purgatory at 0x%lx\n", pbuf.mem);
+       kexec_dprintk("Loaded purgatory at 0x%lx\n", pbuf.mem);
 
 
        /*
@@ -490,8 +495,8 @@ static void *bzImage64_load(struct kimage *image, char *kernel,
        if (ret)
                goto out_free_params;
        bootparam_load_addr = kbuf.mem;
-       pr_debug("Loaded boot_param, command line and misc at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
-                bootparam_load_addr, kbuf.bufsz, kbuf.bufsz);
+       kexec_dprintk("Loaded boot_param, command line and misc at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
+                     bootparam_load_addr, kbuf.bufsz, kbuf.bufsz);
 
        /* Load kernel */
        kbuf.buffer = kernel + kern16_size;
@@ -505,8 +510,8 @@ static void *bzImage64_load(struct kimage *image, char *kernel,
                goto out_free_params;
        kernel_load_addr = kbuf.mem;
 
-       pr_debug("Loaded 64bit kernel at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
-                kernel_load_addr, kbuf.bufsz, kbuf.memsz);
+       kexec_dprintk("Loaded 64bit kernel at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
+                     kernel_load_addr, kbuf.bufsz, kbuf.memsz);
 
        /* Load initrd high */
        if (initrd) {
@@ -520,8 +525,8 @@ static void *bzImage64_load(struct kimage *image, char *kernel,
                        goto out_free_params;
                initrd_load_addr = kbuf.mem;
 
-               pr_debug("Loaded initrd at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
-                               initrd_load_addr, initrd_len, initrd_len);
+               kexec_dprintk("Loaded initrd at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
+                             initrd_load_addr, initrd_len, initrd_len);
 
                setup_initrd(params, initrd_load_addr, initrd_len);
        }