Unify asm-x86/pgtable.h and page.h
Subsystems (3)
cover Unify asm-x86/pgtable.h and page.h
NB: RFC ONLY. DO NOT APPLY.
This series unifies many definitions in asm-x86/pgtable.h and page.h. Later in the series, I take advantage of some of the earlier infrastructure to simplify paravirt.h and bits of the Xen code.
This patch applies on top of Glauber's 64-bit pvops unification, so it won't apply directly to the current tree.
I've tested all the 32-bit combinations (paravirt/non-paravirt/PAE/non-PAE), but haven't set up a 64-bit test box yet.
The diffstat of the pure unification bits is nice:
arch/x86/mm/init_32.c | 31 ++- arch/x86/mm/init_64.c | 3 arch/x86/xen/enlighten.c | 8 arch/x86/xen/mmu.c | 67 +++----- arch/x86/xen/mmu.h | 26 --- include/asm-x86/page.h | 49 ++++- include/asm-x86/page_32.h | 77 +++++---- include/asm-x86/page_64.h | 37 +--- include/asm-x86/paravirt.h | 324 ++++++++++++++++----------------------- include/asm-x86/pgtable-2level.h | 21 -- include/asm-x86/pgtable-3level.h | 40 ---- include/asm-x86/pgtable.h | 318 ++++++++++++++++++++++++++++++++++++++ include/asm-x86/pgtable_32.h | 204 ------------------------ include/asm-x86/pgtable_64.h | 234 ---------------------------- 14 files changed, 630 insertions(+), 809 deletions(-)
(The code formatting patch adds a pile of lines because it splits long single lints into multiline code.)
J
RFC PATCH 1/7 x86: kill mk_pte_huge
It only has a single use, which can be trivially replaced.
--- arch/x86/mm/init_64.c | 3 +-- include/asm-x86/pgtable_64.h | 9 --------- 2 files changed, 1 insertion(+), 11 deletions(-)
===================================================================
arch/x86/mm/init_64.c +1 -2
@@ -768,8 +768,7 @@ int __meminit vmemmap_populate(struct paif (!p)return -ENOMEM ; - entry =pfn_pte (__pa (p) >>PAGE_SHIFT ,PAGE_KERNEL ); -mk_pte_huge (entry); + entry =pfn_pte (__pa (p) >>PAGE_SHIFT ,PAGE_KERNEL_LARGE );set_pmd (pmd,__pmd (pte_val (entry))); printk(KERN_DEBUG " [%lx-%lx] PMD ->%p on node %d\n",
===================================================================
include/asm-x86/pgtable_64.h +0 -9
@@ -378,15 +378,6 @@ static inline pte_t pte_clrhuge(pte_t pt/* page, protection -> pte */ #define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) -static inline pte_t __mk_pte_huge (pte_t entry) -{ -unsigned long pte; - pte =pte_val (entry); - pte |= _PAGE_PRESENT | _PAGE_PSE; -return __pte (pte); -} -#define mk_pte_huge (entry) ((entry) = __mk_pte_huge(entry)) -#include <linux/mm_types.h> static inline int ptep_test_and_clear_young (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep)
RFC PATCH 2/7 x86: clean up mm/init_32.c
In reply to Jeremy FitzhardingeSome code reformatting in init_32.c. No functional change.
--- arch/x86/mm/init_32.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)
===================================================================
arch/x86/mm/init_32.c +21 -10
@@ -165,16 +165,25 @@ static void __init kernel_physical_mappi pmd =one_md_table_init (pgd);if (pfn >= max_low_pfn)continue ; -for (pmd_idx =0 ; pmd_idx <PTRS_PER_PMD && pfn < max_low_pfn; pmd++, pmd_idx++) { +for (pmd_idx =0 ; + pmd_idx <PTRS_PER_PMD && pfn < max_low_pfn; + pmd++, pmd_idx++) {unsigned int address = pfn *PAGE_SIZE +PAGE_OFFSET ; -/* Map with big pages if possible, otherwise create normal page tables. */ +/* Map with big pages if possible, otherwise +create normal page tables. */ if (cpu_has_pse) { -unsigned int address2 = (pfn +PTRS_PER_PTE -1 ) *PAGE_SIZE +PAGE_OFFSET +PAGE_SIZE -1 ; -if (is_kernel_text (address) ||is_kernel_text (address2)) -set_pmd (pmd,pfn_pmd (pfn,PAGE_KERNEL_LARGE_EXEC )); -else -set_pmd (pmd,pfn_pmd (pfn,PAGE_KERNEL_LARGE )); +unsigned int address2; +pgprot_t prot =PAGE_KERNEL_LARGE ; + + address2 = (pfn +PTRS_PER_PTE -1 ) *PAGE_SIZE + +PAGE_OFFSET +PAGE_SIZE -1 ; + +if (is_kernel_text (address) || +is_kernel_text (address2)) + prot =PAGE_KERNEL_LARGE_EXEC ; + +set_pmd (pmd,pfn_pmd (pfn, prot)); pfn +=PTRS_PER_PTE ; }else {
@@ -183,10 +192,12 @@ static void __init kernel_physical_mappifor (pte_ofs =0 ; pte_ofs <PTRS_PER_PTE && pfn < max_low_pfn; pte++, pfn++, pte_ofs++, address +=PAGE_SIZE ) { +pgprot_t prot =PAGE_KERNEL ; +if (is_kernel_text (address)) -set_pte (pte,pfn_pte (pfn,PAGE_KERNEL_EXEC )); -else -set_pte (pte,pfn_pte (pfn,PAGE_KERNEL )); + prot =PAGE_KERNEL_EXEC ; + +set_pte (pte,pfn_pte (pfn, prot)); } } }
Re: [PATCH RFC 2/7] x86: clean up mm/init_32.c
arch/x86/mm/init_32.c static void __init kernel_physical_mappi · line 174
Quoted 3 lines
arch/x86/mm/init_32.c +2
-1-/* Map with big pages if possible, otherwise create normal page tables. */ +/* Map with big pages if possible, otherwise +create normal page tables. */
/*
* multi comment lines are preferred
* this way, IIRC ;-)
*/
Signature · 5 lines
Glauber de Oliveira Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."
Re: [PATCH RFC 2/7] x86: clean up mm/init_32.c
Quoted 9 lines · Glauber de Oliveira Costa
arch/x86/mm/init_32.c static void __init kernel_physical_mappi · line 174
Quoted 4 lines
arch/x86/mm/init_32.c +2
-1-/* Map with big pages if possible, otherwise create normal page tables. */ +/* Map with big pages if possible, otherwise +create normal page tables. */ /*
* multi comment lines are preferred
* this way, IIRC ;-)
*/
I don't think it's worth turning a one-liner into a great big banner.
J
RFC PATCH 3/7 x86: clean up asm-x86/page*.h
In reply to Jeremy FitzhardingeUnify common definitions in page*.h. To simplify other code, I added typedefs for the value of pte/pmd/pud/pgd values, so they can be used symbolically elsewhere without needing to have lots of 32/64/PAE tests.
Also, add PAGETABLE_LEVELS define so that other definitions can test for it directly rather than using indirect 32/64/PAE tests.
--- include/asm-x86/page.h | 49 ++++++++++++++++++++++------ include/asm-x86/page_32.h | 77 +++++++++++++++++++++++++-------------------- include/asm-x86/page_64.h | 37 +++++++-------------- 3 files changed, 95 insertions(+), 68 deletions(-)
===================================================================
include/asm-x86/page.h +39 -10
@@ -1,13 +1,42 @@ +#ifndef _ASM_X86_PAGE_H +#define _ASM_X86_PAGE_H + +#include <linux/const.h> + +/* PAGE_SHIFT determines the page size */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) +#define PHYSICAL_PAGE_MASK (~(PAGE_SIZE-1) & __PHYSICAL_MASK) + +#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1)) +#define LARGE_PAGE_SIZE (_AC(1,UL) << PMD_SHIFT) +#ifdef __KERNEL__ -# ifdef CONFIG_X86_32 -# include "page_32.h" -# else -# include "page_64.h" -# endif + +#ifdef CONFIG_X86_32 +# include "page_32.h" #else -# ifdef __i386__ -# include "page_32.h" -# else -# include "page_64.h" -# endif +# include "page_64.h" #endif + +#ifndef CONFIG_PARAVIRT +#define pgd_val (x) native_pgd_val(x) +#define __pgd (x) native_make_pgd(x) + +#ifndef __PAGETABLE_PUD_FOLDED +#define pud_val (x) native_pud_val(x) +#define __pud (x) native_make_pud(x) +#endif + +#ifndef __PAGETABLE_PMD_FOLDED +#define pmd_val (x) native_pmd_val(x) +#define __pmd (x) native_make_pmd(x) +#endif + +#define pte_val (x) native_pte_val(x) +#define __pte (x) native_make_pte(x) +#endif /* CONFIG_PARAVIRT */ + +#endif /* __KERNEL__ */ +#endif /* _ASM_X86_PAGE_H */
===================================================================
include/asm-x86/page_32.h +44 -33
156 lines not on this page · raw message
===================================================================
include/asm-x86/page_64.h +12 -25
@@ -1,13 +1,13 @@#ifndef _X86_64_PAGE_H#define _X86_64_PAGE_H +#ifndef _ASM_X86_PAGE_H +#error Include asm/page.h +#endif +#include <linux/const.h> -/* PAGE_SHIFT determines the page size */ -#define PAGE_SHIFT 12 -#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) -#define PAGE_MASK (~(PAGE_SIZE-1)) -#define PHYSICAL_PAGE_MASK (~(PAGE_SIZE-1) & __PHYSICAL_MASK) +#define PAGETABLE_LEVELS 4#define THREAD_ORDER 1#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER)
@@ -29,16 +29,14 @@#define MCE_STACK 5#define N_EXCEPTION_STACKS 5/* hw limit: 7 */ -#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1)) -#define LARGE_PAGE_SIZE (_AC(1,UL) << PMD_SHIFT) -#define HPAGE_SHIFT PMD_SHIFT#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)#define HPAGE_MASK (~(HPAGE_SIZE - 1))#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) -#ifdef __KERNEL__#ifndef __ASSEMBLY__ + +#include <linux/types.h> extern unsigned long end_pfn;
@@ -59,6 +57,11 @@ typedef struct { unsigned long pud; } putypedef struct {unsigned long pud; }pud_t ;typedef struct {unsigned long pgd; }pgd_t ;#define PTE_MASK PHYSICAL_PAGE_MASK + +typedef u64 pteval_t ; +typedef u64 pmdval_t ; +typedef u64 pudval_t ; +typedef u64 pgdval_t ;typedef struct {unsigned long pgprot; }pgprot_t ;
@@ -104,20 +107,6 @@ static inline pgd_t native_make_pgd(unsi {return (pgd_t ){ pgd }; } - -#ifdef CONFIG_PARAVIRT -#include <asm/paravirt.h> -#else -#define pte_val (x) native_pte_val(x) -#define pmd_val (x) native_pmd_val(x) -#define pud_val (x) native_pud_val(x) -#define pgd_val (x) native_pgd_val(x) - -#define __pte (x) ((pte_t) { (x) } ) -#define __pmd (x) ((pmd_t) { (x) } ) -#define __pud (x) ((pud_t) { (x) } ) -#define __pgd (x) ((pgd_t) { (x) } ) -#endif /* CONFIG_PARAVIRT */ #define pgprot_val (x) ((x).pgprot)#define __pgprot (x) ((pgprot_t) { (x) } )
@@ -185,6 +174,4 @@ extern unsigned long __phys_addr(unsigne#include <asm-generic/memory_model.h> #include <asm-generic/page.h> -#endif /* __KERNEL__ */ -#endif /* _X86_64_PAGE_H */
Re: [PATCH RFC 3/7] x86: clean up asm-x86/page*.h
include/asm-x86/page_32.h line 60
Quoted 11 lines · Jeremy Fitzhardinge
include/asm-x86/page_32.h +8
-1+#define PAGETABLE_LEVELS 3 + +typedef u64 pteval_t ; +typedef u64 pmdval_t ; +typedef u64 pudval_t ; +typedef u64 pgdval_t ; + -static inline unsigned long long native_pgd_val (pgd_t pgd) +static inline pgdval_t native_pgd_val (pgd_t pgd) {
Maybe these kind of things, the typedef and native_xxx definitions can go into the common header, after we define the PAGETABLE_LEVELS constant?
I think the more goes into common headers, the better.
include/asm-x86/page_32.h line 87
Quoted 5 lines
include/asm-x86/page_32.h +1
-1-static inline pte_t native_make_pte (unsigned long long val) +static inline pte_t native_make_pte (pteval_t val) {return (pte_t ) { .pte_low = val, .pte_high = (val >>32 ) } ; }
Although these make_xxx things can probably be just left here...
Signature · 5 lines
Glauber de Oliveira Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."
Re: [PATCH RFC 3/7] x86: clean up asm-x86/page*.h
Quoted 12 lines · Glauber de Oliveira Costa
Quoted 8 lines · Jeremy Fitzhardinge
include/asm-x86/page_32.h +7
-0+#define PAGETABLE_LEVELS 3 + +typedef u64 pteval_t ; +typedef u64 pmdval_t ; +typedef u64 pudval_t ; +typedef u64 pgdval_t ; +
Quoted 9 lines
include/asm-x86/page_32.h line 60
Quoted 4 lines
include/asm-x86/page_32.h +1
-1-static inline unsigned long long native_pgd_val (pgd_t pgd) +static inline pgdval_t native_pgd_val (pgd_t pgd) {Maybe these kind of things, the typedef and
native_xxxdefinitions can go into the common header, after we define thePAGETABLE_LEVELSconstant?
I think the more goes into common headers, the better.
You mean put them in a common header, but conditionally by #if PAGETABLE_LEVELS? I don't think that would be much of an improvement; it would just add more #ifs, which adds lines and conceptual complexity. If you go that way, you may as well put everything in one header wrapped in #ifs, but personally I don't think that would help.
J
Re: [PATCH RFC 3/7] x86: clean up asm-x86/page*.h
Quoted 23 lines · Jeremy Fitzhardinge
Quoted 12 lines · Glauber de Oliveira Costa
Quoted 8 lines · Jeremy Fitzhardinge
include/asm-x86/page_32.h +7
-0+#define PAGETABLE_LEVELS 3 + +typedef u64 pteval_t ; +typedef u64 pmdval_t ; +typedef u64 pudval_t ; +typedef u64 pgdval_t ; +Quoted 9 lines
include/asm-x86/page_32.h line 60
Quoted 4 lines
include/asm-x86/page_32.h +1
-1-static inline unsigned long long native_pgd_val (pgd_t pgd) +static inline pgdval_t native_pgd_val (pgd_t pgd) {Maybe these kind of things, the typedef and
native_xxxdefinitions can go into the common header, after we define thePAGETABLE_LEVELSconstant?
I think the more goes into common headers, the better.
Quoted 5 lines
You mean put them in a common header, but conditionally by #if
PAGETABLE_LEVELS? I don't think that would be much of an improvement; it would just add more #ifs, which adds lines and conceptual complexity. If you go that way, you may as well put everything in one header wrapped in #ifs, but personally I don't think that would help.
Not exactly.
for the native_ functions, there's room for code sharing. native_pgd_val, and native_pte_val seem to be the same, for at least pae and x86_64.
As for the typedefs, the same thing can be done. Much like you did in paravirt.h, just split out between the < 3 and >= 3 levels.
But if it turns out to be just code movement, and I'm wrong in my supposition that we can turn three variants of the same code into two, then I agree
with you, let's keep it this way.
Signature · 5 lines
Glauber de Oliveira Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."
Re: [PATCH RFC 3/7] x86: clean up asm-x86/page*.h
Quoted 6 lines · Glauber de Oliveira Costa
Not exactly.
for thenative_functions, there's room for code sharing.native_pgd_val, andnative_pte_valseem to be the same, for at least pae andx86_64.
As for the typedefs, the same thing can be done. Much like you did inparavirt.h, just split out between the < 3 and >= 3 levels.
Yeah, I see what you mean. I'll play with it and see how it turns out.
J
RFC PATCH 4/7 x86: unify pgtable*.h
In reply to Jeremy FitzhardingeAll x86 modes and architectures have very similar pagetable
structures: the page flags, the accessors for testing/setting them, and the combinations of page flags used for kernel and usermode mappings are all the same. The main difference is between 32 and 64-bit pagetable entries, with the latter supporting the NX bit.
The most significant difference between the modes/architectures is the number of levels in the pagetable (4 for 64-bit, 3 for 32-bit/PAE, 2 for non-PAE 32-bit). This accounts for the remaining code in the various mode-specific headers.
I've tried to avoid changing formatting as much as possible, so that the code motion is more obvious. A subsequent patch will clean things up in place.
--- include/asm-x86/pgtable-2level.h | 21 -- include/asm-x86/pgtable-3level.h | 40 ---- include/asm-x86/pgtable.h | 318 ++++++++++++++++++++++++++++++++++++++ include/asm-x86/pgtable_32.h | 204 ------------------------ include/asm-x86/pgtable_64.h | 225 -------------------------- 5 files changed, 331 insertions(+), 477 deletions(-)
===================================================================
include/asm-x86/pgtable-2level.h +4 -17
@@ -24,16 +24,13 @@ static inline void native_set_pmd(pmd_t { *pmdp = pmd; } -#ifndef CONFIG_PARAVIRT -#define set_pte (pteptr, pteval) native_set_pte(pteptr, pteval) -#define set_pte_at (mm,addr,ptep,pteval) native_set_pte_at(mm, addr, ptep, pteval) -#define set_pmd (pmdptr, pmdval) native_set_pmd(pmdptr, pmdval) -#endif +#undef set_pte_atomic#define set_pte_atomic (pteptr, pteval) set_pte(pteptr,pteval)#define set_pte_present (mm,addr,ptep,pteval) set_pte_at(mm,addr,ptep,pteval)#define pte_clear (mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0) +#undef pmd_clear#define pmd_clear (xp) do { set_pmd(xp, __pmd(0)); } while (0)static inline void native_pte_clear (struct mm_struct *mm,unsigned long addr,pte_t *xp)
@@ -50,12 +47,6 @@ static inline pte_t native_ptep_get_and_#define native_ptep_get_and_clear (xp) native_local_ptep_get_and_clear(xp)#endif -#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: */
@@ -64,17 +55,13 @@ static inline int pte_exec_kernel(pte_treturn 1 ; } +#define __supported_pte_mask (~0ul) +/* * Bits 0, 6 and 7 are taken, split up the 29 bits of offset * into this range: */ #define PTE_FILE_MAX_BITS 29 - -#define pte_to_pgoff (pte) \ - ((((pte).pte_low >> 1) & 0x1f ) + (((pte).pte_low >> 8) << 5 )) - -#define pgoff_to_pte (off) \ - ((pte_t) { (((off) & 0x1f) << 1) + (((off) >> 5) << 8) + _PAGE_FILE })/* Encode and de-code a swap entry */ #define __swp_type (x) (((x).val >> 1) & 0x1f)
===================================================================
include/asm-x86/pgtable-3level.h +0 -40
@@ -94,17 +94,6 @@ static inline void native_pmd_clear(pmd_ *(tmp +1 ) =0 ; } -#ifndef CONFIG_PARAVIRT -#define set_pte (ptep, pte) native_set_pte(ptep, pte) -#define set_pte_at (mm, addr, ptep, pte) native_set_pte_at(mm, addr, ptep, pte) -#define set_pte_present (mm, addr, ptep, pte) native_set_pte_present(mm, addr, ptep, pte) -#define set_pte_atomic (ptep, pte) native_set_pte_atomic(ptep, pte) -#define set_pmd (pmdp, pmd) native_set_pmd(pmdp, pmd) -#define set_pud (pudp, pud) native_set_pud(pudp, pud) -#define pte_clear (mm, addr, ptep) native_pte_clear(mm, addr, ptep) -#define pmd_clear (pmd) native_pmd_clear(pmd) -#endif -/* * Pentium-II erratum A13: in PAE mode we explicitly have to flush * the TLB via cr3 if the top-level pgd is changed...
@@ -119,10 +108,6 @@ static inline void pud_clear (pud_t * pu#define pud_page_vaddr (pud) \ ((unsigned long) __va(pud_val(pud) & PAGE_MASK)) - -/* Find an entry in the second-level page table.. */ -#define pmd_offset (pud, address) ((pmd_t *) pud_page(*(pud)) + \ - pmd_index(address))#ifdef CONFIG_SMP static inline pte_t native_ptep_get_and_clear (pte_t *ptep)
@@ -146,38 +131,13 @@ static inline int pte_same(pte_t a, pte_return a.pte_low == b.pte_low && a.pte_high == b.pte_high; } -#define pte_page (x) pfn_to_page(pte_pfn(x)) - -static inline int pte_none (pte_t pte) -{ -return !pte.pte_low && !pte.pte_high; -} - -static inline unsigned long pte_pfn (pte_t 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. */ -#define pte_to_pgoff (pte) ((pte).pte_high) -#define pgoff_to_pte (off) ((pte_t) { _PAGE_FILE, (off) })#define PTE_FILE_MAX_BITS 32/* Encode and de-code a swap entry */
===================================================================
include/asm-x86/pgtable.h +318 -0
323 lines not on this page · raw message
===================================================================
include/asm-x86/pgtable_32.h +1 -203
254 lines not on this page · raw message
===================================================================
include/asm-x86/pgtable_64.h +8 -217
286 lines not on this page · raw message
RFC PATCH 5/7 x86: simplify pagetable-related operationsin paravirt.h
In reply to Jeremy FitzhardingeSimplify paravirt.h using the unified page/pgtable.h infrastructure. This removes a fair amount of duplication of the ops function pointers themselves, but also of PVOP_*CALL* wrappers.
The wrappers are complicated by the fact that on a 32-bit PAE system, literal 64-bit values are passed in two arguments, and so a different form of the call must be used compared to 64-bit or 32-bit non-PAE, where all the arguments are less than or equal to the native register size.
The code chooses the appropriate form to use by using the compile-time comparison of sizeof(pteval_t) and sizeof(unsigned long). This does not need to be done for calls which are either PAE or 64-bit specific.
--- include/asm-x86/paravirt.h | 324 +++++++++++++++++++------------------------- 1 file changed, 141 insertions(+), 183 deletions(-)
===================================================================
include/asm-x86/paravirt.h +141 -183
@@ -240,40 +240,38 @@ struct pv_mmu_ops {void (*pte_update_defer)(struct mm_struct *mm,unsigned long addr,pte_t *ptep); +pteval_t (*pte_val)(pte_t); +pgdval_t (*pgd_val)(pgd_t); + +pte_t (*make_pte)(pteval_t pte); +pgd_t (*make_pgd)(pgdval_t pgd); + +#if PAGETABLE_LEVELS >=3 #ifdef CONFIG_X86_PAE void (*set_pte_atomic)(pte_t *ptep,pte_t pteval);void (*set_pte_present)(struct mm_struct *mm,unsigned long addr,pte_t *ptep,pte_t pte);#endif -#if defined(CONFIG_X86_PAE ) || defined(CONFIG_X86_64 ) -void (*set_pud)(pud_t *pudp,pud_t pudval); +void (*pte_clear)(struct mm_struct *mm,unsigned long addr,pte_t *ptep);void (*pmd_clear)(pmd_t *pmdp); -unsigned long long (*pte_val)(pte_t ); -unsigned long long (*pmd_val)(pmd_t ); -unsigned long long (*pgd_val)(pgd_t ); +pmdval_t (*pmd_val)(pmd_t); +pmd_t (*make_pmd)(pmdval_t pmd); -pte_t (*make_pte)(unsigned long long pte); -pmd_t (*make_pmd)(unsigned long long pmd); -pgd_t (*make_pgd)(unsigned long long pgd); -#ifdef CONFIG_X86_64 +void (*set_pud)(pud_t *pudp,pud_t pudval); + +#if PAGETABLE_LEVELS ==4 void (*set_pgd)(pgd_t *pgdp,pgd_t pgdval);void (*pud_clear)(pud_t *pudp);void (*pgd_clear)(pgd_t *pgdp); -unsigned long long (*pud_val)(pud_t ); +pudval_t (*pud_val)(pud_t); -pud_t (*make_pud)(unsigned long long pud); -#endif -#else -unsigned long (*pte_val)(pte_t ); -unsigned long (*pgd_val)(pgd_t ); - -pte_t (*make_pte)(unsigned long pte); -pgd_t (*make_pgd)(unsigned long pgd); -#endif +pud_t (*make_pud)(pudval_t pud); +#endif /* PAGETABLE_LEVELS == 4 */ +#endif /* PAGETABLE_LEVELS >= 3 */ #ifdef CONFIG_HIGHPTE void *(*kmap_atomic_pte)(struct page *page,enum km_type type);
@@ -958,85 +956,137 @@ static inline void pte_update_defer(struPVOP_VCALL3 (pv_mmu_ops.pte_update_defer, mm, addr, ptep); } -#ifdef CONFIG_X86_PAE -static inline pte_t __pte (unsigned long long val) +/* +* Pagetable manipulators +* +* There are three cases to deal with: +* 32-bit processor, non-PAE: 2-level pagetable with 32-bit entries +* 32-bit processor, PAE: 3-level pagetable with 64-bit entries +* 64-bit processor: 4-level pagetable with 64-bit entries +* +* In 32-bit mode, passing 64-bit parameters must be done in two +* 32-bit chunks, so we need to use a separate PVOP_CALLx macro from +* either 64-bit mode or 32-bit/non-PAE. +* +* We rely on the predefined native_make_X/native_X_val to do +* packing/unpacking of the current pagetable type. +*/ +static inline pte_t __pte (pteval_t val) { - unsigned long long ret = PVOP_CALL2(unsigned long long, - pv_mmu_ops.make_pte, - val, val >>32 ); -return (pte_t ) { ret, ret >>32 }; +pteval_t ret; + +if (sizeof (val) >sizeof (unsigned long )) + ret =PVOP_CALL2 (pteval_t, pv_mmu_ops.make_pte, + val, (u64 )val>>32 ); +else + ret =PVOP_CALL1 (pteval_t, pv_mmu_ops.make_pte, val); + +return native_make_pte (ret); } -static inline pmd_t __pmd (unsigned long long val) +static inline pteval_t pte_val (pte_t x) { - return (pmd_t) { PVOP_CALL2(unsigned long long, pv_mmu_ops.make_pmd, - val, val >>32 ) }; +pteval_t val =native_pte_val (x); +if (sizeof (pteval_t) >sizeof (unsigned long )) +return PVOP_CALL2 (pteval_t, pv_mmu_ops.pte_val, + val, (u64 )val>>32 ); +else +return PVOP_CALL1 (pteval_t, pv_mmu_ops.pte_val, val); } -static inline pgd_t __pgd (unsigned long long val) +static inline pgd_t __pgd (pgdval_t val) { - return (pgd_t) { PVOP_CALL2(unsigned long long, pv_mmu_ops.make_pgd, - val, val >>32 ) }; +pgdval_t pgd; + +if (sizeof (val) >sizeof (unsigned long )) + pgd =PVOP_CALL2 (pgdval_t, pv_mmu_ops.make_pgd, + val, (u64 )val>>32 ); +else + pgd =PVOP_CALL1 (pgdval_t, pv_mmu_ops.make_pgd, val); + +return native_make_pgd (pgd); } -static inline unsigned long long pte_val (pte_t x) +static inline pgdval_t pgd_val (pgd_t x) { - return PVOP_CALL2(unsigned long long, pv_mmu_ops.pte_val, - x.pte_low, x.pte_high); -} - -static inline unsigned long long pmd_val (pmd_t x) -{ - return PVOP_CALL2(unsigned long long, pv_mmu_ops.pmd_val, - x.pmd, x.pmd >>32 ); -} - -static inline unsigned long long pgd_val (pgd_t x) -{ - return PVOP_CALL2(unsigned long long, pv_mmu_ops.pgd_val, - x.pgd, x.pgd >>32 ); +pgdval_t val =native_pgd_val (x); +if (sizeof (pgdval_t) >sizeof (unsigned long )) +return PVOP_CALL2 (pgdval_t, pv_mmu_ops.pgd_val, + val, (u64 )val>>32 ); +else +return PVOP_CALL1 (pgdval_t, pv_mmu_ops.pgd_val, val); }static inline void set_pte (pte_t *ptep,pte_t pteval) { -PVOP_VCALL3 (pv_mmu_ops.set_pte, ptep, pteval.pte_low, pteval.pte_high); +pteval_t val =native_pte_val (pteval); +if (sizeof (pteval_t) >sizeof (unsigned long )) +PVOP_VCALL3 (pv_mmu_ops.set_pte, ptep, val, (u64 )val>>32 ); +else +PVOP_VCALL2 (pv_mmu_ops.set_pte, ptep, val); }static inline void set_pte_at (struct mm_struct *mm,unsigned long addr,pte_t *ptep,pte_t pteval) { -/* 5 arg words */ - pv_mmu_ops.set_pte_at (mm, addr, ptep, pteval); +if (sizeof (pteval_t) >sizeof (unsigned long )) + pv_mmu_ops.set_pte_at (mm, addr, ptep, pteval); +else +PVOP_VCALL4 (pv_mmu_ops.set_pte_at, mm, addr, + ptep,native_pte_val (pteval)); +} + +static inline void set_pmd (pmd_t *pmdp,pmd_t pmdval) +{ +pmdval_t val =native_pmd_val (pmdval); +if (sizeof (val) >sizeof (unsigned long )) +PVOP_VCALL3 (pv_mmu_ops.set_pmd, pmdp, val, (u64 )val>>32 ); +else +PVOP_VCALL2 (pv_mmu_ops.set_pmd, pmdp, val); +} + +#if PAGETABLE_LEVELS >=3 +#ifdef CONFIG_X86_PAE +static inline void set_pte_present (struct mm_struct *mm,unsigned long addr, +pte_t *ptep,pte_t pte) +{ + pv_mmu_ops.set_pte_present (mm, addr, ptep, pte); }static inline void set_pte_atomic (pte_t *ptep,pte_t pteval) { -PVOP_VCALL3 (pv_mmu_ops.set_pte_atomic, ptep, - pteval.pte_low, pteval.pte_high); +pteval_t val =native_pte_val (pteval); + +PVOP_VCALL3 (pv_mmu_ops.set_pte_atomic, ptep, val, (u64 )val>>32 ); } - -static inline void set_pte_present (struct mm_struct *mm,unsigned long addr, -pte_t *ptep,pte_t pte) -{ -/* 5 arg words */ - pv_mmu_ops.set_pte_present (mm, addr, ptep, pte); -} - -static inline void set_pmd (pmd_t *pmdp,pmd_t pmdval) -{ -PVOP_VCALL3 (pv_mmu_ops.set_pmd, pmdp, - pmdval.pmd, pmdval.pmd >>32 ); -} - -static inline void set_pud (pud_t *pudp,pud_t pudval) -{ -PVOP_VCALL3 (pv_mmu_ops.set_pud, pudp, - pudval.pgd.pgd, pudval.pgd.pgd >>32 ); -} +#endif /* X86_PAE */ static inline void pte_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep) {PVOP_VCALL3 (pv_mmu_ops.pte_clear, mm, addr, ptep); +} + +static inline pmd_t __pmd (pmdval_t val) +{ +pmdval_t pmd; + +if (sizeof (val) >sizeof (unsigned long )) + pmd =PVOP_CALL2 (pmdval_t, pv_mmu_ops.make_pmd, + val, (u64 )val>>32 ); +else + pmd =PVOP_CALL1 (pmdval_t, pv_mmu_ops.make_pmd, val); + +return native_make_pmd (pmd); +} + +static inline pmdval_t pmd_val (pmd_t x) +{ +pmdval_t val =native_pmd_val (x); +if (sizeof (val) >sizeof (unsigned long )) +return PVOP_CALL2 (pmdval_t, pv_mmu_ops.pmd_val, + val, (u64 )val>>32 ); +else +return PVOP_CALL1 (pmdval_t, pv_mmu_ops.pmd_val, val); }static inline void pmd_clear (pmd_t *pmdp)
@@ -1044,95 +1094,25 @@ static inline void pmd_clear(pmd_t *pmdpPVOP_VCALL1 (pv_mmu_ops.pmd_clear, pmdp); } -#elif defined(CONFIG_X86_64 ) -/* FIXME: There ought to be a way to do it that duplicate less code */ -static inline pte_t __pte (unsigned long long val) +static inline void set_pud (pud_t *pudp,pud_t pudval) { -unsigned long long ret; - ret = PVOP_CALL1(unsigned long long, pv_mmu_ops.make_pte, val); -return (pte_t ) { ret }; +pudval_t val =native_pud_val (pudval); + +if (sizeof (val) >sizeof (unsigned long )) +PVOP_VCALL3 (pv_mmu_ops.set_pud, pudp, val, (u64 )val>>32 ); +else +PVOP_VCALL2 (pv_mmu_ops.set_pud, pudp, val); } -static inline pmd_t __pmd (unsigned long long val) -{ -unsigned long long ret; - ret = PVOP_CALL1(unsigned long long, pv_mmu_ops.make_pmd, val); -return (pmd_t ) { ret }; -} - -static inline pud_t __pud (unsigned long long val) -{ -unsigned long long ret; - ret = PVOP_CALL1(unsigned long long, pv_mmu_ops.make_pud, val); -return (pud_t ) { ret }; -} - -static inline pgd_t __pgd (unsigned long long val) -{ -unsigned long long ret; - ret = PVOP_CALL1(unsigned long long, pv_mmu_ops.make_pgd, val); -return (pgd_t ) { ret }; -} - -static inline unsigned long long pte_val (pte_t x) -{ - return PVOP_CALL1(unsigned long long, pv_mmu_ops.pte_val, x.pte); -} - -static inline unsigned long long pmd_val (pmd_t x) -{ - return PVOP_CALL1(unsigned long long, pv_mmu_ops.pmd_val, x.pmd); -} - -static inline unsigned long long pud_val (pud_t x) -{ - return PVOP_CALL1(unsigned long long, pv_mmu_ops.pud_val, x.pud); -} - -static inline unsigned long long pgd_val (pgd_t x) -{ - return PVOP_CALL1(unsigned long long, pv_mmu_ops.pgd_val, x.pgd); -} - -static inline void set_pte (pte_t *ptep,pte_t pteval) -{ -PVOP_VCALL2 (pv_mmu_ops.set_pte, ptep, pteval.pte); -} - -static inline void set_pte_at (struct mm_struct *mm,unsigned long addr, -pte_t *ptep,pte_t pteval) -{ -PVOP_VCALL4 (pv_mmu_ops.set_pte_at, mm, addr, ptep, pteval.pte); -} - -static inline void set_pmd (pmd_t *pmdp,pmd_t pmdval) -{ -PVOP_VCALL2 (pv_mmu_ops.set_pmd, pmdp, pmdval.pmd); -} - -static inline void set_pud (pud_t *pudp,pud_t pudval) -{ -PVOP_VCALL2 (pv_mmu_ops.set_pud, pudp, pudval.pud); -} +#if PAGETABLE_LEVELS ==4 +/* Always 64-bit processor, so param passing needs no special handling */ +#ifdef CONFIG_X86_32 +#error 4 level pagetables in 32-bit mode?! +#endif static inline void set_pgd (pgd_t *pgdp,pgd_t pgdval) { -PVOP_VCALL2 (pv_mmu_ops.set_pgd, pgdp, pgdval.pgd); -} - -static inline void pte_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep) -{ -PVOP_VCALL3 (pv_mmu_ops.pte_clear, mm, addr, ptep); -} - -static inline void pmd_clear (pmd_t *pmdp) -{ -PVOP_VCALL1 (pv_mmu_ops.pmd_clear, pmdp); -} - -static inline void pud_clear (pud_t *pudp) -{ -PVOP_VCALL1 (pv_mmu_ops.pud_clear, pudp); +PVOP_VCALL2 (pv_mmu_ops.set_pgd, pgdp,native_pgd_val (pgdval)); }static inline void pgd_clear (pgd_t *pgdp)
@@ -1140,44 +1120,22 @@ static inline void pgd_clear(pgd_t *pgdpPVOP_VCALL1 (pv_mmu_ops.pgd_clear, pgdp); } -#else /* !CONFIG_X86_PAE && !CONFIG_X86_64*/ - -static inline pte_t __pte (unsigned long val) +static inline pud_t __pud (pudval_t val) { - return (pte_t) { PVOP_CALL1(unsigned long, pv_mmu_ops.make_pte, val) }; +return native_make_pud (PVOP_CALL1 (pudval_t, pv_mmu_ops.make_pud, val)); } -static inline pgd_t __pgd (unsigned long val) +static inline pudval_t pud_val (pud_t x) { - return (pgd_t) { PVOP_CALL1(unsigned long, pv_mmu_ops.make_pgd, val) }; +return PVOP_CALL1 (pudval_t, pv_mmu_ops.pud_val,native_pud_val (x)); } -static inline unsigned long pte_val (pte_t x) +static inline void pud_clear (pud_t *pudp) { - return PVOP_CALL1(unsigned long, pv_mmu_ops.pte_val, x.pte_low); +PVOP_VCALL1 (pv_mmu_ops.pud_clear, pudp); } - -static inline unsigned long pgd_val (pgd_t x) -{ - return PVOP_CALL1(unsigned long, pv_mmu_ops.pgd_val, x.pgd); -} - -static inline void set_pte (pte_t *ptep,pte_t pteval) -{ -PVOP_VCALL2 (pv_mmu_ops.set_pte, ptep, pteval.pte_low); -} - -static inline void set_pte_at (struct mm_struct *mm,unsigned long addr, -pte_t *ptep,pte_t pteval) -{ -PVOP_VCALL4 (pv_mmu_ops.set_pte_at, mm, addr, ptep, pteval.pte_low); -} - -static inline void set_pmd (pmd_t *pmdp,pmd_t pmdval) -{ -PVOP_VCALL2 (pv_mmu_ops.set_pmd, pmdp, pmdval.pud.pgd.pgd); -} -#endif /* CONFIG_X86_PAE */ +#endif /* PAGETABLE_LEVELS == 4 */ +#endif /* PAGETABLE_LEVELS >= 3 */ /* Lazy mode for batching updates / context switch */ enum paravirt_lazy_mode {
RFC PATCH 6/7 x86/xen: simplify Xen mmu operations
In reply to Jeremy FitzhardingeTake advantage of the unified page/pgtable.h definitions to reduce the number of duplicate definitions of the various Xen mmu_ops functions.
--- arch/x86/xen/enlighten.c | 8 ++++- arch/x86/xen/mmu.c | 67 +++++++++++++++++----------------------------- arch/x86/xen/mmu.h | 26 +++++------------ 3 files changed, 41 insertions(+), 60 deletions(-)
===================================================================
arch/x86/xen/enlighten.c +7 -1
@@ -1038,16 +1038,18 @@ static const struct pv_mmu_ops xen_mmu_o .make_pte = xen_make_pte, .make_pgd = xen_make_pgd, +#if PAGETABLE_LEVELS >=3 #ifdef CONFIG_X86_PAE .set_pte_atomic = xen_set_pte_atomic, .set_pte_present = xen_set_pte_at, +#endif /* PAE */ .set_pud = xen_set_pud, .pte_clear = xen_pte_clear, .pmd_clear = xen_pmd_clear, .make_pmd = xen_make_pmd, .pmd_val = xen_pmd_val, -#endif /* PAE */ +#endif /* PAGETABLE_LEVELS >= 3 */ .activate_mm = xen_activate_mm, .dup_mmap = xen_dup_mmap,
@@ -1175,6 +1177,10 @@ asmlinkage void __init xen_start_kernel(xen_setup_vcpu_info_placement ();#endif +#ifdef CONFIG_X86_PAE + __supported_pte_mask &= ~_PAGE_PCD; +#endif + pv_info.kernel_rpl =1 ;if (xen_feature (XENFEAT_supervisor_mode_kernel)) pv_info.kernel_rpl =0 ;
===================================================================
arch/x86/xen/mmu.c +26 -41
113 lines not on this page · raw message
===================================================================
arch/x86/xen/mmu.h +8 -18
@@ -30,31 +30,21 @@ void xen_pgd_pin(pgd_t *pgd);void xen_pgd_pin (pgd_t *pgd);//void xen_pgd_unpin(pgd_t *pgd); +pteval_t xen_pte_val (pte_t ); +pmdval_t xen_pmd_val (pmd_t ); +pgdval_t xen_pgd_val (pgd_t ); + +pte_t xen_make_pte (pteval_t ); +pmd_t xen_make_pmd (pmdval_t ); +pgd_t xen_make_pgd (pgdval_t ); +#ifdef CONFIG_X86_PAE -unsigned long long xen_pte_val (pte_t ); -unsigned long long xen_pmd_val (pmd_t ); -unsigned long long xen_pgd_val (pgd_t ); - -pte_t xen_make_pte (unsigned long long ); -pmd_t xen_make_pmd (unsigned long long ); -pgd_t xen_make_pgd (unsigned long long ); -void xen_set_pte_at (struct mm_struct *mm,unsigned long addr,pte_t *ptep,pte_t pteval);void xen_set_pte_atomic (pte_t *ptep,pte_t pte);void xen_set_pud (pud_t *ptr,pud_t val);void xen_pte_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep);void xen_pmd_clear (pmd_t *pmdp); - - -#else -unsigned long xen_pte_val (pte_t ); -unsigned long xen_pmd_val (pmd_t ); -unsigned long xen_pgd_val (pgd_t ); - -pte_t xen_make_pte (unsigned long ); -pmd_t xen_make_pmd (unsigned long ); -pgd_t xen_make_pgd (unsigned long );#endif #endif /* _XEN_MMU_H */
RFC PATCH 7/7 x86: fix up formatting in pgtable*.h
In reply to Jeremy FitzhardingeFix up various pieces of unconventional formatting in asm-x86/pgtable*.h. In some cases, the old formatting was arguablly clearer with a wide enough terminal, but this patch gives the option of using a more standard form.
--- include/asm-x86/pgtable-2level.h | 24 +++++++--- include/asm-x86/pgtable-3level.h | 17 ++++--- include/asm-x86/pgtable.h | 91 ++++++++++++++++++++++++++++++++------ include/asm-x86/pgtable_64.h | 20 +++++--- 4 files changed, 118 insertions(+), 34 deletions(-)
===================================================================
include/asm-x86/pgtable-2level.h +18 -6
@@ -15,25 +15,36 @@ static inline void native_set_pte(pte_t { *ptep = pte; } +static inline void native_set_pte_at (struct mm_struct *mm,unsigned long addr,pte_t *ptep ,pte_t pte) {native_set_pte (ptep, pte); } +static inline void native_set_pmd (pmd_t *pmdp,pmd_t pmd) { *pmdp = pmd; }#undef set_pte_atomic -#define set_pte_atomic (pteptr, pteval) set_pte(pteptr,pteval) -#define set_pte_present (mm,addr,ptep,pteval) set_pte_at(mm,addr,ptep,pteval) +#define set_pte_atomic (pteptr, pteval) set_pte(pteptr,pteval) -#define pte_clear (mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0) +#define set_pte_present (mm,addr,ptep,pteval) set_pte_at(mm,addr,ptep,pteval) + +#define pte_clear (mm,addr,xp) \ + do { \ + set_pte_at(mm, addr, xp, __pte(0)); \ + } while (0) +#undef pmd_clear -#define pmd_clear (xp) do { set_pmd(xp, __pmd(0)); } while (0) +#define pmd_clear (xp) \ + do { \ + set_pmd(xp, __pmd(0)); \ + } while (0) -static inline void native_pte_clear (struct mm_struct *mm,unsigned long addr,pte_t *xp) +static inline void native_pte_clear (struct mm_struct *mm, +unsigned long addr,pte_t *xp) { *xp =__pte (0 ); }
@@ -66,7 +77,8 @@ static inline int pte_exec_kernel(pte_t/* Encode and de-code a swap entry */ #define __swp_type (x) (((x).val >> 1) & 0x1f)#define __swp_offset (x) ((x).val >> 8) -#define __swp_entry (type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) }) +#define __swp_entry (type, offset) \ + ((swp_entry_t) { ((type) << 1) | ((offset) << 8) })#define __pte_to_swp_entry (pte) ((swp_entry_t) { (pte).pte_low })#define __swp_entry_to_pte (x) ((pte_t) { (x).val })
===================================================================
include/asm-x86/pgtable-3level.h +11 -6
@@ -9,7 +9,8 @@*/ #define pte_ERROR (e) \ - printk("%s:%d: bad pte %p(%08lx%08lx).\n", __FILE__, __LINE__, &(e), (e).pte_high, (e).pte_low) + printk("%s:%d: bad pte %p(%08lx%08lx).\n", __FILE__, __LINE__, \ + &(e), (e).pte_high, (e).pte_low)#define pmd_ERROR (e) \ printk("%s:%d: bad pmd %p(%016Lx).\n", __FILE__, __LINE__, &(e), pmd_val(e))#define pgd_ERROR (e) \
@@ -39,6 +40,7 @@ static inline void native_set_pte(pte_tsmp_wmb (); ptep->pte_low = pte.pte_low; } +static inline void native_set_pte_at (struct mm_struct *mm,unsigned long addr,pte_t *ptep ,pte_t pte) {
@@ -65,10 +67,12 @@ static inline void native_set_pte_atomic {set_64bit ((unsigned long long *)(ptep),native_pte_val (pte)); } +static inline void native_set_pmd (pmd_t *pmdp,pmd_t pmd) {set_64bit ((unsigned long long *)(pmdp),native_pmd_val (pmd)); } +static inline void native_set_pud (pud_t *pudp,pud_t pud) { *pudp = pud;
@@ -79,7 +83,8 @@ static inline void native_set_pud(pud_t* entry, so clear the bottom half first and enforce ordering with a compiler * barrier. */ -static inline void native_pte_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep) +static inline void native_pte_clear (struct mm_struct *mm, +unsigned long addr,pte_t *ptep) { ptep->pte_low =0 ;smp_wmb ();
@@ -102,11 +107,11 @@ static inline void native_pmd_clear(pmd_*/ static inline void pud_clear (pud_t * pud) { } -#define pud_page (pud) \ -((struct page *) __va(pud_val(pud) & PAGE_MASK)) +#define pud_page (pud) \ + ((struct page *) __va(pud_val(pud) & PAGE_MASK)) -#define pud_page_vaddr (pud) \ -((unsigned long) __va(pud_val(pud) & PAGE_MASK)) +#define pud_page_vaddr (pud) \ + ((unsigned long) __va(pud_val(pud) & PAGE_MASK))#ifdef CONFIG_SMP
===================================================================
include/asm-x86/pgtable.h +77 -14
103 lines not on this page · raw message
===================================================================
include/asm-x86/pgtable_64.h +12 -8
@@ -168,7 +168,8 @@ static inline pte_t ptep_get_and_clear_f/* * Level 4 access. */ -#define pgd_page_vaddr (pgd) ((unsigned long) __va((unsigned long)pgd_val(pgd) & PTE_MASK)) +#define pgd_page_vaddr (pgd) \ + ((unsigned long) __va((unsigned long)pgd_val(pgd) & PTE_MASK))#define pgd_page (pgd) (pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT))#define pgd_index (address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))#define pgd_offset (mm, addr) ((mm)->pgd + pgd_index(addr))
@@ -178,11 +179,13 @@ static inline pte_t ptep_get_and_clear_f/* PUD - Level 3 access */ /* to find an entry in a page-table-directory. */ -#define pud_page_vaddr (pud) ((unsigned long) __va(pud_val(pud) & PHYSICAL_PAGE_MASK)) +#define pud_page_vaddr (pud) ((unsigned long) __va(pud_val(pud) & PHYSICAL_PAGE_MASK))#define pud_page (pud) (pfn_to_page(pud_val(pud) >> PAGE_SHIFT)) -#define pud_index (address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1)) -#define pud_offset (pgd, address) ((pud_t *) pgd_page_vaddr(*(pgd)) + pud_index(address)) -#define pud_present (pud) (pud_val(pud) & _PAGE_PRESENT) +#define pud_index (address) \ + (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1)) +#define pud_offset (pgd, address) \ + ((pud_t *) pgd_page_vaddr(*(pgd)) + pud_index(address)) +#define pud_present (pud) (pud_val(pud) & _PAGE_PRESENT)#define PTE_FILE_MAX_BITS __PHYSICAL_MASK_SHIFT
@@ -241,7 +244,8 @@ static inline void ptep_set_wrprotect(st/* Encode and de-code a swap entry */ #define __swp_type (x) (((x).val >> 1) & 0x3f)#define __swp_offset (x) ((x).val >> 8) -#define __swp_entry (type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) }) +#define __swp_entry (type, offset) \ + ((swp_entry_t) { ((type) << 1) | ((offset) << 8) })#define __pte_to_swp_entry (pte) ((swp_entry_t) { pte_val(pte) })#define __swp_entry_to_pte (x) ((pte_t) { (x).val })
@@ -252,8 +256,8 @@ extern int kern_addr_valid(unsigned longpte_t *lookup_address (unsigned long addr); -#define io_remap_pfn_range (vma, vaddr, pfn, size, prot) \ - remap_pfn_range(vma, vaddr, pfn, size, prot) +#define io_remap_pfn_range (vma, vaddr, pfn, size, prot) \ + remap_pfn_range(vma, vaddr, pfn, size, prot)#define HAVE_ARCH_UNMAPPED_AREA