diff options
Diffstat (limited to 'include/asm-x86/pgtable-3level.h')
| -rw-r--r-- | include/asm-x86/pgtable-3level.h | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/include/asm-x86/pgtable-3level.h b/include/asm-x86/pgtable-3level.h index 1d763eec740f..8b4a9d44b7f4 100644 --- a/include/asm-x86/pgtable-3level.h +++ b/include/asm-x86/pgtable-3level.h | |||
| @@ -8,22 +8,26 @@ | |||
| 8 | * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com> | 8 | * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com> |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | #define pte_ERROR(e) \ | 11 | #define pte_ERROR(e) \ |
| 12 | printk("%s:%d: bad pte %p(%08lx%08lx).\n", __FILE__, __LINE__, &(e), (e).pte_high, (e).pte_low) | 12 | printk("%s:%d: bad pte %p(%08lx%08lx).\n", \ |
| 13 | #define pmd_ERROR(e) \ | 13 | __FILE__, __LINE__, &(e), (e).pte_high, (e).pte_low) |
| 14 | printk("%s:%d: bad pmd %p(%016Lx).\n", __FILE__, __LINE__, &(e), pmd_val(e)) | 14 | #define pmd_ERROR(e) \ |
| 15 | #define pgd_ERROR(e) \ | 15 | printk("%s:%d: bad pmd %p(%016Lx).\n", \ |
| 16 | printk("%s:%d: bad pgd %p(%016Lx).\n", __FILE__, __LINE__, &(e), pgd_val(e)) | 16 | __FILE__, __LINE__, &(e), pmd_val(e)) |
| 17 | 17 | #define pgd_ERROR(e) \ | |
| 18 | printk("%s:%d: bad pgd %p(%016Lx).\n", \ | ||
| 19 | __FILE__, __LINE__, &(e), pgd_val(e)) | ||
| 18 | 20 | ||
| 19 | static inline int pud_none(pud_t pud) | 21 | static inline int pud_none(pud_t pud) |
| 20 | { | 22 | { |
| 21 | return pud_val(pud) == 0; | 23 | return pud_val(pud) == 0; |
| 22 | } | 24 | } |
| 25 | |||
| 23 | static inline int pud_bad(pud_t pud) | 26 | static inline int pud_bad(pud_t pud) |
| 24 | { | 27 | { |
| 25 | return (pud_val(pud) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER)) != 0; | 28 | return (pud_val(pud) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER)) != 0; |
| 26 | } | 29 | } |
| 30 | |||
| 27 | static inline int pud_present(pud_t pud) | 31 | static inline int pud_present(pud_t pud) |
| 28 | { | 32 | { |
| 29 | return pud_val(pud) & _PAGE_PRESENT; | 33 | return pud_val(pud) & _PAGE_PRESENT; |
| @@ -48,7 +52,8 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte) | |||
| 48 | * we are justified in merely clearing the PTE present bit, followed | 52 | * we are justified in merely clearing the PTE present bit, followed |
| 49 | * by a set. The ordering here is important. | 53 | * by a set. The ordering here is important. |
| 50 | */ | 54 | */ |
| 51 | static inline void native_set_pte_present(struct mm_struct *mm, unsigned long addr, | 55 | static inline void native_set_pte_present(struct mm_struct *mm, |
| 56 | unsigned long addr, | ||
| 52 | pte_t *ptep, pte_t pte) | 57 | pte_t *ptep, pte_t pte) |
| 53 | { | 58 | { |
| 54 | ptep->pte_low = 0; | 59 | ptep->pte_low = 0; |
| @@ -60,15 +65,17 @@ static inline void native_set_pte_present(struct mm_struct *mm, unsigned long ad | |||
| 60 | 65 | ||
| 61 | static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte) | 66 | static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte) |
| 62 | { | 67 | { |
| 63 | set_64bit((unsigned long long *)(ptep),native_pte_val(pte)); | 68 | set_64bit((unsigned long long *)(ptep), native_pte_val(pte)); |
| 64 | } | 69 | } |
| 70 | |||
| 65 | static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd) | 71 | static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd) |
| 66 | { | 72 | { |
| 67 | set_64bit((unsigned long long *)(pmdp),native_pmd_val(pmd)); | 73 | set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd)); |
| 68 | } | 74 | } |
| 75 | |||
| 69 | static inline void native_set_pud(pud_t *pudp, pud_t pud) | 76 | static inline void native_set_pud(pud_t *pudp, pud_t pud) |
| 70 | { | 77 | { |
| 71 | set_64bit((unsigned long long *)(pudp),native_pud_val(pud)); | 78 | set_64bit((unsigned long long *)(pudp), native_pud_val(pud)); |
| 72 | } | 79 | } |
| 73 | 80 | ||
| 74 | /* | 81 | /* |
| @@ -76,7 +83,8 @@ static inline void native_set_pud(pud_t *pudp, pud_t pud) | |||
| 76 | * entry, so clear the bottom half first and enforce ordering with a compiler | 83 | * entry, so clear the bottom half first and enforce ordering with a compiler |
| 77 | * barrier. | 84 | * barrier. |
| 78 | */ | 85 | */ |
| 79 | static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) | 86 | static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr, |
| 87 | pte_t *ptep) | ||
| 80 | { | 88 | { |
| 81 | ptep->pte_low = 0; | 89 | ptep->pte_low = 0; |
| 82 | smp_wmb(); | 90 | smp_wmb(); |
| @@ -107,20 +115,19 @@ static inline void pud_clear(pud_t *pudp) | |||
| 107 | * current pgd to avoid unnecessary TLB flushes. | 115 | * current pgd to avoid unnecessary TLB flushes. |
| 108 | */ | 116 | */ |
| 109 | pgd = read_cr3(); | 117 | pgd = read_cr3(); |
| 110 | if (__pa(pudp) >= pgd && __pa(pudp) < (pgd + sizeof(pgd_t)*PTRS_PER_PGD)) | 118 | if (__pa(pudp) >= pgd && __pa(pudp) < |
| 119 | (pgd + sizeof(pgd_t)*PTRS_PER_PGD)) | ||
| 111 | write_cr3(pgd); | 120 | write_cr3(pgd); |
| 112 | } | 121 | } |
| 113 | 122 | ||
| 114 | #define pud_page(pud) \ | 123 | #define pud_page(pud) ((struct page *) __va(pud_val(pud) & PAGE_MASK)) |
| 115 | ((struct page *) __va(pud_val(pud) & PAGE_MASK)) | ||
| 116 | 124 | ||
| 117 | #define pud_page_vaddr(pud) \ | 125 | #define pud_page_vaddr(pud) ((unsigned long) __va(pud_val(pud) & PAGE_MASK)) |
| 118 | ((unsigned long) __va(pud_val(pud) & PAGE_MASK)) | ||
| 119 | 126 | ||
| 120 | 127 | ||
| 121 | /* Find an entry in the second-level page table.. */ | 128 | /* Find an entry in the second-level page table.. */ |
| 122 | #define pmd_offset(pud, address) ((pmd_t *) pud_page(*(pud)) + \ | 129 | #define pmd_offset(pud, address) ((pmd_t *)pud_page(*(pud)) + \ |
| 123 | pmd_index(address)) | 130 | pmd_index(address)) |
| 124 | 131 | ||
| 125 | #ifdef CONFIG_SMP | 132 | #ifdef CONFIG_SMP |
| 126 | static inline pte_t native_ptep_get_and_clear(pte_t *ptep) | 133 | static inline pte_t native_ptep_get_and_clear(pte_t *ptep) |
| @@ -161,7 +168,8 @@ static inline unsigned long pte_pfn(pte_t pte) | |||
| 161 | * put the 32 bits of offset into the high part. | 168 | * put the 32 bits of offset into the high part. |
| 162 | */ | 169 | */ |
| 163 | #define pte_to_pgoff(pte) ((pte).pte_high) | 170 | #define pte_to_pgoff(pte) ((pte).pte_high) |
| 164 | #define pgoff_to_pte(off) ((pte_t) { { .pte_low = _PAGE_FILE, .pte_high = (off) } }) | 171 | #define pgoff_to_pte(off) \ |
| 172 | ((pte_t) { { .pte_low = _PAGE_FILE, .pte_high = (off) } }) | ||
| 165 | #define PTE_FILE_MAX_BITS 32 | 173 | #define PTE_FILE_MAX_BITS 32 |
| 166 | 174 | ||
| 167 | /* Encode and de-code a swap entry */ | 175 | /* Encode and de-code a swap entry */ |
