[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <877c2fr52z.wl-maz@kernel.org>
Date: Sat, 17 May 2025 09:53:24 +0100
From: Marc Zyngier <maz@...nel.org>
To: Vincent Donnefort <vdonnefort@...gle.com>
Cc: oliver.upton@...ux.dev,
joey.gouly@....com,
suzuki.poulose@....com,
yuzenghui@...wei.com,
catalin.marinas@....com,
will@...nel.org,
qperret@...gle.com,
linux-arm-kernel@...ts.infradead.org,
kvmarm@...ts.linux.dev,
linux-kernel@...r.kernel.org,
kernel-team@...roid.com
Subject: Re: [PATCH v4 10/10] KVM: arm64: np-guest CMOs with PMD_SIZE fixmap
On Fri, 16 May 2025 19:03:14 +0100,
Vincent Donnefort <vdonnefort@...gle.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.
Powered by blists - more mailing lists