diff --git a/SOURCES/kexec-tools-2.0.8-makedumpfile-sadump-Change-bit-order.patch b/SOURCES/kexec-tools-2.0.8-makedumpfile-sadump-Change-bit-order.patch new file mode 100644 index 0000000..1733991 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.8-makedumpfile-sadump-Change-bit-order.patch @@ -0,0 +1,149 @@ +From 5f15256acab27859ececcfda1b882e8c49597697 Mon Sep 17 00:00:00 2001 +From: HATAYAMA Daisuke +Date: Tue, 20 Oct 2015 16:08:01 +0900 +Subject: [PATCH 1/2] [PATCH 1/2] sadump: Change bit order. + +sadump formats associate each bit in a bitmap with a physical +page in reverse order with the kdump-compressed format. + +We had not detected this bug for considerably long term because +bitmaps in sadump formats consist mostly of 0x00 and 0xff excluding a +very limited amount of memory space for firmware. + +Signed-off-by: Takao Indoh +Signed-off-by: HATAYAMA Daisuke +--- + makedumpfile-1.5.7/sadump_info.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 73 insertions(+), 2 deletions(-) + +diff --git a/makedumpfile-1.5.7/sadump_info.c b/makedumpfile-1.5.7/sadump_info.c +index 23275e2..4740683 100644 +--- a/makedumpfile-1.5.7/sadump_info.c ++++ b/makedumpfile-1.5.7/sadump_info.c +@@ -85,6 +85,7 @@ struct sadump_info { + unsigned long long backup_offset; + int kdump_backed_up; + mdf_pfn_t max_mapnr; ++ struct dump_bitmap *ram_bitmap; + }; + + static char *guid_to_str(efi_guid_t *guid, char *buf, size_t buflen); +@@ -127,6 +128,35 @@ static int get_registers(int cpu, struct elf_prstatus *prstatus); + static struct sadump_info sadump_info = {}; + static struct sadump_info *si = &sadump_info; + ++static inline int ++sadump_is_on(char *bitmap, mdf_pfn_t i) ++{ ++ return bitmap[i >> 3] & (1 << (7 - (i & 7))); ++} ++ ++static inline int ++sadump_is_dumpable(struct dump_bitmap *bitmap, mdf_pfn_t pfn) ++{ ++ off_t offset; ++ ++ if (pfn == 0 || bitmap->no_block != pfn/PFN_BUFBITMAP) { ++ offset = bitmap->offset + BUFSIZE_BITMAP*(pfn/PFN_BUFBITMAP); ++ lseek(bitmap->fd, offset, SEEK_SET); ++ read(bitmap->fd, bitmap->buf, BUFSIZE_BITMAP); ++ if (pfn == 0) ++ bitmap->no_block = 0; ++ else ++ bitmap->no_block = pfn / PFN_BUFBITMAP; ++ } ++ return sadump_is_on(bitmap->buf, pfn % PFN_BUFBITMAP); ++} ++ ++static inline int ++sadump_is_ram(mdf_pfn_t pfn) ++{ ++ return sadump_is_dumpable(si->ram_bitmap, pfn); ++} ++ + int + check_and_get_sadump_header_info(char *filename) + { +@@ -161,6 +191,21 @@ check_and_get_sadump_header_info(char *filename) + return TRUE; + } + ++static void ++reverse_bit(char *buf, int len) ++{ ++ int i; ++ unsigned char c; ++ ++ for (i = 0; i < len; i++) { ++ c = buf[i]; ++ c = ((c & 0x55) << 1) | ((c & 0xaa) >> 1); /* Swap 1bit */ ++ c = ((c & 0x33) << 2) | ((c & 0xcc) >> 2); /* Swap 2bit */ ++ c = (c << 4) | (c >> 4); /* Swap 4bit */ ++ buf[i] = c; ++ } ++} ++ + int + sadump_copy_1st_bitmap_from_memory(void) + { +@@ -189,6 +234,14 @@ sadump_copy_1st_bitmap_from_memory(void) + info->name_memory, strerror(errno)); + return FALSE; + } ++ /* ++ * sadump formats associate each bit in a bitmap with ++ * a physical page in reverse order with the ++ * kdump-compressed format. We need to change bit ++ * order to reuse bitmaps in sadump formats in the ++ * kdump-compressed format. ++ */ ++ reverse_bit(buf, sizeof(buf)); + if (write(info->bitmap1->fd, buf, sizeof(buf)) != sizeof(buf)) { + ERRMSG("Can't write the bitmap(%s). %s\n", + info->bitmap1->file_name, strerror(errno)); +@@ -808,6 +861,19 @@ sadump_initialize_bitmap_memory(void) + info->bitmap_memory = bmp; + si->block_table = block_table; + ++ bmp = malloc(sizeof(struct dump_bitmap)); ++ if (bmp == NULL) { ++ ERRMSG("Can't allocate memory for the memory-bitmap. %s\n", ++ strerror(errno)); ++ return FALSE; ++ } ++ bmp->fd = info->fd_memory; ++ bmp->file_name = info->name_memory; ++ bmp->no_block = -1; ++ memset(bmp->buf, 0, BUFSIZE_BITMAP); ++ bmp->offset = si->sub_hdr_offset + sh->block_size * sh->sub_hdr_size; ++ si->ram_bitmap = bmp; ++ + return TRUE; + } + +@@ -977,7 +1043,12 @@ readpage_sadump(unsigned long long paddr, void *bufptr) + if (pfn >= si->max_mapnr) + return FALSE; + +- if (!is_dumpable(info->bitmap_memory, pfn)) { ++ if (!sadump_is_ram(pfn)) { ++ ERRMSG("pfn(%llx) is not ram.\n", pfn); ++ return FALSE; ++ } ++ ++ if (!sadump_is_dumpable(info->bitmap_memory, pfn)) { + ERRMSG("pfn(%llx) is excluded from %s.\n", pfn, + info->name_memory); + return FALSE; +@@ -1142,7 +1213,7 @@ pfn_to_block(mdf_pfn_t pfn) + block = 0; + + for (p = section * SADUMP_PF_SECTION_NUM; p < pfn; ++p) +- if (is_dumpable(info->bitmap_memory, p)) ++ if (sadump_is_dumpable(info->bitmap_memory, p)) + block++; + + return block; +-- +2.1.0 + diff --git a/SOURCES/kexec-tools-2.0.8-makedumpfile-sadump-Perform-explicit-zero-page-filterin.patch b/SOURCES/kexec-tools-2.0.8-makedumpfile-sadump-Perform-explicit-zero-page-filterin.patch new file mode 100644 index 0000000..ee4d0e8 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.8-makedumpfile-sadump-Perform-explicit-zero-page-filterin.patch @@ -0,0 +1,59 @@ +From 19b3a91646958089f8ce90ca518c8262bfc8ca88 Mon Sep 17 00:00:00 2001 +From: HATAYAMA Daisuke +Date: Tue, 20 Oct 2015 16:12:01 +0900 +Subject: [PATCH 2/2] [PATCH 2/2] sadump: Perform explicit zero page filtering. + +Currently, crash utility faces different behaviors on reading zero +pages that are filtered out on the kdump-compressed format originating +from kdump ELF and from sadump formats: the former succeeds in reading +zero pages but the latter fails. This is a design bug. To fix this +issue, perform zero pages filtering explicitly if some pages are +filtered out. + +Signed-off-by: Takao Indoh +Signed-off-by: HATAYAMA Daisuke +--- + makedumpfile-1.5.7/sadump_info.c | 20 +++++++++++++++++--- + 1 file changed, 17 insertions(+), 3 deletions(-) + +diff --git a/makedumpfile-1.5.7/sadump_info.c b/makedumpfile-1.5.7/sadump_info.c +index 4740683..20376f0 100644 +--- a/makedumpfile-1.5.7/sadump_info.c ++++ b/makedumpfile-1.5.7/sadump_info.c +@@ -874,6 +874,21 @@ sadump_initialize_bitmap_memory(void) + bmp->offset = si->sub_hdr_offset + sh->block_size * sh->sub_hdr_size; + si->ram_bitmap = bmp; + ++ /* ++ * Perform explicitly zero filtering. Without this processing ++ * crash utility faces different behaviors on reading zero ++ * pages that are filtered out on the kdump-compressed format ++ * originating from kdump ELF and from sadump formats: the ++ * former succeeds in reading zero pages but the latter fails. ++ */ ++ for (pfn = 0; pfn < si->max_mapnr; pfn++) { ++ if (sadump_is_ram(pfn) && ++ !sadump_is_dumpable(info->bitmap_memory, pfn)) { ++ info->dump_level |= DL_EXCLUDE_ZERO; ++ break; ++ } ++ } ++ + return TRUE; + } + +@@ -1049,9 +1064,8 @@ readpage_sadump(unsigned long long paddr, void *bufptr) + } + + if (!sadump_is_dumpable(info->bitmap_memory, pfn)) { +- ERRMSG("pfn(%llx) is excluded from %s.\n", pfn, +- info->name_memory); +- return FALSE; ++ memset(bufptr, 0, info->page_size); ++ return TRUE; + } + + block = pfn_to_block(pfn); +-- +2.1.0 + diff --git a/SPECS/kexec-tools.spec b/SPECS/kexec-tools.spec index f12a449..db8393a 100644 --- a/SPECS/kexec-tools.spec +++ b/SPECS/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.7 -Release: 38%{?dist} +Release: 38%{?dist}.1 License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component. @@ -125,6 +125,8 @@ Patch676: kexec-tools-2.0.8-makedumpfile-Add-tools-for-reading-and-writing-from- Patch677: kexec-tools-2.0.8-makedumpfile-Add-module-of-generating-table.patch Patch678: kexec-tools-2.0.8-makedumpfile-Add-module-of-calculating-start_pfn-and.patch Patch679: kexec-tools-2.0.8-makedumpfile-Add-support-for-splitblock-size.patch +Patch680: kexec-tools-2.0.8-makedumpfile-sadump-Change-bit-order.patch +Patch681: kexec-tools-2.0.8-makedumpfile-sadump-Perform-explicit-zero-page-filterin.patch # # Patch 701 through 800 are meant for kdump anaconda addon @@ -201,6 +203,8 @@ tar -z -x -v -f %{SOURCE25} %patch677 -p1 %patch678 -p1 %patch679 -p1 +%patch680 -p1 +%patch681 -p1 %ifarch ppc @@ -423,6 +427,9 @@ done %doc %changelog +* Fri Jan 15 2016 Minfei Huang - 2.0.7-38.1 +- Makedumpfile: Fix to copy some parts of memory in sadump vmcore formats + * Wed Oct 21 2015 Minfei Huang - 2.0.7-38 - pc64/ppc64le: drop cpu online rule in 40-redhat.rules in kdump initramfs