Commit-ID: 4b05c392955458757790414bd7ba4280e1a515b0 Gitweb: http://git.kernel.org/tip/4b05c392955458757790414bd7ba4280e1a515b0 Author: Yinghai Lu <yinghai@xxxxxxxxxx> AuthorDate: Thu, 2 Jul 2009 11:10:56 -0700 Committer: H. Peter Anvin <hpa@xxxxxxxxx> CommitDate: Thu, 2 Jul 2009 11:53:15 -0700 x86: add boundary check for 32bit res before expand e820 resource to alignment Avoid incorrect address arithmetic, ascerbated by previous improper definition of the round_up() macro. fix hang with HIGHMEM_64G and 32bit resource. according to hpa and Linus, use (resource_size_t)-1 to fend off big ranges. analyized by hpa Alex found: for i386 machine the specjbb2005 still can not run with hugepage -v2: it also fix hugepage problem Reported-and-tested-by: Mikael Pettersson <mikpe@xxxxxxxx> Reported-and-Tested-by: Alex Shi <alex.shi@xxxxxxxxx> Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx> Signed-off-by: H. Peter Anvin <hpa@xxxxxxxxx> --- arch/x86/kernel/e820.c | 20 ++++++++++++-------- 1 files changed, 12 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 7271fa3..98e1f1c 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -1367,9 +1367,9 @@ void __init e820_reserve_resources(void) } /* How much should we pad RAM ending depending on where it is? */ -static unsigned long ram_alignment(resource_size_t pos) +static u64 ram_alignment(u64 pos) { - unsigned long mb = pos >> 20; + u64 mb = pos >> 20; /* To 64kB in the first megabyte */ if (!mb) @@ -1383,6 +1383,8 @@ static unsigned long ram_alignment(resource_size_t pos) return 32*1024*1024; } +#define MAX_RESOURCE_SIZE ((resource_size_t)-1) + void __init e820_reserve_resources_late(void) { int i; @@ -1400,17 +1402,19 @@ void __init e820_reserve_resources_late(void) * avoid stolen RAM: */ for (i = 0; i < e820.nr_map; i++) { - struct e820entry *entry = &e820_saved.map[i]; - resource_size_t start, end; + struct e820entry *entry = &e820.map[i]; + u64 start, end; if (entry->type != E820_RAM) continue; start = entry->addr + entry->size; - end = round_up(start, ram_alignment(start)); - if (start == end) + end = round_up(start, ram_alignment(start)) - 1; + if (end > MAX_RESOURCE_SIZE) + end = MAX_RESOURCE_SIZE; + if (start > end) continue; - reserve_region_with_split(&iomem_resource, start, - end - 1, "RAM buffer"); + reserve_region_with_split(&iomem_resource, start, end, + "RAM buffer"); } } -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html