blob: 014f087d7c27a805cf36b84222d58a4c2677fffe [file] [log] [blame]
Jeremy Fitzhardinge83a51012008-01-30 13:32:41 +01001#ifndef _ASM_X86_PAGE_H
2#define _ASM_X86_PAGE_H
3
4#include <linux/const.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
11#define PHYSICAL_PAGE_MASK (PAGE_MASK & __PHYSICAL_MASK)
Ingo Molnar3da1bcc2008-01-30 13:32:42 +010012#define PTE_MASK PHYSICAL_PAGE_MASK
Jeremy Fitzhardinge83a51012008-01-30 13:32:41 +010013
14#define LARGE_PAGE_SIZE (_AC(1,UL) << PMD_SHIFT)
15#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
16
17#define HPAGE_SHIFT PMD_SHIFT
18#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
19#define HPAGE_MASK (~(HPAGE_SIZE - 1))
20#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
21
22/* to align the pointer to the (next) page boundary */
23#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
24
25#define __PHYSICAL_MASK ((_AC(1,UL) << __PHYSICAL_MASK_SHIFT) - 1)
26#define __VIRTUAL_MASK ((_AC(1,UL) << __VIRTUAL_MASK_SHIFT) - 1)
27
Ingo Molnar3da1bcc2008-01-30 13:32:42 +010028#ifndef __ASSEMBLY__
29#include <linux/types.h>
30#endif
Jeremy Fitzhardinge83a51012008-01-30 13:32:41 +010031
32#ifdef CONFIG_X86_64
Ingo Molnar3da1bcc2008-01-30 13:32:42 +010033#define PAGETABLE_LEVELS 4
34
Jeremy Fitzhardinge83a51012008-01-30 13:32:41 +010035#define THREAD_ORDER 1
36#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER)
37#define CURRENT_MASK (~(THREAD_SIZE-1))
38
39#define EXCEPTION_STACK_ORDER 0
40#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
41
42#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)
43#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
44
45#define IRQSTACK_ORDER 2
46#define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER)
47
48#define STACKFAULT_STACK 1
49#define DOUBLEFAULT_STACK 2
50#define NMI_STACK 3
51#define DEBUG_STACK 4
52#define MCE_STACK 5
53#define N_EXCEPTION_STACKS 5 /* hw limit: 7 */
54
55#define __PAGE_OFFSET _AC(0xffff810000000000, UL)
56
57#define __PHYSICAL_START CONFIG_PHYSICAL_START
58#define __KERNEL_ALIGN 0x200000
59
60/*
61 * Make sure kernel is aligned to 2MB address. Catching it at compile
62 * time is better. Change your config file and compile the kernel
63 * for a 2MB aligned address (CONFIG_PHYSICAL_START)
64 */
65#if (CONFIG_PHYSICAL_START % __KERNEL_ALIGN) != 0
66#error "CONFIG_PHYSICAL_START must be a multiple of 2MB"
Thomas Gleixner96a388d2007-10-11 11:20:03 +020067#endif
Jeremy Fitzhardinge83a51012008-01-30 13:32:41 +010068
69#define __START_KERNEL (__START_KERNEL_map + __PHYSICAL_START)
70#define __START_KERNEL_map _AC(0xffffffff80000000, UL)
71
72/* See Documentation/x86_64/mm.txt for a description of the memory map. */
73#define __PHYSICAL_MASK_SHIFT 46
74#define __VIRTUAL_MASK_SHIFT 48
75
76#define KERNEL_TEXT_SIZE (40*1024*1024)
77#define KERNEL_TEXT_START _AC(0xffffffff80000000, UL)
78
Jeremy Fitzhardinge345b9042008-01-30 13:32:42 +010079#ifndef __ASSEMBLY__
80void clear_page(void *page);
81void copy_page(void *to, void *from);
Ingo Molnarba2b6c52008-01-30 13:32:42 +010082
83/*
84 * These are used to make use of C type-checking..
85 */
86typedef unsigned long pteval_t;
87typedef unsigned long pmdval_t;
88typedef unsigned long pudval_t;
89typedef unsigned long pgdval_t;
90typedef unsigned long pgprotval_t;
91typedef unsigned long phys_addr_t;
92
93typedef struct { pteval_t pte; } pte_t;
94
Ingo Molnard6e3cf62008-01-30 13:32:43 +010095#define native_pte_val(x) ((x).pte)
96#define native_make_pte(x) ((pte_t) { (x) } )
97
Jeremy Fitzhardinge345b9042008-01-30 13:32:42 +010098#endif /* !__ASSEMBLY__ */
99
Jeremy Fitzhardinge83a51012008-01-30 13:32:41 +0100100#endif /* CONFIG_X86_64 */
101
102#ifdef CONFIG_X86_32
103
104/*
105 * This handles the memory map.
106 *
107 * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
108 * a virtual address space of one gigabyte, which limits the
109 * amount of physical memory you can use to about 950MB.
110 *
111 * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
112 * and CONFIG_HIGHMEM64G options in the kernel configuration.
113 */
114#define __PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL)
115
116#ifdef CONFIG_X86_PAE
117#define __PHYSICAL_MASK_SHIFT 36
118#define __VIRTUAL_MASK_SHIFT 32
119#else /* !CONFIG_X86_PAE */
120#define __PHYSICAL_MASK_SHIFT 32
121#define __VIRTUAL_MASK_SHIFT 32
122#endif /* CONFIG_X86_PAE */
123
124#ifdef CONFIG_HUGETLB_PAGE
125#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
126#endif
127
Jeremy Fitzhardinge345b9042008-01-30 13:32:42 +0100128#ifndef __ASSEMBLY__
129#ifdef CONFIG_X86_USE_3DNOW
130#include <asm/mmx.h>
131
132static inline void clear_page(void *page)
133{
134 mmx_clear_page(page);
135}
136
137static inline void copy_page(void *to, void *from)
138{
139 mmx_copy_page(to, from);
140}
141#else /* !CONFIG_X86_USE_3DNOW */
142#include <linux/string.h>
143
144static inline void clear_page(void *page)
145{
146 memset(page, 0, PAGE_SIZE);
147}
148
149static inline void copy_page(void *to, void *from)
150{
151 memcpy(to, from, PAGE_SIZE);
152}
153#endif /* CONFIG_X86_3DNOW */
154#endif /* !__ASSEMBLY__ */
155
Jeremy Fitzhardinge83a51012008-01-30 13:32:41 +0100156#endif /* CONFIG_X86_32 */
157
158#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
159
160#define VM_DATA_DEFAULT_FLAGS \
161 (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
162 VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
163
164
Jeremy Fitzhardinge345b9042008-01-30 13:32:42 +0100165#ifndef __ASSEMBLY__
166struct page;
167
168static void inline clear_user_page(void *page, unsigned long vaddr,
169 struct page *pg)
170{
171 clear_page(page);
172}
173
174static void inline copy_user_page(void *to, void *from, unsigned long vaddr,
175 struct page *topage)
176{
177 copy_page(to, from);
178}
179
180#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
181 alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
182#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
183
Ingo Molnar38f0f122008-01-30 13:32:43 +0100184#ifdef CONFIG_X86_64
185typedef struct { pgdval_t pgd; } pgd_t;
186typedef struct { pgprotval_t pgprot; } pgprot_t;
187
188static inline pgd_t native_make_pgd(pgdval_t val)
189{
190 return (pgd_t) { val };
191}
192
193static inline pgdval_t native_pgd_val(pgd_t pgd)
194{
195 return pgd.pgd;
196}
197
198#if PAGETABLE_LEVELS >= 3
199#if PAGETABLE_LEVELS == 4
200typedef struct { pudval_t pud; } pud_t;
201
202static inline pud_t native_make_pud(pmdval_t val)
203{
204 return (pud_t) { val };
205}
206
207static inline pudval_t native_pud_val(pud_t pud)
208{
209 return pud.pud;
210}
211#else /* PAGETABLE_LEVELS == 3 */
212#include <asm-generic/pgtable-nopud.h>
213#endif /* PAGETABLE_LEVELS == 4 */
214
215typedef struct { pmdval_t pmd; } pmd_t;
216
217static inline pmd_t native_make_pmd(pmdval_t val)
218{
219 return (pmd_t) { val };
220}
221
222static inline pmdval_t native_pmd_val(pmd_t pmd)
223{
224 return pmd.pmd;
225}
226#else /* PAGETABLE_LEVELS == 2 */
227#include <asm-generic/pgtable-nopmd.h>
228#endif /* PAGETABLE_LEVELS >= 3 */
229
230#define pgprot_val(x) ((x).pgprot)
231#define __pgprot(x) ((pgprot_t) { (x) } )
232
233#ifdef CONFIG_PARAVIRT
234#include <asm/paravirt.h>
235#else /* !CONFIG_PARAVIRT */
236
237#define pgd_val(x) native_pgd_val(x)
238#define __pgd(x) native_make_pgd(x)
239
240#ifndef __PAGETABLE_PUD_FOLDED
241#define pud_val(x) native_pud_val(x)
242#define __pud(x) native_make_pud(x)
243#endif
244
245#ifndef __PAGETABLE_PMD_FOLDED
246#define pmd_val(x) native_pmd_val(x)
247#define __pmd(x) native_make_pmd(x)
248#endif
249
250#define pte_val(x) native_pte_val(x)
251#define __pte(x) native_make_pte(x)
252
253#endif /* CONFIG_PARAVIRT */
254
255#endif /* CONFIG_X86_64 */
Jeremy Fitzhardinge345b9042008-01-30 13:32:42 +0100256#endif /* __ASSEMBLY__ */
257
258
Jeremy Fitzhardinge83a51012008-01-30 13:32:41 +0100259#ifdef CONFIG_X86_32
260# include "page_32.h"
261#else
262# include "page_64.h"
263#endif
264
265#endif /* _ASM_X86_PAGE_H */