kexec_file: print out debugging message if required
cover kexec_file: print out debugging message if required
Currently, specifying '-d' will print a lot of debugging information about kexec/kdump loading with kexec_load interface.
However, kexec_file_load prints nothing even though '-d' is specified. It's very inconvenient to debug or analyze the kexec/kdump loading when something wrong happened with kexec/kdump itself or develper want to check the kexec/kdump loading.
In this patchset, a kexec_file flag is KEXEC_FILE_DEBUG added and checked in code. If it's passed in, debugging message of kexec_file code will be printed out and can be seen from console and dmesg. Otherwise, the debugging message is printed via pr_debug().
Note:
=====
1) The code in kexec-tools utility also need be changed to support passing KEXEC_FILE_DEBUG to kernel when 'kexec -s -d' is specified. The patch link is here:
=========
[PATCH] kexec_file: add kexec_file flag to support debug printing
http://lists.infradead.org/pipermail/kexec/2023-November/028505.html
2) s390 also has kexec_file code, while I am not sure what debugging information is necessary. So leave it to s390 dev to add if they think it's needed.
Test:
======
I did testing on x86_64 and arm64. On x86_64, the printed messages look
like below:
--------------------------------------------------------------
kexec measurement buffer for the loaded kernel at 0x207fffe000.
Loaded purgatory at 0x207fff9000
Loaded boot_param, command line and misc at 0x207fff3000 bufsz=0x1180 memsz=0x1180
Loaded 64bit kernel at 0x207c000000 bufsz=0xc88200 memsz=0x3c4a000
Loaded initrd at 0x2079e79000 bufsz=0x2186280 memsz=0x2186280
Final command line is: root=/dev/mapper/fedora_intel--knightslanding--lb--02-root ro rd.lvm.lv=fedora_intel-knightslanding-lb-02/root console=ttyS0,115200N81 crashkernel=256M E820 memmap:
0000000000000000-000000000009a3ff (1)
000000000009a400-000000000009ffff (2)
00000000000e0000-00000000000fffff (2)
0000000000100000-000000006ff83fff (1)
000000006ff84000-000000007ac50fff (2)
......
000000207fff6150-000000207fff615f (128)
000000207fff6160-000000207fff714f (1)
000000207fff7150-000000207fff715f (128)
000000207fff7160-000000207fff814f (1)
000000207fff8150-000000207fff815f (128)
000000207fff8160-000000207fffffff (1)nr_segments = 5
segment[0]: buf=0x000000004e5ece74 bufsz=0x211 mem=0x207fffe000 memsz=0x1000
segment[1]: buf=0x000000009e871498 bufsz=0x4000 mem=0x207fff9000 memsz=0x5000
segment[2]: buf=0x00000000d879f1fe bufsz=0x1180 mem=0x207fff3000 memsz=0x2000
segment[3]: buf=0x000000001101cd86 bufsz=0xc88200 mem=0x207c000000 memsz=0x3c4a000
segment[4]: buf=0x00000000c6e38ac7 bufsz=0x2186280 mem=0x2079e79000 memsz=0x2187000kexec_file_load: type:0, start:0x207fff91a0 head:0x109e004002 flags:0x8
---------------------------------------------------------------------------
Baoquan He (7):
kexec_file: add kexec_file flag to control debug printing
kexec_file: print out debugging message if required kexec_file, x86: print out debugging message if required kexec_file, arm64: print out debugging message if required kexec_file, ricv: print out debugging message if required kexec_file, power: print out debugging message if required kexec_file, parisc: print out debugging message if required
arch/arm64/kernel/kexec_image.c | 2 +- arch/arm64/kernel/machine_kexec.c | 24 ++++++------------------ arch/arm64/kernel/machine_kexec_file.c | 6 +++--- arch/parisc/kernel/kexec_file.c | 6 +++--- arch/powerpc/kexec/elf_64.c | 8 ++++---- arch/powerpc/kexec/file_load_64.c | 14 +++++++------- arch/riscv/kernel/elf_kexec.c | 9 +++++---- arch/riscv/kernel/machine_kexec.c | 26 -------------------------- arch/x86/kernel/crash.c | 2 +- arch/x86/kernel/kexec-bzimage64.c | 23 ++++++++++++++--------- include/linux/kexec.h | 14 +++++++++++++- include/uapi/linux/kexec.h | 1 + kernel/crash_core.c | 3 ++- kernel/kexec_file.c | 12 +++++++++++- security/integrity/ima/ima_kexec.c | 2 +- 15 files changed, 72 insertions(+), 80 deletions(-)
Signature · 1 line
2.41.0
PATCH 5/7 kexec_file, ricv: print out debugging message if required
Replace pr_debug() with the newly added kexec_dprintk() in kexec_file loading related codes.
And also remove kexec_image_info() because the content has been printed out in generic code.
--- arch/riscv/kernel/elf_kexec.c | 9 +++++---- arch/riscv/kernel/machine_kexec.c | 26 -------------------------- 2 files changed, 5 insertions(+), 30 deletions(-)
arch/riscv/kernel/elf_kexec.c +5 -4
@@ -216,7 +216,6 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf,if (ret) goto out; kernel_start = image->start; -pr_notice ("The entry point of kernel at 0x%lx\n" , image->start);/* Add the kernel binary to the image */ ret = riscv_kexec_elf_load(image, &ehdr, &elf_info,
@@ -252,7 +251,7 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf, image->elf_load_addr = kbuf.mem; image->elf_headers_sz = headers_sz; -pr_debug ("Loaded elf core header at 0x%lx bufsz=0x%lx memsz=0x%lx\n" , +kexec_dprintk ("Loaded elf core header at 0x%lx bufsz=0x%lx memsz=0x%lx\n" , image->elf_load_addr, kbuf.bufsz, kbuf.memsz);/* Setup cmdline for kdump kernel case */
@@ -275,6 +274,8 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf,pr_err ("Error loading purgatory ret=%d\n" , ret); goto out; } +kexec_dprintk ("Loaded purgatory at 0x%lx\n" , kbuf.mem); + ret =kexec_purgatory_get_set_symbol (image,"riscv_kernel_entry" , &kernel_start,sizeof (kernel_start),0 );
@@ -293,7 +294,7 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf,if (ret) goto out; initrd_pbase = kbuf.mem; -pr_notice ("Loaded initrd at 0x%lx\n" , initrd_pbase); +kexec_dprintk ("Loaded initrd at 0x%lx\n" , initrd_pbase); }/* Add the DTB to the image */
@@ -318,7 +319,7 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf, }/* Cache the fdt buffer address for memory cleanup */ image->arch.fdt = fdt; -pr_notice ("Loaded device tree at 0x%lx\n" , kbuf.mem); +kexec_dprintk ("Loaded device tree at 0x%lx\n" , kbuf.mem); goto out; out_free_fdt:
arch/riscv/kernel/machine_kexec.c +0 -26
@@ -18,30 +18,6 @@#include <linux/interrupt.h> #include <linux/irq.h> -/* -* kexec_image_info - Print received image details -*/ -static void -kexec_image_info (const struct kimage *image) -{ -unsigned long i; - -pr_debug ("Kexec image info:\n" ); -pr_debug ("\ttype: %d\n" , image->type); -pr_debug ("\tstart: %lx\n" , image->start); -pr_debug ("\thead: %lx\n" , image->head); -pr_debug ("\tnr_segments: %lu\n" , image->nr_segments); - -for (i =0 ; i < image->nr_segments; i++) { -pr_debug ("\t segment[%lu]: %016lx - %016lx" , i, - image->segment[i].mem, - image->segment[i].mem + image->segment[i].memsz); -pr_debug ("\t\t0x%lx bytes, %lu pages\n" , - (unsigned long ) image->segment[i].memsz, - (unsigned long ) image->segment[i].memsz /PAGE_SIZE ); - } -} -/* * machine_kexec_prepare - Initialize kexec *
@@ -60,8 +36,6 @@ machine_kexec_prepare(struct kimage *image)unsigned int control_code_buffer_sz =0 ;int i =0 ; -kexec_image_info (image); -/* Find the Flattened Device Tree and save its physical address */ for (i =0 ; i < image->nr_segments; i++) {if (image->segment[i].memsz <=sizeof (fdt))
Signature · 1 line
2.41.0
PATCH 2/7 kexec_file: print out debugging message if required
In reply to Baoquan HeReplace 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.
--- kernel/crash_core.c | 3 ++- kernel/kexec_file.c | 7 ++++++- security/integrity/ima/ima_kexec.c | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-)
kernel/crash_core.c +2 -1
@@ -551,7 +551,8 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, phdr->p_filesz = phdr->p_memsz = mend - mstart +1 ; phdr->p_align =0 ; ehdr->e_phnum++; -pr_debug ("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n" , +kexec_dprintk ("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, " +"sz=0x%llx e_phnum=%d p_offset=0x%llx\n" , phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, ehdr->e_phnum, phdr->p_offset); phdr++;
kernel/kexec_file.c +6 -1
@@ -206,6 +206,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,
@@ -389,11 +391,12 @@ 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" , +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);
@@ -408,6 +411,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
security/integrity/ima/ima_kexec.c +1 -1
@@ -129,7 +129,7 @@ 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" , +kexec_dprintk ("kexec measurement buffer for the loaded kernel at 0x%lx.\n" , kbuf.mem); }#endif /* IMA_KEXEC */
Signature · 1 line
2.41.0
PATCH 1/7 kexec_file: add kexec_file flag to control debug printing
In reply to Baoquan HeWhen specifying 'kexec -c -d', kexec_load interface will print loading information, e.g the regions where kernel/initrd/purgatory/cmdline are put, the memmap passed to 2nd kernel taken as system RAM ranges, and printing all contents of struct kexec_segment, etc. These are very helpful for analyzing or positioning what's happening when kexec/kdump itself failed. The debugging printing for kexec_load interface is made in user space utility kexec-tools.
Whereas, with kexec_file_load interface, 'kexec -s -d' print nothing. Because kexec_file code is mostly implemented in kernel space, and the debugging printing functionality is missed. It's not convenient when debugging kexec/kdump loading and jumping with kexec_file_load interface.
Now add KEXEC_FILE_DEBUG to kexec_file flag to control the debugging message printing. And add global variable kexec_file_dbg_print and macro kexec_dprintk() to facilitate the printing.
This is a preparation, later kexec_dprintk() will be used to replace the existing pr_debug(). Once 'kexec -s -d' is specified, it will print out kexec/kdump loading information. If '-d' is not specified, it regresses to pr_debug().
--- include/linux/kexec.h | 14 +++++++++++++- include/uapi/linux/kexec.h | 1 + kernel/kexec_file.c | 5 +++++ 3 files changed, 19 insertions(+), 1 deletion(-)
include/linux/kexec.h +13 -1
@@ -264,6 +264,18 @@ arch_kexec_apply_relocations(struct purgatory_info *pi, Elf_Shdr *section,return -ENOEXEC ; }#endif + +extern bool kexec_file_dbg_print; + +#define kexec_dprintk(fmt, args...) \ + do { \ + if (kexec_file_dbg_print) \ + printk(KERN_INFO fmt, ##args); \ + else \ + printk(KERN_DEBUG fmt, ##args); \ + } while (0) + +#endif /* CONFIG_KEXEC_FILE */ #ifdef CONFIG_KEXEC_ELF
@@ -403,7 +415,7 @@ bool kexec_load_permitted(int kexec_image_type);/* List of defined/legal kexec file flags */ #define KEXEC_FILE_FLAGS (KEXEC_FILE_UNLOAD | KEXEC_FILE_ON_CRASH | \ - KEXEC_FILE_NO_INITRAMFS) + KEXEC_FILE_NO_INITRAMFS | KEXEC_FILE_DEBUG)/* flag to track if kexec reboot is in progress */ extern bool kexec_in_progress;
include/uapi/linux/kexec.h +1 -0
@@ -25,6 +25,7 @@#define KEXEC_FILE_UNLOAD 0x00000001#define KEXEC_FILE_ON_CRASH 0x00000002#define KEXEC_FILE_NO_INITRAMFS 0x00000004 +#define KEXEC_FILE_DEBUG 0x00000008/* These values match the ELF architecture values. * Unless there is a good reason that should continue to be the case.
kernel/kexec_file.c +5 -0
@@ -38,6 +38,8 @@ void set_kexec_sig_enforced(void) }#endif +bool kexec_file_dbg_print; +static int kexec_calculate_store_digests (struct kimage *image);/* Maximum size in bytes for kernel/initrd files. */
@@ -123,6 +125,8 @@ void kimage_file_post_load_cleanup(struct kimage *image)*/ kfree (image->image_loader_data); image->image_loader_data =NULL ; + + kexec_file_dbg_print = false; }#ifdef CONFIG_KEXEC_SIG
@@ -278,6 +282,7 @@ kimage_file_alloc_init(struct kimage **rimage, int kernel_fd,if (!image)return -ENOMEM ; + kexec_file_dbg_print = !!(flags &KEXEC_FILE_DEBUG ); image->file_mode =1 ;if (kexec_on_panic) {
Signature · 1 line
2.41.0
PATCH 3/7 kexec_file, x86: print out debugging message if required
In reply to Baoquan HeReplace 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.
--- arch/x86/kernel/crash.c | 2 +- arch/x86/kernel/kexec-bzimage64.c | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-)
arch/x86/kernel/crash.c +1 -1
@@ -386,7 +386,7 @@ 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" , +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;
arch/x86/kernel/kexec-bzimage64.c +14 -9
@@ -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); }
Signature · 1 line
2.41.0
PATCH 6/7 kexec_file, power: print out debugging message if required
In reply to Baoquan HeReplace pr_debug() with the newly added kexec_dprintk() in kexec_file loading related codes.
--- arch/powerpc/kexec/elf_64.c | 8 ++++---- arch/powerpc/kexec/file_load_64.c | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-)
arch/powerpc/kexec/elf_64.c +4 -4
@@ -59,7 +59,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,if (ret) goto out; -pr_debug ("Loaded the kernel at 0x%lx\n" , kernel_load_addr); +kexec_dprintk ("Loaded the kernel at 0x%lx\n" , kernel_load_addr); ret =kexec_load_purgatory (image, &pbuf);if (ret) {
@@ -67,7 +67,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, goto out; } -pr_debug ("Loaded purgatory at 0x%lx\n" , pbuf.mem); +kexec_dprintk ("Loaded purgatory at 0x%lx\n" , pbuf.mem);/* Load additional segments needed for panic kernel */ if (image->type ==KEXEC_TYPE_CRASH ) {
@@ -99,7 +99,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, goto out; initrd_load_addr = kbuf.mem; -pr_debug ("Loaded initrd at 0x%lx\n" , initrd_load_addr); +kexec_dprintk ("Loaded initrd at 0x%lx\n" , initrd_load_addr); } fdt = of_kexec_alloc_and_setup_fdt(image, initrd_load_addr,
@@ -132,7 +132,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, fdt_load_addr = kbuf.mem; -pr_debug ("Loaded device tree at 0x%lx\n" , fdt_load_addr); +kexec_dprintk ("Loaded device tree at 0x%lx\n" , fdt_load_addr); slave_code = elf_info.buffer + elf_info.proghdrs[0 ].p_offset; ret = setup_purgatory_ppc64(image, slave_code, fdt, kernel_load_addr,
arch/powerpc/kexec/file_load_64.c +7 -7
@@ -577,7 +577,7 @@ static int add_usable_mem_property(void *fdt, struct device_node *dn, NODE_PATH_LEN, dn);return -EOVERFLOW ; } -pr_debug ("Memory node path: %s\n" , path); +kexec_dprintk ("Memory node path: %s\n" , path);/* Now that we know the path, find its offset in kdump kernel's fdt */ node =fdt_path_offset (fdt, path);
@@ -590,8 +590,8 @@ static int add_usable_mem_property(void *fdt, struct device_node *dn,/* Get the address & size cells */ n_mem_addr_cells =of_n_addr_cells (dn); n_mem_size_cells =of_n_size_cells (dn); -pr_debug ("address cells: %d, size cells: %d\n" , n_mem_addr_cells, - n_mem_size_cells); +kexec_dprintk ("address cells: %d, size cells: %d\n" , n_mem_addr_cells, + n_mem_size_cells); um_info->idx =0 ;if (!check_realloc_usable_mem (um_info,2 )) {
@@ -664,7 +664,7 @@ static int update_usable_mem_fdt(void *fdt, struct crash_mem *usable_mem) node =fdt_path_offset (fdt,"/ibm,dynamic-reconfiguration-memory" );if (node == -FDT_ERR_NOTFOUND ) -pr_debug ("No dynamic reconfiguration memory found\n" ); +kexec_dprintk ("No dynamic reconfiguration memory found\n" );else if (node <0 ) {pr_err ("Malformed device tree: error reading /ibm,dynamic-reconfiguration-memory.\n" );return -EINVAL ;
@@ -776,7 +776,7 @@ static void update_backup_region_phdr(struct kimage *image, Elf64_Ehdr *ehdr)for (i =0 ; i < ehdr->e_phnum; i++) {if (phdr->p_paddr ==BACKUP_SRC_START ) { phdr->p_offset = image->arch.backup_start; -pr_debug ("Backup region offset updated to 0x%lx\n" , +kexec_dprintk ("Backup region offset updated to 0x%lx\n" , image->arch.backup_start);return ; }
@@ -850,7 +850,7 @@ int load_crashdump_segments_ppc64(struct kimage *image,pr_err ("Failed to load backup segment\n" );return ret; } -pr_debug ("Loaded the backup region at 0x%lx\n" , kbuf->mem); +kexec_dprintk ("Loaded the backup region at 0x%lx\n" , kbuf->mem);/* Load elfcorehdr segment - to export crashing kernel's vmcore */ ret =load_elfcorehdr_segment (image, kbuf);
@@ -858,7 +858,7 @@ int load_crashdump_segments_ppc64(struct kimage *image,pr_err ("Failed to load elfcorehdr segment\n" );return ret; } -pr_debug ("Loaded elf core header at 0x%lx, bufsz=0x%lx memsz=0x%lx\n" , +kexec_dprintk ("Loaded elf core header at 0x%lx, bufsz=0x%lx memsz=0x%lx\n" , image->elf_load_addr, kbuf->bufsz, kbuf->memsz);return 0 ;
Signature · 1 line
2.41.0
PATCH 4/7 kexec_file, arm64: print out debugging message if required
In reply to Baoquan HeReplace pr_debug() with the newly added kexec_dprintk() in kexec_file loading related codes.
And also remove the kimage->segment[] printing because the generic code has done the printing.
--- arch/arm64/kernel/kexec_image.c | 2 +- arch/arm64/kernel/machine_kexec.c | 24 ++++++------------------ arch/arm64/kernel/machine_kexec_file.c | 6 +++--- 3 files changed, 10 insertions(+), 22 deletions(-)
arch/arm64/kernel/kexec_image.c +1 -1
@@ -122,7 +122,7 @@ static void *image_load(struct kimage *image, kernel_segment->memsz -= text_offset; image->start = kernel_segment->mem; -pr_debug ("Loaded kernel at 0x%lx bufsz=0x%lx memsz=0x%lx\n" , +kexec_dprintk ("Loaded kernel at 0x%lx bufsz=0x%lx memsz=0x%lx\n" , kernel_segment->mem, kbuf.bufsz, kernel_segment->memsz);
arch/arm64/kernel/machine_kexec.c +6 -18
@@ -34,24 +34,12 @@ static void _kexec_image_info(const char *func, int line, {unsigned long i; -pr_debug ("%s:%d:\n" , func, line); -pr_debug (" kexec kimage info:\n" ); -pr_debug (" type: %d\n" , kimage->type); -pr_debug (" start: %lx\n" , kimage->start); -pr_debug (" head: %lx\n" , kimage->head); -pr_debug (" nr_segments: %lu\n" , kimage->nr_segments); -pr_debug (" dtb_mem: %pa\n" , &kimage->arch.dtb_mem); -pr_debug (" kern_reloc: %pa\n" , &kimage->arch.kern_reloc); -pr_debug (" el2_vectors: %pa\n" , &kimage->arch.el2_vectors); - -for (i =0 ; i < kimage->nr_segments; i++) { -pr_debug (" segment[%lu]: %016lx - %016lx, 0x%lx bytes, %lu pages\n" , - i, - kimage->segment[i].mem, - kimage->segment[i].mem + kimage->segment[i].memsz, - kimage->segment[i].memsz, - kimage->segment[i].memsz /PAGE_SIZE ); - } +kexec_dprintk ("%s:%d:\n" , func, line); +kexec_dprintk (" kexec kimage info:\n" ); +kexec_dprintk (" type: %d\n" , kimage->type); +kexec_dprintk (" head: %lx\n" , kimage->head); +kexec_dprintk (" kern_reloc: %pa\n" , &kimage->arch.kern_reloc); +kexec_dprintk (" el2_vectors: %pa\n" , &kimage->arch.el2_vectors); }void machine_kexec_cleanup (struct kimage *kimage)
arch/arm64/kernel/machine_kexec_file.c +3 -3
@@ -127,7 +127,7 @@ int load_other_segments(struct kimage *image, image->elf_load_addr = kbuf.mem; image->elf_headers_sz = headers_sz; -pr_debug ("Loaded elf core header at 0x%lx bufsz=0x%lx memsz=0x%lx\n" , +kexec_dprintk ("Loaded elf core header at 0x%lx bufsz=0x%lx memsz=0x%lx\n" , image->elf_load_addr, kbuf.bufsz, kbuf.memsz); }
@@ -148,7 +148,7 @@ int load_other_segments(struct kimage *image, goto out_err; initrd_load_addr = kbuf.mem; -pr_debug ("Loaded initrd at 0x%lx bufsz=0x%lx memsz=0x%lx\n" , +kexec_dprintk ("Loaded initrd at 0x%lx bufsz=0x%lx memsz=0x%lx\n" , initrd_load_addr, kbuf.bufsz, kbuf.memsz); }
@@ -179,7 +179,7 @@ int load_other_segments(struct kimage *image, image->arch.dtb = dtb; image->arch.dtb_mem = kbuf.mem; -pr_debug ("Loaded dtb at 0x%lx bufsz=0x%lx memsz=0x%lx\n" , +kexec_dprintk ("Loaded dtb at 0x%lx bufsz=0x%lx memsz=0x%lx\n" , kbuf.mem, kbuf.bufsz, kbuf.memsz);return 0 ;
Signature · 1 line
2.41.0
PATCH 7/7 kexec_file, parisc: print out debugging message if required
In reply to Baoquan HeReplace pr_debug() with the newly added kexec_dprintk() in kexec_file loading related codes.
--- arch/parisc/kernel/kexec_file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/parisc/kernel/kexec_file.c +3 -3
@@ -38,7 +38,7 @@ static void *elf_load(struct kimage *image, char *kernel_buf,for (i =0 ; i < image->nr_segments; i++) image->segment[i].mem =__pa (image->segment[i].mem); -pr_debug ("Loaded the kernel at 0x%lx, entry at 0x%lx\n" , +kexec_dprintk ("Loaded the kernel at 0x%lx, entry at 0x%lx\n" , kernel_load_addr, image->start);if (initrd !=NULL ) {
@@ -51,7 +51,7 @@ static void *elf_load(struct kimage *image, char *kernel_buf,if (ret) goto out; -pr_debug ("Loaded initrd at 0x%lx\n" , kbuf.mem); +kexec_dprintk ("Loaded initrd at 0x%lx\n" , kbuf.mem); image->arch.initrd_start = kbuf.mem; image->arch.initrd_end = kbuf.mem + initrd_len; }
@@ -68,7 +68,7 @@ static void *elf_load(struct kimage *image, char *kernel_buf,if (ret) goto out; -pr_debug ("Loaded cmdline at 0x%lx\n" , kbuf.mem); +kexec_dprintk ("Loaded cmdline at 0x%lx\n" , kbuf.mem); image->arch.cmdline = kbuf.mem; } out:
Signature · 1 line
2.41.0
Re: [PATCH 1/7] kexec_file: add kexec_file flag to control debug printing
In reply to Baoquan HeQuoted 14 lines · Baoquan He
When specifying 'kexec -c -d',
kexec_loadinterface will print loading information, e.g the regions wherekernel/initrd/purgatory/cmdlineare put, the memmap passed to 2nd kernel taken as system RAM ranges, and printing all contents of structkexec_segment, etc. These are very helpful for analyzing or positioning what's happening when kexec/kdump itself failed. The debugging printing forkexec_loadinterface is made in user space utility kexec-tools.Whereas, with
kexec_file_loadinterface, 'kexec -s -d' print nothing. Becausekexec_filecode is mostly implemented in kernel space, and the debugging printing functionality is missed. It's not convenient when debugging kexec/kdump loading and jumping withkexec_file_loadinterface.
Quoted 8 lines
Now add
KEXEC_FILE_DEBUGtokexec_fileflag to control the debugging message printing. And add global variablekexec_file_dbg_printand macrokexec_dprintk()to facilitate the printing.This is a preparation, later
kexec_dprintk()will be used to replace the existingpr_debug(). Once 'kexec -s -d' is specified, it will print out kexec/kdump loading information. If '-d' is not specified, it regresses topr_debug().
Not quite as pr_debug is completely eliminated with zero object size when DEBUG is not #defined.
Now the object size will be larger and contain the formats in .text.
[]
include/linux/kexec.h
Quoted 1 line
include/linux/kexec.h +0
-0
[]
Quoted 6 lines
include/linux/kexec.h +2
-0@@ -264,6 +264,18 @@ arch_kexec_apply_relocations(struct purgatory_info *pi, Elf_Shdr *section, return -ENOEXEC; }#endif + +extern bool kexec_file_dbg_print;
include/linux/kexec.h arch_kexec_apply_relocations(struct purgatory_info *pi, Elf_Shdr *section, · line 278
Quoted 10 lines
include/linux/kexec.h +10
-0+ +#define kexec_dprintk(fmt, args...) \ + do { \ + if (kexec_file_dbg_print) \ + printk(KERN_INFO fmt, ##args); \ + else \ + printk(KERN_DEBUG fmt, ##args); \ + } while (0) + +
I don't know how many of these printks exist and if overall object size matters but using
#define kexec_dprintkfmt, ...) \
printk("%s" fmt, \
kexec_file_dbg_print ? KERN_INFO : KERN_DEBUG, \
##__VA_ARGS__)should reduce overall object size by eliminating the mostly duplicated format in .text which differs only by the KERN_<PREFIX>
Re: [PATCH 1/7] kexec_file: add kexec_file flag to control debug printing
Quoted 24 lines · Joe Perches
Quoted 14 lines · Baoquan He
When specifying 'kexec -c -d',
kexec_loadinterface will print loading information, e.g the regions wherekernel/initrd/purgatory/cmdlineare put, the memmap passed to 2nd kernel taken as system RAM ranges, and printing all contents of structkexec_segment, etc. These are very helpful for analyzing or positioning what's happening when kexec/kdump itself failed. The debugging printing forkexec_loadinterface is made in user space utility kexec-tools.Whereas, with
kexec_file_loadinterface, 'kexec -s -d' print nothing. Becausekexec_filecode is mostly implemented in kernel space, and the debugging printing functionality is missed. It's not convenient when debugging kexec/kdump loading and jumping withkexec_file_loadinterface.Quoted 8 lines
Now add
KEXEC_FILE_DEBUGtokexec_fileflag to control the debugging message printing. And add global variablekexec_file_dbg_printand macrokexec_dprintk()to facilitate the printing.This is a preparation, later
kexec_dprintk()will be used to replace the existingpr_debug(). Once 'kexec -s -d' is specified, it will print out kexec/kdump loading information. If '-d' is not specified, it regresses topr_debug().
Quoted 5 lines
Not quite as
pr_debugis completely eliminated with zero object size when DEBUG is not #defined.Now the object size will be larger and contain the formats in .text.
Ah, I didn't realize that. Thanks for telling. I didn't take pr_info() and pr_debug because I want to avoid printing the pr_fmt() string in each file.
Quoted 15 lines
[]
include/linux/kexec.h
Quoted 1 line
include/linux/kexec.h +0
-0[]
Quoted 11 lines
include/linux/kexec.h +7
-0@@ -264,6 +264,18 @@ arch_kexec_apply_relocations(struct purgatory_info *pi, Elf_Shdr *section,return -ENOEXEC ; }#endif + +extern bool kexec_file_dbg_print; + +#define kexec_dprintk(fmt, args...) \ + do { \ + if (kexec_file_dbg_print) \ + printk(KERN_INFO fmt, ##args); \
Quoted 8 lines
include/linux/kexec.h arch_kexec_apply_relocations(struct purgatory_info *pi, Elf_Shdr *section, · line 278
Quoted 5 lines
include/linux/kexec.h +5
-0+ else \ + printk(KERN_DEBUG fmt, ##args); \ + }while (0 ) + +I don't know how many of these printks exist and if overall object size matters but using
Not too much because they are spread in different arch.
Quoted 9 lines
#define kexec_dprintkfmt, ...) \ printk("%s" fmt, \ kexec_file_dbg_print ? KERN_INFO : KERN_DEBUG, \ ##__VA_ARGS__)should reduce overall object size by eliminating the mostly duplicated format in .text which differs only by the KERN_<PREFIX>
Sure, the new one looks great to me, I will update code to take it. Thanks a lot for your great suggestion.
Thanks
Baoquan
Re: [PATCH v2 1/7] kexec_file: add kexec_file flag to control debug printing
In reply to Baoquan HeWhen specifying 'kexec -c -d', kexec_load interface will print loading information, e.g the regions where kernel/initrd/purgatory/cmdline are put, the memmap passed to 2nd kernel taken as system RAM ranges, and printing all contents of struct kexec_segment, etc. These are very helpful for analyzing or positioning what's happening when kexec/kdump itself failed. The debugging printing for kexec_load interface is made in user space utility kexec-tools.
Whereas, with kexec_file_load interface, 'kexec -s -d' print nothing. Because kexec_file code is mostly implemented in kernel space, and the debugging printing functionality is missed. It's not convenient when debugging kexec/kdump loading and jumping with kexec_file_load interface.
Now add KEXEC_FILE_DEBUG to kexec_file flag to control the debugging message printing. And add global variable kexec_file_dbg_print and macro kexec_dprintk() to facilitate the printing.
This is a preparation, later kexec_dprintk() will be used to replace the existing pr_debug(). Once 'kexec -s -d' is specified, it will print out kexec/kdump loading information at KERN_INFO level. If '-d' is not specified, it regresses to print message at KERN_DEBUG level.
---v1->v2:
- Rewrite the kexec_dprintk() macro as Joe suggested to reduce kernel text size.
include/linux/kexec.h | 10 +++++++++- include/uapi/linux/kexec.h | 1 + kernel/kexec_file.c | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-)
include/linux/kexec.h +9 -1
@@ -264,6 +264,14 @@ arch_kexec_apply_relocations(struct purgatory_info *pi, Elf_Shdr *section,return -ENOEXEC ; }#endif + +extern bool kexec_file_dbg_print; + +#define kexec_dprintk (fmt, ...) \ + printk("%s" fmt, \ + kexec_file_dbg_print ? KERN_INFO : KERN_DEBUG, \ + ##__VA_ARGS__) +#endif /* CONFIG_KEXEC_FILE */ #ifdef CONFIG_KEXEC_ELF
@@ -403,7 +411,7 @@ bool kexec_load_permitted(int kexec_image_type);/* List of defined/legal kexec file flags */ #define KEXEC_FILE_FLAGS (KEXEC_FILE_UNLOAD | KEXEC_FILE_ON_CRASH | \ - KEXEC_FILE_NO_INITRAMFS) + KEXEC_FILE_NO_INITRAMFS | KEXEC_FILE_DEBUG)/* flag to track if kexec reboot is in progress */ extern bool kexec_in_progress;
include/uapi/linux/kexec.h +1 -0
@@ -25,6 +25,7 @@#define KEXEC_FILE_UNLOAD 0x00000001#define KEXEC_FILE_ON_CRASH 0x00000002#define KEXEC_FILE_NO_INITRAMFS 0x00000004 +#define KEXEC_FILE_DEBUG 0x00000008/* These values match the ELF architecture values. * Unless there is a good reason that should continue to be the case.
kernel/kexec_file.c +5 -0
@@ -38,6 +38,8 @@ void set_kexec_sig_enforced(void) }#endif +bool kexec_file_dbg_print; +static int kexec_calculate_store_digests (struct kimage *image);/* Maximum size in bytes for kernel/initrd files. */
@@ -123,6 +125,8 @@ void kimage_file_post_load_cleanup(struct kimage *image)*/ kfree (image->image_loader_data); image->image_loader_data =NULL ; + + kexec_file_dbg_print = false; }#ifdef CONFIG_KEXEC_SIG
@@ -278,6 +282,7 @@ kimage_file_alloc_init(struct kimage **rimage, int kernel_fd,if (!image)return -ENOMEM ; + kexec_file_dbg_print = !!(flags &KEXEC_FILE_DEBUG ); image->file_mode =1 ;if (kexec_on_panic) {
Signature · 1 line
2.41.0
kernel test robot
build botRe: [PATCH 4/7] kexec_file, arm64: print out debugging message if required
In reply to Baoquan Hekernel test robot noticed the following build warnings:
Hi Baoquan,
kernel test robot noticed the following build warnings:
[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on tip/x86/core powerpc/next powerpc/fixes linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/kexec_file-add-kexec_file-flag-to-control-debug-printing/20231114-234003 base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core patch link: https://lore.kernel.org/r/20231114153253.241262-5-bhe%40redhat.com patch subject: [PATCH 4/7] kexec_file, arm64: print out debugging message if required config: arm64-randconfig-001-20231115 (https://download.01.org/0day-ci/archive/20231116/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
arch/arm64/kernel/machine_kexec.c: In function '_kexec_image_info':
>> arch/arm64/kernel/machine_kexec.c:35:23: warning: unused variable 'i' [-Wunused-variable]
35 | unsigned long i;
| ^vim +/i +35 arch/arm64/kernel/machine_kexec.c
d28f6df1305a86 Geoff Levand 2016-06-23 27
221f2c770e10d3 Geoff Levand 2016-06-23 28 /**
221f2c770e10d3 Geoff Levand 2016-06-23 29 * kexec_image_info - For debugging output.
221f2c770e10d3 Geoff Levand 2016-06-23 30 */
221f2c770e10d3 Geoff Levand 2016-06-23 31 #define kexec_image_info(_i) _kexec_image_info(__func__, __LINE__, _i)
221f2c770e10d3 Geoff Levand 2016-06-23 32 static void _kexec_image_info(const char *func, int line,
221f2c770e10d3 Geoff Levand 2016-06-23 33 const struct kimage *kimage)
221f2c770e10d3 Geoff Levand 2016-06-23 34 {
221f2c770e10d3 Geoff Levand 2016-06-23 @35 unsigned long i;
221f2c770e10d3 Geoff Levand 2016-06-23 36
f24d07b8c8e272 Baoquan He 2023-11-14 37 kexec_dprintk("%s:%d:\n", func, line);
f24d07b8c8e272 Baoquan He 2023-11-14 38 kexec_dprintk(" kexec kimage info:\n");
f24d07b8c8e272 Baoquan He 2023-11-14 39 kexec_dprintk(" type: %d\n", kimage->type);
f24d07b8c8e272 Baoquan He 2023-11-14 40 kexec_dprintk(" head: %lx\n", kimage->head);
f24d07b8c8e272 Baoquan He 2023-11-14 41 kexec_dprintk(" kern_reloc: %pa\n", &kimage->arch.kern_reloc);
f24d07b8c8e272 Baoquan He 2023-11-14 42 kexec_dprintk(" el2_vectors: %pa\n", &kimage->arch.el2_vectors);
221f2c770e10d3 Geoff Levand 2016-06-23 43 }
221f2c770e10d3 Geoff Levand 2016-06-23 44 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Baoquan,
kernel test robot noticed the following build errors:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on tip/x86/core powerpc/next powerpc/fixes linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/kexec_file-add-kexec_file-flag-to-control-debug-printing/20231114-234003 base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core patch link: https://lore.kernel.org/r/20231114153253.241262-3-bhe%40redhat.com patch subject: [PATCH 2/7] kexec_file: print out debugging message if required config: hexagon-comet_defconfig (https://download.01.org/0day-ci/archive/20231116/[email protected]/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from kernel/crash_core.c:13:
In file included from include/linux/kexec.h:19:
In file included from arch/hexagon/include/asm/io.h:337:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __raw_readb(PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
In file included from kernel/crash_core.c:13:
In file included from include/linux/kexec.h:19:
In file included from arch/hexagon/include/asm/io.h:337:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
^
In file included from kernel/crash_core.c:13:
In file included from include/linux/kexec.h:19:
In file included from arch/hexagon/include/asm/io.h:337:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writeb(value, PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
>> kernel/crash_core.c:412:3: error: call to undeclared function 'kexec_dprintk'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
kexec_dprintk("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, "
^6 warnings and 1 error generated.
vim +/kexec_dprintk +412 kernel/crash_core.c
323
324 int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map,
325 void **addr, unsigned long *sz)
326 {
327 Elf64_Ehdr *ehdr;
328 Elf64_Phdr *phdr;
329 unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz;
330 unsigned char *buf;
331 unsigned int cpu, i;
332 unsigned long long notes_addr;
333 unsigned long mstart, mend;
334
335 /* extra phdr for vmcoreinfo ELF note */
336 nr_phdr = nr_cpus + 1;
337 nr_phdr += mem->nr_ranges;
338
339 /*
340 * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping
341 * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64).
342 * I think this is required by tools like gdb. So same physical
343 * memory will be mapped in two ELF headers. One will contain kernel
344 * text virtual addresses and other will have __va(physical) addresses.
345 */
346
347 nr_phdr++;
348 elf_sz = sizeof(Elf64_Ehdr) + nr_phdr * sizeof(Elf64_Phdr);
349 elf_sz = ALIGN(elf_sz, ELF_CORE_HEADER_ALIGN);
350
351 buf = vzalloc(elf_sz);
352 if (!buf)
353 return -ENOMEM;
354
355 ehdr = (Elf64_Ehdr *)buf;
356 phdr = (Elf64_Phdr *)(ehdr + 1);
357 memcpy(ehdr->e_ident, ELFMAG, SELFMAG);
358 ehdr->e_ident[EI_CLASS] = ELFCLASS64;
359 ehdr->e_ident[EI_DATA] = ELFDATA2LSB;
360 ehdr->e_ident[EI_VERSION] = EV_CURRENT;
361 ehdr->e_ident[EI_OSABI] = ELF_OSABI;
362 memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD);
363 ehdr->e_type = ET_CORE;
364 ehdr->e_machine = ELF_ARCH;
365 ehdr->e_version = EV_CURRENT;
366 ehdr->e_phoff = sizeof(Elf64_Ehdr);
367 ehdr->e_ehsize = sizeof(Elf64_Ehdr);
368 ehdr->e_phentsize = sizeof(Elf64_Phdr);
369
370 /* Prepare one phdr of type PT_NOTE for each possible CPU */
371 for_each_possible_cpu(cpu) {
372 phdr->p_type = PT_NOTE;
373 notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu));
374 phdr->p_offset = phdr->p_paddr = notes_addr;
375 phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t);
376 (ehdr->e_phnum)++;
377 phdr++;
378 }
379
380 /* Prepare one PT_NOTE header for vmcoreinfo */
381 phdr->p_type = PT_NOTE;
382 phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note();
383 phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE;
384 (ehdr->e_phnum)++;
385 phdr++;
386
387 /* Prepare PT_LOAD type program header for kernel text region */
388 if (need_kernel_map) {
389 phdr->p_type = PT_LOAD;
390 phdr->p_flags = PF_R|PF_W|PF_X;
391 phdr->p_vaddr = (unsigned long) _text;
392 phdr->p_filesz = phdr->p_memsz = _end - _text;
393 phdr->p_offset = phdr->p_paddr = __pa_symbol(_text);
394 ehdr->e_phnum++;
395 phdr++;
396 }
397
398 /* Go through all the ranges in mem->ranges[] and prepare phdr */
399 for (i = 0; i < mem->nr_ranges; i++) {
400 mstart = mem->ranges[i].start;
401 mend = mem->ranges[i].end;
402
403 phdr->p_type = PT_LOAD;
404 phdr->p_flags = PF_R|PF_W|PF_X;
405 phdr->p_offset = mstart;
406
407 phdr->p_paddr = mstart;
408 phdr->p_vaddr = (unsigned long) __va(mstart);
409 phdr->p_filesz = phdr->p_memsz = mend - mstart + 1;
410 phdr->p_align = 0;
411 ehdr->e_phnum++;
> 412 kexec_dprintk("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, " 413 "sz=0x%llx e_phnum=%d p_offset=0x%llx\n",
414 phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz,
415 ehdr->e_phnum, phdr->p_offset);
416 phdr++;
417 }
418
419 *addr = buf;
420 *sz = elf_sz;
421 return 0;
422 }
423
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Baoquan,
kernel test robot noticed the following build errors:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on tip/x86/core powerpc/next powerpc/fixes linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/kexec_file-add-kexec_file-flag-to-control-debug-printing/20231114-234003 base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core patch link: https://lore.kernel.org/r/20231114153253.241262-3-bhe%40redhat.com patch subject: [PATCH 2/7] kexec_file: print out debugging message if required config: x86_64-randconfig-002-20231115 (https://download.01.org/0day-ci/archive/20231116/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
kernel/crash_core.c: In function 'crash_prepare_elf64_headers':
>> kernel/crash_core.c:412:17: error: implicit declaration of function 'kexec_dprintk'; did you mean '_dev_printk'? [-Werror=implicit-function-declaration]
412 | kexec_dprintk("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, "
| ^~~~~~~~~~~~~
| _dev_printkcc1: some warnings being treated as errors
vim +412 kernel/crash_core.c
323
324 int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map,
325 void **addr, unsigned long *sz)
326 {
327 Elf64_Ehdr *ehdr;
328 Elf64_Phdr *phdr;
329 unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz;
330 unsigned char *buf;
331 unsigned int cpu, i;
332 unsigned long long notes_addr;
333 unsigned long mstart, mend;
334
335 /* extra phdr for vmcoreinfo ELF note */
336 nr_phdr = nr_cpus + 1;
337 nr_phdr += mem->nr_ranges;
338
339 /*
340 * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping
341 * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64).
342 * I think this is required by tools like gdb. So same physical
343 * memory will be mapped in two ELF headers. One will contain kernel
344 * text virtual addresses and other will have __va(physical) addresses.
345 */
346
347 nr_phdr++;
348 elf_sz = sizeof(Elf64_Ehdr) + nr_phdr * sizeof(Elf64_Phdr);
349 elf_sz = ALIGN(elf_sz, ELF_CORE_HEADER_ALIGN);
350
351 buf = vzalloc(elf_sz);
352 if (!buf)
353 return -ENOMEM;
354
355 ehdr = (Elf64_Ehdr *)buf;
356 phdr = (Elf64_Phdr *)(ehdr + 1);
357 memcpy(ehdr->e_ident, ELFMAG, SELFMAG);
358 ehdr->e_ident[EI_CLASS] = ELFCLASS64;
359 ehdr->e_ident[EI_DATA] = ELFDATA2LSB;
360 ehdr->e_ident[EI_VERSION] = EV_CURRENT;
361 ehdr->e_ident[EI_OSABI] = ELF_OSABI;
362 memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD);
363 ehdr->e_type = ET_CORE;
364 ehdr->e_machine = ELF_ARCH;
365 ehdr->e_version = EV_CURRENT;
366 ehdr->e_phoff = sizeof(Elf64_Ehdr);
367 ehdr->e_ehsize = sizeof(Elf64_Ehdr);
368 ehdr->e_phentsize = sizeof(Elf64_Phdr);
369
370 /* Prepare one phdr of type PT_NOTE for each possible CPU */
371 for_each_possible_cpu(cpu) {
372 phdr->p_type = PT_NOTE;
373 notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu));
374 phdr->p_offset = phdr->p_paddr = notes_addr;
375 phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t);
376 (ehdr->e_phnum)++;
377 phdr++;
378 }
379
380 /* Prepare one PT_NOTE header for vmcoreinfo */
381 phdr->p_type = PT_NOTE;
382 phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note();
383 phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE;
384 (ehdr->e_phnum)++;
385 phdr++;
386
387 /* Prepare PT_LOAD type program header for kernel text region */
388 if (need_kernel_map) {
389 phdr->p_type = PT_LOAD;
390 phdr->p_flags = PF_R|PF_W|PF_X;
391 phdr->p_vaddr = (unsigned long) _text;
392 phdr->p_filesz = phdr->p_memsz = _end - _text;
393 phdr->p_offset = phdr->p_paddr = __pa_symbol(_text);
394 ehdr->e_phnum++;
395 phdr++;
396 }
397
398 /* Go through all the ranges in mem->ranges[] and prepare phdr */
399 for (i = 0; i < mem->nr_ranges; i++) {
400 mstart = mem->ranges[i].start;
401 mend = mem->ranges[i].end;
402
403 phdr->p_type = PT_LOAD;
404 phdr->p_flags = PF_R|PF_W|PF_X;
405 phdr->p_offset = mstart;
406
407 phdr->p_paddr = mstart;
408 phdr->p_vaddr = (unsigned long) __va(mstart);
409 phdr->p_filesz = phdr->p_memsz = mend - mstart + 1;
410 phdr->p_align = 0;
411 ehdr->e_phnum++;
> 412 kexec_dprintk("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, " 413 "sz=0x%llx e_phnum=%d p_offset=0x%llx\n",
414 phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz,
415 ehdr->e_phnum, phdr->p_offset);
416 phdr++;
417 }
418
419 *addr = buf;
420 *sz = elf_sz;
421 return 0;
422 }
423
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH 4/7] kexec_file, arm64: print out debugging message if required
In reply to kernel test robotQuoted 23 lines · kernel test robot
Hi Baoquan,
kernel test robot noticed the following build warnings:
[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on tip/x86/core powerpc/next powerpc/fixes linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/kexec_file-add-kexec_file-flag-to-control-debug-printing/20231114-234003 base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core patch link: https://lore.kernel.org/r/20231114153253.241262-5-bhe%40redhat.com patch subject: [PATCH 4/7] kexec_file, arm64: print out debugging message if required config: arm64-randconfig-001-20231115 (https://download.01.org/0day-ci/archive/20231116/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Quoted 6 lines
All warnings (new ones prefixed by >>):
arch/arm64/kernel/machine_kexec.c: In function '_kexec_image_info':Quoted 1 line
Quoted 1 line
arch/arm64/kernel/machine_kexec.c:35:23: warning: unused variable 'i' [-Wunused-variable]35 | unsigned long i; | ^
Yes, this is an obvious one missed, will fix and update in new post, thanks.
Quoted 26 lines · kernel test robot
Hi Baoquan,
kernel test robot noticed the following build errors:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on tip/x86/core powerpc/next powerpc/fixes linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/kexec_file-add-kexec_file-flag-to-control-debug-printing/20231114-234003 base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core patch link: https://lore.kernel.org/r/20231114153253.241262-3-bhe%40redhat.com patch subject: [PATCH 2/7] kexec_file: print out debugging message if required config: x86_64-randconfig-002-20231115 (https://download.01.org/0day-ci/archive/20231116/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
kernel/crash_core.c: In function 'crash_prepare_elf64_headers':
Quoted 8 lines
Quoted 1 line
Quoted 1 line
kernel/crash_core.c:412:17: error: implicit declaration of function 'kexec_dprintk'; did you mean '_dev_printk'? [-Werror=implicit-function-declaration]412 | kexec_dprintk("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, " | ^~~~~~~~~~~~~ | _dev_printkcc1: some warnings being treated as errors
vim +412
kernel/crash_core.c
Thanks for reporting this.
Below code can fix it.
crash_prepare_elf64_headers() could be used by kexec_load interface for cpu/memory hotplug updating elfcoreheader, or by kexec_file_load interface for elfcoreheader composing or updating. Only print out the debugging message about ELF core header when kexec_file_load interface is taken.
kernel/crash_core.c +2 -0
@@ -551,10 +551,12 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, phdr->p_filesz = phdr->p_memsz = mend - mstart +1 ; phdr->p_align =0 ; ehdr->e_phnum++; +#ifdef CONFIG_KEXEC_FILE kexec_dprintk ("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, " "sz=0x%llx e_phnum=%d p_offset=0x%llx\n" , phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, ehdr->e_phnum, phdr->p_offset); +#endif phdr++; }
Hi,
Quoted 10 lines · kernel test robot
Hi Baoquan,
kernel test robot noticed the following build errors:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on tip/x86/core powerpc/next powerpc/fixes linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
Quoted 8 lines
url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/kexec_file-add-kexec_file-flag-to-control-debug-printing/20231114-234003 base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core patch link: https://lore.kernel.org/r/20231114153253.241262-3-bhe%40redhat.com patch subject: [PATCH 2/7] kexec_file: print out debugging message if required config: hexagon-comet_defconfig (https://download.01.org/0day-ci/archive/20231116/[email protected]/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/[email protected]/reproduce)
Thanks for reporting.
I met below failure when following the steps of provided reproducer. Could anyone help check what's wrong with that?
[root@~ linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig Compiler will be installed in /root/0day
lftpget -c https://cdn.kernel.org/pub/tools/llvm/files/
get1: /pub/tools/llvm/files/: files/: Is a directory
Failed to download https://cdn.kernel.org/pub/tools/llvm/files/
clang crosstool install failed
Install clang compiler failedsetup_crosstool failed
Thanks
Baoquan
Hi Baoquan,
Quoted 22 lines · Baoquan He
Hi,
Quoted 10 lines · kernel test robot
Hi Baoquan,
kernel test robot noticed the following build errors:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on tip/x86/core powerpc/next powerpc/fixes linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]Quoted 8 lines
url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/kexec_file-add-kexec_file-flag-to-control-debug-printing/20231114-234003
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
patch link: https://lore.kernel.org/r/20231114153253.241262-3-bhe%40redhat.com
patch subject: [PATCH 2/7]kexec_file: print out debugging message if required
config: hexagon-comet_defconfig (https://download.01.org/0day-ci/archive/20231116/[email protected]/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/[email protected]/reproduce)
Quoted 4 lines
Thanks for reporting.
I met below failure when following the steps of provided reproducer. Could anyone help check what's wrong with that?
Sorry this seems to be a bug in the reproducer. Could you please change the compiler parameter to "COMPILER=clang-16" and rerun the command? We will fix the issue ASAP.
Thanks,
Yujie
Quoted 8 lines
[root@~ linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig Compiler will be installed in
/root/0day
lftpget -c https://cdn.kernel.org/pub/tools/llvm/files/
get1: /pub/tools/llvm/files/: files/: Is a directory
Failed to download https://cdn.kernel.org/pub/tools/llvm/files/
clang crosstool install failed
Install clang compiler failedsetup_crosstoolfailed
Quoted 25 lines · Yujie
Hi Baoquan,
Quoted 22 lines · Baoquan He
Hi,
Quoted 18 lines · kernel test robot
Hi Baoquan,
kernel test robot noticed the following build errors:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on tip/x86/core powerpc/next powerpc/fixes linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/kexec_file-add-kexec_file-flag-to-control-debug-printing/20231114-234003
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
patch link: https://lore.kernel.org/r/20231114153253.241262-3-bhe%40redhat.com
patch subject: [PATCH 2/7]kexec_file: print out debugging message if required
config: hexagon-comet_defconfig (https://download.01.org/0day-ci/archive/20231116/[email protected]/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/[email protected]/reproduce)
Quoted 8 lines
Quoted 4 lines
Thanks for reporting.
I met below failure when following the steps of provided reproducer. Could anyone help check what's wrong with that?
Sorry this seems to be a bug in the reproducer. Could you please change the compiler parameter to "COMPILER=clang-16" and rerun the command? We will fix the issue ASAP.
Here you are. Thanks for your quick response.
------------------------------
[root@~ linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang-16 ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig
Compiler will be installed in /root/0day
lftpget -c https://cdn.kernel.org/pub/tools/llvm/files/./llvm-16.0.6-x86_64.tar.xz/root/linux
tar Jxf /root/0day/./llvm-16.0.6-x86_64.tar.xz -C /root/0day PATH=/root/0day/llvm-16.0.6-x86_64/bin:/root/.local/bin:/root/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
make --keep-going LLVM=1 CROSS_COMPILE=hexagon-linux- LLVM_IAS=1 --jobs=128 KCFLAGS=-Warray-bounds -Wundef -fstrict-flex-arrays=3 -funsigned-char -Wenum-conversion W=1 O=build_dir ARCH=hexagon olddefconfig make[1]: Entering directory '/root/linux/build_dir'
GEN Makefile HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o HOSTCC scripts/kconfig/lexer.lex.o HOSTCC scripts/kconfig/menu.o HOSTCC scripts/kconfig/parser.tab.o HOSTCC scripts/kconfig/preprocess.o HOSTCC scripts/kconfig/symbol.o HOSTCC scripts/kconfig/util.o HOSTLD scripts/kconfig/conf # # configuration written to .config # make[1]: Leaving directory '/root/linux/build_dir'
Quoted 11 lines
Quoted 9 lines
[root@~ linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig Compiler will be installed in
/root/0day
lftpget -c https://cdn.kernel.org/pub/tools/llvm/files/
get1: /pub/tools/llvm/files/: files/: Is a directory
Failed to download https://cdn.kernel.org/pub/tools/llvm/files/
clang crosstool install failed
Install clang compiler failedsetup_crosstoolfailed
Quoted 26 lines · Baoquan He
Quoted 25 lines · Yujie
Hi Baoquan,
Quoted 22 lines · Baoquan He
Hi,
Quoted 18 lines · kernel test robot
Hi Baoquan,
kernel test robot noticed the following build errors:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on tip/x86/core powerpc/next powerpc/fixes linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/kexec_file-add-kexec_file-flag-to-control-debug-printing/20231114-234003
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
patch link: https://lore.kernel.org/r/20231114153253.241262-3-bhe%40redhat.com
patch subject: [PATCH 2/7]kexec_file: print out debugging message if required
config: hexagon-comet_defconfig (https://download.01.org/0day-ci/archive/20231116/[email protected]/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/[email protected]/reproduce)
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Thanks for reporting.
I met below failure when following the steps of provided reproducer. Could anyone help check what's wrong with that?
Sorry this seems to be a bug in the reproducer. Could you please change the compiler parameter to "COMPILER=clang-16" and rerun the command? We will fix the issue ASAP.
Any update for the reproducer? I would like to post v2 with the fix. I doubt it's the same issue as another report on this patch, while not quite sure.
Quoted 40 lines
Here you are. Thanks for your quick response.
------------------------------
[root@~ linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang-16 ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig
Compiler will be installed in/root/0day
lftpget -c https://cdn.kernel.org/pub/tools/llvm/files/./llvm-16.0.6-x86_64.tar.xz/root/linux
tar Jxf/root/0day/./llvm-16.0.6-x86_64.tar.xz-C/root/0dayPATH=/root/0day/llvm-16.0.6-x86_64/bin:/root/.local/bin:/root/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
make --keep-going LLVM=1 CROSS_COMPILE=hexagon-linux- LLVM_IAS=1 --jobs=128 KCFLAGS=-Warray-bounds -Wundef -fstrict-flex-arrays=3 -funsigned-char -Wenum-conversion W=1 O=build_dir ARCH=hexagon olddefconfig make[1]: Entering directory '/root/linux/build_dir'GEN Makefile HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o HOSTCC scripts/kconfig/lexer.lex.o HOSTCC scripts/kconfig/menu.o HOSTCC scripts/kconfig/parser.tab.o HOSTCC scripts/kconfig/preprocess.o HOSTCC scripts/kconfig/symbol.o HOSTCC scripts/kconfig/util.o HOSTLD scripts/kconfig/conf # # configuration written to .config # make[1]: Leaving directory '/root/linux/build_dir'Quoted 11 lines
Quoted 9 lines
[root@~ linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig Compiler will be installed in
/root/0day
lftpget -c https://cdn.kernel.org/pub/tools/llvm/files/
get1: /pub/tools/llvm/files/: files/: Is a directory
Failed to download https://cdn.kernel.org/pub/tools/llvm/files/
clang crosstool install failed
Install clang compiler failedsetup_crosstoolfailed
Quoted 32 lines · On Thu, Nov 23, 2023 at 09:49:20PM +0800, [email protected] wrote:
Quoted 31 lines · Baoquan He
Quoted 30 lines · Yujie
Hi Baoquan,
Quoted 26 lines · Baoquan He
Hi,
Quoted 10 lines · kernel test robot
Hi Baoquan,
kernel test robot noticed the following build errors:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on tip/x86/core powerpc/next powerpc/fixes linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]Quoted 8 lines
url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/kexec_file-add-kexec_file-flag-to-control-debug-printing/20231114-234003
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
patch link: https://lore.kernel.org/r/20231114153253.241262-3-bhe%40redhat.com
patch subject: [PATCH 2/7]kexec_file: print out debugging message if required
config: hexagon-comet_defconfig (https://download.01.org/0day-ci/archive/20231116/[email protected]/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/[email protected]/reproduce)Thanks for reporting.
I met below failure when following the steps of provided reproducer. Could anyone help check what's wrong with that?
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Sorry this seems to be a bug in the reproducer. Could you please change the compiler parameter to "COMPILER=clang-16" and rerun the command? We will fix the issue ASAP.
Any update for the reproducer? I would like to post v2 with the fix. I doubt it's the same issue as another report on this patch, while not quite sure.
Shouldn't you be able to run
$ COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang-16 ~/bin/make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash kernel/
after the command you just ran to reproduce this now? It is essentially the same fix that they mention above but for the second invocation of make.cross.
You can also not even bother with the wrapper altogether if you have the compiler installed in the default path that they provide (W=1 is not necessary to reproduce this issue):
$ mkdir -p build_dir $ curl -LSso build_dir/.config https://download.01.org/0day-ci/archive/20231116/[email protected]/config $ make -skj"$(nproc)" ARCH=hexagon LLVM=$HOME/0day/llvm-16.0.6-x86_64/bin/ O=build_dir olddefconfig kernel/crash_core.o ... kernel/crash_core.c:554:3: error: call to undeclared function 'kexec_dprintk'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] kexec_dprintk("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, " ^ 1 error generated.
Quoted 41 lines
Quoted 39 lines
Here you are. Thanks for your quick response.
------------------------------
[root@~ linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang-16 ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig
Compiler will be installed in/root/0day
lftpget -c https://cdn.kernel.org/pub/tools/llvm/files/./llvm-16.0.6-x86_64.tar.xz/root/linux
tar Jxf/root/0day/./llvm-16.0.6-x86_64.tar.xz-C/root/0dayPATH=/root/0day/llvm-16.0.6-x86_64/bin:/root/.local/bin:/root/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
make --keep-going LLVM=1 CROSS_COMPILE=hexagon-linux- LLVM_IAS=1 --jobs=128 KCFLAGS=-Warray-bounds -Wundef -fstrict-flex-arrays=3 -funsigned-char -Wenum-conversion W=1 O=build_dir ARCH=hexagon olddefconfig make[1]: Entering directory '/root/linux/build_dir'GEN Makefile HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o HOSTCC scripts/kconfig/lexer.lex.o HOSTCC scripts/kconfig/menu.o HOSTCC scripts/kconfig/parser.tab.o HOSTCC scripts/kconfig/preprocess.o HOSTCC scripts/kconfig/symbol.o HOSTCC scripts/kconfig/util.o HOSTLD scripts/kconfig/conf # # configuration written to .config # make[1]: Leaving directory '/root/linux/build_dir'Quoted 11 lines
Quoted 9 lines
[root@~ linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig Compiler will be installed in
/root/0day
lftpget -c https://cdn.kernel.org/pub/tools/llvm/files/
get1: /pub/tools/llvm/files/: files/: Is a directory
Failed to download https://cdn.kernel.org/pub/tools/llvm/files/
clang crosstool install failed
Install clang compiler failedsetup_crosstoolfailed
Quoted 32 lines · On Thu, Nov 23, 2023 at 09:49:20PM +0800, [email protected] wrote:
Quoted 31 lines · Baoquan He
Quoted 30 lines · Yujie
Hi Baoquan,
Quoted 26 lines · Baoquan He
Hi,
Quoted 10 lines · kernel test robot
Hi Baoquan,
kernel test robot noticed the following build errors:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on tip/x86/core powerpc/next powerpc/fixes linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]Quoted 8 lines
url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/kexec_file-add-kexec_file-flag-to-control-debug-printing/20231114-234003
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
patch link: https://lore.kernel.org/r/20231114153253.241262-3-bhe%40redhat.com
patch subject: [PATCH 2/7]kexec_file: print out debugging message if required
config: hexagon-comet_defconfig (https://download.01.org/0day-ci/archive/20231116/[email protected]/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/[email protected]/reproduce)Thanks for reporting.
I met below failure when following the steps of provided reproducer. Could anyone help check what's wrong with that?
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Sorry this seems to be a bug in the reproducer. Could you please change the compiler parameter to "COMPILER=clang-16" and rerun the command? We will fix the issue ASAP.
Any update for the reproducer? I would like to post v2 with the fix. I doubt it's the same issue as another report on this patch, while not quite sure.
Setting "COMPILER=clang-16" is exactly the correct fix and should reproduce the issue in this report. We've fixed the steps of reproducer but this will only take effect in future reports.
Thanks,
Yujie
Quoted 41 lines
Quoted 40 lines
Here you are. Thanks for your quick response.
------------------------------
[root@~ linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang-16 ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig
Compiler will be installed in/root/0day
lftpget -c https://cdn.kernel.org/pub/tools/llvm/files/./llvm-16.0.6-x86_64.tar.xz/root/linux
tar Jxf/root/0day/./llvm-16.0.6-x86_64.tar.xz-C/root/0dayPATH=/root/0day/llvm-16.0.6-x86_64/bin:/root/.local/bin:/root/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
make --keep-going LLVM=1 CROSS_COMPILE=hexagon-linux- LLVM_IAS=1 --jobs=128 KCFLAGS=-Warray-bounds -Wundef -fstrict-flex-arrays=3 -funsigned-char -Wenum-conversion W=1 O=build_dir ARCH=hexagon olddefconfig make[1]: Entering directory '/root/linux/build_dir'GEN Makefile HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o HOSTCC scripts/kconfig/lexer.lex.o HOSTCC scripts/kconfig/menu.o HOSTCC scripts/kconfig/parser.tab.o HOSTCC scripts/kconfig/preprocess.o HOSTCC scripts/kconfig/symbol.o HOSTCC scripts/kconfig/util.o HOSTLD scripts/kconfig/conf # # configuration written to .config # make[1]: Leaving directory '/root/linux/build_dir'Quoted 11 lines
Quoted 9 lines
[root@~ linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig Compiler will be installed in
/root/0day
lftpget -c https://cdn.kernel.org/pub/tools/llvm/files/
get1: /pub/tools/llvm/files/: files/: Is a directory
Failed to download https://cdn.kernel.org/pub/tools/llvm/files/
clang crosstool install failed
Install clang compiler failedsetup_crosstoolfailed
Quoted 37 lines · Nathan Chancellor
Quoted 36 lines · On Thu, Nov 23, 2023 at 09:49:20PM +0800, [email protected] wrote:
Quoted 34 lines · Baoquan He
Quoted 33 lines · Yujie
Hi Baoquan,
Quoted 22 lines · Baoquan He
Hi,
Quoted 10 lines · kernel test robot
Hi Baoquan,
kernel test robot noticed the following build errors:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on tip/x86/core powerpc/next powerpc/fixes linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]Quoted 8 lines
url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/kexec_file-add-kexec_file-flag-to-control-debug-printing/20231114-234003
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
patch link: https://lore.kernel.org/r/20231114153253.241262-3-bhe%40redhat.com
patch subject: [PATCH 2/7]kexec_file: print out debugging message if required
config: hexagon-comet_defconfig (https://download.01.org/0day-ci/archive/20231116/[email protected]/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/[email protected]/reproduce)Quoted 4 lines
Thanks for reporting.
I met below failure when following the steps of provided reproducer. Could anyone help check what's wrong with that?
Sorry this seems to be a bug in the reproducer. Could you please change the compiler parameter to "COMPILER=clang-16" and rerun the command? We will fix the issue ASAP.
Quoted 8 lines
Quoted 3 lines
Any update for the reproducer? I would like to post v2 with the fix. I doubt it's the same issue as another report on this patch, while not quite sure.
Shouldn't you be able to run
$ COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang-16 ~/bin/make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash kernel/
Yes, I can reproduce it, it's the same issue as the one reported on arm64. I thought Yujie is using the clang-16 to debug. Thanks for help.
Quoted 59 lines
after the command you just ran to reproduce this now? It is essentially the same fix that they mention above but for the second invocation of make.cross.
You can also not even bother with the wrapper altogether if you have the compiler installed in the default path that they provide (W=1 is not necessary to reproduce this issue):
$ mkdir -p build_dir $ curl -LSso build_dir/.config https://download.01.org/0day-ci/archive/20231116/[email protected]/config $ make -skj"$(nproc)" ARCH=hexagon LLVM=$HOME/0day/llvm-16.0.6-x86_64/bin/ O=build_dir olddefconfig kernel/crash_core.o ... kernel/crash_core.c:554:3: error: call to undeclared function 'kexec_dprintk'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] kexec_dprintk("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, " ^ 1 error generated.Quoted 41 lines
Quoted 39 lines
Here you are. Thanks for your quick response.
------------------------------
[root@~ linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang-16 ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig
Compiler will be installed in/root/0day
lftpget -c https://cdn.kernel.org/pub/tools/llvm/files/./llvm-16.0.6-x86_64.tar.xz/root/linux
tar Jxf/root/0day/./llvm-16.0.6-x86_64.tar.xz-C/root/0dayPATH=/root/0day/llvm-16.0.6-x86_64/bin:/root/.local/bin:/root/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
make --keep-going LLVM=1 CROSS_COMPILE=hexagon-linux- LLVM_IAS=1 --jobs=128 KCFLAGS=-Warray-bounds -Wundef -fstrict-flex-arrays=3 -funsigned-char -Wenum-conversion W=1 O=build_dir ARCH=hexagon olddefconfig make[1]: Entering directory '/root/linux/build_dir'GEN Makefile HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o HOSTCC scripts/kconfig/lexer.lex.o HOSTCC scripts/kconfig/menu.o HOSTCC scripts/kconfig/parser.tab.o HOSTCC scripts/kconfig/preprocess.o HOSTCC scripts/kconfig/symbol.o HOSTCC scripts/kconfig/util.o HOSTLD scripts/kconfig/conf # # configuration written to .config # make[1]: Leaving directory '/root/linux/build_dir'Quoted 11 lines
Quoted 9 lines
[root@~ linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig Compiler will be installed in
/root/0day
lftpget -c https://cdn.kernel.org/pub/tools/llvm/files/
get1: /pub/tools/llvm/files/: files/: Is a directory
Failed to download https://cdn.kernel.org/pub/tools/llvm/files/
clang crosstool install failed
Install clang compiler failedsetup_crosstoolfailed
Quoted 37 lines · Yujie Liu
Quoted 36 lines · On Thu, Nov 23, 2023 at 09:49:20PM +0800, [email protected] wrote:
Quoted 34 lines · Baoquan He
Quoted 33 lines · Yujie
Hi Baoquan,
Quoted 22 lines · Baoquan He
Hi,
Quoted 10 lines · kernel test robot
Hi Baoquan,
kernel test robot noticed the following build errors:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on tip/x86/core powerpc/next powerpc/fixes linus/master v6.7-rc1 next-20231115] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]Quoted 8 lines
url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/kexec_file-add-kexec_file-flag-to-control-debug-printing/20231114-234003
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
patch link: https://lore.kernel.org/r/20231114153253.241262-3-bhe%40redhat.com
patch subject: [PATCH 2/7]kexec_file: print out debugging message if required
config: hexagon-comet_defconfig (https://download.01.org/0day-ci/archive/20231116/[email protected]/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/[email protected]/reproduce)Quoted 4 lines
Thanks for reporting.
I met below failure when following the steps of provided reproducer. Could anyone help check what's wrong with that?
Sorry this seems to be a bug in the reproducer. Could you please change the compiler parameter to "COMPILER=clang-16" and rerun the command? We will fix the issue ASAP.
Quoted 7 lines
Quoted 3 lines
Any update for the reproducer? I would like to post v2 with the fix. I doubt it's the same issue as another report on this patch, while not quite sure.
Setting "COMPILER=clang-16" is exactly the correct fix and should reproduce the issue in this report. We've fixed the steps of reproducer but this will only take effect in future reports.
Thanks, Yujie. I thought you were asking me to use "COMPILER=clang-16" to get information to debug. I have done the testing according to Nathan's suggestion and can confirm it's the same issue as the one on arm64. Will post v2.
Quoted 43 lines
Quoted 42 lines
Quoted 41 lines
Here you are. Thanks for your quick response.
------------------------------
[root@~ linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang-16 ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig
Compiler will be installed in/root/0day
lftpget -c https://cdn.kernel.org/pub/tools/llvm/files/./llvm-16.0.6-x86_64.tar.xz/root/linux
tar Jxf/root/0day/./llvm-16.0.6-x86_64.tar.xz-C/root/0dayPATH=/root/0day/llvm-16.0.6-x86_64/bin:/root/.local/bin:/root/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
make --keep-going LLVM=1 CROSS_COMPILE=hexagon-linux- LLVM_IAS=1 --jobs=128 KCFLAGS=-Warray-bounds -Wundef -fstrict-flex-arrays=3 -funsigned-char -Wenum-conversion W=1 O=build_dir ARCH=hexagon olddefconfig make[1]: Entering directory '/root/linux/build_dir'GEN Makefile HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o HOSTCC scripts/kconfig/lexer.lex.o HOSTCC scripts/kconfig/menu.o HOSTCC scripts/kconfig/parser.tab.o HOSTCC scripts/kconfig/preprocess.o HOSTCC scripts/kconfig/symbol.o HOSTCC scripts/kconfig/util.o HOSTLD scripts/kconfig/conf # # configuration written to .config # make[1]: Leaving directory '/root/linux/build_dir'Quoted 11 lines
Quoted 9 lines
[root@~ linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig Compiler will be installed in
/root/0day
lftpget -c https://cdn.kernel.org/pub/tools/llvm/files/
get1: /pub/tools/llvm/files/: files/: Is a directory
Failed to download https://cdn.kernel.org/pub/tools/llvm/files/
clang crosstool install failed
Install clang compiler failedsetup_crosstoolfailed