aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2005-06-22 16:43:10 -0400
committerRussell King <rmk@dyn-67.arm.linux.org.uk>2005-06-22 16:43:10 -0400
commit3a66941106855215127f8bf1afd06099b72dc75b (patch)
tree69a0ebb1143bcd2732b4d6e013207e8613ebc5b7
parentb46a58fd4e3cdd107ffccedaa5e233deeb94c5c0 (diff)
[PATCH] ARM: Ensure memory information is page aligned
Ensure that meminfo.bank[] array contains page-aligned start/size information. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/kernel/setup.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 9fed5fa194d9..8cf733daa800 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -395,6 +395,20 @@ static void __init early_initrd(char **p)
395} 395}
396__early_param("initrd=", early_initrd); 396__early_param("initrd=", early_initrd);
397 397
398static void __init add_memory(unsigned long start, unsigned long size)
399{
400 /*
401 * Ensure that start/size are aligned to a page boundary.
402 * Size is appropriately rounded down, start is rounded up.
403 */
404 size -= start & ~PAGE_MASK;
405
406 meminfo.bank[meminfo.nr_banks].start = PAGE_ALIGN(start);
407 meminfo.bank[meminfo.nr_banks].size = size & PAGE_MASK;
408 meminfo.bank[meminfo.nr_banks].node = PHYS_TO_NID(start);
409 meminfo.nr_banks += 1;
410}
411
398/* 412/*
399 * Pick out the memory size. We look for mem=size@start, 413 * Pick out the memory size. We look for mem=size@start,
400 * where start and size are "size[KkMm]" 414 * where start and size are "size[KkMm]"
@@ -419,10 +433,7 @@ static void __init early_mem(char **p)
419 if (**p == '@') 433 if (**p == '@')
420 start = memparse(*p + 1, p); 434 start = memparse(*p + 1, p);
421 435
422 meminfo.bank[meminfo.nr_banks].start = start; 436 add_memory(start, size);
423 meminfo.bank[meminfo.nr_banks].size = size;
424 meminfo.bank[meminfo.nr_banks].node = PHYS_TO_NID(start);
425 meminfo.nr_banks += 1;
426} 437}
427__early_param("mem=", early_mem); 438__early_param("mem=", early_mem);
428 439
@@ -564,11 +575,7 @@ static int __init parse_tag_mem32(const struct tag *tag)
564 tag->u.mem.start, tag->u.mem.size / 1024); 575 tag->u.mem.start, tag->u.mem.size / 1024);
565 return -EINVAL; 576 return -EINVAL;
566 } 577 }
567 meminfo.bank[meminfo.nr_banks].start = tag->u.mem.start; 578 add_memory(tag->u.mem.start, tag->u.mem.size);
568 meminfo.bank[meminfo.nr_banks].size = tag->u.mem.size;
569 meminfo.bank[meminfo.nr_banks].node = PHYS_TO_NID(tag->u.mem.start);
570 meminfo.nr_banks += 1;
571
572 return 0; 579 return 0;
573} 580}
574 581