[PATCH 3/3] KVM: arm64: Move stage-2 teardown into kvm_vm_s2_ops
Fuad Tabba
fuad.tabba at linux.dev
Tue Nov 3 08:22:28 PST 2026
Hi Suzuki,
On Tue, 03 Nov 2026 10:33:15 +0000, Suzuki K Poulose
<suzuki.poulose at arm.com> wrote:
[...]
> > Someone beat you on this (well almost) ;-)
:D
> > https://lore.kernel.org/all/4304d0c7-2220-4add-9c71-e6dc6b4fbc11@arm.com
realm_stage2_destroy() in your sketch doesn't use the range it's
given, so it should fit this hook, which only takes the pgt.
[...]
> >> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> >> index 10b425a0141be..9df3c80a5acd1 100644
> >> --- a/arch/arm64/kvm/mmu.c
> >> +++ b/arch/arm64/kvm/mmu.c
> >> @@ -1029,17 +1029,16 @@ static void stage2_destroy_range(struct
> >> kvm_pgtable *pgt, phys_addr_t addr,
> >> } while (addr = next, addr != end);
> >> }
> >> -static void kvm_stage2_destroy(struct kvm_pgtable *pgt)
> >> +static void kvm_vm_stage2_destroy(struct kvm_pgtable *pgt)
> >> {
> >> - unsigned int ia_bits = VTCR_EL2_IPA(pgt->mmu->vtcr);
> >> + stage2_destroy_range(pgt, 0, kvm_phys_size(pgt->mmu));
>
> Also, now that stage2_destroy_range is only called for normal KVM,
> could we fold that in here ?
Ack.
[...]
> >> @@ -1126,7 +1125,7 @@ int kvm_init_stage2_mmu(struct kvm *kvm, struct
> >> kvm_s2_mmu *mmu, unsigned long t
> >> return 0;
> >> out_destroy_pgtable:
> >> - kvm_stage2_destroy(pgt);
> >> + kvm->arch.vm_s2_ops->vm_stage2_destroy(pgt);
> >
> > minor nit: should we retain the kvm_stage2_destroy() to dispatch the
> > callback ?
I'll keep it in v2.
> >
> > Reviewed-by: Suzuki K Poulose <suzuki.poulose at arm.com>
Thanks!
Cheers,
/fuad
More information about the linux-arm-kernel
mailing list