From 99cfd107280dde3d851ca02f6422df9562b0c75a Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 21 Oct 2003 18:19:16 -0700 Subject: [PATCH] [PATCH] ia32 limit_regions update Sync this up with 2.4: ChangeSet@1.404.2.2 2002-05-06 21:30:10-03:00 hch@infradead.org [PATCH] memsetup fixes (again) The mem= fixes from Red Hat's tree had a small bug: if mem= was not actually used with the additional features, but int plain old way, is used the value as the size of memory it wants, not the upper limit. The problem with this is that there is a small difference due to memory holes. I had one report of a person using mem= to reduce memory size for a broken i386 chipset thaty only supports 64MB cached and the rest as mtd/slram device for swap. I got broken as the boundaries changed. --- arch/i386/kernel/setup.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c index 360159e33b236..0600b02a589a2 100644 --- a/arch/i386/kernel/setup.c +++ b/arch/i386/kernel/setup.c @@ -139,22 +139,23 @@ static void __init probe_roms(void) probe_extension_roms(roms); } -static void __init limit_regions (unsigned long long size) +static void __init limit_regions(unsigned long long size) { + unsigned long long current_addr = 0; int i; - unsigned long long current_size = 0; for (i = 0; i < e820.nr_map; i++) { if (e820.map[i].type == E820_RAM) { - current_size += e820.map[i].size; - if (current_size >= size) { - e820.map[i].size -= current_size-size; + current_addr = e820.map[i].addr + e820.map[i].size; + if (current_addr >= size) { + e820.map[i].size -= current_addr-size; e820.nr_map = i + 1; return; } } } } + static void __init add_memory_region(unsigned long long start, unsigned long long size, int type) { -- 2.53.0