diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2008-01-30 07:32:57 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:32:57 -0500 |
commit | c8e5393ab38564d2f45b560a2f95bc8f9ff6f823 (patch) | |
tree | 2976d59bb412786712bddec0eedf82e1db58401d | |
parent | b7fff536d0ad45c4810f9b99845c707ceadc3afc (diff) |
x86: page.h: make pte_t a union to always include
Make sure pte_t, whatever its definition, has a pte element with type
pteval_t. This allows common code to access it without needing to be
specifically parameterised on what pagetable mode we're compiling for.
For 32-bit, this means that pte_t becomes a union with "pte" and "{
pte_low, pte_high }" (PAE) or just "pte_low" (non-PAE).
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/x86/xen/mmu.c | 4 | ||||
-rw-r--r-- | include/asm-x86/page.h | 10 | ||||
-rw-r--r-- | include/asm-x86/page_32.h | 30 | ||||
-rw-r--r-- | include/asm-x86/page_64.h | 3 | ||||
-rw-r--r-- | include/asm-x86/paravirt.h | 2 | ||||
-rw-r--r-- | include/asm-x86/pgtable-2level.h | 4 | ||||
-rw-r--r-- | include/asm-x86/pgtable-3level.h | 4 | ||||
-rw-r--r-- | include/asm-x86/pgtable_64.h | 6 | ||||
-rw-r--r-- | include/asm-x86/processor.h | 1 | ||||
-rw-r--r-- | include/xen/page.h | 6 |
10 files changed, 29 insertions, 41 deletions
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index 0ac6c5dc49ba..52f392893008 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c | |||
@@ -244,9 +244,7 @@ pte_t xen_make_pte(unsigned long long pte) | |||
244 | if (pte & 1) | 244 | if (pte & 1) |
245 | pte = phys_to_machine(XPADDR(pte)).maddr; | 245 | pte = phys_to_machine(XPADDR(pte)).maddr; |
246 | 246 | ||
247 | pte &= ~_PAGE_PCD; | 247 | return (pte_t){ .pte = pte }; |
248 | |||
249 | return (pte_t){ pte, pte >> 32 }; | ||
250 | } | 248 | } |
251 | 249 | ||
252 | pmd_t xen_make_pmd(unsigned long long pmd) | 250 | pmd_t xen_make_pmd(unsigned long long pmd) |
diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h index 91920565a575..a6495eb5c605 100644 --- a/include/asm-x86/page.h +++ b/include/asm-x86/page.h | |||
@@ -108,6 +108,16 @@ static inline pmdval_t native_pmd_val(pmd_t pmd) | |||
108 | #include <asm-generic/pgtable-nopmd.h> | 108 | #include <asm-generic/pgtable-nopmd.h> |
109 | #endif /* PAGETABLE_LEVELS >= 3 */ | 109 | #endif /* PAGETABLE_LEVELS >= 3 */ |
110 | 110 | ||
111 | static inline pte_t native_make_pte(pteval_t val) | ||
112 | { | ||
113 | return (pte_t) { .pte = val }; | ||
114 | } | ||
115 | |||
116 | static inline pteval_t native_pte_val(pte_t pte) | ||
117 | { | ||
118 | return pte.pte; | ||
119 | } | ||
120 | |||
111 | #define pgprot_val(x) ((x).pgprot) | 121 | #define pgprot_val(x) ((x).pgprot) |
112 | #define __pgprot(x) ((pgprot_t) { (x) } ) | 122 | #define __pgprot(x) ((pgprot_t) { (x) } ) |
113 | 123 | ||
diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h index e424bef4395a..11c4b39cada1 100644 --- a/include/asm-x86/page_32.h +++ b/include/asm-x86/page_32.h | |||
@@ -26,18 +26,12 @@ typedef u64 pgdval_t; | |||
26 | typedef u64 pgprotval_t; | 26 | typedef u64 pgprotval_t; |
27 | typedef u64 phys_addr_t; | 27 | typedef u64 phys_addr_t; |
28 | 28 | ||
29 | typedef struct { unsigned long pte_low, pte_high; } pte_t; | 29 | typedef union { |
30 | 30 | struct { | |
31 | static inline unsigned long long native_pte_val(pte_t pte) | 31 | unsigned long pte_low, pte_high; |
32 | { | 32 | }; |
33 | return pte.pte_low | ((unsigned long long)pte.pte_high << 32); | 33 | pteval_t pte; |
34 | } | 34 | } pte_t; |
35 | |||
36 | static inline pte_t native_make_pte(unsigned long long val) | ||
37 | { | ||
38 | return (pte_t) { .pte_low = val, .pte_high = (val >> 32) } ; | ||
39 | } | ||
40 | |||
41 | #endif /* __ASSEMBLY__ | 35 | #endif /* __ASSEMBLY__ |
42 | */ | 36 | */ |
43 | #else /* !CONFIG_X86_PAE */ | 37 | #else /* !CONFIG_X86_PAE */ |
@@ -53,19 +47,9 @@ typedef unsigned long pgdval_t; | |||
53 | typedef unsigned long pgprotval_t; | 47 | typedef unsigned long pgprotval_t; |
54 | typedef unsigned long phys_addr_t; | 48 | typedef unsigned long phys_addr_t; |
55 | 49 | ||
56 | typedef struct { pteval_t pte_low; } pte_t; | 50 | typedef union { pteval_t pte, pte_low; } pte_t; |
57 | typedef pte_t boot_pte_t; | 51 | typedef pte_t boot_pte_t; |
58 | 52 | ||
59 | static inline unsigned long native_pte_val(pte_t pte) | ||
60 | { | ||
61 | return pte.pte_low; | ||
62 | } | ||
63 | |||
64 | static inline pte_t native_make_pte(unsigned long val) | ||
65 | { | ||
66 | return (pte_t) { .pte_low = val }; | ||
67 | } | ||
68 | |||
69 | #endif /* __ASSEMBLY__ */ | 53 | #endif /* __ASSEMBLY__ */ |
70 | #endif /* CONFIG_X86_PAE */ | 54 | #endif /* CONFIG_X86_PAE */ |
71 | 55 | ||
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h index ebf977a809a8..c1ac42d8707f 100644 --- a/include/asm-x86/page_64.h +++ b/include/asm-x86/page_64.h | |||
@@ -70,9 +70,6 @@ typedef unsigned long phys_addr_t; | |||
70 | 70 | ||
71 | typedef struct { pteval_t pte; } pte_t; | 71 | typedef struct { pteval_t pte; } pte_t; |
72 | 72 | ||
73 | #define native_pte_val(x) ((x).pte) | ||
74 | #define native_make_pte(x) ((pte_t) { (x) } ) | ||
75 | |||
76 | #define vmemmap ((struct page *)VMEMMAP_START) | 73 | #define vmemmap ((struct page *)VMEMMAP_START) |
77 | 74 | ||
78 | #endif /* !__ASSEMBLY__ */ | 75 | #endif /* !__ASSEMBLY__ */ |
diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h index b35ed95166e4..24385decbd47 100644 --- a/include/asm-x86/paravirt.h +++ b/include/asm-x86/paravirt.h | |||
@@ -922,7 +922,7 @@ static inline pte_t __pte(unsigned long long val) | |||
922 | unsigned long long ret = PVOP_CALL2(unsigned long long, | 922 | unsigned long long ret = PVOP_CALL2(unsigned long long, |
923 | pv_mmu_ops.make_pte, | 923 | pv_mmu_ops.make_pte, |
924 | val, val >> 32); | 924 | val, val >> 32); |
925 | return (pte_t) { ret, ret >> 32 }; | 925 | return (pte_t) { .pte = ret }; |
926 | } | 926 | } |
927 | 927 | ||
928 | static inline pmd_t __pmd(unsigned long long val) | 928 | static inline pmd_t __pmd(unsigned long long val) |
diff --git a/include/asm-x86/pgtable-2level.h b/include/asm-x86/pgtable-2level.h index d3171c0cb157..f949bb083089 100644 --- a/include/asm-x86/pgtable-2level.h +++ b/include/asm-x86/pgtable-2level.h | |||
@@ -72,13 +72,13 @@ static inline int pte_exec_kernel(pte_t pte) | |||
72 | ((((pte).pte_low >> 1) & 0x1f ) + (((pte).pte_low >> 8) << 5 )) | 72 | ((((pte).pte_low >> 1) & 0x1f ) + (((pte).pte_low >> 8) << 5 )) |
73 | 73 | ||
74 | #define pgoff_to_pte(off) \ | 74 | #define pgoff_to_pte(off) \ |
75 | ((pte_t) { (((off) & 0x1f) << 1) + (((off) >> 5) << 8) + _PAGE_FILE }) | 75 | ((pte_t) { .pte_low = (((off) & 0x1f) << 1) + (((off) >> 5) << 8) + _PAGE_FILE }) |
76 | 76 | ||
77 | /* Encode and de-code a swap entry */ | 77 | /* Encode and de-code a swap entry */ |
78 | #define __swp_type(x) (((x).val >> 1) & 0x1f) | 78 | #define __swp_type(x) (((x).val >> 1) & 0x1f) |
79 | #define __swp_offset(x) ((x).val >> 8) | 79 | #define __swp_offset(x) ((x).val >> 8) |
80 | #define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) }) | 80 | #define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) }) |
81 | #define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_low }) | 81 | #define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_low }) |
82 | #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) | 82 | #define __swp_entry_to_pte(x) ((pte_t) { .pte = (x).val }) |
83 | 83 | ||
84 | #endif /* _I386_PGTABLE_2LEVEL_H */ | 84 | #endif /* _I386_PGTABLE_2LEVEL_H */ |
diff --git a/include/asm-x86/pgtable-3level.h b/include/asm-x86/pgtable-3level.h index 61a7d0029f60..3da96f792dd0 100644 --- a/include/asm-x86/pgtable-3level.h +++ b/include/asm-x86/pgtable-3level.h | |||
@@ -163,7 +163,7 @@ static inline unsigned long pte_pfn(pte_t pte) | |||
163 | * put the 32 bits of offset into the high part. | 163 | * put the 32 bits of offset into the high part. |
164 | */ | 164 | */ |
165 | #define pte_to_pgoff(pte) ((pte).pte_high) | 165 | #define pte_to_pgoff(pte) ((pte).pte_high) |
166 | #define pgoff_to_pte(off) ((pte_t) { _PAGE_FILE, (off) }) | 166 | #define pgoff_to_pte(off) ((pte_t) { { .pte_low = _PAGE_FILE, .pte_high = (off) } }) |
167 | #define PTE_FILE_MAX_BITS 32 | 167 | #define PTE_FILE_MAX_BITS 32 |
168 | 168 | ||
169 | /* Encode and de-code a swap entry */ | 169 | /* Encode and de-code a swap entry */ |
@@ -171,7 +171,7 @@ static inline unsigned long pte_pfn(pte_t pte) | |||
171 | #define __swp_offset(x) ((x).val >> 5) | 171 | #define __swp_offset(x) ((x).val >> 5) |
172 | #define __swp_entry(type, offset) ((swp_entry_t){(type) | (offset) << 5}) | 172 | #define __swp_entry(type, offset) ((swp_entry_t){(type) | (offset) << 5}) |
173 | #define __pte_to_swp_entry(pte) ((swp_entry_t){ (pte).pte_high }) | 173 | #define __pte_to_swp_entry(pte) ((swp_entry_t){ (pte).pte_high }) |
174 | #define __swp_entry_to_pte(x) ((pte_t){ 0, (x).val }) | 174 | #define __swp_entry_to_pte(x) ((pte_t){ { .pte_high = (x).val } }) |
175 | 175 | ||
176 | #define __pmd_free_tlb(tlb, x) do { } while (0) | 176 | #define __pmd_free_tlb(tlb, x) do { } while (0) |
177 | 177 | ||
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h index 57e4ebe0f7fc..77038d8e9bfd 100644 --- a/include/asm-x86/pgtable_64.h +++ b/include/asm-x86/pgtable_64.h | |||
@@ -72,7 +72,7 @@ extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)]; | |||
72 | 72 | ||
73 | static inline void set_pte(pte_t *dst, pte_t val) | 73 | static inline void set_pte(pte_t *dst, pte_t val) |
74 | { | 74 | { |
75 | pte_val(*dst) = pte_val(val); | 75 | *dst = val; |
76 | } | 76 | } |
77 | #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) | 77 | #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) |
78 | 78 | ||
@@ -222,7 +222,7 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, | |||
222 | #define pmd_pfn(x) ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT) | 222 | #define pmd_pfn(x) ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT) |
223 | 223 | ||
224 | #define pte_to_pgoff(pte) ((pte_val(pte) & PHYSICAL_PAGE_MASK) >> PAGE_SHIFT) | 224 | #define pte_to_pgoff(pte) ((pte_val(pte) & PHYSICAL_PAGE_MASK) >> PAGE_SHIFT) |
225 | #define pgoff_to_pte(off) ((pte_t) { ((off) << PAGE_SHIFT) | _PAGE_FILE }) | 225 | #define pgoff_to_pte(off) ((pte_t) { .pte = ((off) << PAGE_SHIFT) | _PAGE_FILE }) |
226 | #define PTE_FILE_MAX_BITS __PHYSICAL_MASK_SHIFT | 226 | #define PTE_FILE_MAX_BITS __PHYSICAL_MASK_SHIFT |
227 | 227 | ||
228 | /* PTE - Level 1 access. */ | 228 | /* PTE - Level 1 access. */ |
@@ -264,7 +264,7 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, | |||
264 | #define __swp_offset(x) ((x).val >> 8) | 264 | #define __swp_offset(x) ((x).val >> 8) |
265 | #define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) }) | 265 | #define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) }) |
266 | #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) | 266 | #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) |
267 | #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) | 267 | #define __swp_entry_to_pte(x) ((pte_t) { .pte = (x).val }) |
268 | 268 | ||
269 | extern spinlock_t pgd_lock; | 269 | extern spinlock_t pgd_lock; |
270 | extern struct list_head pgd_list; | 270 | extern struct list_head pgd_list; |
diff --git a/include/asm-x86/processor.h b/include/asm-x86/processor.h index cc549bf819a4..e701ac5487e5 100644 --- a/include/asm-x86/processor.h +++ b/include/asm-x86/processor.h | |||
@@ -14,7 +14,6 @@ struct mm_struct; | |||
14 | #include <asm/vm86.h> | 14 | #include <asm/vm86.h> |
15 | #include <asm/math_emu.h> | 15 | #include <asm/math_emu.h> |
16 | #include <asm/segment.h> | 16 | #include <asm/segment.h> |
17 | #include <asm/page.h> | ||
18 | #include <asm/types.h> | 17 | #include <asm/types.h> |
19 | #include <asm/sigcontext.h> | 18 | #include <asm/sigcontext.h> |
20 | #include <asm/current.h> | 19 | #include <asm/current.h> |
diff --git a/include/xen/page.h b/include/xen/page.h index c0c8fcb27899..031ef22a971e 100644 --- a/include/xen/page.h +++ b/include/xen/page.h | |||
@@ -156,16 +156,16 @@ static inline pte_t mfn_pte(unsigned long page_nr, pgprot_t pgprot) | |||
156 | 156 | ||
157 | static inline unsigned long long pte_val_ma(pte_t x) | 157 | static inline unsigned long long pte_val_ma(pte_t x) |
158 | { | 158 | { |
159 | return ((unsigned long long)x.pte_high << 32) | x.pte_low; | 159 | return x.pte; |
160 | } | 160 | } |
161 | #define pmd_val_ma(v) ((v).pmd) | 161 | #define pmd_val_ma(v) ((v).pmd) |
162 | #define pud_val_ma(v) ((v).pgd.pgd) | 162 | #define pud_val_ma(v) ((v).pgd.pgd) |
163 | #define __pte_ma(x) ((pte_t) { .pte_low = (x), .pte_high = (x)>>32 } ) | 163 | #define __pte_ma(x) ((pte_t) { .pte = (x) }) |
164 | #define __pmd_ma(x) ((pmd_t) { (x) } ) | 164 | #define __pmd_ma(x) ((pmd_t) { (x) } ) |
165 | #else /* !X86_PAE */ | 165 | #else /* !X86_PAE */ |
166 | #define pte_mfn(_pte) ((_pte).pte_low >> PAGE_SHIFT) | 166 | #define pte_mfn(_pte) ((_pte).pte_low >> PAGE_SHIFT) |
167 | #define mfn_pte(pfn, prot) __pte_ma(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) | 167 | #define mfn_pte(pfn, prot) __pte_ma(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) |
168 | #define pte_val_ma(x) ((x).pte_low) | 168 | #define pte_val_ma(x) ((x).pte) |
169 | #define pmd_val_ma(v) ((v).pud.pgd.pgd) | 169 | #define pmd_val_ma(v) ((v).pud.pgd.pgd) |
170 | #define __pte_ma(x) ((pte_t) { (x) } ) | 170 | #define __pte_ma(x) ((pte_t) { (x) } ) |
171 | #endif /* CONFIG_X86_PAE */ | 171 | #endif /* CONFIG_X86_PAE */ |