mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-16 14:02:10 +00:00
x86: do kernel direct mapping at boot using GB pages
The AMD Fam10h CPUs support new Gigabyte page table entry for mapping 1GB at a time. Use this for the kernel direct mapping. Only done for 64bit because i386 does not support GB page tables. This only applies to the data portion of the direct mapping; the kernel text mapping stays with 2MB pages because the AMD Fam10h microarchitecture does not support GB ITLBs and AMD recommends against using GB mappings for code. Can be disabled with disable_gbpages on the kernel command line [ tglx@linutronix.de: simplify enable code ] [ Yinghai Lu <yinghai.lu@sun.com>: boot fix on 256 GB RAM ] Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
00d1c5e057
commit
ef9257668e
@ -370,7 +370,14 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end)
|
||||
}
|
||||
|
||||
if (pud_val(*pud)) {
|
||||
phys_pmd_update(pud, addr, end);
|
||||
if (!pud_large(*pud))
|
||||
phys_pmd_update(pud, addr, end);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (direct_gbpages) {
|
||||
set_pte((pte_t *)pud,
|
||||
pfn_pte(addr >> PAGE_SHIFT, PAGE_KERNEL_LARGE));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -391,9 +398,11 @@ static void __init find_early_table_space(unsigned long end)
|
||||
unsigned long puds, pmds, tables, start;
|
||||
|
||||
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);
|
||||
tables = round_up(puds * sizeof(pud_t), PAGE_SIZE);
|
||||
if (!direct_gbpages) {
|
||||
pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
|
||||
tables += round_up(pmds * sizeof(pmd_t), PAGE_SIZE);
|
||||
}
|
||||
|
||||
/*
|
||||
* RED-PEN putting page tables only on node 0 could
|
||||
@ -413,6 +422,14 @@ static void __init find_early_table_space(unsigned long end)
|
||||
(table_start << PAGE_SHIFT) + tables);
|
||||
}
|
||||
|
||||
static void __init init_gbpages(void)
|
||||
{
|
||||
if (direct_gbpages && cpu_has_gbpages)
|
||||
printk(KERN_INFO "Using GB pages for direct mapping\n");
|
||||
else
|
||||
direct_gbpages = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup the direct mapping of the physical memory at PAGE_OFFSET.
|
||||
* This runs before bootmem is initialized and gets pages directly from
|
||||
@ -431,8 +448,10 @@ void __init_refok init_memory_mapping(unsigned long start, unsigned long end)
|
||||
* memory mapped. Unfortunately this is done currently before the
|
||||
* nodes are discovered.
|
||||
*/
|
||||
if (!after_bootmem)
|
||||
if (!after_bootmem) {
|
||||
init_gbpages();
|
||||
find_early_table_space(end);
|
||||
}
|
||||
|
||||
start = (unsigned long)__va(start);
|
||||
end = (unsigned long)__va(end);
|
||||
|
Loading…
Reference in New Issue
Block a user