Support kernel dumps using 5.10 kernel (#662)

* update crash and kexec-tools to support printk in 5.10 kernel

* update patch files with original commits

* fix cgmanifest crash version

* cleanup
This commit is contained in:
Andrew Phelps 2021-02-24 17:29:35 -08:00 committed by GitHub
parent 83e8aaa89a
commit fbb71e839e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 1092 additions and 576 deletions

View File

@ -0,0 +1,452 @@
This patch is a combination of the following commits:
https://github.com/crash-utility/crash/commit/a5531b24750e7949c35640d996ea14c0587938bc
https://github.com/crash-utility/crash/commit/71e159c64000467e94e08aefc144f5e1cdaa4aa0
diff -urN a/defs.h b/defs.h
--- a/defs.h 2020-11-19 15:32:33.000000000 -0800
+++ b/defs.h 2021-02-23 21:33:30.503355697 -0800
@@ -2106,6 +2106,28 @@
long irq_common_data_affinity;
long irq_desc_irq_common_data;
long uts_namespace_name;
+ long printk_info_seq;
+ long printk_info_ts_nsec;
+ long printk_info_text_len;
+ long printk_info_level;
+ long printk_info_caller_id;
+ long printk_info_dev_info;
+ long dev_printk_info_subsystem;
+ long dev_printk_info_device;
+ long prb_desc_ring;
+ long prb_text_data_ring;
+ long prb_desc_ring_count_bits;
+ long prb_desc_ring_descs;
+ long prb_desc_ring_infos;
+ long prb_desc_ring_head_id;
+ long prb_desc_ring_tail_id;
+ long prb_desc_state_var;
+ long prb_desc_text_blk_lpos;
+ long prb_data_blk_lpos_begin;
+ long prb_data_blk_lpos_next;
+ long prb_data_ring_size_bits;
+ long prb_data_ring_data;
+ long atomic_long_t_counter;
};
struct size_table { /* stash of commonly-used sizes */
@@ -2265,6 +2287,9 @@
long xa_node;
long zram_table_entry;
long irq_common_data;
+ long printk_info;
+ long printk_ringbuffer;
+ long prb_desc;
};
struct array_table {
@@ -6697,6 +6722,11 @@
int calc_kaslr_offset(ulong *, ulong *);
/*
+ * printk.c
+ */
+void dump_lockless_record_log(int);
+
+/*
* gnu_binutils.c
*/
diff -urN a/kernel.c b/kernel.c
--- a/kernel.c 2020-11-19 15:32:33.000000000 -0800
+++ b/kernel.c 2021-02-23 21:34:38.771871040 -0800
@@ -5042,6 +5042,11 @@
struct syment *nsp;
int log_wrap, loglevel, log_buf_len;
+ if (kernel_symbol_exists("prb")) {
+ dump_lockless_record_log(msg_flags);
+ return;
+ }
+
if (kernel_symbol_exists("log_first_idx") &&
kernel_symbol_exists("log_next_idx")) {
dump_variable_length_record_log(msg_flags);
@@ -5289,7 +5294,7 @@
}
/*
- * Handle the new variable-length-record log_buf.
+ * Handle the variable-length-record log_buf.
*/
static void
dump_variable_length_record_log(int msg_flags)
diff -urN a/Makefile b/Makefile
--- a/Makefile 2020-11-19 15:32:33.000000000 -0800
+++ b/Makefile 2021-02-23 21:31:25.478200487 -0800
@@ -61,6 +61,7 @@
CFILES=main.c tools.c global_data.c memory.c filesys.c help.c task.c \
kernel.c test.c gdb_interface.c configure.c net.c dev.c bpf.c \
+ printk.c \
alpha.c x86.c ppc.c ia64.c s390.c s390x.c s390dbf.c ppc64.c x86_64.c \
arm.c arm64.c mips.c sparc64.c \
extensions.c remote.c va_server.c va_server_v1.c symbols.c cmdline.c \
@@ -80,6 +81,7 @@
OBJECT_FILES=main.o tools.o global_data.o memory.o filesys.o help.o task.o \
build_data.o kernel.o test.o gdb_interface.o net.o dev.o bpf.o \
+ printk.o \
alpha.o x86.o ppc.o ia64.o s390.o s390x.o s390dbf.o ppc64.o x86_64.o \
arm.o arm64.o mips.o sparc64.o \
extensions.o remote.o va_server.o va_server_v1.o symbols.o cmdline.o \
@@ -363,6 +365,9 @@
kernel.o: ${GENERIC_HFILES} kernel.c
${CC} -c ${CRASH_CFLAGS} kernel.c ${WARNING_OPTIONS} ${WARNING_ERROR}
+printk.o: ${GENERIC_HFILES} printk.c
+ ${CC} -c ${CRASH_CFLAGS} printk.c ${WARNING_OPTIONS} ${WARNING_ERROR}
+
gdb_interface.o: ${GENERIC_HFILES} gdb_interface.c
${CC} -c ${CRASH_CFLAGS} gdb_interface.c ${WARNING_OPTIONS} ${WARNING_ERROR}
diff -urN a/printk.c b/printk.c
--- a/printk.c 1969-12-31 16:00:00.000000000 -0800
+++ b/printk.c 2021-02-23 21:39:00.829282760 -0800
@@ -0,0 +1,290 @@
+#include "defs.h"
+#include <ctype.h>
+
+/* 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;
+};
+
+/*
+ * 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
+init_offsets(void)
+{
+ char *n;
+
+ n = "printk_info";
+ STRUCT_SIZE_INIT(printk_info, n);
+ MEMBER_OFFSET_INIT(printk_info_seq, n, "seq");
+ MEMBER_OFFSET_INIT(printk_info_ts_nsec, n, "ts_nsec");
+ MEMBER_OFFSET_INIT(printk_info_text_len, n, "text_len");
+ MEMBER_OFFSET_INIT(printk_info_level, n, "level");
+ MEMBER_OFFSET_INIT(printk_info_caller_id, n, "caller_id");
+ MEMBER_OFFSET_INIT(printk_info_dev_info, n, "dev_info");
+
+ n = "dev_printk_info";
+ MEMBER_OFFSET_INIT(dev_printk_info_subsystem, n, "subsystem");
+ MEMBER_OFFSET_INIT(dev_printk_info_device, n, "device");
+
+ n = "printk_ringbuffer";
+ STRUCT_SIZE_INIT(printk_ringbuffer, n);
+ MEMBER_OFFSET_INIT(prb_desc_ring, n, "desc_ring");
+ MEMBER_OFFSET_INIT(prb_text_data_ring, n, "text_data_ring");
+
+ n = "prb_desc_ring";
+ MEMBER_OFFSET_INIT(prb_desc_ring_count_bits, n, "count_bits");
+ MEMBER_OFFSET_INIT(prb_desc_ring_descs, n, "descs");
+ MEMBER_OFFSET_INIT(prb_desc_ring_infos, n, "infos");
+ MEMBER_OFFSET_INIT(prb_desc_ring_head_id, n, "head_id");
+ MEMBER_OFFSET_INIT(prb_desc_ring_tail_id, n, "tail_id");
+
+ n = "prb_desc";
+ STRUCT_SIZE_INIT(prb_desc, n);
+ MEMBER_OFFSET_INIT(prb_desc_state_var, n, "state_var");
+ MEMBER_OFFSET_INIT(prb_desc_text_blk_lpos, n, "text_blk_lpos");
+
+ n = "prb_data_blk_lpos";
+ MEMBER_OFFSET_INIT(prb_data_blk_lpos_begin, n, "begin");
+ MEMBER_OFFSET_INIT(prb_data_blk_lpos_next, n, "next");
+
+ n = "prb_data_ring";
+ MEMBER_OFFSET_INIT(prb_data_ring_size_bits, n, "size_bits");
+ MEMBER_OFFSET_INIT(prb_data_ring_data, n, "data");
+
+ n = "atomic_long_t";
+ MEMBER_OFFSET_INIT(atomic_long_t_counter, n, "counter");
+}
+
+static void
+dump_record(struct prb_map *m, unsigned long id, int msg_flags)
+{
+ unsigned short text_len;
+ unsigned long state_var;
+ unsigned int caller_id;
+ enum desc_state state;
+ unsigned char level;
+ unsigned long begin;
+ unsigned long next;
+ char buf[BUFSIZE];
+ uint64_t ts_nsec;
+ ulonglong nanos;
+ ulonglong seq;
+ int ilen = 0, i;
+ char *desc, *info, *text, *p;
+ ulong rem;
+
+ 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));
+ state = get_desc_state(id, state_var);
+ if (state != desc_committed && state != desc_finalized)
+ return;
+
+ info = m->infos + ((id % m->desc_ring_count) * SIZE(printk_info));
+
+ seq = ULONGLONG(info + OFFSET(printk_info_seq));
+ caller_id = UINT(info + OFFSET(printk_info_caller_id));
+ if (CRASHDEBUG(1))
+ fprintf(fp, "seq: %llu caller_id: %x (%s: %u)\n", seq, caller_id,
+ caller_id & 0x80000000 ? "cpu" : "pid", caller_id & ~0x80000000);
+
+ text_len = USHORT(info + OFFSET(printk_info_text_len));
+
+ 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)
+ goto out;
+
+ if ((msg_flags & SHOW_LOG_TEXT) == 0) {
+ ts_nsec = ULONGLONG(info + OFFSET(printk_info_ts_nsec));
+ nanos = (ulonglong)ts_nsec / (ulonglong)1000000000;
+ rem = (ulonglong)ts_nsec % (ulonglong)1000000000;
+ if (msg_flags & SHOW_LOG_CTIME) {
+ time_t t = kt->boot_date.tv_sec + nanos;
+ sprintf(buf, "[%s] ", ctime_tz(&t));
+ } else
+ sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
+
+ ilen += strlen(buf);
+ fprintf(fp, "%s", buf);
+ }
+
+ if (msg_flags & SHOW_LOG_LEVEL) {
+ level = UCHAR(info + OFFSET(printk_info_level)) >> 5;
+ sprintf(buf, "<%x>", level);
+ ilen += strlen(buf);
+ fprintf(fp, "%s", buf);
+ }
+
+ /* 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;
+
+ for (i = 0, p = text; i < text_len; i++, p++) {
+ if (*p == '\n')
+ fprintf(fp, "\n%s", space(ilen));
+ else if (isprint(*p) || isspace(*p))
+ fputc(*p, fp);
+ else
+ fputc('.', fp);
+ }
+
+ if (msg_flags & SHOW_LOG_DICT) {
+ text = info + OFFSET(printk_info_dev_info) +
+ OFFSET(dev_printk_info_subsystem);
+ if (strlen(text))
+ fprintf(fp, "\n%sSUBSYSTEM=%s", space(ilen), text);
+
+ text = info + OFFSET(printk_info_dev_info) +
+ OFFSET(dev_printk_info_device);
+ if (strlen(text))
+ fprintf(fp, "\n%sDEVICE=%s", space(ilen), text);
+ }
+out:
+ fprintf(fp, "\n");
+}
+
+/*
+ * Handle the lockless printk_ringbuffer.
+ */
+void
+dump_lockless_record_log(int msg_flags)
+{
+ unsigned long head_id;
+ unsigned long tail_id;
+ unsigned long kaddr;
+ unsigned long id;
+ struct prb_map m;
+
+ if (INVALID_SIZE(printk_info))
+ init_offsets();
+
+ /* setup printk_ringbuffer */
+ get_symbol_data("prb", sizeof(char *), &kaddr);
+ m.prb = GETBUF(SIZE(printk_ringbuffer));
+ if (!readmem(kaddr, KVADDR, m.prb, SIZE(printk_ringbuffer),
+ "printk_ringbuffer contents", RETURN_ON_ERROR|QUIET)) {
+ error(WARNING, "\ncannot read printk_ringbuffer contents\n");
+ goto out_prb;
+ }
+
+ /* setup descriptor ring */
+ m.desc_ring = m.prb + OFFSET(prb_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 = GETBUF(SIZE(prb_desc) * m.desc_ring_count);
+ if (!readmem(kaddr, KVADDR, m.descs, SIZE(prb_desc) * m.desc_ring_count,
+ "prb_desc_ring contents", RETURN_ON_ERROR|QUIET)) {
+ error(WARNING, "\ncannot read prb_desc_ring contents\n");
+ goto out_descs;
+ }
+
+ kaddr = ULONG(m.desc_ring + OFFSET(prb_desc_ring_infos));
+ m.infos = GETBUF(SIZE(printk_info) * m.desc_ring_count);
+ if (!readmem(kaddr, KVADDR, m.infos, SIZE(printk_info) * m.desc_ring_count,
+ "prb_info_ring contents", RETURN_ON_ERROR|QUIET)) {
+ error(WARNING, "\ncannot read prb_info_ring contents\n");
+ goto out_infos;
+ }
+
+ /* setup text data ring */
+ m.text_data_ring = m.prb + OFFSET(prb_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 = GETBUF(m.text_data_ring_size);
+ if (!readmem(kaddr, KVADDR, m.text_data, m.text_data_ring_size,
+ "prb_text_data_ring contents", RETURN_ON_ERROR|QUIET)) {
+ error(WARNING, "\ncannot read prb_text_data_ring contents\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));
+
+ hq_open();
+
+ for (id = tail_id; id != head_id; id = (id + 1) & DESC_ID_MASK)
+ dump_record(&m, id, msg_flags);
+
+ /* dump head record */
+ dump_record(&m, id, msg_flags);
+
+ hq_close();
+
+out_text_data:
+ FREEBUF(m.text_data);
+out_infos:
+ FREEBUF(m.infos);
+out_descs:
+ FREEBUF(m.descs);
+out_prb:
+ FREEBUF(m.prb);
+}
\ No newline at end of file
diff -urN a/symbols.c b/symbols.c
--- a/symbols.c 2020-11-19 15:32:33.000000000 -0800
+++ b/symbols.c 2021-02-23 21:36:32.596581891 -0800
@@ -10426,6 +10426,30 @@
OFFSET(log_level));
fprintf(fp, " log_flags_level: %ld\n",
OFFSET(log_flags_level));
+
+ fprintf(fp, " printk_info_seq: %ld\n", OFFSET(printk_info_seq));
+ fprintf(fp, " printk_info_ts_nseq: %ld\n", OFFSET(printk_info_ts_nsec));
+ fprintf(fp, " printk_info_text_len: %ld\n", OFFSET(printk_info_text_len));
+ fprintf(fp, " printk_info_level: %ld\n", OFFSET(printk_info_level));
+ fprintf(fp, " printk_info_caller_id: %ld\n", OFFSET(printk_info_caller_id));
+ fprintf(fp, " printk_info_dev_info: %ld\n", OFFSET(printk_info_dev_info));
+ fprintf(fp, " dev_printk_info_subsystem: %ld\n", OFFSET(dev_printk_info_subsystem));
+ fprintf(fp, " dev_printk_info_device: %ld\n", OFFSET(dev_printk_info_device));
+ fprintf(fp, " prb_desc_ring: %ld\n", OFFSET(prb_desc_ring));
+ fprintf(fp, " prb_text_data_ring: %ld\n", OFFSET(prb_text_data_ring));
+ fprintf(fp, " prb_desc_ring_count_bits: %ld\n", OFFSET(prb_desc_ring_count_bits));
+ fprintf(fp, " prb_desc_ring_descs: %ld\n", OFFSET(prb_desc_ring_descs));
+ fprintf(fp, " prb_desc_ring_infos: %ld\n", OFFSET(prb_desc_ring_infos));
+ fprintf(fp, " prb_desc_ring_head_id: %ld\n", OFFSET(prb_desc_ring_head_id));
+ fprintf(fp, " prb_desc_ring_tail_id: %ld\n", OFFSET(prb_desc_ring_tail_id));
+ fprintf(fp, " prb_desc_state_var: %ld\n", OFFSET(prb_desc_state_var));
+ fprintf(fp, " prb_desc_text_blk_lpos: %ld\n", OFFSET(prb_desc_text_blk_lpos));
+ fprintf(fp, " prb_data_blk_lpos_begin: %ld\n", OFFSET(prb_data_blk_lpos_begin));
+ fprintf(fp, " prb_data_blk_lpos_next: %ld\n", OFFSET(prb_data_blk_lpos_next));
+ fprintf(fp, " prb_data_ring_size_bits: %ld\n", OFFSET(prb_data_ring_size_bits));
+ fprintf(fp, " prb_data_ring_data: %ld\n", OFFSET(prb_data_ring_data));
+ fprintf(fp, " atomit_long_t_counter: %ld\n", OFFSET(atomic_long_t_counter));
+
fprintf(fp, " sched_rt_entity_my_q: %ld\n",
OFFSET(sched_rt_entity_my_q));
fprintf(fp, " task_group_parent: %ld\n",
@@ -10850,7 +10874,9 @@
SIZE(xarray));
fprintf(fp, " xa_node: %ld\n",
SIZE(xa_node));
-
+ fprintf(fp, " printk_info: %ld\n", SIZE(printk_info));
+ fprintf(fp, " printk_ringbuffer: %ld\n", SIZE(printk_ringbuffer));
+ fprintf(fp, " prb_desc: %ld\n", SIZE(prb_desc));
fprintf(fp, "\n array_table:\n");
/*

View File

@ -1,6 +1,6 @@
{
"Signatures": {
"crash-7.2.8.tar.gz": "996d3367764c77e23921c164725e4d0221acc7a15a92a3f825053ea37f2452dc",
"crash-7.2.9.tar.gz": "6c07634f7357906dcb21ff3decd1760d7b0b1a11c01472cd17aba2e67f3ce16e",
"gdb-7.6.tar.gz": "8070389a5dcc104eb0be483d582729f98ed4d761ad19cedd3f17b5d2502faa36"
}
}

View File

@ -1,6 +1,6 @@
Name: crash
Version: 7.2.8
Release: 2%{?dist}
Version: 7.2.9
Release: 1%{?dist}
Summary: kernel crash analysis utility for live systems, netdump, diskdump, kdump, LKCD or mcore dumpfiles
Group: Development/Tools
Vendor: Microsoft Corporation
@ -9,6 +9,7 @@ URL: https://github.com/crash-utility/crash
# Source0: https://github.com/crash-utility/%{name}/archive/%{version}.tar.gz
Source0: %{name}-%{version}.tar.gz
Source1: https://ftp.gnu.org/gnu/gdb/gdb-7.6.tar.gz
Patch0: crash-printk-fix.patch
License: GPLv3+
BuildRequires: binutils
BuildRequires: glibc-devel
@ -33,6 +34,7 @@ This package contains libraries and header files need for development.
%prep
%setup -q -n %{name}-%{version}
cp %{SOURCE1} .
%patch0 -p1
%build
make RPMPKG=%{version}-%{release}
@ -62,6 +64,9 @@ cp -p defs.h %{buildroot}%{_includedir}/crash
%{_includedir}/crash/*.h
%changelog
* Tue Feb 23 2021 Andrew Phelps <anphel@microsoft.com> 7.2.9-1
- Update version to 7.2.9.
- Add patches to support new printk in 5.10 kernel
* Sat Jun 20 2020 Andrew Phelps <anphel@microsoft.com> 7.2.8-2
- Add Source1 with gdb source tarball to support offline build.
* Wed Jun 17 2020 Joe Schmitt <joschmit@microsoft.com> 7.2.8-1

View File

@ -1,98 +0,0 @@
From 23daba8bb97ff4291447e54859ed759cfe07975e Mon Sep 17 00:00:00 2001
From: Kairui Song <kasong@redhat.com>
Date: Wed, 29 Jan 2020 10:48:27 +0800
Subject: [PATCH] kexec-tools: Remove duplicated variable declarations
When building kexec-tools for Fedora 32, following error is observed:
/usr/bin/ld: kexec/arch/x86_64/kexec-bzImage64.o:(.bss+0x0): multiple definition of `bzImage_support_efi_boot';
kexec/arch/i386/kexec-bzImage.o:(.bss+0x0): first defined here
/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm/../../fs2dt.h:33: multiple definition of `my_debug';
kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/kexec/fs2dt.h:33: first defined here
/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm64/kexec-arm64.h:68: multiple definition of `arm64_mem';
kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/././kexec/arch/arm64/kexec-arm64.h:68: first defined here
/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm64/kexec-arm64.h:54: multiple definition of `initrd_size';
kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/././kexec/arch/arm64/kexec-arm64.h:54: first defined here
/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm64/kexec-arm64.h:53: multiple definition of `initrd_base';
kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/././kexec/arch/arm64/kexec-arm64.h:53: first defined here
And apparently, these variables are wrongly declared multiple times. So
remove duplicated declaration.
Signed-off-by: Kairui Song <kasong@redhat.com>
---
kexec/arch/arm64/kexec-arm64.h | 6 +++---
kexec/arch/ppc64/kexec-elf-ppc64.c | 2 --
kexec/arch/x86_64/kexec-bzImage64.c | 1 -
kexec/fs2dt.h | 2 +-
4 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/kexec/arch/arm64/kexec-arm64.h b/kexec/arch/arm64/kexec-arm64.h
index 628de79..ed447ac 100644
--- a/kexec/arch/arm64/kexec-arm64.h
+++ b/kexec/arch/arm64/kexec-arm64.h
@@ -50,8 +50,8 @@ int zImage_arm64_load(int argc, char **argv, const char *kernel_buf,
void zImage_arm64_usage(void);
-off_t initrd_base;
-off_t initrd_size;
+extern off_t initrd_base;
+extern off_t initrd_size;
/**
* struct arm64_mem - Memory layout info.
@@ -65,7 +65,7 @@ struct arm64_mem {
};
#define arm64_mem_ngv UINT64_MAX
-struct arm64_mem arm64_mem;
+extern struct arm64_mem arm64_mem;
uint64_t get_phys_offset(void);
uint64_t get_vp_offset(void);
diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c
index 3510b70..695b8b0 100644
--- a/kexec/arch/ppc64/kexec-elf-ppc64.c
+++ b/kexec/arch/ppc64/kexec-elf-ppc64.c
@@ -44,8 +44,6 @@
uint64_t initrd_base, initrd_size;
unsigned char reuse_initrd = 0;
const char *ramdisk;
-/* Used for enabling printing message from purgatory code */
-int my_debug = 0;
int elf_ppc64_probe(const char *buf, off_t len)
{
diff --git a/kexec/arch/x86_64/kexec-bzImage64.c b/kexec/arch/x86_64/kexec-bzImage64.c
index 8edb3e4..ba8dc48 100644
--- a/kexec/arch/x86_64/kexec-bzImage64.c
+++ b/kexec/arch/x86_64/kexec-bzImage64.c
@@ -42,7 +42,6 @@
#include <arch/options.h>
static const int probe_debug = 0;
-int bzImage_support_efi_boot;
int bzImage64_probe(const char *buf, off_t len)
{
diff --git a/kexec/fs2dt.h b/kexec/fs2dt.h
index 7633273..fe24931 100644
--- a/kexec/fs2dt.h
+++ b/kexec/fs2dt.h
@@ -30,7 +30,7 @@ extern struct bootblock bb[1];
/* Used for enabling printing message from purgatory code
* Only has implemented for PPC64 */
-int my_debug;
+extern int my_debug;
extern int dt_no_old_root;
void reserve(unsigned long long where, unsigned long long length);
--
2.24.1

View File

@ -1,36 +0,0 @@
From 2837fb1f5f8362976c188b30ebe50dc8b0377f64 Mon Sep 17 00:00:00 2001
From: Kairui Song <kasong@redhat.com>
Date: Wed, 29 Jan 2020 11:33:18 +0800
Subject: [PATCH] Remove duplicated variable declaration
When building on Fedora 32, following error is observed:
...
/usr/bin/ld: ../eppic/libeppic/libeppic.a(eppic_stat.o):/builddir/build/BUILD/kexec-tools-2.0.20/eppic/libeppic/eppic.h:474: multiple definition of `lastv';
../eppic/libeppic/libeppic.a(eppic_func.o):/builddir/build/BUILD/kexec-tools-2.0.20/eppic/libeppic/eppic.h:474: first defined here
...
And apparently, the variable is wrongly declared multiple times. So
remove duplicated declaration.
Signed-off-by: Kairui Song <kasong@redhat.com>
---
libeppic/eppic.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libeppic/eppic.h b/libeppic/eppic.h
index 5664583..836b475 100644
--- a/eppic-d84c3541035d95077aa8571f5d5c3e07c6ef510b/libeppic/eppic.h
+++ b/eppic-d84c3541035d95077aa8571f5d5c3e07c6ef510b/libeppic/eppic.h
@@ -471,7 +471,7 @@ type_t *eppic_addstorage(type_t *t1, type_t *t2);
type_t *eppic_getvoidstruct(int ctype);
extern int lineno, needvar, instruct, nomacs, eppic_legacy;
-node_t *lastv;
+extern node_t *lastv;
#define NULLNODE ((node_t*)0)
--
2.24.1

View File

@ -1,88 +0,0 @@
From 940c3a1e1a304fbecc850c593a272215b0f52eab Mon Sep 17 00:00:00 2001
From: Kairui Song <kasong@redhat.com>
Date: Wed, 31 Jul 2019 16:30:47 +0800
Subject: [PATCH] x86: Fix broken multiboot2 buliding for i386
When building for i386, an error occured:
kexec/arch/i386/kexec-x86.c:39:22: error: 'multiboot2_x86_probe'
undeclared here (not in a function); did you mean 'multiboot_x86_probe'?
39 | { "multiboot2-x86", multiboot2_x86_probe, multiboot2_x86_load,
| ^~~~~~~~~~~~~~~~~~~~
| multiboot_x86_probe
kexec/arch/i386/kexec-x86.c:39:44: error: 'multiboot2_x86_load'
undeclared here (not in a function); did you mean 'multiboot_x86_load'?
39 | { "multiboot2-x86", multiboot2_x86_probe, multiboot2_x86_load,
| ^~~~~~~~~~~~~~~~~~~
| multiboot_x86_load
kexec/arch/i386/kexec-x86.c:40:4: error: 'multiboot2_x86_usage'
undeclared here (not in a function); did you mean 'multiboot_x86_usage'?
40 | multiboot2_x86_usage },
| ^~~~~~~~~~~~~~~~~~~~
| multiboot_x86_usage
Fix this issue by putting the definition in the right header, also tidy
up Makefile.
Fixes: 22a2ed55132e ("x86: Support multiboot2 images")
Signed-off-by: Kairui Song <kasong@redhat.com>
---
kexec/arch/i386/Makefile | 2 +-
kexec/arch/i386/kexec-x86.h | 5 +++++
kexec/arch/x86_64/kexec-x86_64.h | 5 -----
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/kexec/arch/i386/Makefile b/kexec/arch/i386/Makefile
index 105cefd..f486103 100644
--- a/kexec/arch/i386/Makefile
+++ b/kexec/arch/i386/Makefile
@@ -7,6 +7,7 @@ i386_KEXEC_SRCS += kexec/arch/i386/kexec-elf-x86.c
i386_KEXEC_SRCS += kexec/arch/i386/kexec-elf-rel-x86.c
i386_KEXEC_SRCS += kexec/arch/i386/kexec-bzImage.c
i386_KEXEC_SRCS += kexec/arch/i386/kexec-multiboot-x86.c
+i386_KEXEC_SRCS += kexec/arch/i386/kexec-mb2-x86.c
i386_KEXEC_SRCS += kexec/arch/i386/kexec-beoboot-x86.c
i386_KEXEC_SRCS += kexec/arch/i386/kexec-nbi.c
i386_KEXEC_SRCS += kexec/arch/i386/x86-linux-setup.c
@@ -14,7 +15,6 @@ i386_KEXEC_SRCS += kexec/arch/i386/crashdump-x86.c
dist += kexec/arch/i386/Makefile $(i386_KEXEC_SRCS) \
kexec/arch/i386/crashdump-x86.h \
- kexec/arch/i386/kexec-mb2-x86.c \
kexec/arch/i386/kexec-x86.h \
kexec/arch/i386/x86-linux-setup.h \
kexec/arch/i386/include/arch/options.h
diff --git a/kexec/arch/i386/kexec-x86.h b/kexec/arch/i386/kexec-x86.h
index 1b58c3b..16d0f6c 100644
--- a/kexec/arch/i386/kexec-x86.h
+++ b/kexec/arch/i386/kexec-x86.h
@@ -60,6 +60,11 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len,
struct kexec_info *info);
void multiboot_x86_usage(void);
+int multiboot2_x86_load(int argc, char **argv, const char *buf, off_t len,
+ struct kexec_info *info);
+void multiboot2_x86_usage(void);
+int multiboot2_x86_probe(const char *buf, off_t buf_len);
+
int elf_x86_probe(const char *buf, off_t len);
int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
struct kexec_info *info);
diff --git a/kexec/arch/x86_64/kexec-x86_64.h b/kexec/arch/x86_64/kexec-x86_64.h
index 21c3a73..4cdeffb 100644
--- a/kexec/arch/x86_64/kexec-x86_64.h
+++ b/kexec/arch/x86_64/kexec-x86_64.h
@@ -33,9 +33,4 @@ int bzImage64_load(int argc, char **argv, const char *buf, off_t len,
struct kexec_info *info);
void bzImage64_usage(void);
-int multiboot2_x86_load(int argc, char **argv, const char *buf, off_t len,
- struct kexec_info *info);
-void multiboot2_x86_usage(void);
-int multiboot2_x86_probe(const char *buf, off_t buf_len);
-
#endif /* KEXEC_X86_64_H */
--
2.21.0

View File

@ -1,255 +0,0 @@
From 989152e113bfcb4fbfbad6f3aed6f43be4455919 Mon Sep 17 00:00:00 2001
From: Kazuhito Hagio <k-hagio-ab@nec.com>
Date: Tue, 25 Feb 2020 16:04:55 -0500
Subject: [PATCH] Introduce --check-params option
Currently it's difficult to check whether a makedumpfile command-line
is valid or not without an actual panic. This is inefficient and if
a wrong configuration is not tested, you will miss the vmcore when an
actual panic occurs.
In order for kdump facilities like kexec-tools to be able to check
the specified command-line parameters in advance, introduce the
--check-params option that only checks them and exits immediately.
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
makedumpfile.8 | 5 ++++
makedumpfile.c | 75 ++++++++++++++++++++++++++++++++++++++------------
print_info.c | 4 +++
4 files changed, 69 insertions(+), 17 deletions(-)
diff --git a/makedumpfile-1.6.7/makedumpfile.8 b/makedumpfile-1.6.7/makedumpfile.8
index bf156a8..c5d4806 100644
--- a/makedumpfile-1.6.7/makedumpfile.8
+++ b/makedumpfile-1.6.7/makedumpfile.8
@@ -632,6 +632,11 @@ Show help message and LZO/snappy support status (enabled/disabled).
\fB\-v\fR
Show the version of makedumpfile.
+.TP
+\fB\-\-check-params\fR
+Only check whether the command-line parameters are valid or not, and exit.
+Preferable to be given as the first parameter.
+
.SH ENVIRONMENT VARIABLES
.TP 8
diff --git a/makedumpfile-1.6.7/makedumpfile.c b/makedumpfile-1.6.7/makedumpfile.c
index 607e07f..f5860a1 100644
--- a/makedumpfile-1.6.7/makedumpfile.c
+++ b/makedumpfile-1.6.7/makedumpfile.c
@@ -10978,12 +10978,6 @@ check_param_for_creating_dumpfile(int argc, char *argv[])
if (info->flag_generate_vmcoreinfo || info->flag_rearrange)
return FALSE;
- if ((message_level < MIN_MSG_LEVEL)
- || (MAX_MSG_LEVEL < message_level)) {
- message_level = DEFAULT_MSG_LEVEL;
- MSG("Message_level is invalid.\n");
- return FALSE;
- }
if ((info->flag_compress && info->flag_elf_dumpfile)
|| (info->flag_read_vmcoreinfo && info->name_vmlinux)
|| (info->flag_read_vmcoreinfo && info->name_xen_syms))
@@ -11013,6 +11007,11 @@ check_param_for_creating_dumpfile(int argc, char *argv[])
if (info->flag_partial_dmesg && !info->flag_dmesg)
return FALSE;
+ if (info->flag_excludevm && !info->working_dir) {
+ MSG("-%c requires --work-dir\n", OPT_EXCLUDE_UNUSED_VM);
+ return FALSE;
+ }
+
if ((argc == optind + 2) && !info->flag_flatten
&& !info->flag_split
&& !info->flag_sadump_diskset) {
@@ -11408,6 +11407,23 @@ int show_mem_usage(void)
return TRUE;
}
+static int set_message_level(char *str_ml)
+{
+ int ml;
+
+ ml = atoi(str_ml);
+ if ((ml < MIN_MSG_LEVEL) || (MAX_MSG_LEVEL < ml)) {
+ message_level = DEFAULT_MSG_LEVEL;
+ MSG("Message_level(%d) is invalid.\n", ml);
+ return FALSE;
+ }
+
+ if (info->flag_check_params)
+ return TRUE;
+
+ message_level = ml;
+ return TRUE;
+}
static struct option longopts[] = {
{"split", no_argument, NULL, OPT_SPLIT},
@@ -11429,6 +11445,7 @@ static struct option longopts[] = {
{"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE},
{"work-dir", required_argument, NULL, OPT_WORKING_DIR},
{"num-threads", required_argument, NULL, OPT_NUM_THREADS},
+ {"check-params", no_argument, NULL, OPT_CHECK_PARAMS},
{0, 0, 0, 0}
};
@@ -11527,7 +11544,8 @@ main(int argc, char *argv[])
info->flag_compress = DUMP_DH_COMPRESSED_LZO;
break;
case OPT_MESSAGE_LEVEL:
- message_level = atoi(optarg);
+ if (!set_message_level(optarg))
+ goto out;
break;
case OPT_DUMP_DMESG:
info->flag_dmesg = 1;
@@ -11590,6 +11608,10 @@ main(int argc, char *argv[])
case OPT_NUM_THREADS:
info->num_threads = MAX(atoi(optarg), 0);
break;
+ case OPT_CHECK_PARAMS:
+ info->flag_check_params = TRUE;
+ message_level = DEFAULT_MSG_LEVEL;
+ break;
case '?':
MSG("Commandline parameter is invalid.\n");
MSG("Try `makedumpfile --help' for more information.\n");
@@ -11599,11 +11621,9 @@ main(int argc, char *argv[])
if (flag_debug)
message_level |= ML_PRINT_DEBUG_MSG;
- if (info->flag_excludevm && !info->working_dir) {
- ERRMSG("Error: -%c requires --work-dir\n", OPT_EXCLUDE_UNUSED_VM);
- ERRMSG("Try `makedumpfile --help' for more information\n");
- return COMPLETED;
- }
+ if (info->flag_check_params)
+ /* suppress debugging messages */
+ message_level = DEFAULT_MSG_LEVEL;
if (info->flag_show_usage) {
print_usage();
@@ -11634,6 +11654,9 @@ main(int argc, char *argv[])
MSG("Try `makedumpfile --help' for more information.\n");
goto out;
}
+ if (info->flag_check_params)
+ goto check_ok;
+
if (!open_files_for_generating_vmcoreinfo())
goto out;
@@ -11657,6 +11680,9 @@ main(int argc, char *argv[])
MSG("Try `makedumpfile --help' for more information.\n");
goto out;
}
+ if (info->flag_check_params)
+ goto check_ok;
+
if (!check_dump_file(info->name_dumpfile))
goto out;
@@ -11677,6 +11703,9 @@ main(int argc, char *argv[])
MSG("Try `makedumpfile --help' for more information.\n");
goto out;
}
+ if (info->flag_check_params)
+ goto check_ok;
+
if (!check_dump_file(info->name_dumpfile))
goto out;
@@ -11690,6 +11719,9 @@ main(int argc, char *argv[])
MSG("Try `makedumpfile --help' for more information.\n");
goto out;
}
+ if (info->flag_check_params)
+ goto check_ok;
+
if (!check_dump_file(info->name_dumpfile))
goto out;
if (!dump_dmesg())
@@ -11703,6 +11735,9 @@ main(int argc, char *argv[])
MSG("Try `makedumpfile --help' for more information.\n");
goto out;
}
+ if (info->flag_check_params)
+ goto check_ok;
+
if (!populate_kernel_version())
goto out;
@@ -11721,6 +11756,9 @@ main(int argc, char *argv[])
MSG("Try `makedumpfile --help' for more information.\n");
goto out;
}
+ if (info->flag_check_params)
+ goto check_ok;
+
if (info->flag_split) {
for (i = 0; i < info->num_dumpfile; i++) {
SPLITTING_FD_BITMAP(i) = -1;
@@ -11748,13 +11786,16 @@ main(int argc, char *argv[])
MSG("The dumpfile is saved to %s.\n", info->name_dumpfile);
}
}
+check_ok:
retcd = COMPLETED;
out:
- MSG("\n");
- if (retcd != COMPLETED)
- MSG("makedumpfile Failed.\n");
- else if (!info->flag_mem_usage)
- MSG("makedumpfile Completed.\n");
+ if (!info->flag_check_params) {
+ MSG("\n");
+ if (retcd != COMPLETED)
+ MSG("makedumpfile Failed.\n");
+ else if (!info->flag_mem_usage)
+ MSG("makedumpfile Completed.\n");
+ }
free_for_parallel();
diff --git a/makedumpfile-1.6.7/makedumpfile.h b/makedumpfile-1.6.7/makedumpfile.h
index 7217407..03fb4ce 100644
--- a/makedumpfile-1.6.7/makedumpfile.h
+++ b/makedumpfile-1.6.7/makedumpfile.h
@@ -1303,6 +1303,7 @@ struct DumpInfo {
int flag_read_vmcoreinfo; /* flag of reading vmcoreinfo file */
int flag_show_usage; /* flag of showing usage */
int flag_show_version; /* flag of showing version */
+ int flag_check_params; /* only check parameters */
int flag_flatten; /* flag of outputting flattened
format to a standard out */
int flag_rearrange; /* flag of creating dumpfile from
@@ -2364,6 +2365,7 @@ struct elf_prstatus {
#define OPT_WORKING_DIR OPT_START+15
#define OPT_NUM_THREADS OPT_START+16
#define OPT_PARTIAL_DMESG OPT_START+17
+#define OPT_CHECK_PARAMS OPT_START+18
/*
* Function Prototype.
diff --git a/makedumpfile-1.6.7/print_info.c b/makedumpfile-1.6.7/print_info.c
index 0be12ea..e0c38b4 100644
--- a/makedumpfile-1.6.7/print_info.c
+++ b/makedumpfile-1.6.7/print_info.c
@@ -321,6 +321,10 @@ print_usage(void)
MSG(" [-v]:\n");
MSG(" Show the version of makedumpfile.\n");
MSG("\n");
+ MSG(" [--check-params]:\n");
+ MSG(" Only check whether the command-line parameters are valid or not, and exit.\n");
+ MSG(" Preferable to be given as the first parameter.\n");
+ MSG("\n");
MSG(" VMLINUX:\n");
MSG(" This is a pathname to the first kernel's vmlinux.\n");
MSG(" This file must have the debug information of the first kernel to analyze\n");
--
2.24.1

View File

@ -1,76 +0,0 @@
From efa29d476996a20052be80878767cfe09e4b6224 Mon Sep 17 00:00:00 2001
From: Kairui Song <kasong@redhat.com>
Date: Wed, 29 Jan 2020 10:59:08 +0800
Subject: [PATCH] makedumpfile: Remove duplicated variable declarations
When building on Fedora 32, following error is observed:
/usr/bin/ld: erase_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:2010:
multiple definition of `crash_reserved_mem_nr'; elf_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:2010: first defined here
/usr/bin/ld: erase_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:2009:
multiple definition of `crash_reserved_mem'; elf_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:2009: first defined here
/usr/bin/ld: erase_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:1278:
multiple definition of `parallel_info_t'; elf_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:1278: first defined here
/usr/bin/ld: erase_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:1265:
multiple definition of `splitting_info_t'; elf_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:1265: first defined here
And apparently, these variables are wrongly declared multiple times. So
remove duplicated declaration.
Signed-off-by: Kairui Song <kasong@redhat.com>
---
makedumpfile.c | 2 ++
makedumpfile.h | 10 ++++++----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/makedumpfile.c b/makedumpfile.c
index e290fbd..9aad77b 100644
--- a/makedumpfile-1.6.7/makedumpfile.c
+++ b/makedumpfile-1.6.7/makedumpfile.c
@@ -34,6 +34,8 @@ struct array_table array_table;
struct number_table number_table;
struct srcfile_table srcfile_table;
struct save_control sc;
+struct parallel_info parallel_info_t;
+struct splitting_info splitting_info_t;
struct vm_table vt = { 0 };
struct DumpInfo *info = NULL;
diff --git a/makedumpfile.h b/makedumpfile.h
index 68d9691..614764c 100644
--- a/makedumpfile-1.6.7/makedumpfile.h
+++ b/makedumpfile-1.6.7/makedumpfile.h
@@ -1262,7 +1262,8 @@ struct splitting_info {
mdf_pfn_t end_pfn;
off_t offset_eraseinfo;
unsigned long size_eraseinfo;
-} splitting_info_t;
+};
+extern struct splitting_info splitting_info_t;
struct parallel_info {
int fd_memory;
@@ -1275,7 +1276,8 @@ struct parallel_info {
#ifdef USELZO
lzo_bytep wrkmem;
#endif
-} parallel_info_t;
+};
+extern struct parallel_info parallel_info_t;
struct ppc64_vmemmap {
unsigned long phys;
@@ -2006,8 +2008,8 @@ struct memory_range {
};
#define CRASH_RESERVED_MEM_NR 8
-struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR];
-int crash_reserved_mem_nr;
+extern struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR];
+extern int crash_reserved_mem_nr;
unsigned long read_vmcoreinfo_symbol(char *str_symbol);
int readmem(int type_addr, unsigned long long addr, void *bufptr, size_t size);
--
2.24.1

View File

@ -29,9 +29,9 @@
"kdumpctl": "425419fbb9c21d97ec50d61f2a13bb1ca4ed5a395553075322bd41f99180988a",
"kdumpctl.8": "025a39d212eed0584da7c23c1bb50d6ab797a0fa3c686ac6b80391af875dbaec",
"kexec-kdump-howto.txt": "e783390a9aa582a2b5e7981cd3277081385340b5873a3f0633c789811876eccb",
"kexec-tools-2.0.20.tar.xz": "dad8077f0315445d1f6335579fc4ade222facf82a67124974c7be5303ba4f8c8",
"kexec-tools-2.0.21.tar.xz": "e113142dee891638ad96e0f72cf9277b244477619470b30c41999d312e8e8702",
"live-image-kdump-howto.txt": "465a7ce28ecd9ff8f8c22ebfb17bbbafd01a52d81134be1203ee753856e4c37c",
"makedumpfile-1.6.7.tar.gz": "e702fbdf62b4cd829a76e46f3e24eb3fc7501918b85ebdcd8baef4f53d6ee2c8",
"makedumpfile-1.6.8.tar.gz": "85d79b7090e9a8ce0d426795d3bc1de2858def7e12954d9bc6ae03de160b694c",
"mkdumprd": "ebe0cbd1152d9db3333357e898685854c7667d4c6d9df4c79196ab1e7294dad2",
"mkdumprd.8": "c2e85b4f28cfda870a8d7b4dec656a0bc88895e4b138e9bc4cf756ff7f839bcf"
}

View File

@ -1,11 +1,11 @@
%global eppic_ver d84c3541035d95077aa8571f5d5c3e07c6ef510b
# First 7 digits from ^
%global eppic_shortver d84c354
%global mkdf_ver 1.6.7
%global mkdf_ver 1.6.8
Name: kexec-tools
Version: 2.0.20
Release: 16%{?dist}
Version: 2.0.21
Release: 1%{?dist}
License: GPLv2
Summary: The kexec/kdump userspace component
Vendor: Microsoft Corporation
@ -18,7 +18,7 @@ Source3: kdump.sysconfig.x86_64
Source4: kdump.sysconfig.i386
Source7: mkdumprd
Source8: kdump.conf
Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/%{mkdf_ver}/makedumpfile-%{mkdf_ver}.tar.gz
Source9: https://github.com/makedumpfile/makedumpfile/releases/download/%{mkdf_ver}/makedumpfile-%{mkdf_ver}.tar.gz
Source10: kexec-kdump-howto.txt
Source11: fadump-howto.txt
Source12: mkdumprd.8
@ -86,7 +86,6 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic
#
# Patches 0 through 100 are meant for x86 kexec-tools enablement
#
Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch
#
# Patches 101 through 200 are meant for x86_64 kexec-tools enablement
@ -106,10 +105,7 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch
#
# Patches 601 onward are generic patches
#
Patch601: ./kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch
Patch602: ./kexec-tools-2.0.20-makedumpfile-Remove-duplicated-variable-declarations.patch
Patch603: ./kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch
Patch604: ./kexec-tools-2.0.20-makedumpfile-Introduce-check-params-option.patch
Patch601: makedumpfile-printk-fix.patch
%description
kexec-tools provides /sbin/kexec binary that facilitates a new
@ -125,12 +121,7 @@ mkdir -p -m755 kcp
tar -z -x -v -f %{SOURCE9}
tar -z -x -v -f %{SOURCE19}
%patch0 -p1
%patch601 -p1
%patch602 -p1
%patch603 -p1
%patch604 -p1
%build
autoreconf
@ -331,6 +322,9 @@ done
/usr/share/makedumpfile/
%changelog
* Tue Feb 23 2021 Andrew Phelps <anphel@microsoft.com> 2.0.21-1
- Update version to 2.0.21
- Add patches for makedumpfile to support new printk in 5.10 kernel
* Sun Aug 09 2020 Mateusz Malisz <mamalisz@microsoft.com> 2.0.20-16
- Update configuration to fit CBL-Mariner naming and kernel configuration
- Remove PPC/s390x parts.

View File

@ -0,0 +1,608 @@
This patch is a combination of the following commits:
https://github.com/makedumpfile/makedumpfile/commit/c617ec63339222f3a44d73e36677a9acc8954ccd
https://github.com/makedumpfile/makedumpfile/commit/44b073b7ec467aee0d7de381d455b8ace1199184
diff -urN a/makedumpfile-1.6.8/dwarf_info.c b/makedumpfile-1.6.8/dwarf_info.c
--- a/makedumpfile-1.6.8/dwarf_info.c 2020-11-15 16:29:37.000000000 -0800
+++ b/makedumpfile-1.6.8/dwarf_info.c 2021-02-23 22:05:06.633885710 -0800
@@ -614,6 +614,7 @@
{
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 @@
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 @@
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;
@@ -1617,4 +1649,3 @@
/* check to see whether module debuginfo is available */
return search_module_debuginfo(os_release);
}
-
diff -urN a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c
--- a/makedumpfile-1.6.8/makedumpfile.c 2020-11-15 16:29:37.000000000 -0800
+++ b/makedumpfile-1.6.8/makedumpfile.c 2021-02-23 22:07:30.105141896 -0800
@@ -1555,6 +1555,7 @@
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 @@
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_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_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_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_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_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 @@
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");
@@ -11808,4 +11903,4 @@
free_elf_info();
return retcd;
-}
+}
\ No newline at end of file
diff -urN a/makedumpfile-1.6.8/makedumpfile.h b/makedumpfile-1.6.8/makedumpfile.h
--- a/makedumpfile-1.6.8/makedumpfile.h 2020-11-15 16:29:37.000000000 -0800
+++ b/makedumpfile-1.6.8/makedumpfile.h 2021-02-23 22:08:08.356964339 -0800
@@ -1317,6 +1317,7 @@
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 @@
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;
@@ -1690,6 +1692,13 @@
long printk_log;
/*
+ * for lockless printk ringbuffer
+ */
+ long printk_ringbuffer;
+ long prb_desc;
+ long printk_info;
+
+ /*
* for Xen extraction
*/
long page_info;
@@ -1865,6 +1874,52 @@
} 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
*/
struct mmu_psize_def_s {
@@ -2390,4 +2445,7 @@
int decimal(char *s, int count);
int file_exists(char *file);
-#endif /* MAKEDUMPFILE_H */
+int open_dump_file(void);
+int dump_lockless_dmesg(void);
+
+#endif /* MAKEDUMPFILE_H */
\ No newline at end of file
diff -urN a/makedumpfile-1.6.8/Makefile b/makedumpfile-1.6.8/Makefile
--- a/makedumpfile-1.6.8/Makefile 2020-11-15 16:29:37.000000000 -0800
+++ b/makedumpfile-1.6.8/Makefile 2021-02-23 22:02:53.910708569 -0800
@@ -45,7 +45,7 @@
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 -urN a/makedumpfile-1.6.8/printk.c b/makedumpfile-1.6.8/printk.c
--- a/makedumpfile-1.6.8/printk.c 1969-12-31 16:00:00.000000000 -0800
+++ b/makedumpfile-1.6.8/printk.c 2021-02-23 22:09:59.740488387 -0800
@@ -0,0 +1,241 @@
+#include "makedumpfile.h"
+#include <ctype.h>
+
+/* 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;
+};
+
+/*
+ * 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];
+ 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));
+ 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)) %
+ 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;
+}
\ No newline at end of file

View File

@ -755,8 +755,8 @@
"type": "other",
"other": {
"name": "crash",
"version": "7.2.8",
"downloadUrl": "https://github.com/crash-utility/crash/archive/7.2.8.tar.gz"
"version": "7.2.9",
"downloadUrl": "https://github.com/crash-utility/crash/archive/7.2.9.tar.gz"
}
}
},
@ -2065,8 +2065,8 @@
"type": "other",
"other": {
"name": "kexec-tools",
"version": "2.0.20",
"downloadUrl": "http://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.20.tar.xz"
"version": "2.0.21",
"downloadUrl": "http://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.21.tar.xz"
}
}
},
@ -3300,6 +3300,16 @@
}
}
},
{
"component": {
"type": "other",
"other": {
"name": "makedumpfile",
"version": "1.6.8",
"downloadUrl": "https://github.com/makedumpfile/makedumpfile/releases/download/1.6.8/makedumpfile-1.6.8.tar.gz"
}
}
},
{
"component": {
"type": "other",