From 580e0ad21d6d6f932461d24b47041e3dd499c23f Mon Sep 17 00:00:00 2001 From: Yinghai Lu Date: Tue, 16 Feb 2010 18:40:35 -0800 Subject: [PATCH] core: Move early_res from arch/x86 to kernel/ This makes the range reservation feature available to other architectures. -v2: add get_max_mapped, max_pfn_mapped only defined in x86... to fix PPC compiling -v3: according to hpa, add CONFIG_HAVE_EARLY_RES -v4: fix typo about EARLY_RES in config Signed-off-by: Yinghai Lu LKML-Reference: <4B7B5723.4070009@kernel.org> Signed-off-by: H. Peter Anvin --- arch/x86/Kconfig | 3 +++ arch/x86/include/asm/e820.h | 2 +- arch/x86/kernel/Makefile | 2 +- arch/x86/kernel/e820.c | 10 +++++++++- {arch/x86/include/asm => include/linux}/early_res.h | 7 ++++--- kernel/Makefile | 1 + {arch/x86/kernel => kernel}/early_res.c | 16 ++++------------ 7 files changed, 23 insertions(+), 18 deletions(-) rename {arch/x86/include/asm => include/linux}/early_res.h (85%) rename {arch/x86/kernel => kernel}/early_res.c (97%) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 29f9efb..0e9f8b1 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -183,6 +183,9 @@ config ARCH_SUPPORTS_OPTIMIZED_INLINING config ARCH_SUPPORTS_DEBUG_PAGEALLOC def_bool y +config HAVE_EARLY_RES + def_bool y + config HAVE_INTEL_TXT def_bool y depends on EXPERIMENTAL && DMAR && ACPI diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h index a8299e1..0e22296 100644 --- a/arch/x86/include/asm/e820.h +++ b/arch/x86/include/asm/e820.h @@ -112,7 +112,7 @@ extern unsigned long end_user_pfn; extern u64 find_e820_area(u64 start, u64 end, u64 size, u64 align); extern u64 find_e820_area_size(u64 start, u64 *sizep, u64 align); extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align); -#include +#include extern unsigned long e820_end_of_ram_pfn(void); extern unsigned long e820_end_of_low_ram_pfn(void); diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index f5fb9f0..d87f09b 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -38,7 +38,7 @@ obj-$(CONFIG_X86_32) += probe_roms_32.o obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o -obj-y += bootflag.o e820.o early_res.o +obj-y += bootflag.o e820.o obj-y += pci-dma.o quirks.o i8237.o topology.o kdebugfs.o obj-y += alternative.o i8253.o pci-nommu.o hw_breakpoint.o obj-y += tsc.o io_delay.o rtc.o diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 36918d8..740b440 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -17,7 +17,6 @@ #include #include -#include #include #include @@ -752,6 +751,15 @@ u64 __init find_fw_memmap_area(u64 start, u64 end, u64 size, u64 align) { return find_e820_area(start, end, size, align); } + +u64 __init get_max_mapped(void) +{ + u64 end = max_pfn_mapped; + + end <<= PAGE_SHIFT; + + return end; +} /* * Find next free range after *start */ diff --git a/arch/x86/include/asm/early_res.h b/include/linux/early_res.h similarity index 85% rename from arch/x86/include/asm/early_res.h rename to include/linux/early_res.h index 9758f3d..50f7663 100644 --- a/arch/x86/include/asm/early_res.h +++ b/include/linux/early_res.h @@ -1,5 +1,5 @@ -#ifndef _ASM_X86_EARLY_RES_H -#define _ASM_X86_EARLY_RES_H +#ifndef _LINUX_EARLY_RES_H +#define _LINUX_EARLY_RES_H #ifdef __KERNEL__ extern void reserve_early(u64 start, u64 end, char *name); @@ -13,9 +13,10 @@ u64 find_early_area(u64 ei_start, u64 ei_last, u64 start, u64 end, u64 find_early_area_size(u64 ei_start, u64 ei_last, u64 start, u64 *sizep, u64 align); u64 find_fw_memmap_area(u64 start, u64 end, u64 size, u64 align); +u64 get_max_mapped(void); #include int get_free_all_memory_range(struct range **rangep, int nodeid); #endif /* __KERNEL__ */ -#endif /* _ASM_X86_EARLY_RES_H */ +#endif /* _LINUX_EARLY_RES_H */ diff --git a/kernel/Makefile b/kernel/Makefile index ad47330..1292b86 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -11,6 +11,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o \ hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ notifier.o ksysfs.o pm_qos_params.o sched_clock.o cred.o \ async.o range.o +obj-$(CONFIG_HAVE_EARLY_RES) += early_res.o obj-y += groups.o ifdef CONFIG_FUNCTION_TRACER diff --git a/arch/x86/kernel/early_res.c b/kernel/early_res.c similarity index 97% rename from arch/x86/kernel/early_res.c rename to kernel/early_res.c index 1458dc0..aa5494a 100644 --- a/arch/x86/kernel/early_res.c +++ b/kernel/early_res.c @@ -6,8 +6,7 @@ #include #include #include - -#include +#include /* * Early reserved memory areas. @@ -178,13 +177,6 @@ void __init reserve_early_overlap_ok(u64 start, u64 end, char *name) __reserve_early(start, end, name, 1); } -u64 __init __weak find_fw_memmap_area(u64 start, u64 end, u64 size, u64 align) -{ - panic("should have find_fw_memmap_area defined with arch"); - - return -1ULL; -} - static void __init __check_and_double_early_res(u64 ex_start, u64 ex_end) { u64 start, end, size, mem; @@ -207,7 +199,7 @@ static void __init __check_and_double_early_res(u64 ex_start, u64 ex_end) sizeof(struct early_res)); if (mem == -1ULL) { start = ex_end; - end = max_pfn_mapped << PAGE_SHIFT; + end = get_max_mapped(); if (start + size < end) mem = find_fw_memmap_area(start, end, size, sizeof(struct early_res)); @@ -343,11 +335,11 @@ int __init get_free_all_memory_range(struct range **rangep, int nodeid) count *= 2; size = sizeof(struct range) * count; + end = get_max_mapped(); #ifdef MAX_DMA32_PFN - if (max_pfn_mapped > MAX_DMA32_PFN) + if (end > (MAX_DMA32_PFN << PAGE_SHIFT)) start = MAX_DMA32_PFN << PAGE_SHIFT; #endif - end = max_pfn_mapped << PAGE_SHIFT; mem = find_fw_memmap_area(start, end, size, sizeof(struct range)); if (mem == -1ULL) panic("can not find more space for range free"); -- 2.7.4