Delete several patches which have been merged into kexec-tools-2.0.4
Below patches were applied to kexec-tools-2.0.3, the latest kexec-tools-2.0.4 has included them. Delete them here. kexec-tools-2.0.3-Load-bzImages-smaller-than-32-KiB.patch kexec-tools-2.0.3-kdump-pass-acpi_rsdp-to-2nd-kernel-for-efi-booting.patch kexec-tools-2.0.3-ppc-exec-stack-fix.patch kexec-tools-2.0.3-ppc-ppc64-compile-purgatory-code-with-gcc-option-msoft-float.patch kexec-tools-2.0.3-vmcore-dmesg-Do-not-write-beyond-end-of-buffer.patch kexec-tools-2.0.3-vmcore-dmesg-vmcore-dmesg-Make-it-work-with-new-stru.patch
This commit is contained in:
parent
e1690e4f4c
commit
524483b592
@ -1,73 +0,0 @@
|
|||||||
From 0e4946bc3009e7b9ce6f9d792077eddd7e40cc14 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Eric Biggers <ebiggers3@gmail.com>
|
|
||||||
Date: Tue, 5 Jun 2012 19:46:07 -0400
|
|
||||||
Subject: [PATCH] Load bzImages smaller than 32 KiB
|
|
||||||
|
|
||||||
Allow bzImages smaller than 32KiB to be kexec'ed.
|
|
||||||
|
|
||||||
The current code will fail to load a bzImage smaller than 32768 bytes (sizeof
|
|
||||||
struct x86_linux_header), but the 'memdisk' program that comes with syslinux is
|
|
||||||
only about 26 KiB. This patch changes the minimum size to 1024 bytes (2
|
|
||||||
sectors), which appears to be the limit that syslinux enforces.
|
|
||||||
|
|
||||||
Removed the "tail" field of struct x86_linux_header because it doesn't seem to
|
|
||||||
actually be used (is there a reason for it?).
|
|
||||||
|
|
||||||
Also, note that bzImage_probe() was incorrectly using `sizeof (header)', even
|
|
||||||
though header is a pointer.
|
|
||||||
|
|
||||||
Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
|
|
||||||
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
||||||
---
|
|
||||||
include/x86/x86-linux.h | 2 --
|
|
||||||
kexec/arch/i386/kexec-bzImage.c | 7 +++++--
|
|
||||||
2 files changed, 5 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/x86/x86-linux.h b/include/x86/x86-linux.h
|
|
||||||
index 59d35c9..2ebcc3a 100644
|
|
||||||
--- a/include/x86/x86-linux.h
|
|
||||||
+++ b/include/x86/x86-linux.h
|
|
||||||
@@ -233,7 +233,6 @@ struct x86_linux_header {
|
|
||||||
uint32_t high_base; /* 0x24C */
|
|
||||||
uint32_t high_memsz; /* 0x250 */
|
|
||||||
uint32_t high_filesz; /* 0x254 */
|
|
||||||
- uint32_t tail[32*1024 - 0x258]; /* 0x258 */
|
|
||||||
#else
|
|
||||||
uint32_t kernel_alignment; /* 0x230 */
|
|
||||||
uint8_t relocatable_kernel; /* 0x234 */
|
|
||||||
@@ -241,7 +240,6 @@ struct x86_linux_header {
|
|
||||||
uint32_t cmdline_size; /* 0x238 */
|
|
||||||
uint32_t hardware_subarch; /* 0x23C */
|
|
||||||
uint64_t hardware_subarch_data; /* 0x240 */
|
|
||||||
- uint8_t tail[32*1024 - 0x248]; /* 0x248 */
|
|
||||||
#endif
|
|
||||||
} PACKED;
|
|
||||||
|
|
||||||
diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
|
|
||||||
index 54c4427..6998587 100644
|
|
||||||
--- a/kexec/arch/i386/kexec-bzImage.c
|
|
||||||
+++ b/kexec/arch/i386/kexec-bzImage.c
|
|
||||||
@@ -44,7 +44,10 @@ static const int probe_debug = 0;
|
|
||||||
int bzImage_probe(const char *buf, off_t len)
|
|
||||||
{
|
|
||||||
const struct x86_linux_header *header;
|
|
||||||
- if ((uintmax_t)len < (uintmax_t)sizeof(header)) {
|
|
||||||
+ if ((uintmax_t)len < (uintmax_t)(2 * 512)) {
|
|
||||||
+ if (probe_debug) {
|
|
||||||
+ fprintf(stderr, "File is too short to be a bzImage!\n");
|
|
||||||
+ }
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
header = (const struct x86_linux_header *)buf;
|
|
||||||
@@ -118,7 +121,7 @@ int do_bzImage_load(struct kexec_info *info,
|
|
||||||
/*
|
|
||||||
* Find out about the file I am about to load.
|
|
||||||
*/
|
|
||||||
- if ((uintmax_t)kernel_len < (uintmax_t)sizeof(setup_header)) {
|
|
||||||
+ if ((uintmax_t)kernel_len < (uintmax_t)(2 * 512)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
memcpy(&setup_header, kernel, sizeof(setup_header));
|
|
||||||
--
|
|
||||||
1.7.1
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
|||||||
From 75d1a16f0b4e5b33e91a51d93014f1fd8303f36e Mon Sep 17 00:00:00 2001
|
|
||||||
From: Dave Young <dyoung@redhat.com>
|
|
||||||
Date: Thu, 18 Oct 2012 11:16:08 +0800
|
|
||||||
Subject: [PATCH] kdump: pass acpi_rsdp= to 2nd kernel for efi booting
|
|
||||||
|
|
||||||
In case efi booting, kdump need kernel parameter acpi_rsdp= to retrieve
|
|
||||||
the acpi root table physical address.
|
|
||||||
|
|
||||||
Add a function cmdline_add_efi to get the address from /sys/firmware/efi/systab
|
|
||||||
If there's no such file or read fail the function will just do nothing.
|
|
||||||
|
|
||||||
Tested efi boot Fedora 17 on thinkpad T420.
|
|
||||||
|
|
||||||
Some background info for this issue:
|
|
||||||
http://lists.infradead.org/pipermail/kexec/2010-March/003889.html
|
|
||||||
|
|
||||||
[v1 -> v2]:
|
|
||||||
Address comments from Khalid and Simon
|
|
||||||
use fgets instead of read(2) to iterate the file
|
|
||||||
do not add 'noefi' because kexec does not construct EFI signature
|
|
||||||
in bootloader signature in boot_params, so kexec'd kernel will
|
|
||||||
disable EFI automatically even without noefi.
|
|
||||||
|
|
||||||
Signed-off-by: Dave Young <dyoung@redhat.com>
|
|
||||||
Reviewed-by: Khalid Aziz <khalid@gonehiking.org>
|
|
||||||
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
|
|
||||||
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
||||||
---
|
|
||||||
kexec/arch/i386/crashdump-x86.c | 35 +++++++++++++++++++++++++++++++++++
|
|
||||||
1 file changed, 35 insertions(+)
|
|
||||||
|
|
||||||
--- kexec-tools-2.0.3.orig/kexec/arch/i386/crashdump-x86.c
|
|
||||||
+++ kexec-tools-2.0.3/kexec/arch/i386/crashdump-x86.c
|
|
||||||
@@ -665,6 +665,40 @@ static int cmdline_add_memmap_acpi(char
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
+/* Appends 'acpi_rsdp=' commandline for efi boot crash dump */
|
|
||||||
+static void cmdline_add_efi(char *cmdline)
|
|
||||||
+{
|
|
||||||
+ FILE *fp;
|
|
||||||
+ int cmdlen, len;
|
|
||||||
+ char line[MAX_LINE], *s;
|
|
||||||
+ const char *acpis = " acpi_rsdp=";
|
|
||||||
+
|
|
||||||
+ fp = fopen("/sys/firmware/efi/systab", "r");
|
|
||||||
+ if (!fp)
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ while(fgets(line, sizeof(line), fp) != 0) {
|
|
||||||
+ /* ACPI20= always goes before ACPI= */
|
|
||||||
+ if ((strstr(line, "ACPI20=")) || (strstr(line, "ACPI="))) {
|
|
||||||
+ line[strlen(line) - 1] = '\0';
|
|
||||||
+ s = strchr(line, '=');
|
|
||||||
+ s += 1;
|
|
||||||
+ len = strlen(s) + strlen(acpis);
|
|
||||||
+ cmdlen = strlen(cmdline) + len;
|
|
||||||
+ if (cmdlen > (COMMAND_LINE_SIZE - 1))
|
|
||||||
+ die("Command line overflow\n");
|
|
||||||
+ strcat(cmdline, acpis);
|
|
||||||
+ strcat(cmdline, s);
|
|
||||||
+ dbgprintf("Command line after adding efi\n");
|
|
||||||
+ dbgprintf("%s\n", cmdline);
|
|
||||||
+
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ fclose(fp);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static void get_backup_area(unsigned long *start, unsigned long *end)
|
|
||||||
{
|
|
||||||
const char *iomem = proc_iomem();
|
|
||||||
@@ -838,6 +872,7 @@ int load_crashdump_segments(struct kexec
|
|
||||||
if (delete_memmap(memmap_p, elfcorehdr, memsz) < 0)
|
|
||||||
return -1;
|
|
||||||
cmdline_add_memmap(mod_cmdline, memmap_p);
|
|
||||||
+ cmdline_add_efi(mod_cmdline);
|
|
||||||
cmdline_add_elfcorehdr(mod_cmdline, elfcorehdr);
|
|
||||||
|
|
||||||
/* Inform second kernel about the presence of ACPI tables. */
|
|
@ -1,35 +0,0 @@
|
|||||||
Subject: [PATCH] ppc: exec stack fix
|
|
||||||
|
|
||||||
execstack shows ppc kexec has an executable stack,
|
|
||||||
this leaves it vulnerable to buffer overflows.
|
|
||||||
|
|
||||||
Fix it by adding ASFLAGS --noexecstack
|
|
||||||
|
|
||||||
Tested on PowerMac G4 Macmini:
|
|
||||||
Without the patch:
|
|
||||||
dave@darkstar:~/kexec-tools$ execstack build/sbin/kexec
|
|
||||||
X build/sbin/kexec
|
|
||||||
|
|
||||||
With the patch:
|
|
||||||
dave@darkstar:~/kexec-tools$ execstack build/sbin/kexec
|
|
||||||
- build/sbin/kexec
|
|
||||||
|
|
||||||
Signed-off-by: Dave Young <dyoung@redhat.com>
|
|
||||||
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
||||||
---
|
|
||||||
kexec/arch/ppc/Makefile | 2 ++
|
|
||||||
1 file changed, 2 insertions(+)
|
|
||||||
|
|
||||||
Index: kexec-tools-2.0.3/kexec/arch/ppc/Makefile
|
|
||||||
===================================================================
|
|
||||||
--- kexec-tools-2.0.3.orig/kexec/arch/ppc/Makefile
|
|
||||||
+++ kexec-tools-2.0.3/kexec/arch/ppc/Makefile
|
|
||||||
@@ -23,6 +23,8 @@ CPPFLAGS+=-I$(srcdir)/kexec/arch/$(ARCH)
|
|
||||||
|
|
||||||
ppc_KEXEC_SRCS += $(libfdt_SRCS)
|
|
||||||
|
|
||||||
+ASFLAGS += -Wa,--noexecstack
|
|
||||||
+
|
|
||||||
dist += kexec/arch/ppc/Makefile $(ppc_KEXEC_SRCS) \
|
|
||||||
kexec/arch/ppc/crashdump-powerpc.h kexec/arch/ppc/fixup_dtb.h \
|
|
||||||
kexec/arch/ppc/kexec-ppc.h kexec/arch/ppc/ops.h \
|
|
@ -1,43 +0,0 @@
|
|||||||
From: Vivek Goyal <vgoyal@redhat.com>
|
|
||||||
Recently we faced an issue on power7 machine where kernel hanged in purgatory.
|
|
||||||
Some investigation revealed that gcc is generating hardware FPU instructions.
|
|
||||||
I have been told we can't use it at this point of time and as kernel is
|
|
||||||
compiled with -msoft-float for ppc/ppc64, so should be purgatory (as it runs
|
|
||||||
inside kernel context).
|
|
||||||
|
|
||||||
Thanks to Jakub Jelinek and Lingzhu Xiang for debugging and coming up with
|
|
||||||
a fix for this issue.
|
|
||||||
|
|
||||||
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
|
|
||||||
Tested-by: Lingzhu Xiang <lxiang@redhat.com>
|
|
||||||
Tested-by: Suzuki K. Poulose <suzuki@in.ibm.com>
|
|
||||||
---
|
|
||||||
purgatory/arch/ppc/Makefile | 2 ++
|
|
||||||
purgatory/arch/ppc64/Makefile | 2 +-
|
|
||||||
2 files changed, 3 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
Index: kexec-tools/purgatory/arch/ppc64/Makefile
|
|
||||||
===================================================================
|
|
||||||
--- kexec-tools.orig/purgatory/arch/ppc64/Makefile 2012-02-20 14:45:25.000000000 -0500
|
|
||||||
+++ kexec-tools/purgatory/arch/ppc64/Makefile 2012-06-06 16:19:09.000696306 -0400
|
|
||||||
@@ -9,7 +9,7 @@ ppc64_PURGATORY_SRCS += purgatory/arch/p
|
|
||||||
ppc64_PURGATORY_SRCS += purgatory/arch/ppc64/crashdump_backup.c
|
|
||||||
ppc64_PURGATORY_SRCS += purgatory/arch/ppc64/misc.S
|
|
||||||
|
|
||||||
-ppc64_PURGATORY_EXTRA_CFLAGS += -m64 -mcall-aixdesc
|
|
||||||
+ppc64_PURGATORY_EXTRA_CFLAGS += -m64 -mcall-aixdesc -msoft-float
|
|
||||||
ppc64_PURGATORY_EXTRA_ASFLAGS += -m64 -mcall-aixdesc
|
|
||||||
ppc64_PURGATORY_EXTRA_LDFLAGS += -melf64ppc
|
|
||||||
|
|
||||||
Index: kexec-tools/purgatory/arch/ppc/Makefile
|
|
||||||
===================================================================
|
|
||||||
--- kexec-tools.orig/purgatory/arch/ppc/Makefile 2011-03-18 17:09:38.000000000 -0400
|
|
||||||
+++ kexec-tools/purgatory/arch/ppc/Makefile 2012-06-06 16:33:50.444406235 -0400
|
|
||||||
@@ -7,6 +7,8 @@ ppc_PURGATORY_SRCS += purgatory/arch/ppc
|
|
||||||
ppc_PURGATORY_SRCS += purgatory/arch/ppc/purgatory-ppc.c
|
|
||||||
ppc_PURGATORY_SRCS += purgatory/arch/ppc/console-ppc.c
|
|
||||||
|
|
||||||
+ppc_PURGATORY_EXTRA_CFLAGS += -msoft-float
|
|
||||||
+
|
|
||||||
dist += purgatory/arch/ppc/Makefile $(ppc_PURGATORY_SRCS) \
|
|
||||||
purgatory/arch/ppc/purgatory-ppc.h purgatory/arch/ppc/ppc_asm.h
|
|
@ -1,87 +0,0 @@
|
|||||||
From c96e7736d85e40685939011e6d51b3c0a28739a3 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Vivek Goyal <vgoyal@redhat.com>
|
|
||||||
Date: Wed, 18 Jul 2012 09:33:51 -0400
|
|
||||||
Subject: [PATCH] vmcore-dmesg: Do not write beyond end of buffer
|
|
||||||
|
|
||||||
scan_vmcoreinfo() currently assumes that every vmcoreinfo note line ends
|
|
||||||
with \n and overwrites new line with \0. But last entry in note, CRASHTIME=
|
|
||||||
does not end with \n and this leads to corrupting memory as we write beyond
|
|
||||||
end of buffer.
|
|
||||||
|
|
||||||
Normally things were fine but when I added some fields to vmcoreinfo, this
|
|
||||||
bug started showing and vmcore-dmesg started crashing.
|
|
||||||
|
|
||||||
I am planning to send a patch to fix this in kernel but it might be good
|
|
||||||
idea to handle this case in user space too so that vmcore-dmesg works
|
|
||||||
fine with cores of older kernels.
|
|
||||||
|
|
||||||
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
|
|
||||||
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
||||||
---
|
|
||||||
vmcore-dmesg/vmcore-dmesg.c | 29 ++++++++++++++++++++++++++++-
|
|
||||||
1 files changed, 28 insertions(+), 1 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
|
|
||||||
index 8518150..2e692de 100644
|
|
||||||
--- a/vmcore-dmesg/vmcore-dmesg.c
|
|
||||||
+++ b/vmcore-dmesg/vmcore-dmesg.c
|
|
||||||
@@ -14,6 +14,7 @@
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <elf.h>
|
|
||||||
+#include <stdbool.h>
|
|
||||||
|
|
||||||
/* The 32bit and 64bit note headers make it clear we don't care */
|
|
||||||
typedef Elf32_Nhdr Elf_Nhdr;
|
|
||||||
@@ -220,6 +221,9 @@ static void scan_vmcoreinfo(char *start, size_t size)
|
|
||||||
{
|
|
||||||
char *last = start + size - 1;
|
|
||||||
char *pos, *eol;
|
|
||||||
+ char temp_buf[1024];
|
|
||||||
+ bool last_line = false;
|
|
||||||
+
|
|
||||||
#define SYMBOL(sym) { \
|
|
||||||
.str = "SYMBOL(" #sym ")=", \
|
|
||||||
.name = #sym, \
|
|
||||||
@@ -243,7 +247,27 @@ static void scan_vmcoreinfo(char *start, size_t size)
|
|
||||||
/* Find the end of the current line */
|
|
||||||
for (eol = pos; (eol <= last) && (*eol != '\n') ; eol++)
|
|
||||||
;
|
|
||||||
- len = eol - pos + 1;
|
|
||||||
+ if (eol > last) {
|
|
||||||
+ /*
|
|
||||||
+ * We did not find \n and note ended. Currently kernel
|
|
||||||
+ * is appending last field CRASH_TIME without \n. It
|
|
||||||
+ * is ugly but handle it.
|
|
||||||
+ */
|
|
||||||
+ eol = last;
|
|
||||||
+ len = eol - pos + 1;
|
|
||||||
+ if (len >= sizeof(temp_buf))
|
|
||||||
+ len = sizeof(temp_buf) - 1;
|
|
||||||
+ strncpy(temp_buf, pos, len);
|
|
||||||
+ temp_buf[len + 1] = '\0';
|
|
||||||
+
|
|
||||||
+ pos = temp_buf;
|
|
||||||
+ len = len + 1;
|
|
||||||
+ eol = pos + len -1;
|
|
||||||
+ last_line = true;
|
|
||||||
+ } else {
|
|
||||||
+ len = eol - pos + 1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
/* Stomp the last character so I am guaranteed a terminating null */
|
|
||||||
*eol = '\0';
|
|
||||||
/* Copy OSRELEASE if I see it */
|
|
||||||
@@ -266,6 +290,9 @@ static void scan_vmcoreinfo(char *start, size_t size)
|
|
||||||
/* Remember the virtual address */
|
|
||||||
*symbol[i].vaddr = vaddr;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ if (last_line)
|
|
||||||
+ break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
1.7.1
|
|
||||||
|
|
@ -1,303 +0,0 @@
|
|||||||
From df88cab364cd1a3b8c992042d62efe5e350e6b2a Mon Sep 17 00:00:00 2001
|
|
||||||
From: Vivek Goyal <vgoyal@redhat.com>
|
|
||||||
Date: Mon, 30 Jul 2012 13:32:48 -0400
|
|
||||||
Subject: [PATCH] vmcore-dmesg: vmcore-dmesg: Make it work with new structured logging format
|
|
||||||
|
|
||||||
Now kernel has made kernel logging structured and exsisting vmcore-dmesg
|
|
||||||
does not work with this new format. Hence kernel version 3.5 is broken. In
|
|
||||||
3.6 now a kernel patch has been put which exports relevant fields. This
|
|
||||||
patch parses those fields and makes vmcore-dmesg work with new logging
|
|
||||||
format.
|
|
||||||
|
|
||||||
Currently it does not display log levels or dictionary. I personally think
|
|
||||||
that log levels are not very useful and it also requires additional kernel
|
|
||||||
patches so that log levels are not bitfields and relevant information is
|
|
||||||
exported to user space properly.
|
|
||||||
|
|
||||||
Concept of dictionary is new and relevant information is exported. One can
|
|
||||||
possibly enahnce vmcore-dmesg to also print dictionary contents based on
|
|
||||||
a user command line option.
|
|
||||||
|
|
||||||
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
|
|
||||||
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
||||||
---
|
|
||||||
vmcore-dmesg/vmcore-dmesg.c | 227 +++++++++++++++++++++++++++++++++++++++++-
|
|
||||||
1 files changed, 221 insertions(+), 6 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
|
|
||||||
index 2e692de..ff35740 100644
|
|
||||||
--- a/vmcore-dmesg/vmcore-dmesg.c
|
|
||||||
+++ b/vmcore-dmesg/vmcore-dmesg.c
|
|
||||||
@@ -15,6 +15,7 @@
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <elf.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
+#include <inttypes.h>
|
|
||||||
|
|
||||||
/* The 32bit and 64bit note headers make it clear we don't care */
|
|
||||||
typedef Elf32_Nhdr Elf_Nhdr;
|
|
||||||
@@ -29,6 +30,18 @@ static loff_t log_end_vaddr;
|
|
||||||
static loff_t log_buf_len_vaddr;
|
|
||||||
static loff_t logged_chars_vaddr;
|
|
||||||
|
|
||||||
+/* record format logs */
|
|
||||||
+static loff_t log_first_idx_vaddr;
|
|
||||||
+static loff_t log_next_idx_vaddr;
|
|
||||||
+
|
|
||||||
+/* struct log size */
|
|
||||||
+static uint64_t log_sz;
|
|
||||||
+
|
|
||||||
+/* struct log field offsets */
|
|
||||||
+static uint64_t log_offset_ts_nsec = UINT64_MAX;
|
|
||||||
+static uint16_t log_offset_len = UINT16_MAX;
|
|
||||||
+static uint16_t log_offset_text_len = UINT16_MAX;
|
|
||||||
+
|
|
||||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
||||||
#define ELFDATANATIVE ELFDATA2LSB
|
|
||||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
|
||||||
@@ -240,6 +253,8 @@ static void scan_vmcoreinfo(char *start, size_t size)
|
|
||||||
SYMBOL(log_end),
|
|
||||||
SYMBOL(log_buf_len),
|
|
||||||
SYMBOL(logged_chars),
|
|
||||||
+ SYMBOL(log_first_idx),
|
|
||||||
+ SYMBOL(log_next_idx),
|
|
||||||
};
|
|
||||||
|
|
||||||
for (pos = start; pos <= last; pos = eol + 1) {
|
|
||||||
@@ -291,6 +306,20 @@ static void scan_vmcoreinfo(char *start, size_t size)
|
|
||||||
*symbol[i].vaddr = vaddr;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ /* Check for "SIZE(log)=" */
|
|
||||||
+ if (memcmp("SIZE(log)=", pos, 10) == 0)
|
|
||||||
+ log_sz = strtoull(pos + 10, NULL, 10);
|
|
||||||
+
|
|
||||||
+ /* Check for struct log field offsets */
|
|
||||||
+ if (memcmp("OFFSET(log.ts_nsec)=", pos, 20) == 0)
|
|
||||||
+ log_offset_ts_nsec = strtoull(pos + 20, NULL, 10);
|
|
||||||
+
|
|
||||||
+ if (memcmp("OFFSET(log.len)=", pos, 16) == 0)
|
|
||||||
+ log_offset_len = strtoul(pos + 16, NULL, 10);
|
|
||||||
+
|
|
||||||
+ if (memcmp("OFFSET(log.text_len)=", pos, 21) == 0)
|
|
||||||
+ log_offset_text_len = strtoul(pos + 21, NULL, 10);
|
|
||||||
+
|
|
||||||
if (last_line)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
@@ -400,7 +429,19 @@ static int32_t read_file_s32(int fd, uint64_t addr)
|
|
||||||
return read_file_u32(fd, addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void dump_dmesg(int fd)
|
|
||||||
+static void write_to_stdout(char *buf, unsigned int nr)
|
|
||||||
+{
|
|
||||||
+ ssize_t ret;
|
|
||||||
+
|
|
||||||
+ ret = write(STDOUT_FILENO, buf, nr);
|
|
||||||
+ if (ret != nr) {
|
|
||||||
+ fprintf(stderr, "Failed to write out the dmesg log buffer!:"
|
|
||||||
+ " %s\n", strerror(errno));
|
|
||||||
+ exit(54);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void dump_dmesg_legacy(int fd)
|
|
||||||
{
|
|
||||||
uint64_t log_buf, log_buf_offset;
|
|
||||||
unsigned log_end, logged_chars, log_end_wrapped;
|
|
||||||
@@ -455,12 +496,186 @@ static void dump_dmesg(int fd)
|
|
||||||
strerror(errno));
|
|
||||||
exit(53);
|
|
||||||
}
|
|
||||||
- ret = write(STDOUT_FILENO, buf + (log_buf_len - logged_chars), logged_chars);
|
|
||||||
- if (ret != logged_chars) {
|
|
||||||
- fprintf(stderr, "Failed to write out the dmesg log buffer!: %s\n",
|
|
||||||
- strerror(errno));
|
|
||||||
- exit(54);
|
|
||||||
+
|
|
||||||
+ write_to_stdout(buf + (log_buf_len - logged_chars), logged_chars);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static inline uint16_t struct_val_u16(char *ptr, unsigned int offset)
|
|
||||||
+{
|
|
||||||
+ return(file16_to_cpu(*(uint16_t *)(ptr + offset)));
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static inline uint32_t struct_val_u32(char *ptr, unsigned int offset)
|
|
||||||
+{
|
|
||||||
+ return(file32_to_cpu(*(uint32_t *)(ptr + offset)));
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static inline uint32_t struct_val_u64(char *ptr, unsigned int offset)
|
|
||||||
+{
|
|
||||||
+ return(file64_to_cpu(*(uint64_t *)(ptr + offset)));
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* human readable text of the record */
|
|
||||||
+static char *log_text(char *msg)
|
|
||||||
+{
|
|
||||||
+ return msg + log_sz;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* get record by index; idx must point to valid msg */
|
|
||||||
+static char *log_from_idx(char *log_buf, uint32_t idx)
|
|
||||||
+{
|
|
||||||
+ char *msg = log_buf + idx;
|
|
||||||
+
|
|
||||||
+ /*
|
|
||||||
+ * A length == 0 record is the end of buffer marker. Wrap around and
|
|
||||||
+ * read the message at the start of the buffer.
|
|
||||||
+ */
|
|
||||||
+ if (!struct_val_u16(msg, log_offset_len))
|
|
||||||
+ return log_buf;
|
|
||||||
+ return msg;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* get next record; idx must point to valid msg */
|
|
||||||
+static uint32_t log_next(char *log_buf, uint32_t idx)
|
|
||||||
+{
|
|
||||||
+ char *msg = log_buf + idx;
|
|
||||||
+ uint16_t len;
|
|
||||||
+
|
|
||||||
+ /* length == 0 indicates the end of the buffer; wrap */
|
|
||||||
+ /*
|
|
||||||
+ * A length == 0 record is the end of buffer marker. Wrap around and
|
|
||||||
+ * read the message at the start of the buffer as *this* one, and
|
|
||||||
+ * return the one after that.
|
|
||||||
+ */
|
|
||||||
+ len = struct_val_u16(msg, log_offset_len);
|
|
||||||
+ if (!len) {
|
|
||||||
+ msg = log_buf;
|
|
||||||
+ return struct_val_u16(msg, log_offset_len);
|
|
||||||
+ }
|
|
||||||
+ return idx + len;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* Read headers of log records and dump accordingly */
|
|
||||||
+static void dump_dmesg_structured(int fd)
|
|
||||||
+{
|
|
||||||
+#define OUT_BUF_SIZE 4096
|
|
||||||
+ uint64_t log_buf, log_buf_offset, ts_nsec;
|
|
||||||
+ uint32_t log_first_idx, log_next_idx, current_idx, len = 0, i;
|
|
||||||
+ int log_buf_len;
|
|
||||||
+ char *buf, out_buf[OUT_BUF_SIZE];
|
|
||||||
+ ssize_t ret;
|
|
||||||
+ char *msg;
|
|
||||||
+ uint16_t text_len;
|
|
||||||
+ imaxdiv_t imaxdiv_sec, imaxdiv_usec;
|
|
||||||
+
|
|
||||||
+ if (!log_buf_vaddr) {
|
|
||||||
+ fprintf(stderr, "Missing the log_buf symbol\n");
|
|
||||||
+ exit(60);
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ if (!log_buf_len_vaddr) {
|
|
||||||
+ fprintf(stderr, "Missing the log_bug_len symbol\n");
|
|
||||||
+ exit(61);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (!log_first_idx_vaddr) {
|
|
||||||
+ fprintf(stderr, "Missing the log_first_idx symbol\n");
|
|
||||||
+ exit(62);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (!log_next_idx_vaddr) {
|
|
||||||
+ fprintf(stderr, "Missing the log_next_idx symbol\n");
|
|
||||||
+ exit(63);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (!log_sz) {
|
|
||||||
+ fprintf(stderr, "Missing the struct log size export\n");
|
|
||||||
+ exit(64);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (log_offset_ts_nsec == UINT64_MAX) {
|
|
||||||
+ fprintf(stderr, "Missing the log.ts_nsec offset export\n");
|
|
||||||
+ exit(65);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (log_offset_len == UINT16_MAX) {
|
|
||||||
+ fprintf(stderr, "Missing the log.len offset export\n");
|
|
||||||
+ exit(66);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (log_offset_text_len == UINT16_MAX) {
|
|
||||||
+ fprintf(stderr, "Missing the log.text_len offset export\n");
|
|
||||||
+ exit(67);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ log_buf = read_file_pointer(fd, vaddr_to_offset(log_buf_vaddr));
|
|
||||||
+ log_buf_len = read_file_s32(fd, vaddr_to_offset(log_buf_len_vaddr));
|
|
||||||
+
|
|
||||||
+ log_first_idx = read_file_u32(fd, vaddr_to_offset(log_first_idx_vaddr));
|
|
||||||
+ log_next_idx = read_file_u32(fd, vaddr_to_offset(log_next_idx_vaddr));
|
|
||||||
+
|
|
||||||
+ log_buf_offset = vaddr_to_offset(log_buf);
|
|
||||||
+
|
|
||||||
+ buf = calloc(1, log_buf_len);
|
|
||||||
+ if (!buf) {
|
|
||||||
+ fprintf(stderr, "Failed to malloc %d bytes for the logbuf:"
|
|
||||||
+ " %s\n", log_buf_len, strerror(errno));
|
|
||||||
+ exit(64);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ ret = pread(fd, buf, log_buf_len, log_buf_offset);
|
|
||||||
+ if (ret != log_buf_len) {
|
|
||||||
+ fprintf(stderr, "Failed to read log buffer of size %d bytes:"
|
|
||||||
+ " %s\n", log_buf_len, strerror(errno));
|
|
||||||
+ exit(65);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* Parse records and write out data at standard output */
|
|
||||||
+
|
|
||||||
+ current_idx = log_first_idx;
|
|
||||||
+ len = 0;
|
|
||||||
+ while (current_idx != log_next_idx) {
|
|
||||||
+ msg = log_from_idx(buf, current_idx);
|
|
||||||
+ ts_nsec = struct_val_u64(msg, log_offset_ts_nsec);
|
|
||||||
+ imaxdiv_sec = imaxdiv(ts_nsec, 1000000000);
|
|
||||||
+ imaxdiv_usec = imaxdiv(imaxdiv_sec.rem, 1000);
|
|
||||||
+
|
|
||||||
+ len += sprintf(out_buf + len, "[%5llu.%06llu] ",
|
|
||||||
+ (long long unsigned int)imaxdiv_sec.quot,
|
|
||||||
+ (long long unsigned int)imaxdiv_usec.quot);
|
|
||||||
+
|
|
||||||
+ /* escape non-printable characters */
|
|
||||||
+ text_len = struct_val_u16(msg, log_offset_text_len);
|
|
||||||
+ for (i = 0; i < text_len; i++) {
|
|
||||||
+ unsigned char c = log_text(msg)[i];
|
|
||||||
+
|
|
||||||
+ if (c < ' ' || c >= 128)
|
|
||||||
+ len += sprintf(out_buf + len, "\\x%02x", c);
|
|
||||||
+ else
|
|
||||||
+ out_buf[len++] = c;
|
|
||||||
+
|
|
||||||
+ if (len >= OUT_BUF_SIZE - 16) {
|
|
||||||
+ write_to_stdout(out_buf, len);
|
|
||||||
+ len = 0;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ out_buf[len++] = '\n';
|
|
||||||
+
|
|
||||||
+ /* Move to next record */
|
|
||||||
+ current_idx = log_next(buf, current_idx);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (len)
|
|
||||||
+ write_to_stdout(out_buf, len);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void dump_dmesg(int fd)
|
|
||||||
+{
|
|
||||||
+ if (log_first_idx_vaddr)
|
|
||||||
+ dump_dmesg_structured(fd);
|
|
||||||
+ else
|
|
||||||
+ dump_dmesg_legacy(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
--
|
|
||||||
1.7.1
|
|
||||||
|
|
@ -51,8 +51,6 @@ Obsoletes: diskdumputils netdump
|
|||||||
#
|
#
|
||||||
# Patches 0 through 100 are meant for x86 kexec-tools enablement
|
# Patches 0 through 100 are meant for x86 kexec-tools enablement
|
||||||
#
|
#
|
||||||
Patch001: kexec-tools-2.0.3-Load-bzImages-smaller-than-32-KiB.patch
|
|
||||||
Patch002: kexec-tools-2.0.3-kdump-pass-acpi_rsdp-to-2nd-kernel-for-efi-booting.patch
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Patches 101 through 200 are meant for x86_64 kexec-tools enablement
|
# Patches 101 through 200 are meant for x86_64 kexec-tools enablement
|
||||||
@ -65,7 +63,6 @@ Patch002: kexec-tools-2.0.3-kdump-pass-acpi_rsdp-to-2nd-kernel-for-efi-booting.p
|
|||||||
#
|
#
|
||||||
# Patches 301 through 400 are meant for ppc64 kexec-tools enablement
|
# Patches 301 through 400 are meant for ppc64 kexec-tools enablement
|
||||||
#
|
#
|
||||||
Patch301: kexec-tools-2.0.3-ppc-ppc64-compile-purgatory-code-with-gcc-option-msoft-float.patch
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Patches 401 through 500 are meant for s390 kexec-tools enablement
|
# Patches 401 through 500 are meant for s390 kexec-tools enablement
|
||||||
@ -73,14 +70,11 @@ Patch301: kexec-tools-2.0.3-ppc-ppc64-compile-purgatory-code-with-gcc-option-mso
|
|||||||
#
|
#
|
||||||
# Patches 501 through 600 are meant for ppc kexec-tools enablement
|
# Patches 501 through 600 are meant for ppc kexec-tools enablement
|
||||||
#
|
#
|
||||||
Patch501: kexec-tools-2.0.3-ppc-exec-stack-fix.patch
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Patches 601 onward are generic patches
|
# Patches 601 onward are generic patches
|
||||||
#
|
#
|
||||||
Patch601: kexec-tools-2.0.3-disable-kexec-test.patch
|
Patch601: kexec-tools-2.0.3-disable-kexec-test.patch
|
||||||
Patch602: kexec-tools-2.0.3-vmcore-dmesg-Do-not-write-beyond-end-of-buffer.patch
|
|
||||||
Patch603: kexec-tools-2.0.3-vmcore-dmesg-vmcore-dmesg-Make-it-work-with-new-stru.patch
|
|
||||||
Patch604: kexec-tools-2.0.3-build-makedumpfile-eppic-shared-object.patch
|
Patch604: kexec-tools-2.0.3-build-makedumpfile-eppic-shared-object.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -110,13 +104,7 @@ tar -z -x -v -f %{SOURCE9}
|
|||||||
tar -z -x -v -f %{SOURCE19}
|
tar -z -x -v -f %{SOURCE19}
|
||||||
|
|
||||||
|
|
||||||
%patch001 -p1
|
|
||||||
%patch002 -p1
|
|
||||||
%patch301 -p1
|
|
||||||
%patch501 -p1
|
|
||||||
%patch601 -p1
|
%patch601 -p1
|
||||||
%patch602 -p1
|
|
||||||
%patch603 -p1
|
|
||||||
%patch604 -p1
|
%patch604 -p1
|
||||||
|
|
||||||
tar -z -x -v -f %{SOURCE13}
|
tar -z -x -v -f %{SOURCE13}
|
||||||
|
Loading…
Reference in New Issue
Block a user