aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@goop.org>2008-05-26 18:30:58 -0400
committerThomas Gleixner <tglx@linutronix.de>2008-05-27 04:01:20 -0400
commit4226ab93d8ae3fd895abe45879fe34d489a98718 (patch)
tree4922874bef40068a1ad2adff0f9f265deabed9af
parente490517a039a99d692cb3a5561941b0a5f576172 (diff)
x86: use pteval_t for _PAGE_FOO
Rather than making _PAGE_* constants signed, and then relying on sign-extension to make sure that masks derived from them are wide enough, just explicitly type them pteval_t. This guarantees that they and any derived values are the right size for the current pte format. The reliance on sign extension is fragile, and invokes some very subtle corners of the C type system. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--include/asm-x86/pgtable.h49
1 files changed, 22 insertions, 27 deletions
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index 97c271b2910b..fab3ecb54b68 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -20,30 +20,25 @@
20#define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */ 20#define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
21#define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */ 21#define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
22 22
23/* 23#define _PAGE_PRESENT (_AT(pteval_t, 1) << _PAGE_BIT_PRESENT)
24 * Note: we use _AC(1, L) instead of _AC(1, UL) so that we get a 24#define _PAGE_RW (_AT(pteval_t, 1) << _PAGE_BIT_RW)
25 * sign-extended value on 32-bit with all 1's in the upper word, 25#define _PAGE_USER (_AT(pteval_t, 1) << _PAGE_BIT_USER)
26 * which preserves the upper pte values on 64-bit ptes: 26#define _PAGE_PWT (_AT(pteval_t, 1) << _PAGE_BIT_PWT)
27 */ 27#define _PAGE_PCD (_AT(pteval_t, 1) << _PAGE_BIT_PCD)
28#define _PAGE_PRESENT (_AC(1, L)<<_PAGE_BIT_PRESENT) 28#define _PAGE_ACCESSED (_AT(pteval_t, 1) << _PAGE_BIT_ACCESSED)
29#define _PAGE_RW (_AC(1, L)<<_PAGE_BIT_RW) 29#define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
30#define _PAGE_USER (_AC(1, L)<<_PAGE_BIT_USER) 30#define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
31#define _PAGE_PWT (_AC(1, L)<<_PAGE_BIT_PWT) 31#define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
32#define _PAGE_PCD (_AC(1, L)<<_PAGE_BIT_PCD) 32#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
33#define _PAGE_ACCESSED (_AC(1, L)<<_PAGE_BIT_ACCESSED) 33#define _PAGE_UNUSED2 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED2)
34#define _PAGE_DIRTY (_AC(1, L)<<_PAGE_BIT_DIRTY) 34#define _PAGE_UNUSED3 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED3)
35#define _PAGE_PSE (_AC(1, L)<<_PAGE_BIT_PSE) /* 2MB page */ 35#define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
36#define _PAGE_GLOBAL (_AC(1, L)<<_PAGE_BIT_GLOBAL) /* Global TLB entry */ 36#define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
37#define _PAGE_UNUSED1 (_AC(1, L)<<_PAGE_BIT_UNUSED1)
38#define _PAGE_UNUSED2 (_AC(1, L)<<_PAGE_BIT_UNUSED2)
39#define _PAGE_UNUSED3 (_AC(1, L)<<_PAGE_BIT_UNUSED3)
40#define _PAGE_PAT (_AC(1, L)<<_PAGE_BIT_PAT)
41#define _PAGE_PAT_LARGE (_AC(1, L)<<_PAGE_BIT_PAT_LARGE)
42 37
43#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) 38#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
44#define _PAGE_NX (_AC(1, ULL) << _PAGE_BIT_NX) 39#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
45#else 40#else
46#define _PAGE_NX 0 41#define _PAGE_NX (_AT(pteval_t, 0))
47#endif 42#endif
48 43
49/* If _PAGE_PRESENT is clear, we use these: */ 44/* If _PAGE_PRESENT is clear, we use these: */
@@ -210,22 +205,22 @@ static inline int pmd_large(pmd_t pte)
210 205
211static inline pte_t pte_mkclean(pte_t pte) 206static inline pte_t pte_mkclean(pte_t pte)
212{ 207{
213 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_DIRTY); 208 return __pte(pte_val(pte) & ~_PAGE_DIRTY);
214} 209}
215 210
216static inline pte_t pte_mkold(pte_t pte) 211static inline pte_t pte_mkold(pte_t pte)
217{ 212{
218 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_ACCESSED); 213 return __pte(pte_val(pte) & ~_PAGE_ACCESSED);
219} 214}
220 215
221static inline pte_t pte_wrprotect(pte_t pte) 216static inline pte_t pte_wrprotect(pte_t pte)
222{ 217{
223 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_RW); 218 return __pte(pte_val(pte) & ~_PAGE_RW);
224} 219}
225 220
226static inline pte_t pte_mkexec(pte_t pte) 221static inline pte_t pte_mkexec(pte_t pte)
227{ 222{
228 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_NX); 223 return __pte(pte_val(pte) & ~_PAGE_NX);
229} 224}
230 225
231static inline pte_t pte_mkdirty(pte_t pte) 226static inline pte_t pte_mkdirty(pte_t pte)
@@ -250,7 +245,7 @@ static inline pte_t pte_mkhuge(pte_t pte)
250 245
251static inline pte_t pte_clrhuge(pte_t pte) 246static inline pte_t pte_clrhuge(pte_t pte)
252{ 247{
253 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_PSE); 248 return __pte(pte_val(pte) & ~_PAGE_PSE);
254} 249}
255 250
256static inline pte_t pte_mkglobal(pte_t pte) 251static inline pte_t pte_mkglobal(pte_t pte)
@@ -260,7 +255,7 @@ static inline pte_t pte_mkglobal(pte_t pte)
260 255
261static inline pte_t pte_clrglobal(pte_t pte) 256static inline pte_t pte_clrglobal(pte_t pte)
262{ 257{
263 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_GLOBAL); 258 return __pte(pte_val(pte) & ~_PAGE_GLOBAL);
264} 259}
265 260
266static inline pte_t pte_mkspecial(pte_t pte) 261static inline pte_t pte_mkspecial(pte_t pte)