Blame SOURCES/kexec-tools-2.0.20-arm64-kdump-deal-with-a-lot-of-resource-entries-in-p.patch

f4cf83
From 2572b8d702e452624bdb8d7b7c39f458e7dcf2ce Mon Sep 17 00:00:00 2001
f4cf83
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
f4cf83
Date: Wed, 18 Dec 2019 11:42:32 -0500
f4cf83
Subject: [PATCH 3/3] arm64: kdump: deal with a lot of resource entries in
f4cf83
 /proc/iomem
f4cf83
f4cf83
As described in the commit ("arm64: kexec: allocate memory space avoiding
f4cf83
reserved regions"), /proc/iomem now has a lot of "reserved" entries, and
f4cf83
it's not just enough to have a fixed size of memory range array.
f4cf83
f4cf83
With this patch, kdump is allowed to handle arbitrary number of memory
f4cf83
ranges, using mem_regions_alloc_and_xxx() functions.
f4cf83
f4cf83
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
f4cf83
Tested-by: Bhupesh Sharma <bhsharma@redhat.com>
f4cf83
Tested-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
f4cf83
Signed-off-by: Simon Horman <horms@verge.net.au>
f4cf83
---
f4cf83
 kexec/arch/arm64/crashdump-arm64.c | 25 ++++++++++---------------
f4cf83
 1 file changed, 10 insertions(+), 15 deletions(-)
f4cf83
f4cf83
diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c
f4cf83
index 4fd7aa8fd43c..38d1a0f3000d 100644
f4cf83
--- a/kexec/arch/arm64/crashdump-arm64.c
f4cf83
+++ b/kexec/arch/arm64/crashdump-arm64.c
f4cf83
@@ -23,13 +23,8 @@
f4cf83
 #include "kexec-elf.h"
f4cf83
 #include "mem_regions.h"
f4cf83
 
f4cf83
-/* memory ranges on crashed kernel */
f4cf83
-static struct memory_range system_memory_ranges[CRASH_MAX_MEMORY_RANGES];
f4cf83
-static struct memory_ranges system_memory_rgns = {
f4cf83
-	.size = 0,
f4cf83
-	.max_size = CRASH_MAX_MEMORY_RANGES,
f4cf83
-	.ranges = system_memory_ranges,
f4cf83
-};
f4cf83
+/* memory ranges of crashed kernel */
f4cf83
+static struct memory_ranges system_memory_rgns;
f4cf83
 
f4cf83
 /* memory range reserved for crashkernel */
f4cf83
 struct memory_range crash_reserved_mem;
f4cf83
@@ -82,7 +77,7 @@ static uint64_t get_kernel_page_offset(void)
f4cf83
  *
f4cf83
  * This function is called once for each memory region found in /proc/iomem.
f4cf83
  * It locates system RAM and crashkernel reserved memory and places these to
f4cf83
- * variables, respectively, system_memory_ranges and crash_reserved_mem.
f4cf83
+ * variables, respectively, system_memory_rgns and usablemem_rgns.
f4cf83
  */
f4cf83
 
f4cf83
 static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
f4cf83
@@ -90,11 +85,11 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
f4cf83
 				unsigned long long length)
f4cf83
 {
f4cf83
 	if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0)
f4cf83
-		return mem_regions_add(&usablemem_rgns,
f4cf83
-				       base, length, RANGE_RAM);
f4cf83
+		return mem_regions_alloc_and_add(&usablemem_rgns,
f4cf83
+						base, length, RANGE_RAM);
f4cf83
 	else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0)
f4cf83
-		return mem_regions_add(&system_memory_rgns,
f4cf83
-				       base, length, RANGE_RAM);
f4cf83
+		return mem_regions_alloc_and_add(&system_memory_rgns,
f4cf83
+						base, length, RANGE_RAM);
f4cf83
 	else if (strncmp(str, KERNEL_CODE, strlen(KERNEL_CODE)) == 0)
f4cf83
 		elf_info.kern_paddr_start = base;
f4cf83
 	else if (strncmp(str, KERNEL_DATA, strlen(KERNEL_DATA)) == 0)
f4cf83
@@ -135,9 +130,9 @@ static int crash_get_memory_ranges(void)
f4cf83
 
f4cf83
 	dbgprint_mem_range("Reserved memory range", &crash_reserved_mem, 1);
f4cf83
 
f4cf83
-	if (mem_regions_exclude(&system_memory_rgns, &crash_reserved_mem)) {
f4cf83
-		fprintf(stderr,
f4cf83
-			"Error: Number of crash memory ranges excedeed the max limit\n");
f4cf83
+	if (mem_regions_alloc_and_exclude(&system_memory_rgns,
f4cf83
+						&crash_reserved_mem)) {
f4cf83
+		fprintf(stderr, "Cannot allocate memory for ranges\n");
f4cf83
 		return -ENOMEM;
f4cf83
 	}
f4cf83
 
f4cf83
-- 
f4cf83
2.7.4
f4cf83