Thread (50 messages) 50 messages, 7 authors, 2019-04-08

Re: [PATCH] KVM: ARM: Remove pgtable page standard functions from stage-2 page tables

From: Anshuman Khandual <hidden>
Date: 2019-03-12 11:31:49
Also in: linux-mm


On 03/12/2019 04:07 PM, Suzuki K Poulose wrote:
Hi Anshuman,

On 12/03/2019 02:19, Anshuman Khandual wrote:
quoted
ARM64 standard pgtable functions are going to use pgtable_page_[ctor|dtor]
or pgtable_pmd_page_[ctor|dtor] constructs. At present KVM guest stage-2
PUD|PMD|PTE level page tabe pages are allocated with __get_free_page()
via mmu_memory_cache_alloc() but released with standard pud|pmd_free() or
pte_free_kernel(). These will fail once they start calling into pgtable_
[pmd]_page_dtor() for pages which never originally went through respective
constructor functions. Hence convert all stage-2 page table page release
functions to call buddy directly while freeing pages.

Signed-off-by: Anshuman Khandual <redacted>
---
  arch/arm/include/asm/stage2_pgtable.h   | 4 ++--
  arch/arm64/include/asm/stage2_pgtable.h | 4 ++--
  virt/kvm/arm/mmu.c                      | 2 +-
  3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/arm/include/asm/stage2_pgtable.h b/arch/arm/include/asm/stage2_pgtable.h
index de2089501b8b..417a3be00718 100644
--- a/arch/arm/include/asm/stage2_pgtable.h
+++ b/arch/arm/include/asm/stage2_pgtable.h
@@ -32,14 +32,14 @@
  #define stage2_pgd_present(kvm, pgd)        pgd_present(pgd)
  #define stage2_pgd_populate(kvm, pgd, pud)    pgd_populate(NULL, pgd, pud)
  #define stage2_pud_offset(kvm, pgd, address)    pud_offset(pgd, address)
-#define stage2_pud_free(kvm, pud)        pud_free(NULL, pud)
+#define stage2_pud_free(kvm, pud)        free_page((unsigned long)pud)
That must be a NOP, as we don't have pud on arm32 (we have 3 level table).
The pud_* helpers here all fallback to the generic no-pud helpers.
Which is the following here for pud_free()

#define pud_free(mm, x)                         do { } while (0)

On arm64 its protected by kvm_stage2_has_pud() helper before calling into pud_free().
In this case even though applicable pud_free() is NOP, it is still misleading. If we
are sure about page table level will always remain three it can directly have a NOP
(do/while) in there.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help