diff options
author | Yinghai Lu <yinghai@kernel.org> | 2010-08-25 16:39:17 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-08-27 14:12:29 -0400 |
commit | 72d7c3b33c980843e756681fb4867dc1efd62a76 (patch) | |
tree | 9607345d9fa055dd501aacf0772258fb72897035 /arch/x86/kernel/setup.c | |
parent | 301ff3e88ef9ff4bdb92f36a3e6170fce4c9dd34 (diff) |
x86: Use memblock to replace early_res
1. replace find_e820_area with memblock_find_in_range
2. replace reserve_early with memblock_x86_reserve_range
3. replace free_early with memblock_x86_free_range.
4. NO_BOOTMEM will switch to use memblock too.
5. use _e820, _early wrap in the patch, in following patch, will
replace them all
6. because memblock_x86_free_range support partial free, we can remove some special care
7. Need to make sure that memblock_find_in_range() is called after memblock_x86_fill()
so adjust some calling later in setup.c::setup_arch()
-- corruption_check and mptable_update
-v2: Move reserve_brk() early
Before fill_memblock_area, to avoid overlap between brk and memblock_find_in_range()
that could happen We have more then 128 RAM entry in E820 tables, and
memblock_x86_fill() could use memblock_find_in_range() to find a new place for
memblock.memory.region array.
and We don't need to use extend_brk() after fill_memblock_area()
So move reserve_brk() early before fill_memblock_area().
-v3: Move find_smp_config early
To make sure memblock_find_in_range not find wrong place, if BIOS doesn't put mptable
in right place.
-v4: Treat RESERVED_KERN as RAM in memblock.memory. and they are already in
memblock.reserved already..
use __NOT_KEEP_MEMBLOCK to make sure memblock related code could be freed later.
-v5: Generic version __memblock_find_in_range() is going from high to low, and for 32bit
active_region for 32bit does include high pages
need to replace the limit with memblock.default_alloc_limit, aka get_max_mapped()
-v6: Use current_limit instead
-v7: check with MEMBLOCK_ERROR instead of -1ULL or -1L
-v8: Set memblock_can_resize early to handle EFI with more RAM entries
-v9: update after kmemleak changes in mainline
Suggested-by: David S. Miller <davem@davemloft.net>
Suggested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/kernel/setup.c')
-rw-r--r-- | arch/x86/kernel/setup.c | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index b4ae4acbd031..bbe0aaf77494 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/apm_bios.h> | 31 | #include <linux/apm_bios.h> |
32 | #include <linux/initrd.h> | 32 | #include <linux/initrd.h> |
33 | #include <linux/bootmem.h> | 33 | #include <linux/bootmem.h> |
34 | #include <linux/memblock.h> | ||
34 | #include <linux/seq_file.h> | 35 | #include <linux/seq_file.h> |
35 | #include <linux/console.h> | 36 | #include <linux/console.h> |
36 | #include <linux/mca.h> | 37 | #include <linux/mca.h> |
@@ -614,7 +615,7 @@ static __init void reserve_ibft_region(void) | |||
614 | addr = find_ibft_region(&size); | 615 | addr = find_ibft_region(&size); |
615 | 616 | ||
616 | if (size) | 617 | if (size) |
617 | reserve_early_overlap_ok(addr, addr + size, "ibft"); | 618 | memblock_x86_reserve_range(addr, addr + size, "* ibft"); |
618 | } | 619 | } |
619 | 620 | ||
620 | #ifdef CONFIG_X86_RESERVE_LOW_64K | 621 | #ifdef CONFIG_X86_RESERVE_LOW_64K |
@@ -708,6 +709,15 @@ static void __init trim_bios_range(void) | |||
708 | sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); | 709 | sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); |
709 | } | 710 | } |
710 | 711 | ||
712 | static u64 __init get_max_mapped(void) | ||
713 | { | ||
714 | u64 end = max_pfn_mapped; | ||
715 | |||
716 | end <<= PAGE_SHIFT; | ||
717 | |||
718 | return end; | ||
719 | } | ||
720 | |||
711 | /* | 721 | /* |
712 | * Determine if we were loaded by an EFI loader. If so, then we have also been | 722 | * Determine if we were loaded by an EFI loader. If so, then we have also been |
713 | * passed the efi memmap, systab, etc., so we should use these data structures | 723 | * passed the efi memmap, systab, etc., so we should use these data structures |
@@ -891,8 +901,6 @@ void __init setup_arch(char **cmdline_p) | |||
891 | */ | 901 | */ |
892 | max_pfn = e820_end_of_ram_pfn(); | 902 | max_pfn = e820_end_of_ram_pfn(); |
893 | 903 | ||
894 | /* preallocate 4k for mptable mpc */ | ||
895 | early_reserve_e820_mpc_new(); | ||
896 | /* update e820 for memory not covered by WB MTRRs */ | 904 | /* update e820 for memory not covered by WB MTRRs */ |
897 | mtrr_bp_init(); | 905 | mtrr_bp_init(); |
898 | if (mtrr_trim_uncached_memory(max_pfn)) | 906 | if (mtrr_trim_uncached_memory(max_pfn)) |
@@ -917,15 +925,6 @@ void __init setup_arch(char **cmdline_p) | |||
917 | max_pfn_mapped = KERNEL_IMAGE_SIZE >> PAGE_SHIFT; | 925 | max_pfn_mapped = KERNEL_IMAGE_SIZE >> PAGE_SHIFT; |
918 | #endif | 926 | #endif |
919 | 927 | ||
920 | #ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION | ||
921 | setup_bios_corruption_check(); | ||
922 | #endif | ||
923 | |||
924 | printk(KERN_DEBUG "initial memory mapped : 0 - %08lx\n", | ||
925 | max_pfn_mapped<<PAGE_SHIFT); | ||
926 | |||
927 | reserve_brk(); | ||
928 | |||
929 | /* | 928 | /* |
930 | * Find and reserve possible boot-time SMP configuration: | 929 | * Find and reserve possible boot-time SMP configuration: |
931 | */ | 930 | */ |
@@ -933,6 +932,26 @@ void __init setup_arch(char **cmdline_p) | |||
933 | 932 | ||
934 | reserve_ibft_region(); | 933 | reserve_ibft_region(); |
935 | 934 | ||
935 | /* | ||
936 | * Need to conclude brk, before memblock_x86_fill() | ||
937 | * it could use memblock_find_in_range, could overlap with | ||
938 | * brk area. | ||
939 | */ | ||
940 | reserve_brk(); | ||
941 | |||
942 | memblock.current_limit = get_max_mapped(); | ||
943 | memblock_x86_fill(); | ||
944 | |||
945 | /* preallocate 4k for mptable mpc */ | ||
946 | early_reserve_e820_mpc_new(); | ||
947 | |||
948 | #ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION | ||
949 | setup_bios_corruption_check(); | ||
950 | #endif | ||
951 | |||
952 | printk(KERN_DEBUG "initial memory mapped : 0 - %08lx\n", | ||
953 | max_pfn_mapped<<PAGE_SHIFT); | ||
954 | |||
936 | reserve_trampoline_memory(); | 955 | reserve_trampoline_memory(); |
937 | 956 | ||
938 | #ifdef CONFIG_ACPI_SLEEP | 957 | #ifdef CONFIG_ACPI_SLEEP |
@@ -956,6 +975,7 @@ void __init setup_arch(char **cmdline_p) | |||
956 | max_low_pfn = max_pfn; | 975 | max_low_pfn = max_pfn; |
957 | } | 976 | } |
958 | #endif | 977 | #endif |
978 | memblock.current_limit = get_max_mapped(); | ||
959 | 979 | ||
960 | /* | 980 | /* |
961 | * NOTE: On x86-32, only from this point on, fixmaps are ready for use. | 981 | * NOTE: On x86-32, only from this point on, fixmaps are ready for use. |
@@ -995,7 +1015,7 @@ void __init setup_arch(char **cmdline_p) | |||
995 | 1015 | ||
996 | initmem_init(0, max_pfn, acpi, k8); | 1016 | initmem_init(0, max_pfn, acpi, k8); |
997 | #ifndef CONFIG_NO_BOOTMEM | 1017 | #ifndef CONFIG_NO_BOOTMEM |
998 | early_res_to_bootmem(0, max_low_pfn<<PAGE_SHIFT); | 1018 | memblock_x86_to_bootmem(0, max_low_pfn<<PAGE_SHIFT); |
999 | #endif | 1019 | #endif |
1000 | 1020 | ||
1001 | dma32_reserve_bootmem(); | 1021 | dma32_reserve_bootmem(); |