[PATCH v4 10/10] KVM: arm64: np-guest CMOs with PMD_SIZE fixmap
Marc Zyngier
maz at kernel.org
Sat May 17 01:53:24 PDT 2025
On Fri, 16 May 2025 19:03:14 +0100,
Vincent Donnefort <vdonnefort at google.com> wrote:
>
> > > +}
> > > +
> > > static void clean_dcache_guest_page(void *va, size_t size)
> > > {
> > > WARN_ON(!PAGE_ALIGNED(size));
> > >
> > > while (size) {
> > > - __clean_dcache_guest_page(hyp_fixmap_map(__hyp_pa(va)),
> > > - PAGE_SIZE);
> > > - hyp_fixmap_unmap();
> > > - va += PAGE_SIZE;
> > > - size -= PAGE_SIZE;
> > > + size_t fixmap_size = size == PMD_SIZE ? size : PAGE_SIZE;
> > > + void *addr = __fixmap_guest_page(va, &fixmap_size);
> > > +
> > > + __clean_dcache_guest_page(addr, fixmap_size);
> > > + __fixunmap_guest_page(fixmap_size);
> > > +
> > > + size -= fixmap_size;
> > > + va += fixmap_size;
> >
> > Can this ever be called with a *multiple* of PMD_SIZE? In this case
> > you'd still end-up doing PAGE_SIZEd-bite CMOs until there is only
> > PMD_SIZE left, ruining the optimisation.
> >
> > I think this needs fixing.
>
> So this can be only called with size either equal to PAGE_SIZE or PMD_SIZE. I
> wasn't sure if it was worth to make it more generic than it needs.
>
> But like for the first patch, I can make it more future-proof by handling size >
> PMD_SIZE.
Yup. These things are hard enough to debug that we should try and make
it fool-proof, even if that's not immediately used (and fixing that is
pretty easy).
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
More information about the linux-arm-kernel
mailing list