[PATCH v2 0/2] KVM: arm64: Stop stage-2 teardown scaling with the IPA size

Wei-Lin Chang weilin.chang at arm.com
Thu Nov 5 10:59:55 PST 2026


On Wed, Nov 04, 2026 at 12:44:49PM +0000, Fuad Tabba wrote:
> Hi folks,
> 
> Changes since v1 [1]:
>   - Run all teardown from stage2_destroy_range() (Oliver, Suzuki)
>   - Dropped the Fixes tags (Marc)
>   - Dropped the patch moving the teardown into kvm_vm_s2_ops
>   - Use gfn_to_gpa() for a mapping's address. (Vincent)
> 
> Two patches that make stage-2 teardown take time proportional to what
> is mapped, rather than to the size of the IPA space as it has since
> 4ddfab5436b6.
> 
> Under QEMU TCG ('-cpu max', 16K pages with LPA2), destroying even an
> empty VM takes about 7 seconds in pKVM. Without pKVM it takes about 19
> seconds if the VM requests a 52-bit IPA (crosvm requests the host's
> limit). With the series, both take well under a second. I tested only
> under QEMU, since I don't have hardware with LPA2.
> 
> The first has the page-table walk return where it stopped, so that the
> teardown steps over an invalid entry larger than a block-sized chunk in
> one go. The second has pKVM return where its next mapping starts.
> 
> pKVM gives every VM the host's IPA limit. My series honoring
> KVM_VM_TYPE_ARM_IPA_SIZE in pKVM [2] doesn't change that for crosvm,
> which requests the limit.
> 
> Based on Linux 7.4-rc1 (6628e7d4c6b25).
> 
> Cheers,
> /fuad
> 
> [1] https://lore.kernel.org/all/20261103084742.1302597-1-fuad.tabba@linux.dev/
> [2] https://lore.kernel.org/all/20260917091826.2639205-1-fuad.tabba@linux.dev/
> 

I haven't looked very closely, but do functions that use
stage2_apply_range() suffer a similar problem?

If I'm not mistaken we previously realized unmapping a full IPA with
kvm_vm_stage2_unmap_range() is slow partly for the same reason.

I'm not sure whether optimizing stage2_destroy_range() and
stage2_apply_range() together in a single series is preferrable though.

Thanks,
Wei-Lin Chang

> Fuad Tabba (2):
>   KVM: arm64: Resume stage-2 teardown where the walk stopped
>   KVM: arm64: Resume a pKVM stage-2 teardown at the next mapping
> 
>  arch/arm64/include/asm/kvm_pgtable.h |  8 ++++++--
>  arch/arm64/include/asm/kvm_pkvm.h    |  4 ++--
>  arch/arm64/kvm/hyp/pgtable.c         | 15 ++++++++++++---
>  arch/arm64/kvm/mmu.c                 |  4 ++--
>  arch/arm64/kvm/pkvm.c                | 12 +++++++++---
>  5 files changed, 31 insertions(+), 12 deletions(-)
> 
> 
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
> -- 
> 2.47.3
> 



More information about the linux-arm-kernel mailing list