--- v1
+++ v2
@@ -1,32 +1,43 @@
As part of the conversions to replace pgtable constructor/destructors with
ptdesc equivalents, convert various page table functions to use ptdescs.
+late_alloc() also uses the __get_free_pages() helper function. Convert
+this to use ptdesc_alloc() and ptdesc_address() instead to help
+standardize page tables further.
+
Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
---
- arch/arm64/include/asm/tlb.h | 14 ++++++++------
- arch/arm64/mm/mmu.c | 7 ++++---
- 2 files changed, 12 insertions(+), 9 deletions(-)
+ arch/arm/include/asm/tlb.h | 12 +++++++-----
+ arch/arm/mm/mmu.c | 6 +++---
+ 2 files changed, 10 insertions(+), 8 deletions(-)
-diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h
-index c995d1f4594f..6cb70c247e30 100644
---- a/arch/arm64/include/asm/tlb.h
-+++ b/arch/arm64/include/asm/tlb.h
-@@ -75,18 +75,20 @@ static inline void tlb_flush(struct mmu_gather *tlb)
- static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
- unsigned long addr)
+diff --git a/arch/arm/include/asm/tlb.h b/arch/arm/include/asm/tlb.h
+index b8cbe03ad260..9ab8a6929d35 100644
+--- a/arch/arm/include/asm/tlb.h
++++ b/arch/arm/include/asm/tlb.h
+@@ -39,7 +39,9 @@ static inline void __tlb_remove_table(void *_table)
+ static inline void
+ __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, unsigned long addr)
{
- pgtable_pte_page_dtor(pte);
-- tlb_remove_table(tlb, pte);
+ struct ptdesc *ptdesc = page_ptdesc(pte);
+
+ ptdesc_pte_dtor(ptdesc);
+
+ #ifndef CONFIG_ARM_LPAE
+ /*
+@@ -50,17 +52,17 @@ __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, unsigned long addr)
+ __tlb_adjust_range(tlb, addr - PAGE_SIZE, 2 * PAGE_SIZE);
+ #endif
+
+- tlb_remove_table(tlb, pte);
+ tlb_remove_ptdesc(tlb, ptdesc);
}
- #if CONFIG_PGTABLE_LEVELS > 2
- static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp,
- unsigned long addr)
+ static inline void
+ __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp, unsigned long addr)
{
+ #ifdef CONFIG_ARM_LPAE
- struct page *page = virt_to_page(pmdp);
+ struct ptdesc *ptdesc = virt_to_ptdesc(pmdp);
@@ -34,46 +45,28 @@
- tlb_remove_table(tlb, page);
+ ptdesc_pmd_dtor(ptdesc);
+ tlb_remove_ptdesc(tlb, ptdesc);
+ #endif
}
- #endif
-@@ -94,7 +96,7 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp,
- static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pudp,
- unsigned long addr)
+diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
+index 463fc2a8448f..7add505bd797 100644
+--- a/arch/arm/mm/mmu.c
++++ b/arch/arm/mm/mmu.c
+@@ -737,11 +737,11 @@ static void __init *early_alloc(unsigned long sz)
+
+ static void *__init late_alloc(unsigned long sz)
{
-- tlb_remove_table(tlb, virt_to_page(pudp));
-+ tlb_remove_ptdesc(tlb, virt_to_ptdesc(pudp));
+- void *ptr = (void *)__get_free_pages(GFP_PGTABLE_KERNEL, get_order(sz));
++ void *ptdesc = ptdesc_alloc(GFP_PGTABLE_KERNEL, get_order(sz));
+
+- if (!ptr || !pgtable_pte_page_ctor(virt_to_page(ptr)))
++ if (!ptdesc || !ptdesc_pte_ctor(ptdesc))
+ BUG();
+- return ptr;
++ return ptdesc;
}
- #endif
-diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
-index af6bc8403ee4..5ba005fd607e 100644
---- a/arch/arm64/mm/mmu.c
-+++ b/arch/arm64/mm/mmu.c
-@@ -426,6 +426,7 @@ static phys_addr_t __pgd_pgtable_alloc(int shift)
- static phys_addr_t pgd_pgtable_alloc(int shift)
- {
- phys_addr_t pa = __pgd_pgtable_alloc(shift);
-+ struct ptdesc *ptdesc = page_ptdesc(phys_to_page(pa));
-
- /*
- * Call proper page table ctor in case later we need to
-@@ -433,12 +434,12 @@ static phys_addr_t pgd_pgtable_alloc(int shift)
- * this pre-allocated page table.
- *
- * We don't select ARCH_ENABLE_SPLIT_PMD_PTLOCK if pmd is
-- * folded, and if so pgtable_pmd_page_ctor() becomes nop.
-+ * folded, and if so ptdesc_pte_dtor() becomes nop.
- */
- if (shift == PAGE_SHIFT)
-- BUG_ON(!pgtable_pte_page_ctor(phys_to_page(pa)));
-+ BUG_ON(!ptdesc_pte_dtor(ptdesc));
- else if (shift == PMD_SHIFT)
-- BUG_ON(!pgtable_pmd_page_ctor(phys_to_page(pa)));
-+ BUG_ON(!ptdesc_pte_dtor(ptdesc));
-
- return pa;
- }
+ static pte_t * __init arm_pte_alloc(pmd_t *pmd, unsigned long addr,
--
2.39.2