Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jeremy Fitzhardinge and committed by
Ingo Molnar
c8e5393a b7fff536

+29 -41
+1 -3
arch/x86/xen/mmu.c
··· 244 244 if (pte & 1) 245 245 pte = phys_to_machine(XPADDR(pte)).maddr; 246 246 247 - pte &= ~_PAGE_PCD; 248 - 249 - return (pte_t){ pte, pte >> 32 }; 247 + return (pte_t){ .pte = pte }; 250 248 } 251 249 252 250 pmd_t xen_make_pmd(unsigned long long pmd)
+10
include/asm-x86/page.h
··· 108 108 #include <asm-generic/pgtable-nopmd.h> 109 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 121 #define pgprot_val(x) ((x).pgprot) 112 122 #define __pgprot(x) ((pgprot_t) { (x) } ) 113 123
+7 -23
include/asm-x86/page_32.h
··· 26 26 typedef u64 pgprotval_t; 27 27 typedef u64 phys_addr_t; 28 28 29 - typedef struct { unsigned long pte_low, pte_high; } pte_t; 30 - 31 - static inline unsigned long long native_pte_val(pte_t pte) 32 - { 33 - return pte.pte_low | ((unsigned long long)pte.pte_high << 32); 34 - } 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 - 29 + typedef union { 30 + struct { 31 + unsigned long pte_low, pte_high; 32 + }; 33 + pteval_t pte; 34 + } pte_t; 41 35 #endif /* __ASSEMBLY__ 42 36 */ 43 37 #else /* !CONFIG_X86_PAE */ ··· 47 53 typedef unsigned long pgprotval_t; 48 54 typedef unsigned long phys_addr_t; 49 55 50 - typedef struct { pteval_t pte_low; } pte_t; 56 + typedef union { pteval_t pte, pte_low; } pte_t; 51 57 typedef pte_t boot_pte_t; 52 - 53 - static inline unsigned long native_pte_val(pte_t pte) 54 - { 55 - return pte.pte_low; 56 - } 57 - 58 - static inline pte_t native_make_pte(unsigned long val) 59 - { 60 - return (pte_t) { .pte_low = val }; 61 - } 62 58 63 59 #endif /* __ASSEMBLY__ */ 64 60 #endif /* CONFIG_X86_PAE */
-3
include/asm-x86/page_64.h
··· 70 70 71 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 73 #define vmemmap ((struct page *)VMEMMAP_START) 77 74 78 75 #endif /* !__ASSEMBLY__ */
+1 -1
include/asm-x86/paravirt.h
··· 922 922 unsigned long long ret = PVOP_CALL2(unsigned long long, 923 923 pv_mmu_ops.make_pte, 924 924 val, val >> 32); 925 - return (pte_t) { ret, ret >> 32 }; 925 + return (pte_t) { .pte = ret }; 926 926 } 927 927 928 928 static inline pmd_t __pmd(unsigned long long val)
+2 -2
include/asm-x86/pgtable-2level.h
··· 72 72 ((((pte).pte_low >> 1) & 0x1f ) + (((pte).pte_low >> 8) << 5 )) 73 73 74 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 77 /* Encode and de-code a swap entry */ 78 78 #define __swp_type(x) (((x).val >> 1) & 0x1f) 79 79 #define __swp_offset(x) ((x).val >> 8) 80 80 #define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) }) 81 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 84 #endif /* _I386_PGTABLE_2LEVEL_H */
+2 -2
include/asm-x86/pgtable-3level.h
··· 163 163 * put the 32 bits of offset into the high part. 164 164 */ 165 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 167 #define PTE_FILE_MAX_BITS 32 168 168 169 169 /* Encode and de-code a swap entry */ ··· 171 171 #define __swp_offset(x) ((x).val >> 5) 172 172 #define __swp_entry(type, offset) ((swp_entry_t){(type) | (offset) << 5}) 173 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 176 #define __pmd_free_tlb(tlb, x) do { } while (0) 177 177
+3 -3
include/asm-x86/pgtable_64.h
··· 72 72 73 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 77 #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) 78 78 ··· 222 222 #define pmd_pfn(x) ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT) 223 223 224 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 226 #define PTE_FILE_MAX_BITS __PHYSICAL_MASK_SHIFT 227 227 228 228 /* PTE - Level 1 access. */ ··· 264 264 #define __swp_offset(x) ((x).val >> 8) 265 265 #define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) }) 266 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 269 extern spinlock_t pgd_lock; 270 270 extern struct list_head pgd_list;
-1
include/asm-x86/processor.h
··· 14 14 #include <asm/vm86.h> 15 15 #include <asm/math_emu.h> 16 16 #include <asm/segment.h> 17 - #include <asm/page.h> 18 17 #include <asm/types.h> 19 18 #include <asm/sigcontext.h> 20 19 #include <asm/current.h>
+3 -3
include/xen/page.h
··· 156 156 157 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 161 #define pmd_val_ma(v) ((v).pmd) 162 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 164 #define __pmd_ma(x) ((pmd_t) { (x) } ) 165 165 #else /* !X86_PAE */ 166 166 #define pte_mfn(_pte) ((_pte).pte_low >> PAGE_SHIFT) 167 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 169 #define pmd_val_ma(v) ((v).pud.pgd.pgd) 170 170 #define __pte_ma(x) ((pte_t) { (x) } ) 171 171 #endif /* CONFIG_X86_PAE */