Commit 881d90d0 authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by Ingo Molnar

x86: page.h: move and unify types for pagetable entry

# HG changeset patch
# User Jeremy Fitzhardinge <jeremy@xensource.com>
# Date 1199319654 28800
# Node ID 3bd7db6e85e66e7f3362874802df26a82fcb2d92
# Parent  f7e7db3facd9406545103164f9be8f9ba1a2b549
x86: page.h: move and unify types for pagetable entry definitions

This patch:

1. Defines arch-specific types for the contents of a pagetable entry.
That is, 32-bit entries for 32-bit non-PAE, and 64-bit entries for
32-bit PAE and 64-bit.  However, even though the latter two are the
same size, they're defined with different types in order to retain
compatibility with printk format strings, etc.

2. Defines arch-specific pte_t.  This is different because 32-bit PAE
defines it in two halves, whereas 32-bit PAE and 64-bit define it as a
single entry.  All the other pagetable levels can be defined in a
common way.  This also defines arch-specific pte_val/make_pte functions.

3. Define PAGETABLE_LEVELS for each architecture variation, for later use.

4. Define common pagetable entry accessors in a paravirt-compatible
way. (64-bit does not yet use paravirt-ops in any way).

5. Convert a few instances of using a *_val() as an lvalue where it is
no longer a macro.  There are still places in the 64-bit code which
use pte_val() as an lvalue.
Signed-off-by: default avatarJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 38f0f127
...@@ -116,9 +116,57 @@ typedef struct { pteval_t pte; } pte_t; ...@@ -116,9 +116,57 @@ typedef struct { pteval_t pte; } pte_t;
#ifdef CONFIG_X86_PAE #ifdef CONFIG_X86_PAE
#define __PHYSICAL_MASK_SHIFT 36 #define __PHYSICAL_MASK_SHIFT 36
#define __VIRTUAL_MASK_SHIFT 32 #define __VIRTUAL_MASK_SHIFT 32
#define PAGETABLE_LEVELS 3
#ifndef __ASSEMBLY__
typedef u64 pteval_t;
typedef u64 pmdval_t;
typedef u64 pudval_t;
typedef u64 pgdval_t;
typedef u64 pgprotval_t;
typedef u64 phys_addr_t;
typedef struct { unsigned long pte_low, pte_high; } pte_t;
static inline unsigned long long native_pte_val(pte_t pte)
{
return pte.pte_low | ((unsigned long long)pte.pte_high << 32);
}
static inline pte_t native_make_pte(unsigned long long val)
{
return (pte_t) { .pte_low = val, .pte_high = (val >> 32) } ;
}
#endif /* __ASSEMBLY__
*/
#else /* !CONFIG_X86_PAE */ #else /* !CONFIG_X86_PAE */
#define __PHYSICAL_MASK_SHIFT 32 #define __PHYSICAL_MASK_SHIFT 32
#define __VIRTUAL_MASK_SHIFT 32 #define __VIRTUAL_MASK_SHIFT 32
#define PAGETABLE_LEVELS 2
#ifndef __ASSEMBLY__
typedef unsigned long pteval_t;
typedef unsigned long pmdval_t;
typedef unsigned long pudval_t;
typedef unsigned long pgdval_t;
typedef unsigned long pgprotval_t;
typedef unsigned long phys_addr_t;
typedef struct { pteval_t pte_low; } pte_t;
typedef pte_t boot_pte_t;
static inline unsigned long native_pte_val(pte_t pte)
{
return pte.pte_low;
}
static inline pte_t native_make_pte(unsigned long val)
{
return (pte_t) { .pte_low = val };
}
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_X86_PAE */ #endif /* CONFIG_X86_PAE */
#ifdef CONFIG_HUGETLB_PAGE #ifdef CONFIG_HUGETLB_PAGE
...@@ -181,7 +229,6 @@ static void inline copy_user_page(void *to, void *from, unsigned long vaddr, ...@@ -181,7 +229,6 @@ static void inline copy_user_page(void *to, void *from, unsigned long vaddr,
alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr) alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
#ifdef CONFIG_X86_64
typedef struct { pgdval_t pgd; } pgd_t; typedef struct { pgdval_t pgd; } pgd_t;
typedef struct { pgprotval_t pgprot; } pgprot_t; typedef struct { pgprotval_t pgprot; } pgprot_t;
...@@ -252,7 +299,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd) ...@@ -252,7 +299,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
#endif /* CONFIG_PARAVIRT */ #endif /* CONFIG_PARAVIRT */
#endif /* CONFIG_X86_64 */
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
......
...@@ -9,89 +9,6 @@ ...@@ -9,89 +9,6 @@
*/ */
extern int nx_enabled; extern int nx_enabled;
#ifdef CONFIG_X86_PAE
typedef struct { unsigned long pte_low, pte_high; } pte_t;
typedef struct { unsigned long long pmd; } pmd_t;
typedef struct { unsigned long long pgd; } pgd_t;
typedef struct { unsigned long long pgprot; } pgprot_t;
static inline unsigned long long native_pgd_val(pgd_t pgd)
{
return pgd.pgd;
}
static inline unsigned long long native_pmd_val(pmd_t pmd)
{
return pmd.pmd;
}
static inline unsigned long long native_pte_val(pte_t pte)
{
return pte.pte_low | ((unsigned long long)pte.pte_high << 32);
}
static inline pgd_t native_make_pgd(unsigned long long val)
{
return (pgd_t) { val };
}
static inline pmd_t native_make_pmd(unsigned long long val)
{
return (pmd_t) { val };
}
static inline pte_t native_make_pte(unsigned long long val)
{
return (pte_t) { .pte_low = val, .pte_high = (val >> 32) } ;
}
#ifndef CONFIG_PARAVIRT
#define pmd_val(x) native_pmd_val(x)
#define __pmd(x) native_make_pmd(x)
#endif
#include <asm-generic/pgtable-nopud.h>
#else /* !CONFIG_X86_PAE */
typedef struct { unsigned long pte_low; } pte_t;
typedef struct { unsigned long pgd; } pgd_t;
typedef struct { unsigned long pgprot; } pgprot_t;
#define boot_pte_t pte_t /* or would you rather have a typedef */
static inline unsigned long native_pgd_val(pgd_t pgd)
{
return pgd.pgd;
}
static inline unsigned long native_pte_val(pte_t pte)
{
return pte.pte_low;
}
static inline pgd_t native_make_pgd(unsigned long val)
{
return (pgd_t) { val };
}
static inline pte_t native_make_pte(unsigned long val)
{
return (pte_t) { .pte_low = val };
}
#include <asm-generic/pgtable-nopmd.h>
#endif /* CONFIG_X86_PAE */
#define PTE_MASK PAGE_MASK
#define pgprot_val(x) ((x).pgprot)
#define __pgprot(x) ((pgprot_t) { (x) } )
#ifndef CONFIG_PARAVIRT
#define pgd_val(x) native_pgd_val(x)
#define __pgd(x) native_make_pgd(x)
#define pte_val(x) native_pte_val(x)
#define __pte(x) native_make_pte(x)
#endif
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment