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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 12/03/2019 11:31, Anshuman Khandual wrote:


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

On 12/03/2019 02:19, Anshuman Khandual wrote:
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 <anshuman.khandual@xxxxxxx>
---
   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.


Yes, it is fixed for arm32 and you could have it as do {} while (0), which is
what I meant by NOP. On arm64, we had varied number of levels depending on the
PAGE_SIZE and now due to the dynamic IPA, hence the check.

Cheers
Suzuki




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux