aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2005-01-11 01:50:51 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-01-11 01:50:51 -0800
commit9156123ff70b756a4d2385a4bd546e71cf7a9be8 (patch)
tree5db9e805978c5860d8a4f04490d57f70d76a0588 /arch
parentc2cc6280f832dee7efff479a7938a8086d420522 (diff)
downloadhistory-9156123ff70b756a4d2385a4bd546e71cf7a9be8.tar.gz
[PATCH] x86_64: Cleanups preparing for memory hotplug
From: Matt Tolentino Some cleanup work in early page table init preparing for memory hotplug. Hacked up by AK Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86_64/kernel/setup.c2
-rw-r--r--arch/x86_64/mm/init.c48
2 files changed, 27 insertions, 23 deletions
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 6b0b38c716080e..7a8711a032940a 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -493,7 +493,7 @@ void __init setup_arch(char **cmdline_p)
check_efer();
- init_memory_mapping();
+ init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
#ifdef CONFIG_ACPI_BOOT
/*
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index c2ac2b4b78423d..e4c8d2dc190c7f 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -252,51 +252,55 @@ static void __init phys_pud_init(pud_t *pud, unsigned long address, unsigned lon
__flush_tlb();
}
+static void __init find_early_table_space(unsigned long end)
+{
+ unsigned long puds, pmds, tables;
+
+ puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
+ pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
+ tables = round_up(puds * sizeof(pud_t), PAGE_SIZE) +
+ round_up(pmds * sizeof(pmd_t), PAGE_SIZE);
+
+ table_start = find_e820_area(0x8000, __pa_symbol(&_text), tables);
+ if (table_start == -1UL)
+ panic("Cannot find space for the kernel page tables");
+
+ table_start >>= PAGE_SHIFT;
+ table_end = table_start;
+}
+
/* Setup the direct mapping of the physical memory at PAGE_OFFSET.
This runs before bootmem is initialized and gets pages directly from the
physical memory. To access them they are temporarily mapped. */
-void __init init_memory_mapping(void)
+void __init init_memory_mapping(unsigned long start, unsigned long end)
{
- unsigned long adr;
- unsigned long end;
unsigned long next;
- unsigned long puds, pmds, tables;
Dprintk("init_memory_mapping\n");
- end = end_pfn_map << PAGE_SHIFT;
-
/*
* Find space for the kernel direct mapping tables.
* Later we should allocate these tables in the local node of the memory
* mapped. Unfortunately this is done currently before the nodes are
* discovered.
*/
+ find_early_table_space(end);
- puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
- pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
- tables = round_up(puds*8, PAGE_SIZE) + round_up(pmds * 8, PAGE_SIZE);
-
- table_start = find_e820_area(0x8000, __pa_symbol(&_text), tables);
- if (table_start == -1UL)
- panic("Cannot find space for the kernel page tables");
+ start = (unsigned long)__va(start);
+ end = (unsigned long)__va(end);
- table_start >>= PAGE_SHIFT;
- table_end = table_start;
-
- end += __PAGE_OFFSET; /* turn virtual */
-
- for (adr = PAGE_OFFSET; adr < end; adr = next) {
+ for (; start < end; start = next) {
int map;
unsigned long pud_phys;
pud_t *pud = alloc_low_page(&map, &pud_phys);
- next = adr + PGDIR_SIZE;
+ next = start + PGDIR_SIZE;
if (next > end)
next = end;
- phys_pud_init(pud, adr-PAGE_OFFSET, next-PAGE_OFFSET);
- set_pgd(init_level4_pgt + pgd_index(adr), mk_kernel_pgd(pud_phys));
+ phys_pud_init(pud, __pa(start), __pa(next));
+ set_pgd(pgd_offset_k(start), mk_kernel_pgd(pud_phys));
unmap_low_page(map);
}
+
asm volatile("movq %%cr4,%0" : "=r" (mmu_cr4_features));
__flush_tlb_all();
early_printk("kernel direct mapping tables upto %lx @ %lx-%lx\n", end,