[PATCH 5/8] seperate checking 64bit mem range

Yinghai Lu
2012-11-16T23:04:44Z

Acccording to start value to use right range.

So could avoid put range too high or too low.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
kexec/kexec.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/kexec/kexec.c b/kexec/kexec.c
index b8d77bb..aec3b9e 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -364,6 +364,7 @@ unsigned long add_buffer_phys_virt(struct kexec_info *info,
unsigned long base;
int result;
int pagesize;
+ unsigned long hole_min, hole_max;

result = sort_segments(info);
if (result < 0) {
@@ -374,11 +375,18 @@ unsigned long add_buffer_phys_virt(struct kexec_info *info,
pagesize = getpagesize();
memsz = (memsz + (pagesize - 1)) & ~(pagesize - 1);

- base = locate_hole(info, memsz, buf_align, buf_min, buf_max, buf_end);
- if (base == ULONG_MAX) {
- die("locate_hole failed\n");
+ if (buf_min < (1ULL<<32)) {
+ hole_min = max(buf_min, (unsigned long)mem_min);
+ hole_max = min(buf_max, (unsigned long)mem_max);
+ } else {
+ hole_min = max(buf_min, (unsigned long)mem64_min);
+ hole_max = min(buf_max, (unsigned long)mem64_max);
}
-
+
+ base = __locate_hole(info, memsz, buf_align, hole_min, hole_max, buf_end);
+ if (base == ULONG_MAX)
+ return 0;
+
add_segment_phys_virt(info, buf, bufsz, base, memsz, phys);
return base;
}
--
1.7.7