]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[IA64] Merge overlapping reserved regions at boot
authorPetr Tesarik <ptesarik@suse.cz>
Tue, 29 Nov 2011 14:01:51 +0000 (15:01 +0100)
committerTony Luck <tony.luck@intel.com>
Fri, 9 Dec 2011 23:06:42 +0000 (15:06 -0800)
While working on the upcoming SLES11 SP2, I ran into an issue with booting the
panic kernel on a kernel crash. In the first iteration I found out that the
initial register backing store gets overwritten with zeroes, causing a kernel
crash shortly afterwards.

Further investigation revealed that rsvd_region[] contains overlapping
entries: find_memmap_space() returns a pointer which lies between KERNEL_START
and _end. This is correct with the EFI memmap as patched by the kexec
purgatory code. That code removes vmlinux LOAD segments from the usable map,
but there is a pretty large hole between the gate section and the per-cpu
section.

This happens because reserve_memory() blindly marks [KERNEL_START, __end]
as reserved, even though there is a free block in the middle in the kexec
case because it noticed a large gap between sections and modified the
efi_memory_map to account for this.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Signed-off-by: Tony Luck <tony.luck@intel.com>
arch/ia64/kernel/setup.c

index 5e2c72498c516322d14b293b81b4365593bff1d1..cd57d7312de0f597bb5a2a32f0db745ec8a67dbf 100644 (file)
@@ -220,6 +220,23 @@ sort_regions (struct rsvd_region *rsvd_region, int max)
        }
 }
 
+/* merge overlaps */
+static int __init
+merge_regions (struct rsvd_region *rsvd_region, int max)
+{
+       int i;
+       for (i = 1; i < max; ++i) {
+               if (rsvd_region[i].start >= rsvd_region[i-1].end)
+                       continue;
+               if (rsvd_region[i].end > rsvd_region[i-1].end)
+                       rsvd_region[i-1].end = rsvd_region[i].end;
+               --max;
+               memmove(&rsvd_region[i], &rsvd_region[i+1],
+                       (max - i) * sizeof(struct rsvd_region));
+       }
+       return max;
+}
+
 /*
  * Request address space for all standard resources
  */
@@ -270,6 +287,7 @@ static void __init setup_crashkernel(unsigned long total, int *n)
        if (ret == 0 && size > 0) {
                if (!base) {
                        sort_regions(rsvd_region, *n);
+                       *n = merge_regions(rsvd_region, *n);
                        base = kdump_find_rsvd_region(size,
                                        rsvd_region, *n);
                }
@@ -373,6 +391,7 @@ reserve_memory (void)
        BUG_ON(IA64_MAX_RSVD_REGIONS + 1 < n);
 
        sort_regions(rsvd_region, num_rsvd_regions);
+       num_rsvd_regions = merge_regions(rsvd_region, num_rsvd_regions);
 }