aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2010-10-04 17:57:39 -0400
committerH. Peter Anvin <hpa@zytor.com>2010-10-06 00:45:35 -0400
commitf1af98c7629a1b76fd7336decbc776acdeed2120 (patch)
tree4886c7d9469f147a5c3d0ece2c3aa5993ae77ae3
parent1d931264af0f10649b35afa8fbd2e169da51ac08 (diff)
memblock: Fix wraparound in find_region()
When trying to find huge range for crashkernel, get [ 0.000000] ------------[ cut here ]------------ [ 0.000000] WARNING: at arch/x86/mm/memblock.c:248 memblock_x86_reserve_range+0x40/0x7a() [ 0.000000] Hardware name: Sun Fire x4800 [ 0.000000] memblock_x86_reserve_range: wrong range [0xffffffff37000000, 0x137000000) [ 0.000000] Modules linked in: [ 0.000000] Pid: 0, comm: swapper Not tainted 2.6.36-rc5-tip-yh-01876-g1cac214-dirty #59 [ 0.000000] Call Trace: [ 0.000000] [<ffffffff82816f7e>] ? memblock_x86_reserve_range+0x40/0x7a [ 0.000000] [<ffffffff81078c2d>] warn_slowpath_common+0x85/0x9e [ 0.000000] [<ffffffff81078d38>] warn_slowpath_fmt+0x6e/0x70 [ 0.000000] [<ffffffff8281e77c>] ? memblock_find_region+0x40/0x78 [ 0.000000] [<ffffffff8281eb1f>] ? memblock_find_base+0x9a/0xb9 [ 0.000000] [<ffffffff82816f7e>] memblock_x86_reserve_range+0x40/0x7a [ 0.000000] [<ffffffff8280452c>] setup_arch+0x99d/0xb2a [ 0.000000] [<ffffffff810a3e02>] ? trace_hardirqs_off+0xd/0xf [ 0.000000] [<ffffffff81cec7d8>] ? _raw_spin_unlock_irqrestore+0x3d/0x4c [ 0.000000] [<ffffffff827ffcec>] start_kernel+0xde/0x3f1 [ 0.000000] [<ffffffff827ff2d4>] x86_64_start_reservations+0xa0/0xa4 [ 0.000000] [<ffffffff827ff3de>] x86_64_start_kernel+0x106/0x10d [ 0.000000] ---[ end trace a7919e7f17c0a725 ]--- [ 0.000000] Reserving 8192MB of memory at 17592186041200MB for crashkernel (System RAM: 526336MB) This is caused by a wraparound in the test due to size > end; explicitly check for this condition and fail. Signed-off-by: Yinghai Lu <yinghai@kernel.org> LKML-Reference: <4CAA4DD3.1080401@kernel.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--mm/memblock.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/mm/memblock.c b/mm/memblock.c
index d5d63ac1fd83..9ad39690a2bd 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -105,13 +105,18 @@ static phys_addr_t __init memblock_find_region(phys_addr_t start, phys_addr_t en
105 phys_addr_t base, res_base; 105 phys_addr_t base, res_base;
106 long j; 106 long j;
107 107
108 /* In case, huge size is requested */
109 if (end < size)
110 return MEMBLOCK_ERROR;
111
112 base = memblock_align_down((end - size), align);
113
108 /* Prevent allocations returning 0 as it's also used to 114 /* Prevent allocations returning 0 as it's also used to
109 * indicate an allocation failure 115 * indicate an allocation failure
110 */ 116 */
111 if (start == 0) 117 if (start == 0)
112 start = PAGE_SIZE; 118 start = PAGE_SIZE;
113 119
114 base = memblock_align_down((end - size), align);
115 while (start <= base) { 120 while (start <= base) {
116 j = memblock_overlaps_region(&memblock.reserved, base, size); 121 j = memblock_overlaps_region(&memblock.reserved, base, size);
117 if (j < 0) 122 if (j < 0)