Re: [PATCH v2 1/2] KVM: arm64: nv: Discard undersized TTL hints in compute_tlb_inval_range()
From: Colton Lewis
Date: Tue Dec 01 2026 - 19:12:44 EST
On Wed, 25 Nov 2026 09:56:18 +0000,
Wei-Lin Chang <weilin.chang@xxxxxxx> wrote:
> For the other option, how can we recognize when a tracking entry can be
> safely removed?
> i.e. No more shadow mapping in the tracked nipa range.
>
> We don't even know for certain what shadow mappings exist in the first
> place.
Every tracked range [nested_start, nested_start + map_size - 1] is
aligned to a single host stage-2 granule size (PAGE_SIZE, PMD_SIZE, or
PUD_SIZE), so it corresponds to one PTE slot in mmu->pgt at the level
matching map_size.
Under write_lock(&kvm->mmu_lock) after kvm_pgtable_stage2_unmap(), a
single kvm_pgtable_get_leaf(mmu->pgt, nested_start, &pte, &level, 0)
shows whether anything remains under that slot:
- !kvm_pte_valid(pte) && kvm_granule_size(level) >= map_size: the PTE
at (or above) that level is invalid, so neither a block mapping nor a
child table exists anywhere in the tracked range. Safe to remove.
- kvm_granule_size(level) < map_size: a child table is still linked
there (for example page mappings under dirty logging or partial
-EAGAIN mappings), so sibling entries may remain live. Keep the
tracking entry.
- kvm_pte_valid(pte): a live mapping still covers nested_start. Keep it.
Because stage2_unmap_walker() unlinks an empty child table in
KVM_PGTABLE_WALK_TABLE_POST, that child table also reaches the first
case once all of its leaf mappings are unmapped.
I will send v3 with this check shortly.