]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm: rename pud_page_vaddr to pud_pgtable and make it return pmd_t *
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Thu, 8 Jul 2021 01:09:53 +0000 (18:09 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 8 Jul 2021 18:48:22 +0000 (11:48 -0700)
No functional change in this patch.

[aneesh.kumar@linux.ibm.com: fix]
Link: https://lkml.kernel.org/r/87wnqtnb60.fsf@linux.ibm.com
[sfr@canb.auug.org.au: another fix]
Link: https://lkml.kernel.org/r/20210619134410.89559-1-aneesh.kumar@linux.ibm.com
Link: https://lkml.kernel.org/r/20210615110859.320299-1-aneesh.kumar@linux.ibm.com
Link: https://lore.kernel.org/linuxppc-dev/CAHk-=wi+J+iodze9FtjM3Zi4j4OeS+qqbKxME9QN4roxPEXH9Q@mail.gmail.com/
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Hugh Dickins <hughd@google.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Kalesh Singh <kaleshsingh@google.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
22 files changed:
arch/alpha/include/asm/pgtable.h
arch/arm/include/asm/pgtable-3level.h
arch/arm64/include/asm/pgtable.h
arch/ia64/include/asm/pgtable.h
arch/m68k/include/asm/motorola_pgtable.h
arch/mips/include/asm/pgtable-64.h
arch/parisc/include/asm/pgtable.h
arch/powerpc/include/asm/book3s/64/pgtable.h
arch/powerpc/include/asm/nohash/64/pgtable.h
arch/powerpc/mm/book3s64/radix_pgtable.c
arch/powerpc/mm/pgtable_64.c
arch/riscv/include/asm/pgtable-64.h
arch/sh/include/asm/pgtable-3level.h
arch/sparc/include/asm/pgtable_32.h
arch/sparc/include/asm/pgtable_64.h
arch/um/include/asm/pgtable-3level.h
arch/x86/include/asm/pgtable.h
arch/x86/mm/pat/set_memory.c
arch/x86/mm/pgtable.c
include/asm-generic/pgtable-nopmd.h
include/asm-generic/pgtable-nopud.h
include/linux/pgtable.h

index ff690846465e37b4844c8e4b02167461d9e5e13e..02f0429f1068abddd72e9baa02ed394222140642 100644 (file)
@@ -236,8 +236,10 @@ pmd_page_vaddr(pmd_t pmd)
 #define pmd_page(pmd)  (pfn_to_page(pmd_val(pmd) >> 32))
 #define pud_page(pud)  (pfn_to_page(pud_val(pud) >> 32))
 
-extern inline unsigned long pud_page_vaddr(pud_t pgd)
-{ return PAGE_OFFSET + ((pud_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
+extern inline pmd_t *pud_pgtable(pud_t pgd)
+{
+       return (pmd_t *)(PAGE_OFFSET + ((pud_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)));
+}
 
 extern inline int pte_none(pte_t pte)          { return !pte_val(pte); }
 extern inline int pte_present(pte_t pte)       { return pte_val(pte) & _PAGE_VALID; }
@@ -287,7 +289,7 @@ extern inline pte_t pte_mkyoung(pte_t pte)  { pte_val(pte) |= __ACCESS_BITS; retu
 /* Find an entry in the second-level page table.. */
 extern inline pmd_t * pmd_offset(pud_t * dir, unsigned long address)
 {
-       pmd_t *ret = (pmd_t *) pud_page_vaddr(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
+       pmd_t *ret = pud_pgtable(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
        smp_rmb(); /* see above */
        return ret;
 }
index d4edab51a77c075d3914e3c18d9ba1a578bec19f..eabe72ff7381522c6725a3e51bcf50d30362f6ee 100644 (file)
                flush_pmd_entry(pudp);  \
        } while (0)
 
-static inline pmd_t *pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
        return __va(pud_val(pud) & PHYS_MASK & (s32)PAGE_MASK);
 }
index 508c7ffad515cdbbc87e8ee7ef6ac9a168835c3e..d6b8e74f3018653703d9b33375f9afa08067b4a5 100644 (file)
@@ -649,9 +649,9 @@ static inline phys_addr_t pud_page_paddr(pud_t pud)
        return __pud_to_phys(pud);
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-       return (unsigned long)__va(pud_page_paddr(pud));
+       return (pmd_t *)__va(pud_page_paddr(pud));
 }
 
 /* Find an entry in the second-level page table. */
index 3f5dbbd8b9d8ce4bd7baa726ecab804e67d439c3..7599d04ae19228a4aff1f42880aa90ce3cad21bc 100644 (file)
@@ -273,7 +273,7 @@ ia64_phys_addr_valid (unsigned long addr)
 #define pud_bad(pud)                   (!ia64_phys_addr_valid(pud_val(pud)))
 #define pud_present(pud)               (pud_val(pud) != 0UL)
 #define pud_clear(pudp)                        (pud_val(*(pudp)) = 0UL)
-#define pud_page_vaddr(pud)            ((unsigned long) __va(pud_val(pud) & _PFN_MASK))
+#define pud_pgtable(pud)               ((pmd_t *) __va(pud_val(pud) & _PFN_MASK))
 #define pud_page(pud)                  virt_to_page((pud_val(pud) + PAGE_OFFSET))
 
 #if CONFIG_PGTABLE_LEVELS == 4
index a2908164ee6fc46d8a6081673a8fe3574304c3ac..022c3abc280d2a71e3c2acf3676b335417d1967c 100644 (file)
@@ -131,7 +131,7 @@ static inline void pud_set(pud_t *pudp, pmd_t *pmdp)
 
 #define __pte_page(pte) ((unsigned long)__va(pte_val(pte) & PAGE_MASK))
 #define pmd_page_vaddr(pmd) ((unsigned long)__va(pmd_val(pmd) & _TABLE_MASK))
-#define pud_page_vaddr(pud) ((unsigned long)__va(pud_val(pud) & _TABLE_MASK))
+#define pud_pgtable(pud) ((pmd_t *)__va(pud_val(pud) & _TABLE_MASK))
 
 
 #define pte_none(pte)          (!pte_val(pte))
index 046465906c825e20a36b8179aad65e488a9e3837..1136b6f3e41e6422aa239df8201f97460ea42ce0 100644 (file)
@@ -313,9 +313,9 @@ static inline void pud_clear(pud_t *pudp)
 #endif
 
 #ifndef __PAGETABLE_PMD_FOLDED
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-       return pud_val(pud);
+       return (pmd_t *)pud_val(pud);
 }
 #define pud_phys(pud)          virt_to_phys((void *)pud_val(pud))
 #define pud_page(pud)          (pfn_to_page(pud_phys(pud) >> PAGE_SHIFT))
index 7f33c29764cc18bc9d9818663983323b54977ee4..43937af127b111a7e500d0e89af86bb0908b93a5 100644 (file)
@@ -322,8 +322,8 @@ static inline void pmd_clear(pmd_t *pmd) {
 
 
 #if CONFIG_PGTABLE_LEVELS == 3
-#define pud_page_vaddr(pud) ((unsigned long) __va(pud_address(pud)))
-#define pud_page(pud)  virt_to_page((void *)pud_page_vaddr(pud))
+#define pud_pgtable(pud) ((pmd_t *) __va(pud_address(pud)))
+#define pud_page(pud)  virt_to_page((void *)pud_pgtable(pud))
 
 /* For 64 bit we have three level tables */
 
index 4d9941b2fe517e9a1dd6fc9f939ba23687809dcc..536037017c3ea2d12a68837170303952634790eb 100644 (file)
@@ -1051,9 +1051,13 @@ extern struct page *p4d_page(p4d_t p4d);
 /* Pointers in the page table tree are physical addresses */
 #define __pgtable_ptr_val(ptr) __pa(ptr)
 
-#define pud_page_vaddr(pud)    __va(pud_val(pud) & ~PUD_MASKED_BITS)
 #define p4d_page_vaddr(p4d)    __va(p4d_val(p4d) & ~P4D_MASKED_BITS)
 
+static inline pmd_t *pud_pgtable(pud_t pud)
+{
+       return (pmd_t *)__va(pud_val(pud) & ~PUD_MASKED_BITS);
+}
+
 #define pte_ERROR(e) \
        pr_err("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
 #define pmd_ERROR(e) \
index 53fbfdfac93d04eea63370c5c87d49f0d3c4e0fa..d081704b13fb914432e82591055f640a6c623d42 100644 (file)
@@ -162,7 +162,11 @@ static inline void pud_clear(pud_t *pudp)
 #define        pud_bad(pud)            (!is_kernel_addr(pud_val(pud)) \
                                 || (pud_val(pud) & PUD_BAD_BITS))
 #define pud_present(pud)       (pud_val(pud) != 0)
-#define pud_page_vaddr(pud)    (pud_val(pud) & ~PUD_MASKED_BITS)
+
+static inline pmd_t *pud_pgtable(pud_t pud)
+{
+       return (pmd_t *)(pud_val(pud) & ~PUD_MASKED_BITS);
+}
 
 extern struct page *pud_page(pud_t pud);
 
index 2176a5f70746c7e8a758f9e1de7b253aab462617..54f135b1ee60e2361fa6d9c75941b136f1b54a0f 100644 (file)
@@ -820,7 +820,7 @@ static void __meminit remove_pud_table(pud_t *pud_start, unsigned long addr,
                        continue;
                }
 
-               pmd_base = (pmd_t *)pud_page_vaddr(*pud);
+               pmd_base = pud_pgtable(*pud);
                remove_pmd_table(pmd_base, addr, next);
                free_pmd_table(pmd_base, pud);
        }
@@ -1105,7 +1105,7 @@ int pud_free_pmd_page(pud_t *pud, unsigned long addr)
        pmd_t *pmd;
        int i;
 
-       pmd = (pmd_t *)pud_page_vaddr(*pud);
+       pmd = pud_pgtable(*pud);
        pud_clear(pud);
 
        flush_tlb_kernel_range(addr, addr + PUD_SIZE);
index cc6e2f94517fcbae716c9b1c6119002603497327..4ba311808bdbc805b0265358f797e81cbf0edee1 100644 (file)
@@ -115,7 +115,7 @@ struct page *pud_page(pud_t pud)
                VM_WARN_ON(!pud_huge(pud));
                return pte_page(pud_pte(pud));
        }
-       return virt_to_page(pud_page_vaddr(pud));
+       return virt_to_page(pud_pgtable(pud));
 }
 
 /*
index f3b0da64c6c8f2c1d6c87373b336a9737d3fcfe0..0e863f3f7187a95cfe28c232b0b6d480a917ad6f 100644 (file)
@@ -60,9 +60,9 @@ static inline void pud_clear(pud_t *pudp)
        set_pud(pudp, __pud(0));
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-       return (unsigned long)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT);
+       return (pmd_t *)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT);
 }
 
 static inline struct page *pud_page(pud_t pud)
index 82d74472dfcdab0fc96be442892951ef5220dab4..56bf35c2f29c2b832170d67468c1a23d5f27383e 100644 (file)
@@ -32,9 +32,9 @@ typedef struct { unsigned long long pmd; } pmd_t;
 #define pmd_val(x)     ((x).pmd)
 #define __pmd(x)       ((pmd_t) { (x) } )
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-       return pud_val(pud);
+       return (pmd_t *)pud_val(pud);
 }
 
 /* only used by the stubbed out hugetlb gup code, should never be called */
index ebaf374b55ab924ba69c0f975a1a03b61f278efc..ffccfe3b22ed3ced2a3e2425c320b6034cf9b0ad 100644 (file)
@@ -151,13 +151,13 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
        return (unsigned long)__nocache_va(v << 4);
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
        if (srmmu_device_memory(pud_val(pud))) {
-               return ~0;
+               return (pmd_t *)~0;
        } else {
                unsigned long v = pud_val(pud) & SRMMU_PTD_PMASK;
-               return (unsigned long)__nocache_va(v << 4);
+               return (pmd_t *)__nocache_va(v << 4);
        }
 }
 
index e0ee48ec390304bd62192deec4d143dcc8bf101e..23da25d4765c890658c9ac9a35ccd7a485490d05 100644 (file)
@@ -841,18 +841,18 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
        return ((unsigned long) __va(pfn << PAGE_SHIFT));
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
        pte_t pte = __pte(pud_val(pud));
        unsigned long pfn;
 
        pfn = pte_pfn(pte);
 
-       return ((unsigned long) __va(pfn << PAGE_SHIFT));
+       return ((pmd_t *) __va(pfn << PAGE_SHIFT));
 }
 
 #define pmd_page(pmd)                  virt_to_page((void *)pmd_page_vaddr(pmd))
-#define pud_page(pud)                  virt_to_page((void *)pud_page_vaddr(pud))
+#define pud_page(pud)                  virt_to_page((void *)pud_pgtable(pud))
 #define pmd_clear(pmdp)                        (pmd_val(*(pmdp)) = 0UL)
 #define pud_present(pud)               (pud_val(pud) != 0U)
 #define pud_clear(pudp)                        (pud_val(*(pudp)) = 0UL)
index 9289a86643a9d2ca0d3d07bb9c9b3acb708593ae..cb896e6121c8e611641e32c491dd97687bd781eb 100644 (file)
@@ -83,7 +83,7 @@ static inline void pud_clear (pud_t *pud)
 }
 
 #define pud_page(pud) phys_to_page(pud_val(pud) & PAGE_MASK)
-#define pud_page_vaddr(pud) ((unsigned long) __va(pud_val(pud) & PAGE_MASK))
+#define pud_pgtable(pud) ((pmd_t *) __va(pud_val(pud) & PAGE_MASK))
 
 static inline unsigned long pte_pfn(pte_t pte)
 {
index ec0d8e106646b0e27b817f2ea1abc80c8d34689c..e064c5fef0f3b5aca9bc7d294855dedec15d83a7 100644 (file)
@@ -836,9 +836,9 @@ static inline int pud_present(pud_t pud)
        return pud_flags(pud) & _PAGE_PRESENT;
 }
 
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
 {
-       return (unsigned long)__va(pud_val(pud) & pud_pfn_mask(pud));
+       return (pmd_t *)__va(pud_val(pud) & pud_pfn_mask(pud));
 }
 
 /*
index 156cd235659f3d516a4323f5a0498676b63fdbe6..ad8a5c586a353a92454484fdbc7b29276a06e15c 100644 (file)
@@ -1134,7 +1134,7 @@ static void __unmap_pmd_range(pud_t *pud, pmd_t *pmd,
                              unsigned long start, unsigned long end)
 {
        if (unmap_pte_range(pmd, start, end))
-               if (try_to_free_pmd_page((pmd_t *)pud_page_vaddr(*pud)))
+               if (try_to_free_pmd_page(pud_pgtable(*pud)))
                        pud_clear(pud);
 }
 
@@ -1178,7 +1178,7 @@ static void unmap_pmd_range(pud_t *pud, unsigned long start, unsigned long end)
         * Try again to free the PMD page if haven't succeeded above.
         */
        if (!pud_none(*pud))
-               if (try_to_free_pmd_page((pmd_t *)pud_page_vaddr(*pud)))
+               if (try_to_free_pmd_page(pud_pgtable(*pud)))
                        pud_clear(pud);
 }
 
index 1303ff6ef7be5fda90ec17be8600cb09a898c25e..3364fe62b9037430b29df58837d0d9ca8defbc28 100644 (file)
@@ -801,7 +801,7 @@ int pud_free_pmd_page(pud_t *pud, unsigned long addr)
        pte_t *pte;
        int i;
 
-       pmd = (pmd_t *)pud_page_vaddr(*pud);
+       pmd = pud_pgtable(*pud);
        pmd_sv = (pmd_t *)__get_free_page(GFP_KERNEL);
        if (!pmd_sv)
                return 0;
index 3e13acd019aefc2fdbc9f2aede12a31e52c83b77..10789cf51d1603337c270c204d7074e71a0442f6 100644 (file)
@@ -51,7 +51,7 @@ static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)
 #define __pmd(x)                               ((pmd_t) { __pud(x) } )
 
 #define pud_page(pud)                          (pmd_page((pmd_t){ pud }))
-#define pud_page_vaddr(pud)                    (pmd_page_vaddr((pmd_t){ pud }))
+#define pud_pgtable(pud)                       ((pmd_t *)(pmd_page_vaddr((pmd_t){ pud })))
 
 /*
  * allocating and freeing a pmd is trivial: the 1-entry pmd is
index a9d751fbda9e87f2ccb66638438ef868ec5b6855..7cbd15f70bf55d6477967fdbf375c9abbc33c3b7 100644 (file)
@@ -49,7 +49,7 @@ static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
 #define __pud(x)                               ((pud_t) { __p4d(x) })
 
 #define p4d_page(p4d)                          (pud_page((pud_t){ p4d }))
-#define p4d_page_vaddr(p4d)                    (pud_page_vaddr((pud_t){ p4d }))
+#define p4d_page_vaddr(p4d)                    (pud_pgtable((pud_t){ p4d }))
 
 /*
  * allocating and freeing a pud is trivial: the 1-entry pud is
index e82660f7b9e4defc0dc4310a6f4e8b60c265592b..c7c992ada1fe34c1faef9866279b189c60628b2f 100644 (file)
@@ -106,7 +106,7 @@ static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address)
 #ifndef pmd_offset
 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
 {
-       return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address);
+       return pud_pgtable(*pud) + pmd_index(address);
 }
 #define pmd_offset pmd_offset
 #endif