Blame SOURCES/kexec-tools-2.0.17-makedumpfile-sadump-fix-failure-of-reading-640-KB-ba.patch

893e0b
From d015e6df8bd320fbabcd98cc157acf655fc0851b Mon Sep 17 00:00:00 2001
893e0b
From: "Hatayama, Daisuke" <d.hatayama@jp.fujitsu.com>
893e0b
Date: Tue, 30 Oct 2018 02:47:22 +0000
893e0b
Subject: [PATCH] makedumpfile: sadump: fix failure of reading 640 KB backup
893e0b
 region if at over 4GB location
893e0b
893e0b
Currently, in function sadump_kdump_backup_region_init(), variable mem
893e0b
holding physical memory to read as a candidate of the ELF core header
893e0b
is of type unsigned int with just 4 byte length:
893e0b
893e0b
        for (i = 0; i < ARRAY_LENGTH(kimage.segment); ++i) {
893e0b
                char e_ident[EI_NIDENT];
893e0b
                unsigned mem;
893e0b
893e0b
                mem=ULONG(buf+i*SIZE(kexec_segment)+OFFSET(kexec_segment.mem));
893e0b
                if (!mem)
893e0b
                        continue;
893e0b
893e0b
                if (!readmem(PADDR, mem, e_ident, SELFMAG)) {
893e0b
                        DEBUG_MSG("sadump: failed to read elfcorehdr buffer\n");
893e0b
                        return;
893e0b
                }
893e0b
893e0b
Thus, if backup region for the first 640KB physical memory is located
893e0b
at over 4GB location thanks to crashkernel=size,high like:
893e0b
893e0b
    # grep crashkernel /proc/cmdline
893e0b
    BOOT_IMAGE=(hd0,gpt2)/vmlinuz-4.18 root=/dev/mapper/rhel-root ro crashkernel=512M,high
893e0b
893e0b
    # grep Crash /proc/iomem
893e0b
      06000000-15ffffff : Crash kernel
893e0b
      107f000000-109effffff : Crash kernel
893e0b
893e0b
    crash> rd -p 0x109ef5d000
893e0b
	  109ef5d000:  00010102464c457f                    .ELF....
893e0b
893e0b
the upper 32-bit of the physical address in mem variable is dropped
893e0b
and readmem() fails while outputting the following debug message:
893e0b
893e0b
    # LANG=C ./makedumpfile --message-level 8 -f -l -d 31 -x ./vmlinux /dev/sdc vmcore-ld31
893e0b
    sadump: read dump device as single partition
893e0b
    sadump: single partition configuration
893e0b
    page_size    : 4096
893e0b
    sadump: timezone information is missing
893e0b
    sadump: idtr=fffffe0000000000
893e0b
    sadump: cr3=86b42e000
893e0b
    sadump: idtr(phys)=4c35cc000
893e0b
    sadump: devide_error(vmlinux)=ffffffff81a00c50
893e0b
    sadump: devide_error(vmcore)=ffffffffa0c00c50
893e0b
    sadump: cmdline vaddr: ffffffffa1bcf008
893e0b
    sadump: cmdline paddr: 4c35cf008
893e0b
    sadump: cmdline buf vaddr: ffff8ae89ffceec0
893e0b
    sadump: cmdline buf paddr: 109ffceec0
893e0b
    sadump: kaslr_offset=1f200000
893e0b
    sadump: phys_base=4a1a00000
893e0b
    sadump: online cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 [...]
893e0b
    sadump: nr_cpus: 60
893e0b
893e0b
    sadump: failed to read elfcorehdr buffer <--- This is the debug message indicating
893e0b
                                                  reading ELF core header fails
893e0b
893e0b
Then, the generated vmcore has invalid data in its first 640KB part.
893e0b
893e0b
The variable mem needs to have type of 64-bit length.
893e0b
893e0b
With this patch, kdump backup region is successfully found as follows:
893e0b
893e0b
    # LANG=C ./makedumpfile --message-level 31 -f -l -d 31 -x ./vmlinux /dev/sdc vmcore-ld31
893e0b
    sadump: read dump device as single partition
893e0b
    sadump: single partition configuration
893e0b
    page_size    : 4096
893e0b
    sadump: timezone information is missing
893e0b
    sadump: idtr=fffffe0000000000
893e0b
    sadump: cr3=86b42e000
893e0b
    sadump: idtr(phys)=4c35cc000
893e0b
    sadump: devide_error(vmlinux)=ffffffff81a00c50
893e0b
    sadump: devide_error(vmcore)=ffffffffa0c00c50
893e0b
    sadump: cmdline vaddr: ffffffffa1bcf008
893e0b
    sadump: cmdline paddr: 4c35cf008
893e0b
    sadump: cmdline buf vaddr: ffff8ae89ffceec0
893e0b
    sadump: cmdline buf paddr: 109ffceec0
893e0b
    sadump: kaslr_offset=1f200000
893e0b
    sadump: phys_base=4a1a00000
893e0b
    sadump: online cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 [...]
893e0b
    sadump: nr_cpus: 60
893e0b
    The kernel version is not supported.
893e0b
    The makedumpfile operation may be incomplete.
893e0b
    sadump: SRC_START: 0x00000000001000 SRC_SIZE: 0x0000000009f000 SRC_OFFSET: 0x0000109ef61000
893e0b
    sadump: kdump backup region used
893e0b
    ...<snip>...
893e0b
893e0b
By the way, before crashkernel=size,high was introduced, there was
893e0b
limitation that ELF core header resides at under 4GB location, so
893e0b
defining it as unsigned int was not entirely wrong at that time.
893e0b
893e0b
Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
893e0b
---
893e0b
 sadump_info.c | 2 +-
893e0b
 1 file changed, 1 insertion(+), 1 deletion(-)
893e0b
893e0b
diff --git a/makedumpfile-1.6.4/sadump_info.c b/makedumpfile-1.6.4/sadump_info.c
893e0b
index 34b568c..46867ce 100644
893e0b
--- a/makedumpfile-1.6.4/sadump_info.c
893e0b
+++ b/makedumpfile-1.6.4/sadump_info.c
893e0b
@@ -2395,7 +2395,7 @@ sadump_kdump_backup_region_init(void)
893e0b
 	elfcorehdr_p = 0;
893e0b
 	for (i = 0; i < ARRAY_LENGTH(kimage.segment); ++i) {
893e0b
 		char e_ident[EI_NIDENT];
893e0b
-		unsigned mem;
893e0b
+		unsigned long mem;
893e0b
 
893e0b
 		mem=ULONG(buf+i*SIZE(kexec_segment)+OFFSET(kexec_segment.mem));
893e0b
 		if (!mem)
893e0b
-- 
893e0b
2.17.1
893e0b