public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>, Andi Kleen <ak@suse.de>,
	Glauber de Oliveira Costa <glommer@gmail.com>,
	Jan Beulich <jbeulich@novell.com>
Subject: [PATCH 04 of 10] x86: unify pgtable accessors which use supported_pte_mask
Date: Tue, 08 Jan 2008 14:00:07 -0800	[thread overview]
Message-ID: <aecbf28ecb53fb7b2830.1199829607@localhost> (raw)
In-Reply-To: <patchbomb.1199829603@localhost>

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>

---
 arch/x86/mm/init_32.c            |    5 +++--
 include/asm-x86/pgtable-2level.h |    2 --
 include/asm-x86/pgtable-3level.h |   14 --------------
 include/asm-x86/pgtable.h        |   32 ++++++++++++++++++++++++++++++++
 include/asm-x86/pgtable_32.h     |   16 ----------------
 include/asm-x86/pgtable_64.h     |   18 ------------------
 6 files changed, 35 insertions(+), 52 deletions(-)

diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -473,11 +473,12 @@ void zap_low_mappings (void)
 
 int nx_enabled = 0;
 
+pteval_t __supported_pte_mask __read_mostly = ~_PAGE_NX;
+EXPORT_SYMBOL_GPL(__supported_pte_mask);
+
 #ifdef CONFIG_X86_PAE
 
 static int disable_nx __initdata = 0;
-u64 __supported_pte_mask __read_mostly = ~_PAGE_NX;
-EXPORT_SYMBOL_GPL(__supported_pte_mask);
 
 /*
  * noexec = on|off
diff --git a/include/asm-x86/pgtable-2level.h b/include/asm-x86/pgtable-2level.h
--- 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_
 #define pte_page(x)		pfn_to_page(pte_pfn(x))
 #define pte_none(x)		(!(x).pte_low)
 #define pte_pfn(x)		(pte_val(x) >> PAGE_SHIFT)
-#define pfn_pte(pfn, prot)	__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
-#define pfn_pmd(pfn, prot)	__pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
 
 /*
  * All present pages are kernel-executable:
diff --git a/include/asm-x86/pgtable-3level.h b/include/asm-x86/pgtable-3level.h
--- 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_
 	return pte_val(pte) >> PAGE_SHIFT;
 }
 
-extern unsigned long long __supported_pte_mask;
-
-static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
-{
-	return __pte((((unsigned long long)page_nr << PAGE_SHIFT) |
-		      pgprot_val(pgprot)) & __supported_pte_mask);
-}
-
-static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
-{
-	return __pmd((((unsigned long long)page_nr << PAGE_SHIFT) |
-		      pgprot_val(pgprot)) & __supported_pte_mask);
-}
-
 /*
  * Bits 0, 6 and 7 are taken in the low part of the pte,
  * put the 32 bits of offset into the high part.
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -135,6 +135,38 @@ static inline pte_t pte_mkhuge(pte_t pte
 static inline pte_t pte_mkhuge(pte_t pte)	{ return __pte(pte_val(pte) | _PAGE_PSE); }
 static inline pte_t pte_clrhuge(pte_t pte)	{ return __pte(pte_val(pte) & ~_PAGE_PSE); }
 
+extern pteval_t __supported_pte_mask;
+
+static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
+{
+	return __pte((((phys_addr_t)page_nr << PAGE_SHIFT) |
+		      pgprot_val(pgprot)) & __supported_pte_mask);
+}
+
+static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
+{
+	return __pmd((((phys_addr_t)page_nr << PAGE_SHIFT) |
+		      pgprot_val(pgprot)) & __supported_pte_mask);
+}
+
+static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
+{
+	pteval_t val = pte_val(pte);
+
+	val &= _PAGE_CHG_MASK;
+	val |= pgprot_val(newprot);
+
+	/*
+	 * Chop off the NX bit (if present), and add the NX portion of
+	 * the newprot (if present):
+	 */
+	val &= ~_PAGE_NX;
+	val |= pgprot_val(newprot) & __supported_pte_mask;
+
+	return __pte(val);
+}
+
+
 #endif	/* __ASSEMBLER__ */
 
 #ifdef CONFIG_X86_32
diff --git a/include/asm-x86/pgtable_32.h b/include/asm-x86/pgtable_32.h
--- a/include/asm-x86/pgtable_32.h
+++ b/include/asm-x86/pgtable_32.h
@@ -235,22 +235,6 @@ static inline void clone_pgd_range(pgd_t
 
 #define mk_pte(page, pgprot)	pfn_pte(page_to_pfn(page), (pgprot))
 
-static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
-{
-	pte.pte_low &= _PAGE_CHG_MASK;
-	pte.pte_low |= pgprot_val(newprot);
-#ifdef CONFIG_X86_PAE
-	/*
-	 * Chop off the NX bit (if present), and add the NX portion of
-	 * the newprot (if present):
-	 */
-	pte.pte_high &= ~(1 << (_PAGE_BIT_NX - 32));
-	pte.pte_high |= (pgprot_val(newprot) >> 32) & \
-					(__supported_pte_mask >> 32);
-#endif
-	return pte;
-}
-
 /*
  * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD]
  *
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h
--- a/include/asm-x86/pgtable_64.h
+++ b/include/asm-x86/pgtable_64.h
@@ -17,7 +17,6 @@ extern pud_t level3_ident_pgt[512];
 extern pud_t level3_ident_pgt[512];
 extern pmd_t level2_kernel_pgt[512];
 extern pgd_t init_level4_pgt[];
-extern unsigned long __supported_pte_mask;
 
 #define swapper_pg_dir init_level4_pgt
 
@@ -165,14 +164,6 @@ static inline unsigned long pmd_bad(pmd_
 #define pte_page(x)	pfn_to_page(pte_pfn(x))
 #define pte_pfn(x)  ((pte_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT)
 
-static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
-{
-	pte_t pte;
-	pte_val(pte) = (page_nr << PAGE_SHIFT);
-	pte_val(pte) |= pgprot_val(pgprot);
-	pte_val(pte) &= __supported_pte_mask;
-	return pte;
-}
 struct vm_area_struct;
 
 static 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(st
 /* page, protection -> pte */
 #define mk_pte(page, pgprot)	pfn_pte(page_to_pfn(page), (pgprot))
  
-/* Change flags of a PTE */
-static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
-{ 
-	pte_val(pte) &= _PAGE_CHG_MASK;
-	pte_val(pte) |= pgprot_val(newprot);
-	pte_val(pte) &= __supported_pte_mask;
-       return pte; 
-}
-
 #define pte_index(address) \
 		(((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir, address) ((pte_t *) pmd_page_vaddr(*(dir)) + \



  parent reply	other threads:[~2008-01-08 22:15 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-08 22:00 [PATCH 00 of 10] x86: unify asm/pgtable.h Jeremy Fitzhardinge
2008-01-08 22:00 ` [PATCH 01 of 10] x86: move all asm/pgtable constants into one place Jeremy Fitzhardinge
2008-01-08 22:00 ` [PATCH 02 of 10] x86: avoid name conflict for Voyager leave_mm Jeremy Fitzhardinge
2008-01-08 22:00 ` [PATCH 03 of 10] x86/pgtable: unify pagetable accessors Jeremy Fitzhardinge
2008-01-08 22:00 ` Jeremy Fitzhardinge [this message]
2008-01-08 22:00 ` [PATCH 05 of 10] x86: page.h: make pte_t a union to always include pte element Jeremy Fitzhardinge
2008-01-08 22:00 ` [PATCH 06 of 10] x86/vmi: fix compilation as a result of pte_t changes Jeremy Fitzhardinge
2008-01-08 22:00 ` [PATCH 07 of 10] x86: pgtable: unify pte accessors Jeremy Fitzhardinge
2008-01-08 22:00 ` [PATCH 08 of 10] x86: unify zero_page definition Jeremy Fitzhardinge
2008-01-08 22:00 ` [PATCH 09 of 10] x86: unify paravirt pagetable accessors Jeremy Fitzhardinge
2008-01-08 22:00 ` [PATCH 10 of 10] xen: mask out PWT too Jeremy Fitzhardinge
2008-01-09  9:17   ` Jan Beulich
2008-01-09 19:04     ` Jeremy Fitzhardinge
2008-01-08 22:42 ` [PATCH 00 of 10] x86: unify asm/pgtable.h Ingo Molnar
2008-01-08 23:12   ` Ingo Molnar
2008-01-08 23:23     ` Jeremy Fitzhardinge
2008-01-08 23:28       ` Ingo Molnar
2008-01-08 23:44         ` Ingo Molnar
2008-01-08 23:51           ` Ingo Molnar
2008-01-09  0:01           ` Ingo Molnar
2008-01-09  0:13             ` Jeremy Fitzhardinge
2008-01-09  0:20               ` Ingo Molnar
2008-01-09  0:28                 ` Ingo Molnar
2008-01-09  0:30                   ` Ingo Molnar
2008-01-09  0:43                     ` Ingo Molnar
2008-01-09  0:55                       ` Jeremy Fitzhardinge
2008-01-09  1:09                       ` Jeremy Fitzhardinge
2008-01-09  1:16                         ` Ingo Molnar
2008-01-09  1:18                           ` Andi Kleen
2008-01-09  1:22                             ` Ingo Molnar
2008-01-09  1:37                               ` Andi Kleen
2008-01-09  1:21                           ` Jeremy Fitzhardinge
2008-01-09  1:37                             ` Ingo Molnar
2008-01-09  0:53                     ` Jeremy Fitzhardinge
2008-01-09  0:59                       ` Ingo Molnar
2008-01-09  1:07                         ` Jeremy Fitzhardinge
2008-01-09  1:12                           ` Andi Kleen
2008-01-09  1:20                             ` Ingo Molnar
2008-01-09  1:35                             ` Jeremy Fitzhardinge
2008-01-09  1:42                               ` Andi Kleen
2008-01-09  1:56                                 ` Jeremy Fitzhardinge
2008-01-09  2:11                                   ` Andi Kleen
2008-01-09  3:22                                     ` Jeremy Fitzhardinge
2008-01-09 10:48                                       ` Ingo Molnar
2008-01-09 10:47                                     ` Ingo Molnar
2008-01-09 14:26                                       ` Andi Kleen
2008-01-09  9:37                               ` Jan Beulich
2008-01-09  1:11                       ` Andi Kleen
2008-01-09  0:07         ` Jeremy Fitzhardinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aecbf28ecb53fb7b2830.1199829607@localhost \
    --to=jeremy@goop.org \
    --cc=ak@suse.de \
    --cc=glommer@gmail.com \
    --cc=jbeulich@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox