aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/x86/Kconfig3
-rw-r--r--arch/x86/include/asm/e820.h2
-rw-r--r--arch/x86/kernel/Makefile2
-rw-r--r--arch/x86/kernel/e820.c10
-rw-r--r--include/linux/early_res.h (renamed from arch/x86/include/asm/early_res.h)7
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/early_res.c (renamed from arch/x86/kernel/early_res.c)16
7 files changed, 23 insertions, 18 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 29f9efb74fc7..0e9f8b10de52 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 a8299e134437..0e22296790d3 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 <asm/early_res.h>
+#include <linux/early_res.h>
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 f5fb9f0b6277..d87f09bc5a52 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 36918d8463ab..740b440fbd73 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -17,7 +17,6 @@
#include <linux/firmware-map.h>
#include <asm/e820.h>
-#include <asm/early_res.h>
#include <asm/proto.h>
#include <asm/setup.h>
@@ -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
index 9758f3df9dad..50f7663bb8b1 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 <linux/range.h>
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 ad47330ccf32..1292b863d667 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
index 1458dc022343..aa5494ac4462 100644
--- a/arch/x86/kernel/early_res.c
+++ b/kernel/early_res.c
@@ -6,8 +6,7 @@
#include <linux/init.h>
#include <linux/bootmem.h>
#include <linux/mm.h>
-
-#include <asm/early_res.h>
+#include <linux/early_res.h>
/*
* 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");