diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2008-06-25 00:19:06 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-08 07:10:30 -0400 |
commit | fb15a9b3047a245a30a51696e4d8e29b1175a598 (patch) | |
tree | 422a2347cc8f819bddcc0d55e671ad612565fefa /include/asm-x86 | |
parent | e7a9b0b3c32aa13f4c766eb6a4e7038260718d4c (diff) |
x86: unify pgd_index
pgd_index is common for 32 and 64-bit, so move it to a common place.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/asm-x86')
-rw-r--r-- | include/asm-x86/pgtable.h | 20 | ||||
-rw-r--r-- | include/asm-x86/pgtable_32.h | 20 | ||||
-rw-r--r-- | include/asm-x86/pgtable_64.h | 3 |
3 files changed, 20 insertions, 23 deletions
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h index 1330e7487da1..85f851a0b998 100644 --- a/include/asm-x86/pgtable.h +++ b/include/asm-x86/pgtable.h | |||
@@ -357,6 +357,26 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pte); | |||
357 | # include "pgtable_64.h" | 357 | # include "pgtable_64.h" |
358 | #endif | 358 | #endif |
359 | 359 | ||
360 | /* | ||
361 | * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD] | ||
362 | * | ||
363 | * this macro returns the index of the entry in the pgd page which would | ||
364 | * control the given virtual address | ||
365 | */ | ||
366 | #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)) | ||
367 | |||
368 | /* | ||
369 | * pgd_offset() returns a (pgd_t *) | ||
370 | * pgd_index() is used get the offset into the pgd page's array of pgd_t's; | ||
371 | */ | ||
372 | #define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address))) | ||
373 | /* | ||
374 | * a shortcut which implies the use of the kernel's pgd, instead | ||
375 | * of a process's | ||
376 | */ | ||
377 | #define pgd_offset_k(address) pgd_offset(&init_mm, (address)) | ||
378 | |||
379 | |||
360 | #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET) | 380 | #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET) |
361 | #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY) | 381 | #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY) |
362 | 382 | ||
diff --git a/include/asm-x86/pgtable_32.h b/include/asm-x86/pgtable_32.h index 32ca03109a4c..ec871c420d7e 100644 --- a/include/asm-x86/pgtable_32.h +++ b/include/asm-x86/pgtable_32.h | |||
@@ -113,26 +113,6 @@ extern unsigned long pg0[]; | |||
113 | */ | 113 | */ |
114 | #define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) | 114 | #define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) |
115 | 115 | ||
116 | /* | ||
117 | * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD] | ||
118 | * | ||
119 | * this macro returns the index of the entry in the pgd page which would | ||
120 | * control the given virtual address | ||
121 | */ | ||
122 | #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)) | ||
123 | #define pgd_index_k(addr) pgd_index((addr)) | ||
124 | |||
125 | /* | ||
126 | * pgd_offset() returns a (pgd_t *) | ||
127 | * pgd_index() is used get the offset into the pgd page's array of pgd_t's; | ||
128 | */ | ||
129 | #define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address))) | ||
130 | |||
131 | /* | ||
132 | * a shortcut which implies the use of the kernel's pgd, instead | ||
133 | * of a process's | ||
134 | */ | ||
135 | #define pgd_offset_k(address) pgd_offset(&init_mm, (address)) | ||
136 | 116 | ||
137 | static inline int pud_large(pud_t pud) { return 0; } | 117 | static inline int pud_large(pud_t pud) { return 0; } |
138 | 118 | ||
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h index 23f35fff5fca..9a9350abe4ef 100644 --- a/include/asm-x86/pgtable_64.h +++ b/include/asm-x86/pgtable_64.h | |||
@@ -190,9 +190,6 @@ static inline int pmd_bad(pmd_t pmd) | |||
190 | #define pgd_page_vaddr(pgd) \ | 190 | #define pgd_page_vaddr(pgd) \ |
191 | ((unsigned long)__va((unsigned long)pgd_val((pgd)) & PTE_MASK)) | 191 | ((unsigned long)__va((unsigned long)pgd_val((pgd)) & PTE_MASK)) |
192 | #define pgd_page(pgd) (pfn_to_page(pgd_val((pgd)) >> PAGE_SHIFT)) | 192 | #define pgd_page(pgd) (pfn_to_page(pgd_val((pgd)) >> PAGE_SHIFT)) |
193 | #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)) | ||
194 | #define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address))) | ||
195 | #define pgd_offset_k(address) (init_level4_pgt + pgd_index((address))) | ||
196 | #define pgd_present(pgd) (pgd_val(pgd) & _PAGE_PRESENT) | 193 | #define pgd_present(pgd) (pgd_val(pgd) & _PAGE_PRESENT) |
197 | static inline int pgd_large(pgd_t pgd) { return 0; } | 194 | static inline int pgd_large(pgd_t pgd) { return 0; } |
198 | #define mk_kernel_pgd(address) __pgd((address) | _KERNPG_TABLE) | 195 | #define mk_kernel_pgd(address) __pgd((address) | _KERNPG_TABLE) |