[PATCH v3 0/2] KVM: arm64: nv: Fix stale and duplicate guest S2 tracking entries

From: Colton Lewis

Date: Tue Dec 01 2026 - 19:13:43 EST


When kvm_pgtable_stage2_unmap_tracked() is called with a size smaller
than a tracked block mapping (such as from a TLBI RIPAS2E1IS range or a
TLBI IPAS2E1IS with a 4kB TTL hint on a 2MB block),
kvm_pgtable_stage2_unmap() clears the entire block in the shadow stage-2
page table while kvm_remove_guest_s2_mappings() leaves its stale
tracking entry behind in guest_s2_mappings.

Patch 1 checks nested_start in the shadow page table with
kvm_pgtable_get_leaf() on partial overlaps in
kvm_remove_guest_s2_mappings() and removes the tracking entry once no
valid PTE or child table remains at its tracked granule size, leaving
compute_tlb_inval_range() untouched so this series is independent of
Marc's sub-page TTL fix [1].

Patch 2 avoids inserting identical duplicate entries in
kvm_record_guest_s2_mapping().

Tool-generated content:
- Initial bug discovery: automated LLM-assisted audit of the arm64
nested stage-2 tracking code.
- Patch and text drafting: interactive Gemini session (patches, commit
messages, and cover letter).

Changes since v2:
- Drop the compute_tlb_inval_range() changes and return to the v1
kvm_remove_guest_s2_mappings() approach (Marc Zyngier).
- Simplify the Patch 1 commit message and comments per v1 review
(Wei-Lin Chang).

Link to v1: https://lore.kernel.org/r/20261119185105.626343-1-coltonlewis@xxxxxxxxxx
Link to v2: https://lore.kernel.org/r/20261123232647.3733149-1-coltonlewis@xxxxxxxxxx
[1] https://lore.kernel.org/r/20261123182312.4842-1-maz@xxxxxxxxxx

Colton Lewis (2):
KVM: arm64: nv: Remove unmapped guest stage-2 mapping entries
KVM: arm64: nv: Avoid duplicate guest stage-2 mapping entries

arch/arm64/kvm/nested.c | 66 +++++++++++++++++++++++++++++++++++++----
1 file changed, 61 insertions(+), 5 deletions(-)


base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
--
2.56.1.911.g883d8bcb20-goog