diff options
Diffstat (limited to 'arch/x86/kernel/setup.c')
-rw-r--r-- | arch/x86/kernel/setup.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index f28c56e6bf94..e6b742d2a3f5 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
@@ -114,6 +114,9 @@ | |||
114 | 114 | ||
115 | unsigned int boot_cpu_id __read_mostly; | 115 | unsigned int boot_cpu_id __read_mostly; |
116 | 116 | ||
117 | static __initdata unsigned long _brk_start = (unsigned long)__brk_base; | ||
118 | unsigned long _brk_end = (unsigned long)__brk_base; | ||
119 | |||
117 | #ifdef CONFIG_X86_64 | 120 | #ifdef CONFIG_X86_64 |
118 | int default_cpu_present_to_apicid(int mps_cpu) | 121 | int default_cpu_present_to_apicid(int mps_cpu) |
119 | { | 122 | { |
@@ -337,6 +340,34 @@ static void __init relocate_initrd(void) | |||
337 | } | 340 | } |
338 | #endif | 341 | #endif |
339 | 342 | ||
343 | void * __init extend_brk(size_t size, size_t align) | ||
344 | { | ||
345 | size_t mask = align - 1; | ||
346 | void *ret; | ||
347 | |||
348 | BUG_ON(_brk_start == 0); | ||
349 | BUG_ON(align & mask); | ||
350 | |||
351 | _brk_end = (_brk_end + mask) & ~mask; | ||
352 | BUG_ON((char *)(_brk_end + size) > __brk_limit); | ||
353 | |||
354 | ret = (void *)_brk_end; | ||
355 | _brk_end += size; | ||
356 | |||
357 | memset(ret, 0, size); | ||
358 | |||
359 | return ret; | ||
360 | } | ||
361 | |||
362 | static void __init reserve_brk(void) | ||
363 | { | ||
364 | if (_brk_end > _brk_start) | ||
365 | reserve_early(__pa(_brk_start), __pa(_brk_end), "BRK"); | ||
366 | |||
367 | /* Mark brk area as locked down and no longer taking any new allocations */ | ||
368 | _brk_start = 0; | ||
369 | } | ||
370 | |||
340 | static void __init reserve_initrd(void) | 371 | static void __init reserve_initrd(void) |
341 | { | 372 | { |
342 | u64 ramdisk_image = boot_params.hdr.ramdisk_image; | 373 | u64 ramdisk_image = boot_params.hdr.ramdisk_image; |
@@ -717,11 +748,7 @@ void __init setup_arch(char **cmdline_p) | |||
717 | init_mm.start_code = (unsigned long) _text; | 748 | init_mm.start_code = (unsigned long) _text; |
718 | init_mm.end_code = (unsigned long) _etext; | 749 | init_mm.end_code = (unsigned long) _etext; |
719 | init_mm.end_data = (unsigned long) _edata; | 750 | init_mm.end_data = (unsigned long) _edata; |
720 | #ifdef CONFIG_X86_32 | 751 | init_mm.brk = _brk_end; |
721 | init_mm.brk = init_pg_tables_end + PAGE_OFFSET; | ||
722 | #else | ||
723 | init_mm.brk = (unsigned long) &_end; | ||
724 | #endif | ||
725 | 752 | ||
726 | code_resource.start = virt_to_phys(_text); | 753 | code_resource.start = virt_to_phys(_text); |
727 | code_resource.end = virt_to_phys(_etext)-1; | 754 | code_resource.end = virt_to_phys(_etext)-1; |
@@ -842,6 +869,8 @@ void __init setup_arch(char **cmdline_p) | |||
842 | setup_bios_corruption_check(); | 869 | setup_bios_corruption_check(); |
843 | #endif | 870 | #endif |
844 | 871 | ||
872 | reserve_brk(); | ||
873 | |||
845 | /* max_pfn_mapped is updated here */ | 874 | /* max_pfn_mapped is updated here */ |
846 | max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn<<PAGE_SHIFT); | 875 | max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn<<PAGE_SHIFT); |
847 | max_pfn_mapped = max_low_pfn_mapped; | 876 | max_pfn_mapped = max_low_pfn_mapped; |