summaryrefslogtreecommitdiff
path: root/kexec/kexec.c
diff options
context:
space:
mode:
authorVivek Goyal <vgoyal@in.ibm.com>2005-08-04 17:49:45 +0530
committerEric W. Biederman <ebiederm@xmission.com>2006-07-27 09:39:41 -0600
commit71b37c87c709970c62924c58fe436857d569fe80 (patch)
tree670b975f2894c1158273e1282399fb2da5cc00b8 /kexec/kexec.c
parente2ffd1d4de78a165c8b9a4540378d5783cc9109b (diff)
Align memsz before locate hole fix
o This patch fixes a problem reported on the platform where memory end is not page aligned. There kexec gives an error "Invalid memory segment". The problem has been identified by Aaron Klingaman. o Problem occurs when add_buffer() tries to add a buffer of size memsz which is not integral multiple of page size. Add buffer calls locate_hole() which returns successfully. Later add_buffer() calls add_segment() which in turn makes all segment sizes page aligned and then verifies if memory range is valid or not. This creates a problem if memory end is not page aligned and a buffer has been allocated on memory end boundary. Because memsz has been made page aligned after calling locate_buffer(), it might have crossed valid memory locations. o Problem is fixed by page aligning the memsz in add_buffer() before calling locate_hole(). Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com> Signed-off-by: Maneesh Soni <maneesh@in.ibm.com>
Diffstat (limited to 'kexec/kexec.c')
-rw-r--r--kexec/kexec.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/kexec/kexec.c b/kexec/kexec.c
index fd66e15..d6cca88 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -324,12 +324,17 @@ unsigned long add_buffer(struct kexec_info *info,
{
unsigned long base;
int result;
+ int pagesize;
result = sort_segments(info);
if (result < 0) {
die("sort_segments failed\n");
}
+ /* Round memsz up to a multiple of pagesize */
+ 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");