]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
x86: do kernel direct mapping at boot using GB pages
authorAndi Kleen <ak@suse.de>
Thu, 17 Apr 2008 15:40:45 +0000 (17:40 +0200)
committerIngo Molnar <mingo@elte.hu>
Thu, 17 Apr 2008 15:40:45 +0000 (17:40 +0200)
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>
arch/x86/mm/init_64.c

index 6e7d5a42a09ae19fa997aff8b104c3c9ffec3f04..ae66d8d4c58d5a2df98feedd3a1e18853bc91389 100644 (file)
@@ -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);