ANDROID: KVM: arm64: Split stage2_put_pte function

Refactor the code and add stage2_clear_pte(..) which removes the PTE
without dropping the refcount for an entry.

Bug: 222044487
Signed-off-by: Sebastian Ene <sebastianene@google.com>
Change-Id: Ia2cb47f2ffad6faa5c6b4ec8a37bcbe61be0bc2f
This commit is contained in:
Sebastian Ene
2022-08-10 13:38:34 +00:00
parent 90048d36dc
commit 393afc04df

View File

@@ -662,6 +662,16 @@ static bool stage2_pte_is_counted(kvm_pte_t pte)
return !!pte;
}
static void stage2_clear_pte(kvm_pte_t *ptep, struct kvm_s2_mmu *mmu, u64 addr,
u32 level)
{
if (!kvm_pte_valid(*ptep))
return;
kvm_clear_pte(ptep);
kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, mmu, addr, level);
}
static void stage2_put_pte(kvm_pte_t *ptep, struct kvm_s2_mmu *mmu, u64 addr,
u32 level, struct kvm_pgtable_mm_ops *mm_ops)
{
@@ -669,11 +679,7 @@ static void stage2_put_pte(kvm_pte_t *ptep, struct kvm_s2_mmu *mmu, u64 addr,
* Clear the existing PTE, and perform break-before-make with
* TLB maintenance if it was valid.
*/
if (kvm_pte_valid(*ptep)) {
kvm_clear_pte(ptep);
kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, mmu, addr, level);
}
stage2_clear_pte(ptep, mmu, addr, level);
mm_ops->put_page(ptep);
}