diff options
author | Vladimir Berezniker <vmpn@hitechman.com> | 2008-01-30 07:30:46 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:30:46 -0500 |
commit | b3ca74a2bfc66262d21443b160815eb26d6699e6 (patch) | |
tree | a2e6e99b7c650e7275958992d5fecabbc2243afa | |
parent | efd1ca52d04d2f6df337a3332cee56cd60e6d4c4 (diff) |
x86: sanitize user specified e820 memmap values
Sanitize user specified e820 memory ranges, using the same logic that is
applied to the values returned by the BIOS. This ensures consistent
handling regardless of the source of the memory mappings.
Allows overriding portions of the memory map without specifying one in
it's entirety (memmap=exactmap).
E.g. marking a range of bad RAM as reserved with memmap=48M$528M
BIOS supplied range
BIOS-e820: 0000000000100000 - 000000007fe80000 (usable)
becomes
user: 0000000000100000 - 0000000021000000 (usable)
user: 0000000021000000 - 0000000024000000 (reserved)
user: 0000000024000000 - 000000007fe80000 (usable)
Previously this did not work, as the original BIOS range was left
untouched while the user defined range was appended to the end of the
memory map.
[ tglx: arch/x86 adaptation ]
Signed-off-by: Vladimir Berezniker <vmpn@hitechman.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/x86/kernel/e820_64.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/x86/kernel/e820_64.c b/arch/x86/kernel/e820_64.c index 151236896243..8e7321101a0a 100644 --- a/arch/x86/kernel/e820_64.c +++ b/arch/x86/kernel/e820_64.c | |||
@@ -691,6 +691,8 @@ static int __init parse_memmap_opt(char *p) | |||
691 | mem_size = memparse(p, &p); | 691 | mem_size = memparse(p, &p); |
692 | if (p == oldp) | 692 | if (p == oldp) |
693 | return -EINVAL; | 693 | return -EINVAL; |
694 | |||
695 | userdef = 1; | ||
694 | if (*p == '@') { | 696 | if (*p == '@') { |
695 | start_at = memparse(p+1, &p); | 697 | start_at = memparse(p+1, &p); |
696 | add_memory_region(start_at, mem_size, E820_RAM); | 698 | add_memory_region(start_at, mem_size, E820_RAM); |
@@ -710,6 +712,12 @@ early_param("memmap", parse_memmap_opt); | |||
710 | void __init finish_e820_parsing(void) | 712 | void __init finish_e820_parsing(void) |
711 | { | 713 | { |
712 | if (userdef) { | 714 | if (userdef) { |
715 | char nr = e820.nr_map; | ||
716 | |||
717 | if (sanitize_e820_map(e820.map, &nr) < 0) | ||
718 | early_panic("Invalid user supplied memory map"); | ||
719 | e820.nr_map = nr; | ||
720 | |||
713 | printk(KERN_INFO "user-defined physical RAM map:\n"); | 721 | printk(KERN_INFO "user-defined physical RAM map:\n"); |
714 | e820_print_map("user"); | 722 | e820_print_map("user"); |
715 | } | 723 | } |