diff --git a/.gitignore b/.gitignore index b231ca3..0e4d7eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -SOURCES/1.6.8.tar.gz +SOURCES/1.7.0.tar.gz SOURCES/eppic_050615.tar.gz SOURCES/kexec-tools-2.0.20.tar.xz diff --git a/.kexec-tools.metadata b/.kexec-tools.metadata index 553f89d..fd2e018 100644 --- a/.kexec-tools.metadata +++ b/.kexec-tools.metadata @@ -1,3 +1,3 @@ -7af5b92c69df9f63b9f02ad07a76a2a2581d4660 SOURCES/1.6.8.tar.gz +a931a40b80df204be1b02bfb502921cc618810fd SOURCES/1.7.0.tar.gz a096c8e0892b559f40b01916aae240652f75b68a SOURCES/eppic_050615.tar.gz 5d9acd2e741d356d4a48fe4f2d63f66ba431051d SOURCES/kexec-tools-2.0.20.tar.xz diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-1-printk-add-support-for-lockless-ringbuffer.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-1-printk-add-support-for-lockless-ringbuffer.patch deleted file mode 100644 index 629ca8c..0000000 --- a/SOURCES/kexec-tools-2.0.20-makedumpfile-1-printk-add-support-for-lockless-ringbuffer.patch +++ /dev/null @@ -1,587 +0,0 @@ -From c617ec63339222f3a44d73e36677a9acc8954ccd Mon Sep 17 00:00:00 2001 -From: John Ogness -Date: Thu, 19 Nov 2020 02:41:21 +0000 -Subject: [PATCH 1/2] [PATCH 1/2] printk: add support for lockless ringbuffer - -* Required for kernel 5.10 - -Linux 5.10 introduces a new lockless ringbuffer. The new ringbuffer -is structured completely different to the previous iterations. -Add support for retrieving the ringbuffer from debug information -and/or using vmcoreinfo. The new ringbuffer is detected based on -the availability of the "prb" symbol. - -Signed-off-by: John Ogness -Signed-off-by: Kazuhito Hagio ---- - Makefile | 2 +- - dwarf_info.c | 36 ++++++++- - makedumpfile.c | 103 +++++++++++++++++++++++- - makedumpfile.h | 58 ++++++++++++++ - printk.c | 207 +++++++++++++++++++++++++++++++++++++++++++++++++ - 5 files changed, 399 insertions(+), 7 deletions(-) - create mode 100644 printk.c - -diff --git a/makedumpfile-1.6.8/Makefile b/makedumpfile-1.6.8/Makefile -index e5ac71a..cb6bd42 100644 ---- a/makedumpfile-1.6.8/Makefile -+++ b/makedumpfile-1.6.8/Makefile -@@ -45,7 +45,7 @@ CFLAGS_ARCH += -m32 - endif - - SRC_BASE = makedumpfile.c makedumpfile.h diskdump_mod.h sadump_mod.h sadump_info.h --SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c -+SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c printk.c - OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART)) - SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c - OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH)) -diff --git a/makedumpfile-1.6.8/dwarf_info.c b/makedumpfile-1.6.8/dwarf_info.c -index e42a9f5..543588b 100644 ---- a/makedumpfile-1.6.8/dwarf_info.c -+++ b/makedumpfile-1.6.8/dwarf_info.c -@@ -614,6 +614,7 @@ search_structure(Dwarf_Die *die, int *found) - { - int tag; - const char *name; -+ Dwarf_Die die_type; - - /* - * If we get to here then we don't have any more -@@ -622,9 +623,31 @@ search_structure(Dwarf_Die *die, int *found) - do { - tag = dwarf_tag(die); - name = dwarf_diename(die); -- if ((tag != DW_TAG_structure_type) || (!name) -- || strcmp(name, dwarf_info.struct_name)) -+ if ((!name) || strcmp(name, dwarf_info.struct_name)) -+ continue; -+ -+ if (tag == DW_TAG_typedef) { -+ if (!get_die_type(die, &die_type)) { -+ ERRMSG("Can't get CU die of DW_AT_type.\n"); -+ break; -+ } -+ -+ /* Resolve typedefs of typedefs. */ -+ while ((tag = dwarf_tag(&die_type)) == DW_TAG_typedef) { -+ if (!get_die_type(&die_type, &die_type)) { -+ ERRMSG("Can't get CU die of DW_AT_type.\n"); -+ return; -+ } -+ } -+ -+ if (tag != DW_TAG_structure_type) -+ continue; -+ die = &die_type; -+ -+ } else if (tag != DW_TAG_structure_type) { - continue; -+ } -+ - /* - * Skip if DW_AT_byte_size is not included. - */ -@@ -740,6 +763,15 @@ search_typedef(Dwarf_Die *die, int *found) - ERRMSG("Can't get CU die of DW_AT_type.\n"); - break; - } -+ -+ /* Resolve typedefs of typedefs. */ -+ while ((tag = dwarf_tag(&die_type)) == DW_TAG_typedef) { -+ if (!get_die_type(&die_type, &die_type)) { -+ ERRMSG("Can't get CU die of DW_AT_type.\n"); -+ return; -+ } -+ } -+ - dwarf_info.struct_size = dwarf_bytesize(&die_type); - if (dwarf_info.struct_size <= 0) - continue; -diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c -index cdde040..061741f 100644 ---- a/makedumpfile-1.6.8/makedumpfile.c -+++ b/makedumpfile-1.6.8/makedumpfile.c -@@ -1555,6 +1555,7 @@ get_symbol_info(void) - SYMBOL_INIT(node_data, "node_data"); - SYMBOL_INIT(pgdat_list, "pgdat_list"); - SYMBOL_INIT(contig_page_data, "contig_page_data"); -+ SYMBOL_INIT(prb, "prb"); - SYMBOL_INIT(log_buf, "log_buf"); - SYMBOL_INIT(log_buf_len, "log_buf_len"); - SYMBOL_INIT(log_end, "log_end"); -@@ -1971,16 +1972,47 @@ get_structure_info(void) - OFFSET_INIT(elf64_phdr.p_memsz, "elf64_phdr", "p_memsz"); - - SIZE_INIT(printk_log, "printk_log"); -- if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { -+ SIZE_INIT(printk_ringbuffer, "printk_ringbuffer"); -+ if ((SIZE(printk_ringbuffer) != NOT_FOUND_STRUCTURE)) { -+ info->flag_use_printk_ringbuffer = TRUE; -+ info->flag_use_printk_log = FALSE; -+ -+ OFFSET_INIT(printk_ringbuffer.desc_ring, "printk_ringbuffer", "desc_ring"); -+ OFFSET_INIT(printk_ringbuffer.text_data_ring, "printk_ringbuffer", "text_data_ring"); -+ -+ OFFSET_INIT(prb_desc_ring.count_bits, "prb_desc_ring", "count_bits"); -+ OFFSET_INIT(prb_desc_ring.descs, "prb_desc_ring", "descs"); -+ OFFSET_INIT(prb_desc_ring.infos, "prb_desc_ring", "infos"); -+ OFFSET_INIT(prb_desc_ring.head_id, "prb_desc_ring", "head_id"); -+ OFFSET_INIT(prb_desc_ring.tail_id, "prb_desc_ring", "tail_id"); -+ -+ SIZE_INIT(prb_desc, "prb_desc"); -+ OFFSET_INIT(prb_desc.state_var, "prb_desc", "state_var"); -+ OFFSET_INIT(prb_desc.text_blk_lpos, "prb_desc", "text_blk_lpos"); -+ -+ OFFSET_INIT(prb_data_blk_lpos.begin, "prb_data_blk_lpos", "begin"); -+ OFFSET_INIT(prb_data_blk_lpos.next, "prb_data_blk_lpos", "next"); -+ -+ OFFSET_INIT(prb_data_ring.size_bits, "prb_data_ring", "size_bits"); -+ OFFSET_INIT(prb_data_ring.data, "prb_data_ring", "data"); -+ -+ SIZE_INIT(printk_info, "printk_info"); -+ OFFSET_INIT(printk_info.ts_nsec, "printk_info", "ts_nsec"); -+ OFFSET_INIT(printk_info.text_len, "printk_info", "text_len"); -+ -+ OFFSET_INIT(atomic_long_t.counter, "atomic_long_t", "counter"); -+ } else if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { - /* - * In kernel 3.11-rc4 the log structure name was renamed - * to "printk_log". - */ -+ info->flag_use_printk_ringbuffer = FALSE; - info->flag_use_printk_log = TRUE; - OFFSET_INIT(printk_log.ts_nsec, "printk_log", "ts_nsec"); - OFFSET_INIT(printk_log.len, "printk_log", "len"); - OFFSET_INIT(printk_log.text_len, "printk_log", "text_len"); - } else { -+ info->flag_use_printk_ringbuffer = FALSE; - info->flag_use_printk_log = FALSE; - SIZE_INIT(printk_log, "log"); - OFFSET_INIT(printk_log.ts_nsec, "log", "ts_nsec"); -@@ -2191,6 +2223,7 @@ write_vmcoreinfo_data(void) - WRITE_SYMBOL("node_data", node_data); - WRITE_SYMBOL("pgdat_list", pgdat_list); - WRITE_SYMBOL("contig_page_data", contig_page_data); -+ WRITE_SYMBOL("prb", prb); - WRITE_SYMBOL("log_buf", log_buf); - WRITE_SYMBOL("log_buf_len", log_buf_len); - WRITE_SYMBOL("log_end", log_end); -@@ -2222,7 +2255,11 @@ write_vmcoreinfo_data(void) - WRITE_STRUCTURE_SIZE("node_memblk_s", node_memblk_s); - WRITE_STRUCTURE_SIZE("nodemask_t", nodemask_t); - WRITE_STRUCTURE_SIZE("pageflags", pageflags); -- if (info->flag_use_printk_log) -+ if (info->flag_use_printk_ringbuffer) { -+ WRITE_STRUCTURE_SIZE("printk_ringbuffer", printk_ringbuffer); -+ WRITE_STRUCTURE_SIZE("prb_desc", prb_desc); -+ WRITE_STRUCTURE_SIZE("printk_info", printk_info); -+ } else if (info->flag_use_printk_log) - WRITE_STRUCTURE_SIZE("printk_log", printk_log); - else - WRITE_STRUCTURE_SIZE("log", printk_log); -@@ -2268,7 +2305,30 @@ write_vmcoreinfo_data(void) - WRITE_MEMBER_OFFSET("vm_struct.addr", vm_struct.addr); - WRITE_MEMBER_OFFSET("vmap_area.va_start", vmap_area.va_start); - WRITE_MEMBER_OFFSET("vmap_area.list", vmap_area.list); -- if (info->flag_use_printk_log) { -+ if (info->flag_use_printk_ringbuffer) { -+ WRITE_MEMBER_OFFSET("printk_ringbuffer.desc_ring", printk_ringbuffer.desc_ring); -+ WRITE_MEMBER_OFFSET("printk_ringbuffer.text_data_ring", printk_ringbuffer.text_data_ring); -+ -+ WRITE_MEMBER_OFFSET("prb_desc_ring.count_bits", prb_desc_ring.count_bits); -+ WRITE_MEMBER_OFFSET("prb_desc_ring.descs", prb_desc_ring.descs); -+ WRITE_MEMBER_OFFSET("prb_desc_ring.infos", prb_desc_ring.infos); -+ WRITE_MEMBER_OFFSET("prb_desc_ring.head_id", prb_desc_ring.head_id); -+ WRITE_MEMBER_OFFSET("prb_desc_ring.tail_id", prb_desc_ring.tail_id); -+ -+ WRITE_MEMBER_OFFSET("prb_desc.state_var", prb_desc.state_var); -+ WRITE_MEMBER_OFFSET("prb_desc.text_blk_lpos", prb_desc.text_blk_lpos); -+ -+ WRITE_MEMBER_OFFSET("prb_data_blk_lpos.begin", prb_data_blk_lpos.begin); -+ WRITE_MEMBER_OFFSET("prb_data_blk_lpos.next", prb_data_blk_lpos.next); -+ -+ WRITE_MEMBER_OFFSET("prb_data_ring.size_bits", prb_data_ring.size_bits); -+ WRITE_MEMBER_OFFSET("prb_data_ring.data", prb_data_ring.data); -+ -+ WRITE_MEMBER_OFFSET("printk_info.ts_nsec", printk_info.ts_nsec); -+ WRITE_MEMBER_OFFSET("printk_info.text_len", printk_info.text_len); -+ -+ WRITE_MEMBER_OFFSET("atomic_long_t.counter", atomic_long_t.counter); -+ } else if (info->flag_use_printk_log) { - WRITE_MEMBER_OFFSET("printk_log.ts_nsec", printk_log.ts_nsec); - WRITE_MEMBER_OFFSET("printk_log.len", printk_log.len); - WRITE_MEMBER_OFFSET("printk_log.text_len", printk_log.text_len); -@@ -2606,6 +2666,7 @@ read_vmcoreinfo(void) - READ_SYMBOL("node_data", node_data); - READ_SYMBOL("pgdat_list", pgdat_list); - READ_SYMBOL("contig_page_data", contig_page_data); -+ READ_SYMBOL("prb", prb); - READ_SYMBOL("log_buf", log_buf); - READ_SYMBOL("log_buf_len", log_buf_len); - READ_SYMBOL("log_end", log_end); -@@ -2684,12 +2745,43 @@ read_vmcoreinfo(void) - READ_MEMBER_OFFSET("cpu_spec.mmu_features", cpu_spec.mmu_features); - - READ_STRUCTURE_SIZE("printk_log", printk_log); -- if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { -+ READ_STRUCTURE_SIZE("printk_ringbuffer", printk_ringbuffer); -+ if (SIZE(printk_ringbuffer) != NOT_FOUND_STRUCTURE) { -+ info->flag_use_printk_ringbuffer = TRUE; -+ info->flag_use_printk_log = FALSE; -+ -+ READ_MEMBER_OFFSET("printk_ringbuffer.desc_ring", printk_ringbuffer.desc_ring); -+ READ_MEMBER_OFFSET("printk_ringbuffer.text_data_ring", printk_ringbuffer.text_data_ring); -+ -+ READ_MEMBER_OFFSET("prb_desc_ring.count_bits", prb_desc_ring.count_bits); -+ READ_MEMBER_OFFSET("prb_desc_ring.descs", prb_desc_ring.descs); -+ READ_MEMBER_OFFSET("prb_desc_ring.infos", prb_desc_ring.infos); -+ READ_MEMBER_OFFSET("prb_desc_ring.head_id", prb_desc_ring.head_id); -+ READ_MEMBER_OFFSET("prb_desc_ring.tail_id", prb_desc_ring.tail_id); -+ -+ READ_STRUCTURE_SIZE("prb_desc", prb_desc); -+ READ_MEMBER_OFFSET("prb_desc.state_var", prb_desc.state_var); -+ READ_MEMBER_OFFSET("prb_desc.text_blk_lpos", prb_desc.text_blk_lpos); -+ -+ READ_MEMBER_OFFSET("prb_data_blk_lpos.begin", prb_data_blk_lpos.begin); -+ READ_MEMBER_OFFSET("prb_data_blk_lpos.next", prb_data_blk_lpos.next); -+ -+ READ_MEMBER_OFFSET("prb_data_ring.size_bits", prb_data_ring.size_bits); -+ READ_MEMBER_OFFSET("prb_data_ring.data", prb_data_ring.data); -+ -+ READ_STRUCTURE_SIZE("printk_info", printk_info); -+ READ_MEMBER_OFFSET("printk_info.ts_nsec", printk_info.ts_nsec); -+ READ_MEMBER_OFFSET("printk_info.text_len", printk_info.text_len); -+ -+ READ_MEMBER_OFFSET("atomic_long_t.counter", atomic_long_t.counter); -+ } else if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { -+ info->flag_use_printk_ringbuffer = FALSE; - info->flag_use_printk_log = TRUE; - READ_MEMBER_OFFSET("printk_log.ts_nsec", printk_log.ts_nsec); - READ_MEMBER_OFFSET("printk_log.len", printk_log.len); - READ_MEMBER_OFFSET("printk_log.text_len", printk_log.text_len); - } else { -+ info->flag_use_printk_ringbuffer = FALSE; - info->flag_use_printk_log = FALSE; - READ_STRUCTURE_SIZE("log", printk_log); - READ_MEMBER_OFFSET("log.ts_nsec", printk_log.ts_nsec); -@@ -5286,6 +5378,9 @@ dump_dmesg() - if (!initial()) - return FALSE; - -+ if ((SYMBOL(prb) != NOT_FOUND_SYMBOL)) -+ return dump_lockless_dmesg(); -+ - if ((SYMBOL(log_buf) == NOT_FOUND_SYMBOL) - || (SYMBOL(log_buf_len) == NOT_FOUND_SYMBOL)) { - ERRMSG("Can't find some symbols for log_buf.\n"); -diff --git a/makedumpfile-1.6.8/makedumpfile.h b/makedumpfile-1.6.8/makedumpfile.h -index 698c054..47f7e79 100644 ---- a/makedumpfile-1.6.8/makedumpfile.h -+++ b/makedumpfile-1.6.8/makedumpfile.h -@@ -1317,6 +1317,7 @@ struct DumpInfo { - int flag_partial_dmesg; /* dmesg dump only from the last cleared index*/ - int flag_mem_usage; /*show the page number of memory in different use*/ - int flag_use_printk_log; /* did we read printk_log symbol name? */ -+ int flag_use_printk_ringbuffer; /* using lockless printk ringbuffer? */ - int flag_nospace; /* the flag of "No space on device" error */ - int flag_vmemmap; /* kernel supports vmemmap address space */ - int flag_excludevm; /* -e - excluding unused vmemmap pages */ -@@ -1602,6 +1603,7 @@ struct symbol_table { - unsigned long long node_data; - unsigned long long pgdat_list; - unsigned long long contig_page_data; -+ unsigned long long prb; - unsigned long long log_buf; - unsigned long long log_buf_len; - unsigned long long log_end; -@@ -1689,6 +1691,13 @@ struct size_table { - long nodemask_t; - long printk_log; - -+ /* -+ * for lockless printk ringbuffer -+ */ -+ long printk_ringbuffer; -+ long prb_desc; -+ long printk_info; -+ - /* - * for Xen extraction - */ -@@ -1864,6 +1873,52 @@ struct offset_table { - long text_len; - } printk_log; - -+ /* -+ * for lockless printk ringbuffer -+ */ -+ struct printk_ringbuffer_s { -+ long desc_ring; -+ long text_data_ring; -+ long fail; -+ } printk_ringbuffer; -+ -+ struct prb_desc_ring_s { -+ long count_bits; -+ long descs; -+ long infos; -+ long head_id; -+ long tail_id; -+ } prb_desc_ring; -+ -+ struct prb_desc_s { -+ long state_var; -+ long text_blk_lpos; -+ } prb_desc; -+ -+ struct prb_data_blk_lpos_s { -+ long begin; -+ long next; -+ } prb_data_blk_lpos; -+ -+ struct printk_info_s { -+ long seq; -+ long ts_nsec; -+ long text_len; -+ long caller_id; -+ long dev_info; -+ } printk_info; -+ -+ struct prb_data_ring_s { -+ long size_bits; -+ long data; -+ long head_lpos; -+ long tail_lpos; -+ } prb_data_ring; -+ -+ struct atomic_long_t_s { -+ long counter; -+ } atomic_long_t; -+ - /* - * symbols on ppc64 arch - */ -@@ -2390,4 +2445,7 @@ int hexadecimal(char *s, int count); - int decimal(char *s, int count); - int file_exists(char *file); - -+int open_dump_file(void); -+int dump_lockless_dmesg(void); -+ - #endif /* MAKEDUMPFILE_H */ -diff --git a/makedumpfile-1.6.8/printk.c b/makedumpfile-1.6.8/printk.c -new file mode 100644 -index 0000000..acffb6c ---- /dev/null -+++ b/makedumpfile-1.6.8/printk.c -@@ -0,0 +1,207 @@ -+#include "makedumpfile.h" -+#include -+ -+#define DESC_SV_BITS (sizeof(unsigned long) * 8) -+#define DESC_COMMITTED_MASK (1UL << (DESC_SV_BITS - 1)) -+#define DESC_REUSE_MASK (1UL << (DESC_SV_BITS - 2)) -+#define DESC_FLAGS_MASK (DESC_COMMITTED_MASK | DESC_REUSE_MASK) -+#define DESC_ID_MASK (~DESC_FLAGS_MASK) -+ -+/* convenience struct for passing many values to helper functions */ -+struct prb_map { -+ char *prb; -+ -+ char *desc_ring; -+ unsigned long desc_ring_count; -+ char *descs; -+ char *infos; -+ -+ char *text_data_ring; -+ unsigned long text_data_ring_size; -+ char *text_data; -+}; -+ -+static void -+dump_record(struct prb_map *m, unsigned long id) -+{ -+ unsigned long long ts_nsec; -+ unsigned long state_var; -+ unsigned short text_len; -+ unsigned long begin; -+ unsigned long next; -+ char buf[BUFSIZE]; -+ ulonglong nanos; -+ int indent_len; -+ int buf_need; -+ char *bufp; -+ char *text; -+ char *desc; -+ char *inf; -+ ulong rem; -+ char *p; -+ int i; -+ -+ desc = m->descs + ((id % m->desc_ring_count) * SIZE(prb_desc)); -+ -+ /* skip non-committed record */ -+ state_var = ULONG(desc + OFFSET(prb_desc.state_var) + OFFSET(atomic_long_t.counter)); -+ if ((state_var & DESC_FLAGS_MASK) != DESC_COMMITTED_MASK) -+ return; -+ -+ begin = ULONG(desc + OFFSET(prb_desc.text_blk_lpos) + OFFSET(prb_data_blk_lpos.begin)) % -+ m->text_data_ring_size; -+ next = ULONG(desc + OFFSET(prb_desc.text_blk_lpos) + OFFSET(prb_data_blk_lpos.next)) % -+ m->text_data_ring_size; -+ -+ /* skip data-less text blocks */ -+ if (begin == next) -+ return; -+ -+ inf = m->infos + ((id % m->desc_ring_count) * SIZE(printk_info)); -+ -+ text_len = USHORT(inf + OFFSET(printk_info.text_len)); -+ -+ /* handle wrapping data block */ -+ if (begin > next) -+ begin = 0; -+ -+ /* skip over descriptor ID */ -+ begin += sizeof(unsigned long); -+ -+ /* handle truncated messages */ -+ if (next - begin < text_len) -+ text_len = next - begin; -+ -+ text = m->text_data + begin; -+ -+ ts_nsec = ULONGLONG(inf + OFFSET(printk_info.ts_nsec)); -+ nanos = (ulonglong)ts_nsec / (ulonglong)1000000000; -+ rem = (ulonglong)ts_nsec % (ulonglong)1000000000; -+ -+ bufp = buf; -+ bufp += sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000); -+ indent_len = strlen(buf); -+ -+ /* How much buffer space is needed in the worst case */ -+ buf_need = MAX(sizeof("\\xXX\n"), sizeof("\n") + indent_len); -+ -+ for (i = 0, p = text; i < text_len; i++, p++) { -+ if (bufp - buf >= sizeof(buf) - buf_need) { -+ if (write(info->fd_dumpfile, buf, bufp - buf) < 0) -+ return; -+ bufp = buf; -+ } -+ -+ if (*p == '\n') -+ bufp += sprintf(bufp, "\n%-*s", indent_len, ""); -+ else if (isprint(*p) || isspace(*p)) -+ *bufp++ = *p; -+ else -+ bufp += sprintf(bufp, "\\x%02x", *p); -+ } -+ -+ *bufp++ = '\n'; -+ -+ write(info->fd_dumpfile, buf, bufp - buf); -+} -+ -+int -+dump_lockless_dmesg(void) -+{ -+ unsigned long head_id; -+ unsigned long tail_id; -+ unsigned long kaddr; -+ unsigned long id; -+ struct prb_map m; -+ int ret = FALSE; -+ -+ /* setup printk_ringbuffer */ -+ if (!readmem(VADDR, SYMBOL(prb), &kaddr, sizeof(kaddr))) { -+ ERRMSG("Can't get the prb address.\n"); -+ return ret; -+ } -+ -+ m.prb = malloc(SIZE(printk_ringbuffer)); -+ if (!m.prb) { -+ ERRMSG("Can't allocate memory for prb.\n"); -+ return ret; -+ } -+ if (!readmem(VADDR, kaddr, m.prb, SIZE(printk_ringbuffer))) { -+ ERRMSG("Can't get prb.\n"); -+ goto out_prb; -+ } -+ -+ /* setup descriptor ring */ -+ m.desc_ring = m.prb + OFFSET(printk_ringbuffer.desc_ring); -+ m.desc_ring_count = 1 << UINT(m.desc_ring + OFFSET(prb_desc_ring.count_bits)); -+ -+ kaddr = ULONG(m.desc_ring + OFFSET(prb_desc_ring.descs)); -+ m.descs = malloc(SIZE(prb_desc) * m.desc_ring_count); -+ if (!m.descs) { -+ ERRMSG("Can't allocate memory for prb.desc_ring.descs.\n"); -+ goto out_prb; -+ } -+ if (!readmem(VADDR, kaddr, m.descs, -+ SIZE(prb_desc) * m.desc_ring_count)) { -+ ERRMSG("Can't get prb.desc_ring.descs.\n"); -+ goto out_descs; -+ } -+ -+ kaddr = ULONG(m.desc_ring + OFFSET(prb_desc_ring.infos)); -+ m.infos = malloc(SIZE(printk_info) * m.desc_ring_count); -+ if (!m.infos) { -+ ERRMSG("Can't allocate memory for prb.desc_ring.infos.\n"); -+ goto out_descs; -+ } -+ if (!readmem(VADDR, kaddr, m.infos, SIZE(printk_info) * m.desc_ring_count)) { -+ ERRMSG("Can't get prb.desc_ring.infos.\n"); -+ goto out_infos; -+ } -+ -+ /* setup text data ring */ -+ m.text_data_ring = m.prb + OFFSET(printk_ringbuffer.text_data_ring); -+ m.text_data_ring_size = 1 << UINT(m.text_data_ring + OFFSET(prb_data_ring.size_bits)); -+ -+ kaddr = ULONG(m.text_data_ring + OFFSET(prb_data_ring.data)); -+ m.text_data = malloc(m.text_data_ring_size); -+ if (!m.text_data) { -+ ERRMSG("Can't allocate memory for prb.text_data_ring.data.\n"); -+ goto out_infos; -+ } -+ if (!readmem(VADDR, kaddr, m.text_data, m.text_data_ring_size)) { -+ ERRMSG("Can't get prb.text_data_ring.\n"); -+ goto out_text_data; -+ } -+ -+ /* ready to go */ -+ -+ tail_id = ULONG(m.desc_ring + OFFSET(prb_desc_ring.tail_id) + -+ OFFSET(atomic_long_t.counter)); -+ head_id = ULONG(m.desc_ring + OFFSET(prb_desc_ring.head_id) + -+ OFFSET(atomic_long_t.counter)); -+ -+ if (!open_dump_file()) { -+ ERRMSG("Can't open output file.\n"); -+ goto out_text_data; -+ } -+ -+ for (id = tail_id; id != head_id; id = (id + 1) & DESC_ID_MASK) -+ dump_record(&m, id); -+ -+ /* dump head record */ -+ dump_record(&m, id); -+ -+ if (!close_files_for_creating_dumpfile()) -+ goto out_text_data; -+ -+ ret = TRUE; -+out_text_data: -+ free(m.text_data); -+out_infos: -+ free(m.infos); -+out_descs: -+ free(m.descs); -+out_prb: -+ free(m.prb); -+ return ret; -+} --- -2.31.1 - diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-2-printk-use-committed-finalized-state-value.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-2-printk-use-committed-finalized-state-value.patch deleted file mode 100644 index d05bf12..0000000 --- a/SOURCES/kexec-tools-2.0.20-makedumpfile-2-printk-use-committed-finalized-state-value.patch +++ /dev/null @@ -1,99 +0,0 @@ -From 44b073b7ec467aee0d7de381d455b8ace1199184 Mon Sep 17 00:00:00 2001 -From: John Ogness -Date: Wed, 25 Nov 2020 10:10:31 +0106 -Subject: [PATCH 2/2] [PATCH 2/2] printk: use committed/finalized state values - -* Required for kernel 5.10 - -The ringbuffer entries use 2 state values (committed and finalized) -rather than a single flag to represent being available for reading. -Copy the definitions and state lookup function directly from the -kernel source and use the new states. - -Signed-off-by: John Ogness ---- - printk.c | 48 +++++++++++++++++++++++++++++++++++++++++------- - 1 file changed, 41 insertions(+), 7 deletions(-) - -diff --git a/makedumpfile-1.6.8/printk.c b/makedumpfile-1.6.8/printk.c -index acffb6c..2af8562 100644 ---- a/makedumpfile-1.6.8/printk.c -+++ b/makedumpfile-1.6.8/printk.c -@@ -1,12 +1,6 @@ - #include "makedumpfile.h" - #include - --#define DESC_SV_BITS (sizeof(unsigned long) * 8) --#define DESC_COMMITTED_MASK (1UL << (DESC_SV_BITS - 1)) --#define DESC_REUSE_MASK (1UL << (DESC_SV_BITS - 2)) --#define DESC_FLAGS_MASK (DESC_COMMITTED_MASK | DESC_REUSE_MASK) --#define DESC_ID_MASK (~DESC_FLAGS_MASK) -- - /* convenience struct for passing many values to helper functions */ - struct prb_map { - char *prb; -@@ -21,12 +15,51 @@ struct prb_map { - char *text_data; - }; - -+/* -+ * desc_state and DESC_* definitions taken from kernel source: -+ * -+ * kernel/printk/printk_ringbuffer.h -+ */ -+ -+/* The possible responses of a descriptor state-query. */ -+enum desc_state { -+ desc_miss = -1, /* ID mismatch (pseudo state) */ -+ desc_reserved = 0x0, /* reserved, in use by writer */ -+ desc_committed = 0x1, /* committed by writer, could get reopened */ -+ desc_finalized = 0x2, /* committed, no further modification allowed */ -+ desc_reusable = 0x3, /* free, not yet used by any writer */ -+}; -+ -+#define DESC_SV_BITS (sizeof(unsigned long) * 8) -+#define DESC_FLAGS_SHIFT (DESC_SV_BITS - 2) -+#define DESC_FLAGS_MASK (3UL << DESC_FLAGS_SHIFT) -+#define DESC_STATE(sv) (3UL & (sv >> DESC_FLAGS_SHIFT)) -+#define DESC_ID_MASK (~DESC_FLAGS_MASK) -+#define DESC_ID(sv) ((sv) & DESC_ID_MASK) -+ -+/* -+ * get_desc_state() taken from kernel source: -+ * -+ * kernel/printk/printk_ringbuffer.c -+ */ -+ -+/* Query the state of a descriptor. */ -+static enum desc_state get_desc_state(unsigned long id, -+ unsigned long state_val) -+{ -+ if (id != DESC_ID(state_val)) -+ return desc_miss; -+ -+ return DESC_STATE(state_val); -+} -+ - static void - dump_record(struct prb_map *m, unsigned long id) - { - unsigned long long ts_nsec; - unsigned long state_var; - unsigned short text_len; -+ enum desc_state state; - unsigned long begin; - unsigned long next; - char buf[BUFSIZE]; -@@ -45,7 +78,8 @@ dump_record(struct prb_map *m, unsigned long id) - - /* skip non-committed record */ - state_var = ULONG(desc + OFFSET(prb_desc.state_var) + OFFSET(atomic_long_t.counter)); -- if ((state_var & DESC_FLAGS_MASK) != DESC_COMMITTED_MASK) -+ state = get_desc_state(id, state_var); -+ if (state != desc_committed && state != desc_finalized) - return; - - begin = ULONG(desc + OFFSET(prb_desc.text_blk_lpos) + OFFSET(prb_data_blk_lpos.begin)) % --- -2.31.1 - diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-Add-dry-run-option-to-prevent-writing.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-Add-dry-run-option-to-prevent-writing.patch deleted file mode 100644 index 631d039..0000000 --- a/SOURCES/kexec-tools-2.0.20-makedumpfile-Add-dry-run-option-to-prevent-writing.patch +++ /dev/null @@ -1,177 +0,0 @@ -From 3422e1d6bc3511c5af9cb05ba74ad97dd93ffd7f Mon Sep 17 00:00:00 2001 -From: Julien Thierry -Date: Tue, 24 Nov 2020 10:45:24 +0000 -Subject: [PATCH] [PATCH 1/2] Add --dry-run option to prevent writing the - dumpfile - -Add a --dry-run option to run all operations without writing the -dump to the output file. - -Signed-off-by: Julien Thierry -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.8 | 6 ++++++ - makedumpfile.c | 37 ++++++++++++++++++++++++++++++------- - makedumpfile.h | 2 ++ - print_info.c | 3 +++ - 4 files changed, 41 insertions(+), 7 deletions(-) - -diff --git a/makedumpfile-1.6.8/makedumpfile.8 b/makedumpfile-1.6.8/makedumpfile.8 -index b68a7e3..5e902cd 100644 ---- a/makedumpfile-1.6.8/makedumpfile.8 -+++ b/makedumpfile-1.6.8/makedumpfile.8 -@@ -637,6 +637,12 @@ Show the version of makedumpfile. - Only check whether the command-line parameters are valid or not, and exit. - Preferable to be given as the first parameter. - -+.TP -+\fB\-\-dry-run\fR -+Do not write the output dump file while still performing operations specified -+by other options. -+This option cannot be used with the --dump-dmesg, --reassemble and -g options. -+ - .SH ENVIRONMENT VARIABLES - - .TP 8 -diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c -index ecd63fa..8c80c49 100644 ---- a/makedumpfile-1.6.8/makedumpfile.c -+++ b/makedumpfile-1.6.8/makedumpfile.c -@@ -1372,6 +1372,8 @@ open_dump_file(void) - if (info->flag_flatten) { - fd = STDOUT_FILENO; - info->name_dumpfile = filename_stdout; -+ } else if (info->flag_dry_run) { -+ fd = -1; - } else if ((fd = open(info->name_dumpfile, open_flags, - S_IRUSR|S_IWUSR)) < 0) { - ERRMSG("Can't open the dump file(%s). %s\n", -@@ -4711,6 +4713,9 @@ write_and_check_space(int fd, void *buf, size_t buf_size, char *file_name) - { - int status, written_size = 0; - -+ if (info->flag_dry_run) -+ return TRUE; -+ - while (written_size < buf_size) { - status = write(fd, buf + written_size, - buf_size - written_size); -@@ -4748,13 +4753,12 @@ write_buffer(int fd, off_t offset, void *buf, size_t buf_size, char *file_name) - } - if (!write_and_check_space(fd, &fdh, sizeof(fdh), file_name)) - return FALSE; -- } else { -- if (lseek(fd, offset, SEEK_SET) == failed) { -- ERRMSG("Can't seek the dump file(%s). %s\n", -- file_name, strerror(errno)); -- return FALSE; -- } -+ } else if (!info->flag_dry_run && -+ lseek(fd, offset, SEEK_SET) == failed) { -+ ERRMSG("Can't seek the dump file(%s). %s\n", file_name, strerror(errno)); -+ return FALSE; - } -+ - if (!write_and_check_space(fd, buf, buf_size, file_name)) - return FALSE; - -@@ -9112,7 +9116,7 @@ close_dump_memory(void) - void - close_dump_file(void) - { -- if (info->flag_flatten) -+ if (info->flag_flatten || info->flag_dry_run) - return; - - if (close(info->fd_dumpfile) < 0) -@@ -10985,6 +10989,11 @@ check_param_for_generating_vmcoreinfo(int argc, char *argv[]) - - return FALSE; - -+ if (info->flag_dry_run) { -+ MSG("--dry-run cannot be used with -g.\n"); -+ return FALSE; -+ } -+ - return TRUE; - } - -@@ -11029,6 +11038,11 @@ check_param_for_reassembling_dumpfile(int argc, char *argv[]) - || info->flag_exclude_xen_dom || info->flag_split) - return FALSE; - -+ if (info->flag_dry_run) { -+ MSG("--dry-run cannot be used with --reassemble.\n"); -+ return FALSE; -+ } -+ - if ((info->splitting_info - = malloc(sizeof(struct splitting_info) * info->num_dumpfile)) - == NULL) { -@@ -11057,6 +11071,11 @@ check_param_for_creating_dumpfile(int argc, char *argv[]) - || (info->flag_read_vmcoreinfo && info->name_xen_syms)) - return FALSE; - -+ if (info->flag_dry_run && info->flag_dmesg) { -+ MSG("--dry-run cannot be used with --dump-dmesg.\n"); -+ return FALSE; -+ } -+ - if (info->flag_flatten && info->flag_split) - return FALSE; - -@@ -11520,6 +11539,7 @@ static struct option longopts[] = { - {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, - {"num-threads", required_argument, NULL, OPT_NUM_THREADS}, - {"check-params", no_argument, NULL, OPT_CHECK_PARAMS}, -+ {"dry-run", no_argument, NULL, OPT_DRY_RUN}, - {0, 0, 0, 0} - }; - -@@ -11686,6 +11706,9 @@ main(int argc, char *argv[]) - info->flag_check_params = TRUE; - message_level = DEFAULT_MSG_LEVEL; - break; -+ case OPT_DRY_RUN: -+ info->flag_dry_run = TRUE; -+ break; - case '?': - MSG("Commandline parameter is invalid.\n"); - MSG("Try `makedumpfile --help' for more information.\n"); -diff --git a/makedumpfile-1.6.8/makedumpfile.h b/makedumpfile-1.6.8/makedumpfile.h -index 5f50080..4c4222c 100644 ---- a/makedumpfile-1.6.8/makedumpfile.h -+++ b/makedumpfile-1.6.8/makedumpfile.h -@@ -1322,6 +1322,7 @@ struct DumpInfo { - int flag_vmemmap; /* kernel supports vmemmap address space */ - int flag_excludevm; /* -e - excluding unused vmemmap pages */ - int flag_use_count; /* _refcount is named _count in struct page */ -+ int flag_dry_run; /* do not create a vmcore file */ - unsigned long vaddr_for_vtop; /* virtual address for debugging */ - long page_size; /* size of page */ - long page_shift; -@@ -2425,6 +2426,7 @@ struct elf_prstatus { - #define OPT_NUM_THREADS OPT_START+16 - #define OPT_PARTIAL_DMESG OPT_START+17 - #define OPT_CHECK_PARAMS OPT_START+18 -+#define OPT_DRY_RUN OPT_START+19 - - /* - * Function Prototype. -diff --git a/makedumpfile-1.6.8/print_info.c b/makedumpfile-1.6.8/print_info.c -index e0c38b4..d2b0cb7 100644 ---- a/makedumpfile-1.6.8/print_info.c -+++ b/makedumpfile-1.6.8/print_info.c -@@ -308,6 +308,9 @@ print_usage(void) - MSG(" the crashkernel range, then calculates the page number of different kind per\n"); - MSG(" vmcoreinfo. So currently /proc/kcore need be specified explicitly.\n"); - MSG("\n"); -+ MSG(" [--dry-run]:\n"); -+ MSG(" This option runs makedumpfile without writting output dump file.\n"); -+ MSG("\n"); - MSG(" [-D]:\n"); - MSG(" Print debugging message.\n"); - MSG("\n"); --- -2.29.2 - diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-Add-shorthand-show-stats-option-to-show.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-Add-shorthand-show-stats-option-to-show.patch deleted file mode 100644 index 5e935f0..0000000 --- a/SOURCES/kexec-tools-2.0.20-makedumpfile-Add-shorthand-show-stats-option-to-show.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 6f3e75a558ed50d6ff0b42e3f61c099b2005b7bb Mon Sep 17 00:00:00 2001 -From: Julien Thierry -Date: Tue, 24 Nov 2020 10:45:25 +0000 -Subject: [PATCH] [PATCH 2/2] Add shorthand --show-stats option to show report - stats - -Provide shorthand --show-stats option to enable report messages -without needing to set a particular value for message-level. - -Signed-off-by: Julien Thierry -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.8 | 5 +++++ - makedumpfile.c | 9 ++++++++- - makedumpfile.h | 1 + - print_info.c | 7 ++++++- - 4 files changed, 20 insertions(+), 2 deletions(-) - -diff --git a/makedumpfile-1.6.8/makedumpfile.8 b/makedumpfile-1.6.8/makedumpfile.8 -index 5e902cd..dcca2dd 100644 ---- a/makedumpfile-1.6.8/makedumpfile.8 -+++ b/makedumpfile-1.6.8/makedumpfile.8 -@@ -643,6 +643,11 @@ Do not write the output dump file while still performing operations specified - by other options. - This option cannot be used with the --dump-dmesg, --reassemble and -g options. - -+.TP -+\fB\-\-show-stats\fR -+Display report messages. This is an alternative to enabling bit 4 in the level -+provided to --message-level. -+ - .SH ENVIRONMENT VARIABLES - - .TP 8 -diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c -index 8c80c49..ba0003a 100644 ---- a/makedumpfile-1.6.8/makedumpfile.c -+++ b/makedumpfile-1.6.8/makedumpfile.c -@@ -11540,13 +11540,14 @@ static struct option longopts[] = { - {"num-threads", required_argument, NULL, OPT_NUM_THREADS}, - {"check-params", no_argument, NULL, OPT_CHECK_PARAMS}, - {"dry-run", no_argument, NULL, OPT_DRY_RUN}, -+ {"show-stats", no_argument, NULL, OPT_SHOW_STATS}, - {0, 0, 0, 0} - }; - - int - main(int argc, char *argv[]) - { -- int i, opt, flag_debug = FALSE; -+ int i, opt, flag_debug = FALSE, flag_show_stats = FALSE; - - if ((info = calloc(1, sizeof(struct DumpInfo))) == NULL) { - ERRMSG("Can't allocate memory for the pagedesc cache. %s.\n", -@@ -11709,6 +11710,9 @@ main(int argc, char *argv[]) - case OPT_DRY_RUN: - info->flag_dry_run = TRUE; - break; -+ case OPT_SHOW_STATS: -+ flag_show_stats = TRUE; -+ break; - case '?': - MSG("Commandline parameter is invalid.\n"); - MSG("Try `makedumpfile --help' for more information.\n"); -@@ -11718,6 +11722,9 @@ main(int argc, char *argv[]) - if (flag_debug) - message_level |= ML_PRINT_DEBUG_MSG; - -+ if (flag_show_stats) -+ message_level |= ML_PRINT_REPORT_MSG; -+ - if (info->flag_check_params) - /* suppress debugging messages */ - message_level = DEFAULT_MSG_LEVEL; -diff --git a/makedumpfile-1.6.8/makedumpfile.h b/makedumpfile-1.6.8/makedumpfile.h -index 4c4222c..2fcb62e 100644 ---- a/makedumpfile-1.6.8/makedumpfile.h -+++ b/makedumpfile-1.6.8/makedumpfile.h -@@ -2427,6 +2427,7 @@ struct elf_prstatus { - #define OPT_PARTIAL_DMESG OPT_START+17 - #define OPT_CHECK_PARAMS OPT_START+18 - #define OPT_DRY_RUN OPT_START+19 -+#define OPT_SHOW_STATS OPT_START+20 - - /* - * Function Prototype. -diff --git a/makedumpfile-1.6.8/print_info.c b/makedumpfile-1.6.8/print_info.c -index d2b0cb7..ad4184e 100644 ---- a/makedumpfile-1.6.8/print_info.c -+++ b/makedumpfile-1.6.8/print_info.c -@@ -309,7 +309,12 @@ print_usage(void) - MSG(" vmcoreinfo. So currently /proc/kcore need be specified explicitly.\n"); - MSG("\n"); - MSG(" [--dry-run]:\n"); -- MSG(" This option runs makedumpfile without writting output dump file.\n"); -+ MSG(" Do not write the output dump file while still performing operations specified\n"); -+ MSG(" by other options. This option cannot be used with --dump-dmesg, --reassemble\n"); -+ MSG(" and -g options.\n"); -+ MSG("\n"); -+ MSG(" [--show-stats]:\n"); -+ MSG(" Set message-level to print report messages\n"); - MSG("\n"); - MSG(" [-D]:\n"); - MSG(" Print debugging message.\n"); --- -2.29.2 - diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-Show-write-byte-size-in-report-messages.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-Show-write-byte-size-in-report-messages.patch deleted file mode 100644 index 337288e..0000000 --- a/SOURCES/kexec-tools-2.0.20-makedumpfile-Show-write-byte-size-in-report-messages.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 0ef2ca6c9fa2f61f217a4bf5d7fd70f24e12b2eb Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Thu, 4 Feb 2021 16:29:06 +0900 -Subject: [PATCH] [PATCH] Show write byte size in report messages - -Show write byte size in report messages. This value can be different -from the size of the actual file because of some holes on dumpfile -data structure. - - $ makedumpfile --show-stats -l -d 1 vmcore dump.ld1 - ... - Total pages : 0x0000000000080000 - Write bytes : 377686445 - ... - # ls -l dump.ld1 - -rw------- 1 root root 377691573 Feb 4 16:28 dump.ld1 - -Note that this value should not be used with /proc/kcore to determine -how much disk space is needed for crash dump, because the real memory -usage when a crash occurs can vary widely. - -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c -index fcd766b..894c88e 100644 ---- a/makedumpfile-1.6.8/makedumpfile.c -+++ b/makedumpfile-1.6.8/makedumpfile.c -@@ -48,6 +48,8 @@ char filename_stdout[] = FILENAME_STDOUT; - static unsigned long long cache_hit; - static unsigned long long cache_miss; - -+static unsigned long long write_bytes; -+ - static void first_cycle(mdf_pfn_t start, mdf_pfn_t max, struct cycle *cycle) - { - cycle->start_pfn = round(start, info->pfn_cyclic); -@@ -4715,6 +4717,8 @@ write_and_check_space(int fd, void *buf, size_t buf_size, char *file_name) - { - int status, written_size = 0; - -+ write_bytes += buf_size; -+ - if (info->flag_dry_run) - return TRUE; - -@@ -10002,6 +10006,7 @@ print_report(void) - REPORT_MSG("Memory Hole : 0x%016llx\n", pfn_memhole); - REPORT_MSG("--------------------------------------------------\n"); - REPORT_MSG("Total pages : 0x%016llx\n", info->max_mapnr); -+ REPORT_MSG("Write bytes : %llu\n", write_bytes); - REPORT_MSG("\n"); - REPORT_MSG("Cache hit: %lld, miss: %lld", cache_hit, cache_miss); - if (cache_hit + cache_miss) --- -2.29.2 - diff --git a/SOURCES/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch b/SOURCES/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch deleted file mode 100644 index c6eb40f..0000000 --- a/SOURCES/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 38d921a2ef50ebd36258097553626443ffe27496 Mon Sep 17 00:00:00 2001 -From: Coiby Xu -Date: Tue, 15 Jun 2021 18:26:31 +0800 -Subject: [PATCH] check for invalid physical address of /proc/kcore - when finding max_paddr - -Kernel commit 464920104bf7adac12722035bfefb3d772eb04d8 ("/proc/kcore: -update physical address for kcore ram and text") sets an invalid paddr -(0xffffffffffffffff = -1) for PT_LOAD segments of not direct mapped -regions: - - $ readelf -l /proc/kcore - ... - Program Headers: - Type Offset VirtAddr PhysAddr - FileSiz MemSiz Flags Align - NOTE 0x0000000000000120 0x0000000000000000 0x0000000000000000 - 0x0000000000002320 0x0000000000000000 0x0 - LOAD 0x1000000000010000 0xd000000000000000 0xffffffffffffffff - ^^^^^^^^^^^^^^^^^^ - 0x0001f80000000000 0x0001f80000000000 RWE 0x10000 - -makedumpfile uses max_paddr to calculate the number of sections for -sparse memory model thus wrong number is obtained based on max_paddr -(-1). This error could lead to the failure of copying /proc/kcore -for RHEL-8.5 on ppc64le machine [1]: - - $ makedumpfile /proc/kcore vmcore1 - get_mem_section: Could not validate mem_section. - get_mm_sparsemem: Can't get the address of mem_section. - - makedumpfile Failed. - -Let's check if the phys_start of the segment is a valid physical -address to fix this problem. - -[1] https://bugzilla.redhat.com/show_bug.cgi?id=1965267 - -Reported-by: Xiaoying Yan -Signed-off-by: Coiby Xu ---- - elf_info.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/makedumpfile-1.6.8/elf_info.c b/makedumpfile-1.6.8/elf_info.c -index e8affb7..bc24083 100644 ---- a/makedumpfile-1.6.8/elf_info.c -+++ b/makedumpfile-1.6.8/elf_info.c -@@ -628,7 +628,7 @@ get_max_paddr(void) - - for (i = 0; i < num_pt_loads; i++) { - pls = &pt_loads[i]; -- if (max_paddr < pls->phys_end) -+ if (pls->phys_start != NOT_PADDR && max_paddr < pls->phys_end) - max_paddr = pls->phys_end; - } - return max_paddr; --- -2.29.2 - diff --git a/SOURCES/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch b/SOURCES/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch deleted file mode 100644 index 9180dc6..0000000 --- a/SOURCES/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 9a6f589d99dcef114c89fde992157f5467028c8f Mon Sep 17 00:00:00 2001 -From: Tao Liu -Date: Fri, 18 Jun 2021 18:28:04 +0800 -Subject: [PATCH] check for invalid physical address of /proc/kcore - when making ELF dumpfile - -Previously when executing makedumpfile with -E option against -/proc/kcore, makedumpfile will fail: - - # makedumpfile -E -d 31 /proc/kcore kcore.dump - ... - write_elf_load_segment: Can't convert physaddr(ffffffffffffffff) to an offset. - - makedumpfile Failed. - -It's because /proc/kcore contains PT_LOAD program headers which have -physaddr (0xffffffffffffffff). With -E option, makedumpfile will -try to convert the physaddr to an offset and fails. - -Skip the PT_LOAD program headers which have such physaddr. - -Signed-off-by: Tao Liu -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c -index 894c88e..fcb571f 100644 ---- a/makedumpfile-1.6.8/makedumpfile.c -+++ b/makedumpfile-1.6.8/makedumpfile.c -@@ -7764,7 +7764,7 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page) - if (!get_phdr_memory(i, &load)) - return FALSE; - -- if (load.p_type != PT_LOAD) -+ if (load.p_type != PT_LOAD || load.p_paddr == NOT_PADDR) - continue; - - off_memory= load.p_offset; --- -2.29.2 - diff --git a/SOURCES/rhelonly-kexec-tools-2.0.20-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch b/SOURCES/rhelonly-kexec-tools-2.0.20-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch index 85b5496..7b7ad63 100644 --- a/SOURCES/rhelonly-kexec-tools-2.0.20-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch +++ b/SOURCES/rhelonly-kexec-tools-2.0.20-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch @@ -1,27 +1,30 @@ -From 16028a119c85ed73944bcf6ca310a7ee4d2e64fe Mon Sep 17 00:00:00 2001 +From 0f632fa180e5a44219ab6bbe0879c3583f8c65cf Mon Sep 17 00:00:00 2001 From: Pingfan Liu -Date: Mon, 21 Dec 2020 13:35:38 +0800 +Date: Tue, 9 Nov 2021 11:24:22 +0800 Subject: [PATCH] RHEL-only +Cope with RHEL8 kernel + +Signed-off-by: Pingfan Liu --- arch/arm64.c | 14 +++++++++++++- makedumpfile.c | 2 ++ makedumpfile.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) -diff --git a/makedumpfile-1.6.8/arch/arm64.c b/makedumpfile-1.6.8/arch/arm64.c -index 3d7b416..c8e7f62 100644 ---- a/makedumpfile-1.6.8/arch/arm64.c -+++ b/makedumpfile-1.6.8/arch/arm64.c -@@ -48,6 +48,7 @@ static int lpa_52_bit_support_available; - static int pgtable_level; - static int va_bits; +diff --git a/makedumpfile-1.7.0/arch/arm64.c b/makedumpfile-1.7.0/arch/arm64.c +index 1072178..95beae6 100644 +--- a/makedumpfile-1.7.0/arch/arm64.c ++++ b/makedumpfile-1.7.0/arch/arm64.c +@@ -50,6 +50,7 @@ static int va_bits; + static int vabits_actual; + static int flipped_va; static unsigned long kimage_voffset; +static int max_user_va_bits; #define SZ_4K 4096 #define SZ_16K 16384 -@@ -107,7 +108,7 @@ typedef unsigned long pgdval_t; +@@ -108,7 +109,7 @@ typedef unsigned long pgdval_t; #define PGDIR_SHIFT ARM64_HW_PGTABLE_LEVEL_SHIFT(4 - (pgtable_level)) #define PGDIR_SIZE (_AC(1, UL) << PGDIR_SHIFT) #define PGDIR_MASK (~(PGDIR_SIZE-1)) @@ -30,7 +33,7 @@ index 3d7b416..c8e7f62 100644 /* * Section address mask and size definitions. -@@ -366,6 +367,17 @@ get_machdep_info_arm64(void) +@@ -449,6 +450,17 @@ get_machdep_info_arm64(void) ERRMSG("Can't determine platform config values\n"); return FALSE; } @@ -48,38 +51,38 @@ index 3d7b416..c8e7f62 100644 kimage_voffset = NUMBER(kimage_voffset); info->section_size_bits = SECTIONS_SIZE_BITS; -diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c -index cdde040..9fd3ae9 100644 ---- a/makedumpfile-1.6.8/makedumpfile.c -+++ b/makedumpfile-1.6.8/makedumpfile.c -@@ -2322,6 +2322,7 @@ write_vmcoreinfo_data(void) +diff --git a/makedumpfile-1.7.0/makedumpfile.c b/makedumpfile-1.7.0/makedumpfile.c +index 3ad4443..018ea4c 100644 +--- a/makedumpfile-1.7.0/makedumpfile.c ++++ b/makedumpfile-1.7.0/makedumpfile.c +@@ -2417,6 +2417,7 @@ write_vmcoreinfo_data(void) WRITE_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR); #ifdef __aarch64__ + WRITE_NUMBER("MAX_USER_VA_BITS", MAX_USER_VA_BITS); WRITE_NUMBER("VA_BITS", VA_BITS); + /* WRITE_NUMBER("TCR_EL1_T1SZ", TCR_EL1_T1SZ); should not exists */ WRITE_NUMBER_UNSIGNED("PHYS_OFFSET", PHYS_OFFSET); - WRITE_NUMBER_UNSIGNED("kimage_voffset", kimage_voffset); -@@ -2728,6 +2729,7 @@ read_vmcoreinfo(void) +@@ -2863,6 +2864,7 @@ read_vmcoreinfo(void) READ_NUMBER("phys_base", phys_base); READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE); #ifdef __aarch64__ + READ_NUMBER("MAX_USER_VA_BITS", MAX_USER_VA_BITS); READ_NUMBER("VA_BITS", VA_BITS); + READ_NUMBER("TCR_EL1_T1SZ", TCR_EL1_T1SZ); READ_NUMBER_UNSIGNED("PHYS_OFFSET", PHYS_OFFSET); - READ_NUMBER_UNSIGNED("kimage_voffset", kimage_voffset); -diff --git a/makedumpfile-1.6.8/makedumpfile.h b/makedumpfile-1.6.8/makedumpfile.h -index 698c054..2763a47 100644 ---- a/makedumpfile-1.6.8/makedumpfile.h -+++ b/makedumpfile-1.6.8/makedumpfile.h -@@ -1937,6 +1937,7 @@ struct number_table { +diff --git a/makedumpfile-1.7.0/makedumpfile.h b/makedumpfile-1.7.0/makedumpfile.h +index e59239d..b6236dd 100644 +--- a/makedumpfile-1.7.0/makedumpfile.h ++++ b/makedumpfile-1.7.0/makedumpfile.h +@@ -2064,6 +2064,7 @@ struct number_table { long phys_base; long KERNEL_IMAGE_SIZE; #ifdef __aarch64__ + long MAX_USER_VA_BITS; long VA_BITS; + long TCR_EL1_T1SZ; unsigned long PHYS_OFFSET; - unsigned long kimage_voffset; -- -2.21.0 +2.31.1 diff --git a/SPECS/kexec-tools.spec b/SPECS/kexec-tools.spec index 633b782..f6fcbb6 100644 --- a/SPECS/kexec-tools.spec +++ b/SPECS/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.20 -Release: 60%{?dist} +Release: 61%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -13,7 +13,7 @@ Source4: kdump.sysconfig.i386 Source5: kdump.sysconfig.ppc64 Source7: mkdumprd Source8: kdump.conf -Source9: https://github.com/makedumpfile/makedumpfile/archive/1.6.8.tar.gz +Source9: https://github.com/makedumpfile/makedumpfile/archive/1.7.0.tar.gz Source10: kexec-kdump-howto.txt Source12: mkdumprd.8 Source13: 98-kexec.rules @@ -124,13 +124,6 @@ Patch616: kexec-tools-2.0.20-3-printk-Use-zu-to-format-size_t.patch # Patches 701 onward for makedumpfile Patch701: rhelonly-kexec-tools-2.0.20-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch -Patch702: kexec-tools-2.0.20-makedumpfile-Add-dry-run-option-to-prevent-writing.patch -Patch703: kexec-tools-2.0.20-makedumpfile-Add-shorthand-show-stats-option-to-show.patch -Patch704: kexec-tools-2.0.20-makedumpfile-Show-write-byte-size-in-report-messages.patch -Patch705: kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch -Patch706: kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch -Patch707: kexec-tools-2.0.20-makedumpfile-1-printk-add-support-for-lockless-ringbuffer.patch -Patch708: kexec-tools-2.0.20-makedumpfile-2-printk-use-committed-finalized-state-value.patch %description kexec-tools provides /usr/sbin/kexec binary that facilitates a new @@ -163,13 +156,6 @@ tar -z -x -v -f %{SOURCE19} %patch615 -p1 %patch616 -p1 %patch701 -p1 -%patch702 -p1 -%patch703 -p1 -%patch704 -p1 -%patch705 -p1 -%patch706 -p1 -%patch707 -p1 -%patch708 -p1 %ifarch ppc %define archdef ARCH=ppc @@ -199,8 +185,8 @@ cp %{SOURCE31} . make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 make -C eppic/libeppic -make -C makedumpfile-1.6.8 LINKTYPE=dynamic USELZO=on USESNAPPY=on -make -C makedumpfile-1.6.8 LDFLAGS="$LDFLAGS -I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so +make -C makedumpfile-1.7.0 LINKTYPE=dynamic USELZO=on USESNAPPY=on +make -C makedumpfile-1.7.0 LDFLAGS="$LDFLAGS -I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so %endif %install @@ -261,13 +247,13 @@ install -m 755 -D %{SOURCE32} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60- %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 -install -m 755 makedumpfile-1.6.8/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile -install -m 644 makedumpfile-1.6.8/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz -install -m 644 makedumpfile-1.6.8/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz -install -m 644 makedumpfile-1.6.8/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample -install -m 755 makedumpfile-1.6.8/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so +install -m 755 makedumpfile-1.7.0/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile +install -m 644 makedumpfile-1.7.0/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz +install -m 644 makedumpfile-1.7.0/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz +install -m 644 makedumpfile-1.7.0/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample +install -m 755 makedumpfile-1.7.0/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ -install -m 644 makedumpfile-1.6.8/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ +install -m 644 makedumpfile-1.7.0/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ %endif %define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g') @@ -431,6 +417,9 @@ done %endif %changelog +* Tue Nov 9 2021 Pingfan Liu - 2.0.20-61 +- rebase makedumpfile to 1.7.0 + * Fri Oct 22 2021 Pingfan Liu - 2.0.20-60 - fadump-init: clean up mount points properly - fadump: kdumpctl should check the modules used by the fadump initramfs