diff options
Diffstat (limited to 'arch/x86/kernel/e820.c')
-rw-r--r-- | arch/x86/kernel/e820.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 269d367d2ace..a5383ae2cbe3 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -1056,7 +1056,7 @@ unsigned long __initdata end_user_pfn = MAX_ARCH_PFN; /* * Find the highest page frame number we have available */ -unsigned long __init e820_end(void) +static unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type) { int i; unsigned long last_pfn = 0; @@ -1064,12 +1064,21 @@ unsigned long __init e820_end(void) for (i = 0; i < e820.nr_map; i++) { struct e820entry *ei = &e820.map[i]; + unsigned long start_pfn; unsigned long end_pfn; - if (ei->type != E820_RAM) + if (ei->type != type) continue; + start_pfn = ei->addr >> PAGE_SHIFT; end_pfn = (ei->addr + ei->size) >> PAGE_SHIFT; + + if (start_pfn >= limit_pfn) + continue; + if (end_pfn > limit_pfn) { + last_pfn = limit_pfn; + break; + } if (end_pfn > last_pfn) last_pfn = end_pfn; } @@ -1083,7 +1092,15 @@ unsigned long __init e820_end(void) last_pfn, max_arch_pfn); return last_pfn; } +unsigned long __init e820_end_of_ram_pfn(void) +{ + return e820_end_pfn(MAX_ARCH_PFN, E820_RAM); +} +unsigned long __init e820_end_of_low_ram_pfn(void) +{ + return e820_end_pfn(1UL<<(32 - PAGE_SHIFT), E820_RAM); +} /* * Finds an active region in the address range from start_pfn to last_pfn and * returns its range in ei_startpfn and ei_endpfn for the e820 entry. @@ -1165,6 +1182,8 @@ static void early_panic(char *msg) panic(msg); } +static int userdef __initdata; + /* "mem=nopentium" disables the 4MB page tables. */ static int __init parse_memopt(char *p) { @@ -1180,17 +1199,15 @@ static int __init parse_memopt(char *p) } #endif + userdef = 1; mem_size = memparse(p, &p); end_user_pfn = mem_size>>PAGE_SHIFT; - e820_update_range(mem_size, ULLONG_MAX - mem_size, - E820_RAM, E820_RESERVED); + e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1); return 0; } early_param("mem", parse_memopt); -static int userdef __initdata; - static int __init parse_memmap_opt(char *p) { char *oldp; @@ -1206,7 +1223,7 @@ static int __init parse_memmap_opt(char *p) * the real mem size before original memory map is * reset. */ - saved_max_pfn = e820_end(); + saved_max_pfn = e820_end_of_ram_pfn(); #endif e820.nr_map = 0; userdef = 1; @@ -1230,8 +1247,7 @@ static int __init parse_memmap_opt(char *p) e820_add_region(start_at, mem_size, E820_RESERVED); } else { end_user_pfn = (mem_size >> PAGE_SHIFT); - e820_update_range(mem_size, ULLONG_MAX - mem_size, - E820_RAM, E820_RESERVED); + e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1); } return *p == '\0' ? 0 : -EINVAL; } |