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

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