From b7b3b15f91259c3127543b7b1c331f58273fcd9a Mon Sep 17 00:00:00 2001 From: Sebastian Ene Date: Wed, 10 Aug 2022 13:38:34 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Split stage2_put_pte function Refactor the code and introduce stage2_unmap_clear_pte which removes the page table entry without dropping the refcount of the page table page. This will be used later when we modify the refcounting mechanism so that we will be able to clear the entries without dropping the refcount. Change-Id: I4a159b78bd17ff53ce063309b4b02ebb2d1c192d Bug: 357781595 Signed-off-by: Sebastian Ene --- arch/arm64/kvm/hyp/pgtable.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 4cf7359c3c4d..b1dfd9832e37 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -864,17 +864,10 @@ static bool stage2_unmap_defer_tlb_flush(struct kvm_pgtable *pgt) return system_supports_tlb_range() && stage2_has_fwb(pgt); } -static void stage2_unmap_put_pte(const struct kvm_pgtable_visit_ctx *ctx, - struct kvm_s2_mmu *mmu, - struct kvm_pgtable_mm_ops *mm_ops) +static void stage2_unmap_clear_pte(const struct kvm_pgtable_visit_ctx *ctx, + struct kvm_s2_mmu *mmu) { struct kvm_pgtable *pgt = ctx->arg; - - /* - * Clear the existing PTE, and perform break-before-make if it was - * valid. Depending on the system support, defer the TLB maintenance - * for the same until the entire unmap walk is completed. - */ if (kvm_pte_valid(ctx->old)) { kvm_clear_pte(ctx->ptep); @@ -886,7 +879,18 @@ static void stage2_unmap_put_pte(const struct kvm_pgtable_visit_ctx *ctx, ctx->level); } } +} +static void stage2_unmap_put_pte(const struct kvm_pgtable_visit_ctx *ctx, + struct kvm_s2_mmu *mmu, + struct kvm_pgtable_mm_ops *mm_ops) +{ + /* + * Clear the existing PTE, and perform break-before-make if it was + * valid. Depending on the system support, defer the TLB maintenance + * for the same until the entire unmap walk is completed. + */ + stage2_unmap_clear_pte(ctx, mmu); mm_ops->put_page(ctx->ptep); }