[PATCH 2/3] KVM: arm64: Skip empty IPA ranges when destroying stage-2 page-tables

Oliver Upton oupton at kernel.org
Tue Nov 3 08:55:28 PST 2026


On Tue, Nov 03, 2026 at 04:19:38PM +0000, Fuad Tabba wrote:
> > > @@ -1010,9 +1010,20 @@ static void stage2_destroy_range(struct kvm_pgtable *pgt, phys_addr_t addr,
> [...]
> > >                   next = stage2_range_addr_end(addr, end);
> > > -                KVM_PGT_FN(kvm_pgtable_stage2_destroy_range)(pgt, addr,
> > > -                                                             next - addr);
> > > +                kvm_pgtable_stage2_destroy_range(pgt, addr, next - addr);
> >
> > minor nit: Given the kvm_pgtable_stage2_destroy_range() is the only
> > called from here, and this caller would benefit from the walk
> > information, would it make sense to return a hint back ? Not sure how
> > much of that is possible. We do this in the RMM, always return a hint
> > of the next possible address. Of course this is not that expensive
> > as the CCA case and could be dealt in a separate series.
> 
> kvm_pgtable_stage2_destroy_range() is also called by
> kvm_pgtable_stage2_destroy(), which EL2 uses to free a pKVM guest's
> stage-2, so I'd rather not change it in a fix.

This one is still an optimization, not a fix. The re-walk after destroy
is a bit fiddly, especially when the inner walk knows exactly what IPA
it stopped at.

Thanks,
Oliver



More information about the linux-arm-kernel mailing list