aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@goop.org>2008-01-30 07:32:57 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:32:57 -0500
commit6fdc05d4794056e0b98901646c4b68c60a01d5eb (patch)
treea6cfb308becd6fe47c549084b29c3e9db3a07f68
parentc3bcfb57e1e64b9b2f8b2d90564826637e21c5ea (diff)
x86: unify pgtable accessors which use
Make users of supported_pte_mask common. This has the side-effect of introducing the variable for 32-bit non-PAE, but I think its a pretty small cost to simplify the code. 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/mm/init_32.c5
-rw-r--r--include/asm-x86/pgtable-2level.h2
-rw-r--r--include/asm-x86/pgtable-3level.h14
-rw-r--r--include/asm-x86/pgtable.h14
-rw-r--r--include/asm-x86/pgtable_64.h18
5 files changed, 17 insertions, 36 deletions
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 29130970c193..04332c09ad1d 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -478,11 +478,12 @@ void zap_low_mappings (void)
478 478
479int nx_enabled = 0; 479int nx_enabled = 0;
480 480
481pteval_t __supported_pte_mask __read_mostly = ~_PAGE_NX;
482EXPORT_SYMBOL_GPL(__supported_pte_mask);
483
481#ifdef CONFIG_X86_PAE 484#ifdef CONFIG_X86_PAE
482 485
483static int disable_nx __initdata = 0; 486static int disable_nx __initdata = 0;
484u64 __supported_pte_mask __read_mostly = ~_PAGE_NX;
485EXPORT_SYMBOL_GPL(__supported_pte_mask);
486 487
487/* 488/*
488 * noexec = on|off 489 * noexec = on|off
diff --git a/include/asm-x86/pgtable-2level.h b/include/asm-x86/pgtable-2level.h
index 84b03cf56a79..d3171c0cb157 100644
--- a/include/asm-x86/pgtable-2level.h
+++ b/include/asm-x86/pgtable-2level.h
@@ -53,8 +53,6 @@ static inline pte_t native_ptep_get_and_clear(pte_t *xp)
53#define pte_page(x) pfn_to_page(pte_pfn(x)) 53#define pte_page(x) pfn_to_page(pte_pfn(x))
54#define pte_none(x) (!(x).pte_low) 54#define pte_none(x) (!(x).pte_low)
55#define pte_pfn(x) (pte_val(x) >> PAGE_SHIFT) 55#define pte_pfn(x) (pte_val(x) >> PAGE_SHIFT)
56#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
57#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
58 56
59/* 57/*
60 * All present pages are kernel-executable: 58 * All present pages are kernel-executable:
diff --git a/include/asm-x86/pgtable-3level.h b/include/asm-x86/pgtable-3level.h
index 9816346f7df6..61a7d0029f60 100644
--- a/include/asm-x86/pgtable-3level.h
+++ b/include/asm-x86/pgtable-3level.h
@@ -158,20 +158,6 @@ static inline unsigned long pte_pfn(pte_t pte)
158 return (pte_val(pte) & ~_PAGE_NX) >> PAGE_SHIFT; 158 return (pte_val(pte) & ~_PAGE_NX) >> PAGE_SHIFT;
159} 159}
160 160
161extern unsigned long long __supported_pte_mask;
162
163static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
164{
165 return __pte((((unsigned long long)page_nr << PAGE_SHIFT) |
166 pgprot_val(pgprot)) & __supported_pte_mask);
167}
168
169static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
170{
171 return __pmd((((unsigned long long)page_nr << PAGE_SHIFT) |
172 pgprot_val(pgprot)) & __supported_pte_mask);
173}
174
175/* 161/*
176 * Bits 0, 6 and 7 are taken in the low part of the pte, 162 * Bits 0, 6 and 7 are taken in the low part of the pte,
177 * put the 32 bits of offset into the high part. 163 * put the 32 bits of offset into the high part.
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index 4c03ff2246fd..b29a122fc1ff 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -141,6 +141,20 @@ static inline pte_t pte_mkwrite(pte_t pte) { return __pte(pte_val(pte) | _PAGE_R
141static inline pte_t pte_mkhuge(pte_t pte) { return __pte(pte_val(pte) | _PAGE_PSE); } 141static inline pte_t pte_mkhuge(pte_t pte) { return __pte(pte_val(pte) | _PAGE_PSE); }
142static inline pte_t pte_clrhuge(pte_t pte) { return __pte(pte_val(pte) & ~_PAGE_PSE); } 142static inline pte_t pte_clrhuge(pte_t pte) { return __pte(pte_val(pte) & ~_PAGE_PSE); }
143 143
144extern pteval_t __supported_pte_mask;
145
146static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
147{
148 return __pte((((phys_addr_t)page_nr << PAGE_SHIFT) |
149 pgprot_val(pgprot)) & __supported_pte_mask);
150}
151
152static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
153{
154 return __pmd((((phys_addr_t)page_nr << PAGE_SHIFT) |
155 pgprot_val(pgprot)) & __supported_pte_mask);
156}
157
144#endif /* __ASSEMBLY__ */ 158#endif /* __ASSEMBLY__ */
145 159
146#ifdef CONFIG_X86_32 160#ifdef CONFIG_X86_32
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h
index 84f47f9d7896..57e4ebe0f7fc 100644
--- a/include/asm-x86/pgtable_64.h
+++ b/include/asm-x86/pgtable_64.h
@@ -17,7 +17,6 @@ extern pud_t level3_kernel_pgt[512];
17extern pud_t level3_ident_pgt[512]; 17extern pud_t level3_ident_pgt[512];
18extern pmd_t level2_kernel_pgt[512]; 18extern pmd_t level2_kernel_pgt[512];
19extern pgd_t init_level4_pgt[]; 19extern pgd_t init_level4_pgt[];
20extern unsigned long __supported_pte_mask;
21 20
22#define swapper_pg_dir init_level4_pgt 21#define swapper_pg_dir init_level4_pgt
23 22
@@ -165,14 +164,6 @@ static inline unsigned long pmd_bad(pmd_t pmd)
165#define pte_page(x) pfn_to_page(pte_pfn(x)) 164#define pte_page(x) pfn_to_page(pte_pfn(x))
166#define pte_pfn(x) ((pte_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT) 165#define pte_pfn(x) ((pte_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT)
167 166
168static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
169{
170 pte_t pte;
171 pte_val(pte) = (page_nr << PAGE_SHIFT);
172 pte_val(pte) |= pgprot_val(pgprot);
173 pte_val(pte) &= __supported_pte_mask;
174 return pte;
175}
176struct vm_area_struct; 167struct vm_area_struct;
177 168
178static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) 169static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
@@ -239,15 +230,6 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
239/* page, protection -> pte */ 230/* page, protection -> pte */
240#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) 231#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
241 232
242/* Change flags of a PTE */
243static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
244{
245 pte_val(pte) &= _PAGE_CHG_MASK;
246 pte_val(pte) |= pgprot_val(newprot);
247 pte_val(pte) &= __supported_pte_mask;
248 return pte;
249}
250
251#define pte_index(address) \ 233#define pte_index(address) \
252 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) 234 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
253#define pte_offset_kernel(dir, address) ((pte_t *) pmd_page_vaddr(*(dir)) + \ 235#define pte_offset_kernel(dir, address) ((pte_t *) pmd_page_vaddr(*(dir)) + \