/* * paging_init() sets up the page tables - note that all of lowmem is * already mapped by head.S. */ void __init paging_init(void) { #ifdef __tilegx__ pud_t *pud; #endif pgd_t *pgd_base = swapper_pg_dir; kernel_physical_mapping_init(pgd_base); /* Fixed mappings, only the page table structure has to be created. */ page_table_range_init(fix_to_virt(__end_of_fixed_addresses - 1), FIXADDR_TOP, pgd_base); #ifdef CONFIG_HIGHMEM permanent_kmaps_init(pgd_base); #endif #ifdef __tilegx__ /* * Since GX allocates just one pmd_t array worth of vmalloc space, * we go ahead and allocate it statically here, then share it * globally. As a result we don't have to worry about any task * changing init_mm once we get up and running, and there's no * need for e.g. vmalloc_sync_all(). */ BUILD_BUG_ON(pgd_index(VMALLOC_START) != pgd_index(VMALLOC_END - 1)); pud = pud_offset(pgd_base + pgd_index(VMALLOC_START), VMALLOC_START); assign_pmd(pud, alloc_pmd()); #endif }
/* * paging_init() sets up the page tables */ void __init paging_init(void) { unsigned long max_zone_pfns[MAX_NR_ZONES]; int nid; /* We don't need to map the kernel through the TLB, as * it is permanatly mapped using P1. So clear the * entire pgd. */ memset(swapper_pg_dir, 0, sizeof(swapper_pg_dir)); /* Set an initial value for the MMU.TTB so we don't have to * check for a null value. */ set_TTB(swapper_pg_dir); /* Populate the relevant portions of swapper_pg_dir so that * we can use the fixmap entries without calling kmalloc. * pte's will be filled in by __set_fixmap(). */ page_table_range_init(FIXADDR_START, FIXADDR_TOP, swapper_pg_dir); memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); for_each_online_node(nid) { pg_data_t *pgdat = NODE_DATA(nid); unsigned long low, start_pfn; start_pfn = pgdat->bdata->node_min_pfn; low = pgdat->bdata->node_low_pfn; if (max_zone_pfns[ZONE_NORMAL] < low) max_zone_pfns[ZONE_NORMAL] = low; printk("Node %u: start_pfn = 0x%lx, low = 0x%lx\n", nid, start_pfn, low); } free_area_init_nodes(max_zone_pfns); #ifdef CONFIG_SUPERH32 /* Set up the uncached fixmap */ set_fixmap_nocache(FIX_UNCACHED, __pa(&__uncached_start)); #ifdef CONFIG_29BIT /* * Handle trivial transitions between cached and uncached * segments, making use of the 1:1 mapping relationship in * 512MB lowmem. */ cached_to_uncached = P2SEG - P1SEG; #endif #endif }
static void __init pagetable_init (void) { unsigned long vaddr; pgd_t *pgd_base = swapper_pg_dir; #ifdef CONFIG_X86_PAE int i; /* Init entries of the first-level page table to the zero page */ for (i = 0; i < PTRS_PER_PGD; i++) set_pgd(pgd_base + i, __pgd(__pa(empty_zero_page) | _PAGE_PRESENT)); #endif /* Enable PSE if available */ if (cpu_has_pse) { set_in_cr4(X86_CR4_PSE); } /* Enable PGE if available */ if (cpu_has_pge) { set_in_cr4(X86_CR4_PGE); __PAGE_KERNEL |= _PAGE_GLOBAL; __PAGE_KERNEL_EXEC |= _PAGE_GLOBAL; } kernel_physical_mapping_init(pgd_base); remap_numa_kva(); /* * Fixed mappings, only the page table structure has to be * created - mappings will be set by set_fixmap(): */ vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK; page_table_range_init(vaddr, 0, pgd_base); permanent_kmaps_init(pgd_base); #ifdef CONFIG_X86_PAE /* * Add low memory identity-mappings - SMP needs it when * starting up on an AP from real-mode. In the non-PAE * case we already have these mappings through head.S. * All user-space mappings are explicitly cleared after * SMP startup. */ set_pgd(&pgd_base[0], pgd_base[USER_PTRS_PER_PGD]); #endif }
static void __init permanent_kmaps_init(pgd_t *pgd_base) { pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t *pte; unsigned long vaddr; vaddr = PKMAP_BASE; page_table_range_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base); pgd = swapper_pg_dir + pgd_index(vaddr); pud = pud_offset(pgd, vaddr); pmd = pmd_offset(pud, vaddr); pte = pte_offset_kernel(pmd, vaddr); pkmap_page_table = pte; }
/* * paging_init() sets up the page tables */ void __init paging_init(void) { unsigned long max_zone_pfns[MAX_NR_ZONES]; unsigned long vaddr; int nid; /* We don't need to map the kernel through the TLB, as * it is permanatly mapped using P1. So clear the * entire pgd. */ memset(swapper_pg_dir, 0, sizeof(swapper_pg_dir)); /* Set an initial value for the MMU.TTB so we don't have to * check for a null value. */ set_TTB(swapper_pg_dir); /* * Populate the relevant portions of swapper_pg_dir so that * we can use the fixmap entries without calling kmalloc. * pte's will be filled in by __set_fixmap(). */ vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK; page_table_range_init(vaddr, 0, swapper_pg_dir); kmap_coherent_init(); memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); for_each_online_node(nid) { pg_data_t *pgdat = NODE_DATA(nid); unsigned long low, start_pfn; start_pfn = pgdat->bdata->node_min_pfn; low = pgdat->bdata->node_low_pfn; if (max_zone_pfns[ZONE_NORMAL] < low) max_zone_pfns[ZONE_NORMAL] = low; printk("Node %u: start_pfn = 0x%lx, low = 0x%lx\n", nid, start_pfn, low); } free_area_init_nodes(max_zone_pfns); /* Set up the uncached fixmap */ set_fixmap_nocache(FIX_UNCACHED, __pa(&__uncached_start)); }