File kdump-calibrate-top-down.patch of Package kdump

From: Petr Tesarik <ptesarik@suse.com>
Date: Fri Nov 6 10:10:43 2015 +0100
Subject: calibrate: Search memory ranges from top to bottom
References: bsc#952141
Patch-mainline: v.0.8.16
Git-commit: 8f86bf14fb3f7486cd3c0b58d86afdcb4f6bdc72

Crash area is allocated as high as possible by the kernel. This
should be reflected by the calibration code to make sure low memory
is allocated whenever necessary.

Signed-off-by: Petr Tesarik <ptesarik@suse.com>

---
 kdumptool/calibrate.cc |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

--- a/kdumptool/calibrate.cc
+++ b/kdumptool/calibrate.cc
@@ -863,14 +863,15 @@ unsigned long long MemMap::find(unsigned
     List::const_reverse_iterator it;
 
     for (it = m_ranges.rbegin(); it != m_ranges.rend(); ++it) {
-	MemRange::Addr start, end;
+	MemRange::Addr base = (*it)->end() + 1;
 
-	start = (*it)->start();
-	if ((start % align) != 0)
-	    start += align - (start % align);
-	end = (*it)->end();
-	if (start + size - 1 <= end)
-	    return start;
+	if (base < size)
+	    continue;
+
+	base -= size;
+	base -= base % align;
+	if (base >= (*it)->start())
+	    return base;
     }
 
     return ~0ULL;
openSUSE Build Service is sponsored by