diff options
Diffstat (limited to 'arch/x86/include/asm/page.h')
-rw-r--r-- | arch/x86/include/asm/page.h | 152 |
1 files changed, 4 insertions, 148 deletions
diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h index 776579119a00..89ed9d70b0aa 100644 --- a/arch/x86/include/asm/page.h +++ b/arch/x86/include/asm/page.h | |||
@@ -1,42 +1,11 @@ | |||
1 | #ifndef _ASM_X86_PAGE_H | 1 | #ifndef _ASM_X86_PAGE_H |
2 | #define _ASM_X86_PAGE_H | 2 | #define _ASM_X86_PAGE_H |
3 | 3 | ||
4 | #include <linux/const.h> | 4 | #include <linux/types.h> |
5 | |||
6 | /* PAGE_SHIFT determines the page size */ | ||
7 | #define PAGE_SHIFT 12 | ||
8 | #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) | ||
9 | #define PAGE_MASK (~(PAGE_SIZE-1)) | ||
10 | 5 | ||
11 | #ifdef __KERNEL__ | 6 | #ifdef __KERNEL__ |
12 | 7 | ||
13 | #define __PHYSICAL_MASK ((phys_addr_t)(1ULL << __PHYSICAL_MASK_SHIFT) - 1) | 8 | #include <asm/page_types.h> |
14 | #define __VIRTUAL_MASK ((1UL << __VIRTUAL_MASK_SHIFT) - 1) | ||
15 | |||
16 | /* Cast PAGE_MASK to a signed type so that it is sign-extended if | ||
17 | virtual addresses are 32-bits but physical addresses are larger | ||
18 | (ie, 32-bit PAE). */ | ||
19 | #define PHYSICAL_PAGE_MASK (((signed long)PAGE_MASK) & __PHYSICAL_MASK) | ||
20 | |||
21 | /* PTE_PFN_MASK extracts the PFN from a (pte|pmd|pud|pgd)val_t */ | ||
22 | #define PTE_PFN_MASK ((pteval_t)PHYSICAL_PAGE_MASK) | ||
23 | |||
24 | /* PTE_FLAGS_MASK extracts the flags from a (pte|pmd|pud|pgd)val_t */ | ||
25 | #define PTE_FLAGS_MASK (~PTE_PFN_MASK) | ||
26 | |||
27 | #define PMD_PAGE_SIZE (_AC(1, UL) << PMD_SHIFT) | ||
28 | #define PMD_PAGE_MASK (~(PMD_PAGE_SIZE-1)) | ||
29 | |||
30 | #define HPAGE_SHIFT PMD_SHIFT | ||
31 | #define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT) | ||
32 | #define HPAGE_MASK (~(HPAGE_SIZE - 1)) | ||
33 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) | ||
34 | |||
35 | #define HUGE_MAX_HSTATE 2 | ||
36 | |||
37 | #ifndef __ASSEMBLY__ | ||
38 | #include <linux/types.h> | ||
39 | #endif | ||
40 | 9 | ||
41 | #ifdef CONFIG_X86_64 | 10 | #ifdef CONFIG_X86_64 |
42 | #include <asm/page_64.h> | 11 | #include <asm/page_64.h> |
@@ -44,38 +13,18 @@ | |||
44 | #include <asm/page_32.h> | 13 | #include <asm/page_32.h> |
45 | #endif /* CONFIG_X86_64 */ | 14 | #endif /* CONFIG_X86_64 */ |
46 | 15 | ||
47 | #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) | ||
48 | |||
49 | #define VM_DATA_DEFAULT_FLAGS \ | ||
50 | (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \ | ||
51 | VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | ||
52 | |||
53 | |||
54 | #ifndef __ASSEMBLY__ | 16 | #ifndef __ASSEMBLY__ |
55 | 17 | ||
56 | typedef struct { pgdval_t pgd; } pgd_t; | ||
57 | typedef struct { pgprotval_t pgprot; } pgprot_t; | ||
58 | |||
59 | extern int page_is_ram(unsigned long pagenr); | ||
60 | extern int devmem_is_allowed(unsigned long pagenr); | ||
61 | extern void map_devmem(unsigned long pfn, unsigned long size, | ||
62 | pgprot_t vma_prot); | ||
63 | extern void unmap_devmem(unsigned long pfn, unsigned long size, | ||
64 | pgprot_t vma_prot); | ||
65 | |||
66 | extern unsigned long max_low_pfn_mapped; | ||
67 | extern unsigned long max_pfn_mapped; | ||
68 | |||
69 | struct page; | 18 | struct page; |
70 | 19 | ||
71 | static inline void clear_user_page(void *page, unsigned long vaddr, | 20 | static inline void clear_user_page(void *page, unsigned long vaddr, |
72 | struct page *pg) | 21 | struct page *pg) |
73 | { | 22 | { |
74 | clear_page(page); | 23 | clear_page(page); |
75 | } | 24 | } |
76 | 25 | ||
77 | static inline void copy_user_page(void *to, void *from, unsigned long vaddr, | 26 | static inline void copy_user_page(void *to, void *from, unsigned long vaddr, |
78 | struct page *topage) | 27 | struct page *topage) |
79 | { | 28 | { |
80 | copy_page(to, from); | 29 | copy_page(to, from); |
81 | } | 30 | } |
@@ -84,99 +33,6 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr, | |||
84 | alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr) | 33 | alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr) |
85 | #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE | 34 | #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE |
86 | 35 | ||
87 | static inline pgd_t native_make_pgd(pgdval_t val) | ||
88 | { | ||
89 | return (pgd_t) { val }; | ||
90 | } | ||
91 | |||
92 | static inline pgdval_t native_pgd_val(pgd_t pgd) | ||
93 | { | ||
94 | return pgd.pgd; | ||
95 | } | ||
96 | |||
97 | #if PAGETABLE_LEVELS >= 3 | ||
98 | #if PAGETABLE_LEVELS == 4 | ||
99 | typedef struct { pudval_t pud; } pud_t; | ||
100 | |||
101 | static inline pud_t native_make_pud(pmdval_t val) | ||
102 | { | ||
103 | return (pud_t) { val }; | ||
104 | } | ||
105 | |||
106 | static inline pudval_t native_pud_val(pud_t pud) | ||
107 | { | ||
108 | return pud.pud; | ||
109 | } | ||
110 | #else /* PAGETABLE_LEVELS == 3 */ | ||
111 | #include <asm-generic/pgtable-nopud.h> | ||
112 | |||
113 | static inline pudval_t native_pud_val(pud_t pud) | ||
114 | { | ||
115 | return native_pgd_val(pud.pgd); | ||
116 | } | ||
117 | #endif /* PAGETABLE_LEVELS == 4 */ | ||
118 | |||
119 | typedef struct { pmdval_t pmd; } pmd_t; | ||
120 | |||
121 | static inline pmd_t native_make_pmd(pmdval_t val) | ||
122 | { | ||
123 | return (pmd_t) { val }; | ||
124 | } | ||
125 | |||
126 | static inline pmdval_t native_pmd_val(pmd_t pmd) | ||
127 | { | ||
128 | return pmd.pmd; | ||
129 | } | ||
130 | #else /* PAGETABLE_LEVELS == 2 */ | ||
131 | #include <asm-generic/pgtable-nopmd.h> | ||
132 | |||
133 | static inline pmdval_t native_pmd_val(pmd_t pmd) | ||
134 | { | ||
135 | return native_pgd_val(pmd.pud.pgd); | ||
136 | } | ||
137 | #endif /* PAGETABLE_LEVELS >= 3 */ | ||
138 | |||
139 | static inline pte_t native_make_pte(pteval_t val) | ||
140 | { | ||
141 | return (pte_t) { .pte = val }; | ||
142 | } | ||
143 | |||
144 | static inline pteval_t native_pte_val(pte_t pte) | ||
145 | { | ||
146 | return pte.pte; | ||
147 | } | ||
148 | |||
149 | static inline pteval_t native_pte_flags(pte_t pte) | ||
150 | { | ||
151 | return native_pte_val(pte) & PTE_FLAGS_MASK; | ||
152 | } | ||
153 | |||
154 | #define pgprot_val(x) ((x).pgprot) | ||
155 | #define __pgprot(x) ((pgprot_t) { (x) } ) | ||
156 | |||
157 | #ifdef CONFIG_PARAVIRT | ||
158 | #include <asm/paravirt.h> | ||
159 | #else /* !CONFIG_PARAVIRT */ | ||
160 | |||
161 | #define pgd_val(x) native_pgd_val(x) | ||
162 | #define __pgd(x) native_make_pgd(x) | ||
163 | |||
164 | #ifndef __PAGETABLE_PUD_FOLDED | ||
165 | #define pud_val(x) native_pud_val(x) | ||
166 | #define __pud(x) native_make_pud(x) | ||
167 | #endif | ||
168 | |||
169 | #ifndef __PAGETABLE_PMD_FOLDED | ||
170 | #define pmd_val(x) native_pmd_val(x) | ||
171 | #define __pmd(x) native_make_pmd(x) | ||
172 | #endif | ||
173 | |||
174 | #define pte_val(x) native_pte_val(x) | ||
175 | #define pte_flags(x) native_pte_flags(x) | ||
176 | #define __pte(x) native_make_pte(x) | ||
177 | |||
178 | #endif /* CONFIG_PARAVIRT */ | ||
179 | |||
180 | #define __pa(x) __phys_addr((unsigned long)(x)) | 36 | #define __pa(x) __phys_addr((unsigned long)(x)) |
181 | #define __pa_nodebug(x) __phys_addr_nodebug((unsigned long)(x)) | 37 | #define __pa_nodebug(x) __phys_addr_nodebug((unsigned long)(x)) |
182 | /* __pa_symbol should be used for C visible symbols. | 38 | /* __pa_symbol should be used for C visible symbols. |