2 * arch/s390/mm/pgtable.c
4 * Copyright IBM Corp. 2007
5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
8 #include <linux/sched.h>
9 #include <linux/kernel.h>
10 #include <linux/errno.h>
12 #include <linux/swap.h>
13 #include <linux/smp.h>
14 #include <linux/highmem.h>
15 #include <linux/slab.h>
16 #include <linux/pagemap.h>
17 #include <linux/spinlock.h>
18 #include <linux/module.h>
19 #include <linux/quicklist.h>
21 #include <asm/system.h>
22 #include <asm/pgtable.h>
23 #include <asm/pgalloc.h>
25 #include <asm/tlbflush.h>
33 unsigned long *crst_table_alloc(struct mm_struct
*mm
, int noexec
)
35 struct page
*page
= alloc_pages(GFP_KERNEL
, ALLOC_ORDER
);
41 struct page
*shadow
= alloc_pages(GFP_KERNEL
, ALLOC_ORDER
);
43 __free_pages(page
, ALLOC_ORDER
);
46 page
->index
= page_to_phys(shadow
);
48 return (unsigned long *) page_to_phys(page
);
51 void crst_table_free(unsigned long *table
)
53 unsigned long *shadow
= get_shadow_table(table
);
56 free_pages((unsigned long) shadow
, ALLOC_ORDER
);
57 free_pages((unsigned long) table
, ALLOC_ORDER
);
61 * page table entry allocation/free routines.
63 unsigned long *page_table_alloc(int noexec
)
65 struct page
*page
= alloc_page(GFP_KERNEL
);
72 struct page
*shadow
= alloc_page(GFP_KERNEL
);
77 table
= (unsigned long *) page_to_phys(shadow
);
78 clear_table(table
, _PAGE_TYPE_EMPTY
, PAGE_SIZE
);
79 page
->index
= (addr_t
) table
;
81 table
= (unsigned long *) page_to_phys(page
);
82 clear_table(table
, _PAGE_TYPE_EMPTY
, PAGE_SIZE
);
86 void page_table_free(unsigned long *table
)
88 unsigned long *shadow
= get_shadow_pte(table
);
91 free_page((unsigned long) shadow
);
92 free_page((unsigned long) table
);