Blame SOURCES/kexec-tools-2.0.14-ppc64-Reduce-number-of-ELF-LOAD-segments.patch

23ef29
From f63d8530b9b6a2d7e79b946e326e5a2197eb8f87 Mon Sep 17 00:00:00 2001
23ef29
From: Petr Tesarik <ptesarik@suse.com>
23ef29
Date: Thu, 19 Jan 2017 18:37:09 +0100
23ef29
Subject: [PATCH] ppc64: Reduce number of ELF LOAD segments
23ef29
23ef29
The number of program header table entries (e_phnum) is an Elf64_Half,
23ef29
which is a 16-bit entity, i.e. the limit is 65534 entries (one entry is
23ef29
reserved for NOTE). This is a hard limit, defined by the ELF standard.
23ef29
It is possible that more LMBs (Logical Memory Blocks) are needed to
23ef29
represent all RAM on some machines, and this field overflows, causing
23ef29
an incomplete /proc/vmcore file.
23ef29
23ef29
This has actually happened on a machine with 31TB of RAM and an LMB size
23ef29
of 256MB.
23ef29
23ef29
However, since there is usually no memory hole between adjacent LMBs, the
23ef29
map can be "compressed", combining multiple adjacent into a single LOAD
23ef29
segment.
23ef29
23ef29
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
23ef29
Signed-off-by: Simon Horman <horms@verge.net.au>
23ef29
Signed-off-by: Pingfan Liu <piliu@redhat.com>
23ef29
---
23ef29
 kexec/arch/ppc64/crashdump-ppc64.c | 12 +++++++++++-
23ef29
 1 file changed, 11 insertions(+), 1 deletion(-)
23ef29
23ef29
diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c
23ef29
index b3c8928..f62b159 100644
23ef29
--- a/kexec/arch/ppc64/crashdump-ppc64.c
23ef29
+++ b/kexec/arch/ppc64/crashdump-ppc64.c
23ef29
@@ -123,6 +123,7 @@ static void exclude_crash_region(uint64_t start, uint64_t end)
23ef29
 static int get_dyn_reconf_crash_memory_ranges(void)
23ef29
 {
23ef29
 	uint64_t start, end;
23ef29
+	uint64_t startrange, endrange;
23ef29
 	char fname[128], buf[32];
23ef29
 	FILE *file;
23ef29
 	unsigned int i;
23ef29
@@ -137,6 +138,7 @@ static int get_dyn_reconf_crash_memory_ranges(void)
23ef29
 	}
23ef29
 
23ef29
 	fseek(file, 4, SEEK_SET);
23ef29
+	startrange = endrange = 0;
23ef29
 	for (i = 0; i < num_of_lmbs; i++) {
23ef29
 		if ((n = fread(buf, 1, 24, file)) < 0) {
23ef29
 			perror(fname);
23ef29
@@ -162,8 +164,16 @@ static int get_dyn_reconf_crash_memory_ranges(void)
23ef29
 		if ((flags & 0x80) || !(flags & 0x8))
23ef29
 			continue;
23ef29
 
23ef29
-		exclude_crash_region(start, end);
23ef29
+		if (start != endrange) {
23ef29
+			if (startrange != endrange)
23ef29
+				exclude_crash_region(startrange, endrange);
23ef29
+			startrange = start;
23ef29
+		}
23ef29
+		endrange = end;
23ef29
 	}
23ef29
+	if (startrange != endrange)
23ef29
+		exclude_crash_region(startrange, endrange);
23ef29
+
23ef29
 	fclose(file);
23ef29
 	return 0;
23ef29
 }
23ef29
-- 
23ef29
2.7.4
23ef29