ia64/xen-unstable
changeset 14018:832b252f1f6f
Merge
author | Tim Deegan <Tim.Deegan@xensource.com> |
---|---|
date | Tue Feb 20 09:34:22 2007 +0000 (2007-02-20) |
parents | 919879a49266 d2dff286994d |
children | 4b9680c58d73 |
files |
line diff
1.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/maddr.h Mon Feb 19 20:44:42 2007 -0800 1.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/maddr.h Tue Feb 20 09:34:22 2007 +0000 1.3 @@ -21,6 +21,7 @@ typedef unsigned long maddr_t; 1.4 #ifdef CONFIG_XEN 1.5 1.6 extern unsigned long *phys_to_machine_mapping; 1.7 +extern unsigned long max_mapnr; 1.8 1.9 #undef machine_to_phys_mapping 1.10 extern unsigned long *machine_to_phys_mapping; 1.11 @@ -30,20 +31,20 @@ static inline unsigned long pfn_to_mfn(u 1.12 { 1.13 if (xen_feature(XENFEAT_auto_translated_physmap)) 1.14 return pfn; 1.15 - return phys_to_machine_mapping[(unsigned int)(pfn)] & 1.16 - ~FOREIGN_FRAME_BIT; 1.17 + BUG_ON(max_mapnr && pfn >= max_mapnr); 1.18 + return phys_to_machine_mapping[pfn] & ~FOREIGN_FRAME_BIT; 1.19 } 1.20 1.21 static inline int phys_to_machine_mapping_valid(unsigned long pfn) 1.22 { 1.23 if (xen_feature(XENFEAT_auto_translated_physmap)) 1.24 return 1; 1.25 + BUG_ON(max_mapnr && pfn >= max_mapnr); 1.26 return (phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY); 1.27 } 1.28 1.29 static inline unsigned long mfn_to_pfn(unsigned long mfn) 1.30 { 1.31 - extern unsigned long max_mapnr; 1.32 unsigned long pfn; 1.33 1.34 if (xen_feature(XENFEAT_auto_translated_physmap)) 1.35 @@ -92,7 +93,6 @@ static inline unsigned long mfn_to_pfn(u 1.36 */ 1.37 static inline unsigned long mfn_to_local_pfn(unsigned long mfn) 1.38 { 1.39 - extern unsigned long max_mapnr; 1.40 unsigned long pfn = mfn_to_pfn(mfn); 1.41 if ((pfn < max_mapnr) 1.42 && !xen_feature(XENFEAT_auto_translated_physmap) 1.43 @@ -103,6 +103,7 @@ static inline unsigned long mfn_to_local 1.44 1.45 static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn) 1.46 { 1.47 + BUG_ON(pfn >= max_mapnr); 1.48 if (xen_feature(XENFEAT_auto_translated_physmap)) { 1.49 BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY); 1.50 return; 1.51 @@ -124,6 +125,20 @@ static inline paddr_t machine_to_phys(ma 1.52 return phys; 1.53 } 1.54 1.55 +#ifdef CONFIG_X86_PAE 1.56 +static inline paddr_t pte_phys_to_machine(paddr_t phys) 1.57 +{ 1.58 + /* 1.59 + * In PAE mode, the NX bit needs to be dealt with in the value 1.60 + * passed to pfn_to_mfn(). On x86_64, we need to mask it off, 1.61 + * but for i386 the conversion to ulong for the argument will 1.62 + * clip it off. 1.63 + */ 1.64 + maddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT); 1.65 + machine = (machine << PAGE_SHIFT) | (phys & ~PHYSICAL_PAGE_MASK); 1.66 + return machine; 1.67 +} 1.68 + 1.69 static inline paddr_t pte_machine_to_phys(maddr_t machine) 1.70 { 1.71 /* 1.72 @@ -136,6 +151,7 @@ static inline paddr_t pte_machine_to_phy 1.73 phys = (phys << PAGE_SHIFT) | (machine & ~PHYSICAL_PAGE_MASK); 1.74 return phys; 1.75 } 1.76 +#endif 1.77 1.78 #else /* !CONFIG_XEN */ 1.79 1.80 @@ -146,7 +162,6 @@ static inline paddr_t pte_machine_to_phy 1.81 #define phys_to_machine_mapping_valid(pfn) (1) 1.82 #define phys_to_machine(phys) ((maddr_t)(phys)) 1.83 #define machine_to_phys(mach) ((paddr_t)(mach)) 1.84 -#define pte_machine_to_phys(mach) ((paddr_t)(mach)) 1.85 1.86 #endif /* !CONFIG_XEN */ 1.87
2.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h Mon Feb 19 20:44:42 2007 -0800 2.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h Tue Feb 20 09:34:22 2007 +0000 2.3 @@ -29,6 +29,13 @@ 2.4 #include <xen/interface/xen.h> 2.5 #include <xen/features.h> 2.6 2.7 +/* 2.8 + * Need to repeat this here in order to not include pgtable.h (which in turn 2.9 + * depends on definitions made here), but to be able to use the symbolic 2.10 + * below. The preprocessor will warn if the two definitions aren't identical. 2.11 + */ 2.12 +#define _PAGE_PRESENT 0x001 2.13 + 2.14 #define arch_free_page(_page,_order) \ 2.15 ({ int foreign = PageForeign(_page); \ 2.16 if (foreign) \ 2.17 @@ -81,40 +88,38 @@ typedef struct { unsigned long long pgpr 2.18 #define pgprot_val(x) ((x).pgprot) 2.19 #include <asm/maddr.h> 2.20 #define __pte(x) ({ unsigned long long _x = (x); \ 2.21 - if (_x & 1) _x = phys_to_machine(_x); \ 2.22 + if (_x & _PAGE_PRESENT) _x = pte_phys_to_machine(_x); \ 2.23 ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); }) 2.24 #define __pgd(x) ({ unsigned long long _x = (x); \ 2.25 - (((_x)&1) ? ((pgd_t) {phys_to_machine(_x)}) : ((pgd_t) {(_x)})); }) 2.26 + (pgd_t) {((_x) & _PAGE_PRESENT) ? pte_phys_to_machine(_x) : (_x)}; }) 2.27 #define __pmd(x) ({ unsigned long long _x = (x); \ 2.28 - (((_x)&1) ? ((pmd_t) {phys_to_machine(_x)}) : ((pmd_t) {(_x)})); }) 2.29 + (pmd_t) {((_x) & _PAGE_PRESENT) ? pte_phys_to_machine(_x) : (_x)}; }) 2.30 +static inline unsigned long long pte_val_ma(pte_t x) 2.31 +{ 2.32 + return ((unsigned long long)x.pte_high << 32) | x.pte_low; 2.33 +} 2.34 static inline unsigned long long pte_val(pte_t x) 2.35 { 2.36 - unsigned long long ret; 2.37 - 2.38 - if (x.pte_low) { 2.39 - ret = x.pte_low | (unsigned long long)x.pte_high << 32; 2.40 - ret = pte_machine_to_phys(ret) | 1; 2.41 - } else { 2.42 - ret = 0; 2.43 - } 2.44 + unsigned long long ret = pte_val_ma(x); 2.45 + if (x.pte_low & _PAGE_PRESENT) ret = pte_machine_to_phys(ret); 2.46 return ret; 2.47 } 2.48 static inline unsigned long long pmd_val(pmd_t x) 2.49 { 2.50 unsigned long long ret = x.pmd; 2.51 - if (ret) ret = pte_machine_to_phys(ret) | 1; 2.52 +#ifdef CONFIG_XEN_COMPAT_030002 2.53 + if (ret) ret = pte_machine_to_phys(ret) | _PAGE_PRESENT; 2.54 +#else 2.55 + if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret); 2.56 +#endif 2.57 return ret; 2.58 } 2.59 static inline unsigned long long pgd_val(pgd_t x) 2.60 { 2.61 unsigned long long ret = x.pgd; 2.62 - if (ret) ret = pte_machine_to_phys(ret) | 1; 2.63 + if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret); 2.64 return ret; 2.65 } 2.66 -static inline unsigned long long pte_val_ma(pte_t x) 2.67 -{ 2.68 - return (unsigned long long)x.pte_high << 32 | x.pte_low; 2.69 -} 2.70 #define HPAGE_SHIFT 21 2.71 #else 2.72 typedef struct { unsigned long pte_low; } pte_t; 2.73 @@ -123,23 +128,23 @@ typedef struct { unsigned long pgprot; } 2.74 #define pgprot_val(x) ((x).pgprot) 2.75 #include <asm/maddr.h> 2.76 #define boot_pte_t pte_t /* or would you rather have a typedef */ 2.77 -#define pte_val(x) (((x).pte_low & 1) ? \ 2.78 - pte_machine_to_phys((x).pte_low) : \ 2.79 +#define pte_val(x) (((x).pte_low & _PAGE_PRESENT) ? \ 2.80 + machine_to_phys((x).pte_low) : \ 2.81 (x).pte_low) 2.82 #define pte_val_ma(x) ((x).pte_low) 2.83 #define __pte(x) ({ unsigned long _x = (x); \ 2.84 - (((_x)&1) ? ((pte_t) {phys_to_machine(_x)}) : ((pte_t) {(_x)})); }) 2.85 + (pte_t) {((_x) & _PAGE_PRESENT) ? phys_to_machine(_x) : (_x)}; }) 2.86 #define __pgd(x) ({ unsigned long _x = (x); \ 2.87 - (((_x)&1) ? ((pgd_t) {phys_to_machine(_x)}) : ((pgd_t) {(_x)})); }) 2.88 + (pgd_t) {((_x) & _PAGE_PRESENT) ? phys_to_machine(_x) : (_x)}; }) 2.89 static inline unsigned long pgd_val(pgd_t x) 2.90 { 2.91 unsigned long ret = x.pgd; 2.92 - if (ret) ret = pte_machine_to_phys(ret) | 1; 2.93 + if (ret & _PAGE_PRESENT) ret = machine_to_phys(ret); 2.94 return ret; 2.95 } 2.96 #define HPAGE_SHIFT 22 2.97 #endif 2.98 -#define PTE_MASK PAGE_MASK 2.99 +#define PTE_MASK PHYSICAL_PAGE_MASK 2.100 2.101 #ifdef CONFIG_HUGETLB_PAGE 2.102 #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
3.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgtable-2level.h Mon Feb 19 20:44:42 2007 -0800 3.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgtable-2level.h Tue Feb 20 09:34:22 2007 +0000 3.3 @@ -38,8 +38,11 @@ 3.4 3.5 #define ptep_get_and_clear(mm,addr,xp) __pte_ma(xchg(&(xp)->pte_low, 0)) 3.6 #define pte_same(a, b) ((a).pte_low == (b).pte_low) 3.7 -#define pte_mfn(_pte) ((_pte).pte_low >> PAGE_SHIFT) 3.8 -#define pte_pfn(_pte) mfn_to_local_pfn(pte_mfn(_pte)) 3.9 +#define __pte_mfn(_pte) ((_pte).pte_low >> PAGE_SHIFT) 3.10 +#define pte_mfn(_pte) ((_pte).pte_low & _PAGE_PRESENT ? \ 3.11 + __pte_mfn(_pte) : pfn_to_mfn(__pte_mfn(_pte))) 3.12 +#define pte_pfn(_pte) ((_pte).pte_low & _PAGE_PRESENT ? \ 3.13 + mfn_to_local_pfn(__pte_mfn(_pte)) : __pte_mfn(_pte)) 3.14 3.15 #define pte_page(_pte) pfn_to_page(pte_pfn(_pte)) 3.16
4.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgtable-3level.h Mon Feb 19 20:44:42 2007 -0800 4.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgtable-3level.h Tue Feb 20 09:34:22 2007 +0000 4.3 @@ -145,21 +145,24 @@ static inline int pte_none(pte_t pte) 4.4 return !pte.pte_low && !pte.pte_high; 4.5 } 4.6 4.7 -#define pte_mfn(_pte) (((_pte).pte_low >> PAGE_SHIFT) |\ 4.8 - (((_pte).pte_high & 0xfff) << (32-PAGE_SHIFT))) 4.9 -#define pte_pfn(_pte) mfn_to_local_pfn(pte_mfn(_pte)) 4.10 +#define __pte_mfn(_pte) (((_pte).pte_low >> PAGE_SHIFT) | \ 4.11 + ((_pte).pte_high << (32-PAGE_SHIFT))) 4.12 +#define pte_mfn(_pte) ((_pte).pte_low & _PAGE_PRESENT ? \ 4.13 + __pte_mfn(_pte) : pfn_to_mfn(__pte_mfn(_pte))) 4.14 +#define pte_pfn(_pte) ((_pte).pte_low & _PAGE_PRESENT ? \ 4.15 + mfn_to_local_pfn(__pte_mfn(_pte)) : __pte_mfn(_pte)) 4.16 4.17 extern unsigned long long __supported_pte_mask; 4.18 4.19 static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) 4.20 { 4.21 - return pfn_pte_ma(pfn_to_mfn(page_nr), pgprot); 4.22 + return __pte((((unsigned long long)page_nr << PAGE_SHIFT) | 4.23 + pgprot_val(pgprot)) & __supported_pte_mask); 4.24 } 4.25 4.26 static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot) 4.27 { 4.28 - BUG(); panic("needs review"); 4.29 - return __pmd((((unsigned long long)page_nr << PAGE_SHIFT) | \ 4.30 + return __pmd((((unsigned long long)page_nr << PAGE_SHIFT) | 4.31 pgprot_val(pgprot)) & __supported_pte_mask); 4.32 } 4.33
5.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgtable.h Mon Feb 19 20:44:42 2007 -0800 5.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgtable.h Tue Feb 20 09:34:22 2007 +0000 5.3 @@ -315,18 +315,19 @@ static inline void clone_pgd_range(pgd_t 5.4 5.5 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 5.6 { 5.7 - pte.pte_low &= _PAGE_CHG_MASK; 5.8 - pte.pte_low |= pgprot_val(newprot); 5.9 + /* 5.10 + * Since this might change the present bit (which controls whether 5.11 + * a pte_t object has undergone p2m translation), we must use 5.12 + * pte_val() on the input pte and __pte() for the return value. 5.13 + */ 5.14 + paddr_t pteval = pte_val(pte); 5.15 + 5.16 + pteval &= _PAGE_CHG_MASK; 5.17 + pteval |= pgprot_val(newprot); 5.18 #ifdef CONFIG_X86_PAE 5.19 - /* 5.20 - * Chop off the NX bit (if present), and add the NX portion of 5.21 - * the newprot (if present): 5.22 - */ 5.23 - pte.pte_high &= ~(1 << (_PAGE_BIT_NX - 32)); 5.24 - pte.pte_high |= (pgprot_val(newprot) >> 32) & \ 5.25 - (__supported_pte_mask >> 32); 5.26 + pteval &= __supported_pte_mask; 5.27 #endif 5.28 - return pte; 5.29 + return __pte(pteval); 5.30 } 5.31 5.32 #define pmd_large(pmd) \
6.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/maddr.h Mon Feb 19 20:44:42 2007 -0800 6.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/maddr.h Tue Feb 20 09:34:22 2007 +0000 6.3 @@ -25,14 +25,15 @@ static inline unsigned long pfn_to_mfn(u 6.4 { 6.5 if (xen_feature(XENFEAT_auto_translated_physmap)) 6.6 return pfn; 6.7 - return phys_to_machine_mapping[(unsigned int)(pfn)] & 6.8 - ~FOREIGN_FRAME_BIT; 6.9 + BUG_ON(end_pfn && pfn >= end_pfn); 6.10 + return phys_to_machine_mapping[pfn] & ~FOREIGN_FRAME_BIT; 6.11 } 6.12 6.13 static inline int phys_to_machine_mapping_valid(unsigned long pfn) 6.14 { 6.15 if (xen_feature(XENFEAT_auto_translated_physmap)) 6.16 return 1; 6.17 + BUG_ON(end_pfn && pfn >= end_pfn); 6.18 return (phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY); 6.19 } 6.20 6.21 @@ -96,6 +97,7 @@ static inline unsigned long mfn_to_local 6.22 6.23 static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn) 6.24 { 6.25 + BUG_ON(pfn >= end_pfn); 6.26 if (xen_feature(XENFEAT_auto_translated_physmap)) { 6.27 BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY); 6.28 return; 6.29 @@ -117,6 +119,14 @@ static inline paddr_t machine_to_phys(ma 6.30 return phys; 6.31 } 6.32 6.33 +static inline paddr_t pte_phys_to_machine(paddr_t phys) 6.34 +{ 6.35 + maddr_t machine; 6.36 + machine = pfn_to_mfn((phys & PHYSICAL_PAGE_MASK) >> PAGE_SHIFT); 6.37 + machine = (machine << PAGE_SHIFT) | (phys & ~PHYSICAL_PAGE_MASK); 6.38 + return machine; 6.39 +} 6.40 + 6.41 static inline paddr_t pte_machine_to_phys(maddr_t machine) 6.42 { 6.43 paddr_t phys; 6.44 @@ -134,7 +144,6 @@ static inline paddr_t pte_machine_to_phy 6.45 #define phys_to_machine_mapping_valid(pfn) (1) 6.46 #define phys_to_machine(phys) ((maddr_t)(phys)) 6.47 #define machine_to_phys(mach) ((paddr_t)(mach)) 6.48 -#define pte_machine_to_phys(mach) ((paddr_t)(mach)) 6.49 6.50 #endif /* !CONFIG_XEN */ 6.51
7.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h Mon Feb 19 20:44:42 2007 -0800 7.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h Tue Feb 20 09:34:22 2007 +0000 7.3 @@ -9,6 +9,13 @@ 7.4 #endif 7.5 #include <xen/interface/xen.h> 7.6 7.7 +/* 7.8 + * Need to repeat this here in order to not include pgtable.h (which in turn 7.9 + * depends on definitions made here), but to be able to use the symbolic 7.10 + * below. The preprocessor will warn if the two definitions aren't identical. 7.11 + */ 7.12 +#define _PAGE_PRESENT 0x001 7.13 + 7.14 #define arch_free_page(_page,_order) \ 7.15 ({ int foreign = PageForeign(_page); \ 7.16 if (foreign) \ 7.17 @@ -95,28 +102,33 @@ typedef struct { unsigned long pgd; } pg 7.18 7.19 typedef struct { unsigned long pgprot; } pgprot_t; 7.20 7.21 -#define pte_val(x) (((x).pte & 1) ? pte_machine_to_phys((x).pte) : \ 7.22 +#define pte_val(x) (((x).pte & _PAGE_PRESENT) ? \ 7.23 + pte_machine_to_phys((x).pte) : \ 7.24 (x).pte) 7.25 #define pte_val_ma(x) ((x).pte) 7.26 7.27 static inline unsigned long pmd_val(pmd_t x) 7.28 { 7.29 unsigned long ret = x.pmd; 7.30 - if (ret) ret = pte_machine_to_phys(ret); 7.31 +#ifdef CONFIG_XEN_COMPAT_030002 7.32 + if (ret) ret = pte_machine_to_phys(ret) | _PAGE_PRESENT; 7.33 +#else 7.34 + if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret); 7.35 +#endif 7.36 return ret; 7.37 } 7.38 7.39 static inline unsigned long pud_val(pud_t x) 7.40 { 7.41 unsigned long ret = x.pud; 7.42 - if (ret) ret = pte_machine_to_phys(ret); 7.43 + if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret); 7.44 return ret; 7.45 } 7.46 7.47 static inline unsigned long pgd_val(pgd_t x) 7.48 { 7.49 unsigned long ret = x.pgd; 7.50 - if (ret) ret = pte_machine_to_phys(ret); 7.51 + if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret); 7.52 return ret; 7.53 } 7.54 7.55 @@ -124,25 +136,25 @@ static inline unsigned long pgd_val(pgd_ 7.56 7.57 static inline pte_t __pte(unsigned long x) 7.58 { 7.59 - if (x & 1) x = phys_to_machine(x); 7.60 + if (x & _PAGE_PRESENT) x = pte_phys_to_machine(x); 7.61 return ((pte_t) { (x) }); 7.62 } 7.63 7.64 static inline pmd_t __pmd(unsigned long x) 7.65 { 7.66 - if ((x & 1)) x = phys_to_machine(x); 7.67 + if (x & _PAGE_PRESENT) x = pte_phys_to_machine(x); 7.68 return ((pmd_t) { (x) }); 7.69 } 7.70 7.71 static inline pud_t __pud(unsigned long x) 7.72 { 7.73 - if ((x & 1)) x = phys_to_machine(x); 7.74 + if (x & _PAGE_PRESENT) x = pte_phys_to_machine(x); 7.75 return ((pud_t) { (x) }); 7.76 } 7.77 7.78 static inline pgd_t __pgd(unsigned long x) 7.79 { 7.80 - if ((x & 1)) x = phys_to_machine(x); 7.81 + if (x & _PAGE_PRESENT) x = pte_phys_to_machine(x); 7.82 return ((pgd_t) { (x) }); 7.83 } 7.84
8.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/pgtable.h Mon Feb 19 20:44:42 2007 -0800 8.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/pgtable.h Tue Feb 20 09:34:22 2007 +0000 8.3 @@ -302,19 +302,20 @@ static inline unsigned long pud_bad(pud_ 8.4 8.5 #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) 8.6 8.7 -#define pte_mfn(_pte) (((_pte).pte & PTE_MASK) >> PAGE_SHIFT) 8.8 -#define pte_pfn(_pte) mfn_to_local_pfn(pte_mfn(_pte)) 8.9 +#define __pte_mfn(_pte) (((_pte).pte & PTE_MASK) >> PAGE_SHIFT) 8.10 +#define pte_mfn(_pte) ((_pte).pte & _PAGE_PRESENT ? \ 8.11 + __pte_mfn(_pte) : pfn_to_mfn(__pte_mfn(_pte))) 8.12 +#define pte_pfn(_pte) ((_pte).pte & _PAGE_PRESENT ? \ 8.13 + mfn_to_local_pfn(__pte_mfn(_pte)) : __pte_mfn(_pte)) 8.14 8.15 #define pte_page(x) pfn_to_page(pte_pfn(x)) 8.16 8.17 static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) 8.18 { 8.19 - pte_t pte; 8.20 - 8.21 - (pte).pte = (pfn_to_mfn(page_nr) << PAGE_SHIFT); 8.22 - (pte).pte |= pgprot_val(pgprot); 8.23 - (pte).pte &= __supported_pte_mask; 8.24 - return pte; 8.25 + unsigned long pte = page_nr << PAGE_SHIFT; 8.26 + pte |= pgprot_val(pgprot); 8.27 + pte &= __supported_pte_mask; 8.28 + return __pte(pte); 8.29 } 8.30 8.31 /* 8.32 @@ -446,18 +447,25 @@ static inline pud_t *pud_offset_k(pgd_t 8.33 /* physical address -> PTE */ 8.34 static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot) 8.35 { 8.36 - pte_t pte; 8.37 - (pte).pte = physpage | pgprot_val(pgprot); 8.38 - return pte; 8.39 + unsigned long pteval; 8.40 + pteval = physpage | pgprot_val(pgprot); 8.41 + return __pte(pteval); 8.42 } 8.43 8.44 /* Change flags of a PTE */ 8.45 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 8.46 { 8.47 - (pte).pte &= _PAGE_CHG_MASK; 8.48 - (pte).pte |= pgprot_val(newprot); 8.49 - (pte).pte &= __supported_pte_mask; 8.50 - return pte; 8.51 + /* 8.52 + * Since this might change the present bit (which controls whether 8.53 + * a pte_t object has undergone p2m translation), we must use 8.54 + * pte_val() on the input pte and __pte() for the return value. 8.55 + */ 8.56 + unsigned long pteval = pte_val(pte); 8.57 + 8.58 + pteval &= _PAGE_CHG_MASK; 8.59 + pteval |= pgprot_val(newprot); 8.60 + pteval &= __supported_pte_mask; 8.61 + return __pte(pteval); 8.62 } 8.63 8.64 #define pte_index(address) \