xref: /openbmc/linux/arch/um/kernel/mem.c (revision ab26a5276c1b0945c3281a73b3a89d025906c880)
11da177e4SLinus Torvalds /*
2009ec2a9SJeff Dike  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
31da177e4SLinus Torvalds  * Licensed under the GPL
41da177e4SLinus Torvalds  */
51da177e4SLinus Torvalds 
6009ec2a9SJeff Dike #include <linux/stddef.h>
7009ec2a9SJeff Dike #include <linux/bootmem.h>
8009ec2a9SJeff Dike #include <linux/gfp.h>
9009ec2a9SJeff Dike #include <linux/highmem.h>
10009ec2a9SJeff Dike #include <linux/mm.h>
11009ec2a9SJeff Dike #include <linux/swap.h>
12009ec2a9SJeff Dike #include <asm/fixmap.h>
13009ec2a9SJeff Dike #include <asm/page.h>
144ff83ce1SJeff Dike #include "as-layout.h"
15114069f7SJeff Dike #include "init.h"
16009ec2a9SJeff Dike #include "kern.h"
17009ec2a9SJeff Dike #include "kern_util.h"
18009ec2a9SJeff Dike #include "mem_user.h"
19009ec2a9SJeff Dike #include "os.h"
201da177e4SLinus Torvalds 
216bf79482SJeff Dike /* allocated in paging_init, zeroed in mem_init, and unchanged thereafter */
221da177e4SLinus Torvalds unsigned long *empty_zero_page = NULL;
236bf79482SJeff Dike /* allocated in paging_init and unchanged thereafter */
241da177e4SLinus Torvalds unsigned long *empty_bad_page = NULL;
2580e39311SJeff Dike 
2680e39311SJeff Dike /*
2780e39311SJeff Dike  * Initialized during boot, and readonly for initializing page tables
2880e39311SJeff Dike  * afterwards
2980e39311SJeff Dike  */
301da177e4SLinus Torvalds pgd_t swapper_pg_dir[PTRS_PER_PGD];
3180e39311SJeff Dike 
3280e39311SJeff Dike /* Initialized at boot time, and readonly after that */
339902abd7SJeff Dike unsigned long long highmem;
341da177e4SLinus Torvalds int kmalloc_ok = 0;
351da177e4SLinus Torvalds 
3680e39311SJeff Dike /* Used during early boot */
371da177e4SLinus Torvalds static unsigned long brk_end;
381da177e4SLinus Torvalds 
391da177e4SLinus Torvalds #ifdef CONFIG_HIGHMEM
401da177e4SLinus Torvalds static void setup_highmem(unsigned long highmem_start,
411da177e4SLinus Torvalds 			  unsigned long highmem_len)
421da177e4SLinus Torvalds {
431da177e4SLinus Torvalds 	struct page *page;
441da177e4SLinus Torvalds 	unsigned long highmem_pfn;
451da177e4SLinus Torvalds 	int i;
461da177e4SLinus Torvalds 
471da177e4SLinus Torvalds 	highmem_pfn = __pa(highmem_start) >> PAGE_SHIFT;
481da177e4SLinus Torvalds 	for (i = 0; i < highmem_len >> PAGE_SHIFT; i++) {
491da177e4SLinus Torvalds 		page = &mem_map[highmem_pfn + i];
501da177e4SLinus Torvalds 		ClearPageReserved(page);
517835e98bSNick Piggin 		init_page_count(page);
521da177e4SLinus Torvalds 		__free_page(page);
531da177e4SLinus Torvalds 	}
541da177e4SLinus Torvalds }
551da177e4SLinus Torvalds #endif
561da177e4SLinus Torvalds 
5797a1fcbbSJeff Dike void __init mem_init(void)
581da177e4SLinus Torvalds {
591da177e4SLinus Torvalds 	/* clear the zero-page */
60c0a9290eSWANG Cong 	memset(empty_zero_page, 0, PAGE_SIZE);
611da177e4SLinus Torvalds 
621da177e4SLinus Torvalds 	/* Map in the area just after the brk now that kmalloc is about
631da177e4SLinus Torvalds 	 * to be turned on.
641da177e4SLinus Torvalds 	 */
651da177e4SLinus Torvalds 	brk_end = (unsigned long) UML_ROUND_UP(sbrk(0));
66*ab26a527SJeff Dike 	map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0);
671da177e4SLinus Torvalds 	free_bootmem(__pa(brk_end), uml_reserved - brk_end);
681da177e4SLinus Torvalds 	uml_reserved = brk_end;
691da177e4SLinus Torvalds 
701da177e4SLinus Torvalds 	/* this will put all low memory onto the freelists */
711da177e4SLinus Torvalds 	totalram_pages = free_all_bootmem();
72af84eab2SJason Lunz 	max_low_pfn = totalram_pages;
73c1f60a5aSChristoph Lameter #ifdef CONFIG_HIGHMEM
741da177e4SLinus Torvalds 	totalhigh_pages = highmem >> PAGE_SHIFT;
751da177e4SLinus Torvalds 	totalram_pages += totalhigh_pages;
76c1f60a5aSChristoph Lameter #endif
771da177e4SLinus Torvalds 	num_physpages = totalram_pages;
781da177e4SLinus Torvalds 	max_pfn = totalram_pages;
791da177e4SLinus Torvalds 	printk(KERN_INFO "Memory: %luk available\n",
801da177e4SLinus Torvalds 	       (unsigned long) nr_free_pages() << (PAGE_SHIFT-10));
811da177e4SLinus Torvalds 	kmalloc_ok = 1;
821da177e4SLinus Torvalds 
831da177e4SLinus Torvalds #ifdef CONFIG_HIGHMEM
841da177e4SLinus Torvalds 	setup_highmem(end_iomem, highmem);
851da177e4SLinus Torvalds #endif
861da177e4SLinus Torvalds }
871da177e4SLinus Torvalds 
8812f49643SJeff Dike /*
8912f49643SJeff Dike  * Create a page table and place a pointer to it in a middle page
9012f49643SJeff Dike  * directory entry.
9112f49643SJeff Dike  */
9212f49643SJeff Dike static void __init one_page_table_init(pmd_t *pmd)
9312f49643SJeff Dike {
9412f49643SJeff Dike 	if (pmd_none(*pmd)) {
9512f49643SJeff Dike 		pte_t *pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
9612f49643SJeff Dike 		set_pmd(pmd, __pmd(_KERNPG_TABLE +
9712f49643SJeff Dike 					   (unsigned long) __pa(pte)));
9812f49643SJeff Dike 		if (pte != pte_offset_kernel(pmd, 0))
9912f49643SJeff Dike 			BUG();
10012f49643SJeff Dike 	}
10112f49643SJeff Dike }
10212f49643SJeff Dike 
10312f49643SJeff Dike static void __init one_md_table_init(pud_t *pud)
10412f49643SJeff Dike {
10512f49643SJeff Dike #ifdef CONFIG_3_LEVEL_PGTABLES
10612f49643SJeff Dike 	pmd_t *pmd_table = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
10712f49643SJeff Dike 	set_pud(pud, __pud(_KERNPG_TABLE + (unsigned long) __pa(pmd_table)));
10812f49643SJeff Dike 	if (pmd_table != pmd_offset(pud, 0))
10912f49643SJeff Dike 		BUG();
11012f49643SJeff Dike #endif
11112f49643SJeff Dike }
11212f49643SJeff Dike 
1131da177e4SLinus Torvalds static void __init fixrange_init(unsigned long start, unsigned long end,
1141da177e4SLinus Torvalds 				 pgd_t *pgd_base)
1151da177e4SLinus Torvalds {
1161da177e4SLinus Torvalds 	pgd_t *pgd;
11712f49643SJeff Dike 	pud_t *pud;
1181da177e4SLinus Torvalds 	pmd_t *pmd;
1191da177e4SLinus Torvalds 	int i, j;
1201da177e4SLinus Torvalds 	unsigned long vaddr;
1211da177e4SLinus Torvalds 
1221da177e4SLinus Torvalds 	vaddr = start;
1231da177e4SLinus Torvalds 	i = pgd_index(vaddr);
1241da177e4SLinus Torvalds 	j = pmd_index(vaddr);
1251da177e4SLinus Torvalds 	pgd = pgd_base + i;
1261da177e4SLinus Torvalds 
1271da177e4SLinus Torvalds 	for ( ; (i < PTRS_PER_PGD) && (vaddr < end); pgd++, i++) {
12812f49643SJeff Dike 		pud = pud_offset(pgd, vaddr);
12912f49643SJeff Dike 		if (pud_none(*pud))
13012f49643SJeff Dike 			one_md_table_init(pud);
13112f49643SJeff Dike 		pmd = pmd_offset(pud, vaddr);
132655e4ed0SJeff Dike 		for (; (j < PTRS_PER_PMD) && (vaddr < end); pmd++, j++) {
13312f49643SJeff Dike 			one_page_table_init(pmd);
1341da177e4SLinus Torvalds 			vaddr += PMD_SIZE;
1351da177e4SLinus Torvalds 		}
1361da177e4SLinus Torvalds 		j = 0;
1371da177e4SLinus Torvalds 	}
1381da177e4SLinus Torvalds }
1391da177e4SLinus Torvalds 
1401da177e4SLinus Torvalds #ifdef CONFIG_HIGHMEM
1411da177e4SLinus Torvalds pte_t *kmap_pte;
1421da177e4SLinus Torvalds pgprot_t kmap_prot;
1431da177e4SLinus Torvalds 
1441da177e4SLinus Torvalds #define kmap_get_fixmap_pte(vaddr)					\
1451da177e4SLinus Torvalds 	pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr), (vaddr)),\
1461da177e4SLinus Torvalds 				     (vaddr)), (vaddr))
1471da177e4SLinus Torvalds 
1481da177e4SLinus Torvalds static void __init kmap_init(void)
1491da177e4SLinus Torvalds {
1501da177e4SLinus Torvalds 	unsigned long kmap_vstart;
1511da177e4SLinus Torvalds 
1521da177e4SLinus Torvalds 	/* cache the first kmap pte */
1531da177e4SLinus Torvalds 	kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
1541da177e4SLinus Torvalds 	kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
1551da177e4SLinus Torvalds 
1561da177e4SLinus Torvalds 	kmap_prot = PAGE_KERNEL;
1571da177e4SLinus Torvalds }
1581da177e4SLinus Torvalds 
159b4a08a10SAl Viro static void __init init_highmem(void)
1601da177e4SLinus Torvalds {
1611da177e4SLinus Torvalds 	pgd_t *pgd;
1621da177e4SLinus Torvalds 	pud_t *pud;
1631da177e4SLinus Torvalds 	pmd_t *pmd;
1641da177e4SLinus Torvalds 	pte_t *pte;
1651da177e4SLinus Torvalds 	unsigned long vaddr;
1661da177e4SLinus Torvalds 
1671da177e4SLinus Torvalds 	/*
1681da177e4SLinus Torvalds 	 * Permanent kmaps:
1691da177e4SLinus Torvalds 	 */
1701da177e4SLinus Torvalds 	vaddr = PKMAP_BASE;
1711da177e4SLinus Torvalds 	fixrange_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, swapper_pg_dir);
1721da177e4SLinus Torvalds 
1731da177e4SLinus Torvalds 	pgd = swapper_pg_dir + pgd_index(vaddr);
1741da177e4SLinus Torvalds 	pud = pud_offset(pgd, vaddr);
1751da177e4SLinus Torvalds 	pmd = pmd_offset(pud, vaddr);
1761da177e4SLinus Torvalds 	pte = pte_offset_kernel(pmd, vaddr);
1771da177e4SLinus Torvalds 	pkmap_page_table = pte;
1781da177e4SLinus Torvalds 
1791da177e4SLinus Torvalds 	kmap_init();
1801da177e4SLinus Torvalds }
1811da177e4SLinus Torvalds #endif /* CONFIG_HIGHMEM */
1821da177e4SLinus Torvalds 
1831da177e4SLinus Torvalds static void __init fixaddr_user_init( void)
1841da177e4SLinus Torvalds {
1859a0b3869Sviro@ZenIV.linux.org.uk #ifdef CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA
1861da177e4SLinus Torvalds 	long size = FIXADDR_USER_END - FIXADDR_USER_START;
1871da177e4SLinus Torvalds 	pgd_t *pgd;
1881da177e4SLinus Torvalds 	pud_t *pud;
1891da177e4SLinus Torvalds 	pmd_t *pmd;
1901da177e4SLinus Torvalds 	pte_t *pte;
191655e4ed0SJeff Dike 	phys_t p;
192655e4ed0SJeff Dike 	unsigned long v, vaddr = FIXADDR_USER_START;
1931da177e4SLinus Torvalds 
1941da177e4SLinus Torvalds 	if (!size)
1951da177e4SLinus Torvalds 		return;
1961da177e4SLinus Torvalds 
1971da177e4SLinus Torvalds 	fixrange_init( FIXADDR_USER_START, FIXADDR_USER_END, swapper_pg_dir);
198655e4ed0SJeff Dike 	v = (unsigned long) alloc_bootmem_low_pages(size);
199655e4ed0SJeff Dike 	memcpy((void *) v , (void *) FIXADDR_USER_START, size);
200655e4ed0SJeff Dike 	p = __pa(v);
201009ec2a9SJeff Dike 	for ( ; size > 0; size -= PAGE_SIZE, vaddr += PAGE_SIZE,
202655e4ed0SJeff Dike 		      p += PAGE_SIZE) {
2031da177e4SLinus Torvalds 		pgd = swapper_pg_dir + pgd_index(vaddr);
2041da177e4SLinus Torvalds 		pud = pud_offset(pgd, vaddr);
2051da177e4SLinus Torvalds 		pmd = pmd_offset(pud, vaddr);
2061da177e4SLinus Torvalds 		pte = pte_offset_kernel(pmd, vaddr);
207655e4ed0SJeff Dike 		pte_set_val(*pte, p, PAGE_READONLY);
2081da177e4SLinus Torvalds 	}
2091da177e4SLinus Torvalds #endif
2101da177e4SLinus Torvalds }
2111da177e4SLinus Torvalds 
21236e45463SJeff Dike void __init paging_init(void)
2131da177e4SLinus Torvalds {
2141da177e4SLinus Torvalds 	unsigned long zones_size[MAX_NR_ZONES], vaddr;
2151da177e4SLinus Torvalds 	int i;
2161da177e4SLinus Torvalds 
2171da177e4SLinus Torvalds 	empty_zero_page = (unsigned long *) alloc_bootmem_low_pages(PAGE_SIZE);
2181da177e4SLinus Torvalds 	empty_bad_page = (unsigned long *) alloc_bootmem_low_pages(PAGE_SIZE);
21991b165c0SJeff Dike 	for (i = 0; i < ARRAY_SIZE(zones_size); i++)
2201da177e4SLinus Torvalds 		zones_size[i] = 0;
22191b165c0SJeff Dike 
2220715501bSJeff Dike 	zones_size[ZONE_NORMAL] = (end_iomem >> PAGE_SHIFT) -
2230715501bSJeff Dike 		(uml_physmem >> PAGE_SHIFT);
224e53ef38dSChristoph Lameter #ifdef CONFIG_HIGHMEM
225353f8d1cSPaolo 'Blaisorblade' Giarrusso 	zones_size[ZONE_HIGHMEM] = highmem >> PAGE_SHIFT;
226e53ef38dSChristoph Lameter #endif
2271da177e4SLinus Torvalds 	free_area_init(zones_size);
2281da177e4SLinus Torvalds 
2291da177e4SLinus Torvalds 	/*
2301da177e4SLinus Torvalds 	 * Fixed mappings, only the page table structure has to be
2311da177e4SLinus Torvalds 	 * created - mappings will be set by set_fixmap():
2321da177e4SLinus Torvalds 	 */
2331da177e4SLinus Torvalds 	vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
2341da177e4SLinus Torvalds 	fixrange_init(vaddr, FIXADDR_TOP, swapper_pg_dir);
2351da177e4SLinus Torvalds 
2361da177e4SLinus Torvalds 	fixaddr_user_init();
2371da177e4SLinus Torvalds 
2381da177e4SLinus Torvalds #ifdef CONFIG_HIGHMEM
2391da177e4SLinus Torvalds 	init_highmem();
2401da177e4SLinus Torvalds #endif
2411da177e4SLinus Torvalds }
2421da177e4SLinus Torvalds 
24353f9fc93SAl Viro struct page *arch_validate(struct page *page, gfp_t mask, int order)
2441da177e4SLinus Torvalds {
2451da177e4SLinus Torvalds 	unsigned long addr, zero = 0;
2461da177e4SLinus Torvalds 	int i;
2471da177e4SLinus Torvalds 
2481da177e4SLinus Torvalds  again:
24960678bbcSJeff Dike 	if (page == NULL)
25060678bbcSJeff Dike 		return page;
25160678bbcSJeff Dike 	if (PageHighMem(page))
25260678bbcSJeff Dike 		return page;
2531da177e4SLinus Torvalds 
2541da177e4SLinus Torvalds 	addr = (unsigned long) page_address(page);
2551da177e4SLinus Torvalds 	for (i = 0; i < (1 << order); i++) {
2561da177e4SLinus Torvalds 		current->thread.fault_addr = (void *) addr;
2571da177e4SLinus Torvalds 		if (__do_copy_to_user((void __user *) addr, &zero,
2581da177e4SLinus Torvalds 				     sizeof(zero),
2591da177e4SLinus Torvalds 				     &current->thread.fault_addr,
2601da177e4SLinus Torvalds 				     &current->thread.fault_catcher)) {
26160678bbcSJeff Dike 			if (!(mask & __GFP_WAIT))
26260678bbcSJeff Dike 				return NULL;
2631da177e4SLinus Torvalds 			else break;
2641da177e4SLinus Torvalds 		}
2651da177e4SLinus Torvalds 		addr += PAGE_SIZE;
2661da177e4SLinus Torvalds 	}
2671da177e4SLinus Torvalds 
26860678bbcSJeff Dike 	if (i == (1 << order))
26960678bbcSJeff Dike 		return page;
2701da177e4SLinus Torvalds 	page = alloc_pages(mask, order);
2711da177e4SLinus Torvalds 	goto again;
2721da177e4SLinus Torvalds }
2731da177e4SLinus Torvalds 
2748192ab42SJeff Dike /*
2758192ab42SJeff Dike  * This can't do anything because nothing in the kernel image can be freed
2761da177e4SLinus Torvalds  * since it's not in kernel physical memory.
2771da177e4SLinus Torvalds  */
2781da177e4SLinus Torvalds 
2791da177e4SLinus Torvalds void free_initmem(void)
2801da177e4SLinus Torvalds {
2811da177e4SLinus Torvalds }
2821da177e4SLinus Torvalds 
2831da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
2841da177e4SLinus Torvalds void free_initrd_mem(unsigned long start, unsigned long end)
2851da177e4SLinus Torvalds {
2861da177e4SLinus Torvalds 	if (start < end)
287009ec2a9SJeff Dike 		printk(KERN_INFO "Freeing initrd memory: %ldk freed\n",
2881da177e4SLinus Torvalds 		       (end - start) >> 10);
2891da177e4SLinus Torvalds 	for (; start < end; start += PAGE_SIZE) {
2901da177e4SLinus Torvalds 		ClearPageReserved(virt_to_page(start));
2917835e98bSNick Piggin 		init_page_count(virt_to_page(start));
2921da177e4SLinus Torvalds 		free_page(start);
2931da177e4SLinus Torvalds 		totalram_pages++;
2941da177e4SLinus Torvalds 	}
2951da177e4SLinus Torvalds }
2961da177e4SLinus Torvalds #endif
2971da177e4SLinus Torvalds 
2981da177e4SLinus Torvalds void show_mem(void)
2991da177e4SLinus Torvalds {
3001da177e4SLinus Torvalds 	int pfn, total = 0, reserved = 0;
3011da177e4SLinus Torvalds 	int shared = 0, cached = 0;
3021da177e4SLinus Torvalds 	int highmem = 0;
3031da177e4SLinus Torvalds 	struct page *page;
3041da177e4SLinus Torvalds 
305009ec2a9SJeff Dike 	printk(KERN_INFO "Mem-info:\n");
3061da177e4SLinus Torvalds 	show_free_areas();
307009ec2a9SJeff Dike 	printk(KERN_INFO "Free swap:       %6ldkB\n",
308009ec2a9SJeff Dike 	       nr_swap_pages<<(PAGE_SHIFT-10));
3091da177e4SLinus Torvalds 	pfn = max_mapnr;
3101da177e4SLinus Torvalds 	while (pfn-- > 0) {
3111da177e4SLinus Torvalds 		page = pfn_to_page(pfn);
3121da177e4SLinus Torvalds 		total++;
3131da177e4SLinus Torvalds 		if (PageHighMem(page))
3141da177e4SLinus Torvalds 			highmem++;
3151da177e4SLinus Torvalds 		if (PageReserved(page))
3161da177e4SLinus Torvalds 			reserved++;
3171da177e4SLinus Torvalds 		else if (PageSwapCache(page))
3181da177e4SLinus Torvalds 			cached++;
3191da177e4SLinus Torvalds 		else if (page_count(page))
3201da177e4SLinus Torvalds 			shared += page_count(page) - 1;
3211da177e4SLinus Torvalds 	}
322009ec2a9SJeff Dike 	printk(KERN_INFO "%d pages of RAM\n", total);
323009ec2a9SJeff Dike 	printk(KERN_INFO "%d pages of HIGHMEM\n", highmem);
324009ec2a9SJeff Dike 	printk(KERN_INFO "%d reserved pages\n", reserved);
325009ec2a9SJeff Dike 	printk(KERN_INFO "%d pages shared\n", shared);
326009ec2a9SJeff Dike 	printk(KERN_INFO "%d pages swap cached\n", cached);
3271da177e4SLinus Torvalds }
3281da177e4SLinus Torvalds 
3298192ab42SJeff Dike /* Allocate and free page tables. */
3301da177e4SLinus Torvalds 
3311da177e4SLinus Torvalds pgd_t *pgd_alloc(struct mm_struct *mm)
3321da177e4SLinus Torvalds {
3331da177e4SLinus Torvalds 	pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL);
3341da177e4SLinus Torvalds 
3351da177e4SLinus Torvalds 	if (pgd) {
3361da177e4SLinus Torvalds 		memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
3371da177e4SLinus Torvalds 		memcpy(pgd + USER_PTRS_PER_PGD,
3381da177e4SLinus Torvalds 		       swapper_pg_dir + USER_PTRS_PER_PGD,
3391da177e4SLinus Torvalds 		       (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
3401da177e4SLinus Torvalds 	}
3411da177e4SLinus Torvalds 	return pgd;
3421da177e4SLinus Torvalds }
3431da177e4SLinus Torvalds 
3445e541973SBenjamin Herrenschmidt void pgd_free(struct mm_struct *mm, pgd_t *pgd)
3451da177e4SLinus Torvalds {
3461da177e4SLinus Torvalds 	free_page((unsigned long) pgd);
3471da177e4SLinus Torvalds }
3481da177e4SLinus Torvalds 
3491da177e4SLinus Torvalds pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
3501da177e4SLinus Torvalds {
3511da177e4SLinus Torvalds 	pte_t *pte;
3521da177e4SLinus Torvalds 
3531da177e4SLinus Torvalds 	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
3541da177e4SLinus Torvalds 	return pte;
3551da177e4SLinus Torvalds }
3561da177e4SLinus Torvalds 
3571da177e4SLinus Torvalds struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
3581da177e4SLinus Torvalds {
3591da177e4SLinus Torvalds 	struct page *pte;
3601da177e4SLinus Torvalds 
3611da177e4SLinus Torvalds 	pte = alloc_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
3621da177e4SLinus Torvalds 	return pte;
3631da177e4SLinus Torvalds }
3648192ab42SJeff Dike 
3658192ab42SJeff Dike #ifdef CONFIG_3_LEVEL_PGTABLES
3668192ab42SJeff Dike pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
3678192ab42SJeff Dike {
3688192ab42SJeff Dike 	pmd_t *pmd = (pmd_t *) __get_free_page(GFP_KERNEL);
3698192ab42SJeff Dike 
3708192ab42SJeff Dike 	if (pmd)
3718192ab42SJeff Dike 		memset(pmd, 0, PAGE_SIZE);
3728192ab42SJeff Dike 
3738192ab42SJeff Dike 	return pmd;
3748192ab42SJeff Dike }
3758192ab42SJeff Dike #endif
376