Re: [PATCH v5 0/6] KVM: arm64: nv: Implement nested stage-2 reverse map (new data structure)

From: Wei-Lin Chang

Date: Fri Sep 11 2026 - 09:32:15 EST


On Mon, Aug 10, 2026 at 09:50:32PM +0100, Wei-Lin Chang wrote:
> Hi,
>
> This is v5 of optimizing the shadow s2 mmu unmapping during MMU
> notifiers.

I did a more targetted test of this series in a (ad-hoc) way similar to
pkvm_ownership_selftest(). I allocated and initialized an in kernel VM,
its locks, 2 nested_mmus, and a memcache.

By calling kvm_pgtable_stage2_map(), kvm_record_guest_s2_mapping()
together I create mappings and track them, then
kvm_nested_unmap_cipa_range() simulates mmu notifier unmaps, and
kvm_stage2_unmap_range() simulates L1 TLBIs.

Combining these I tried a few scenarios:

1. Mapping the same CIPA in two nested mmus, and checked that
unmapping the CIPA it removes both mappings, but keeps unrelated
mappings.

2. Mapping a block and a page to an overlapping CIPA region, checked
that unmapping the overlapping CIPA regions removes both mappings.

3. Unmapping CIPA of the last page of a block, checking that the block
is removed, but keeps unrelated mappings.

4. Unmapping a CIPA range that starts in an empty region, checking that
it finds and removes the mappings inside the range, keeps unrelated
mappings.

5. First map NIPA -> CIPA1, unmap that NIPA, then create NIPA -> CIPA2,
and check that unmapping the CIPA1 leaves the new mapping alone.

6. Creating multiple identical mappings, and checked unmapping the
CIPA once removes the mapping.

The dumped shadow page tables all contain the expected mappings.

Thanks,
Wei-Lin Chang

[...]