Re: [PATCH v2] KVM: arm64: Size the stage-2 memcache from kvm_mmu_cache_min_pages()

From: Leonardo Bras

Date: Wed Dec 02 2026 - 11:05:47 EST


On Wed, Dec 02, 2026 at 07:59:06AM -0800, Usama Arif wrote:
> On Tue, 1 Dec 2026 18:19:42 +0000 Leonardo Bras <leo.bras@xxxxxxx> wrote:
>
> > On Tue, Dec 01, 2026 at 12:46:22PM +0000, Leonardo Bras wrote:
> > > On Mon, Nov 30, 2026 at 08:05:32PM +0000, Usama Arif wrote:
> > [...]
> > > > >> I tried your MULTIPLIER * min_pages version under QEMU with
> > > > >> kvm-arm.mode=nested: 4K pages, an IPA limit of 52 bits, and a 40-bit
> > > > >> IPA VM whose L1 runs an L2. In all six runs, across two tests, L2's
> > > > >> first fault that needs a refill hits that WARN_ON_ONCE() and KVM_RUN
> > > > >> fails with EIO.
> > > > >
> > > > > Out of curiosity, is it fully KVM, or are you using QEMU to emulate a
> > > > > 4k-pagesize host?
> > > >
> > > >
> > > > QEMU emulates the host. I don't have hardware with FEAT_NV2, so L0 is a
> > > > 4K kernel booted with kvm-arm.mode=nested in qemu-system-aarch64 with
> > > > TCG (-cpu max, virtualization=on). Only the NV tests ran that way,
> > > > the numbers above are from the Grace host.
> > > >
> > >
> > > Ah, I see your point.
> > > The issue is that QEMU TCG is not really great for gathering performance
> > > numbers :(
> > >
> > > I can try running the tests for you in a NV2-enabled machine, if that's ok
> > > :)
> > >
> >
> > Humm, but again, why do you need NV2? That path is tested on both
> > user_mem_abort and gmem_abort, it could easily be tested by replacing the
> > host kernel.
> >
> > Do you have any limitation replacing the host kernel?
> >
>
> (Replying here instead of the previous email for this part of the thread.)
>
> Ah no limitation, and all the numbers are from a patched host kernel on
> the Grace host. Only the NV tests ran under TCG, and they only check
> for warnings. None of the performance numbers are from TCG.
>
> It's the same code, but only with NV does the vCPU's memcache also
> feed shadow stage-2s, which can be deeper than the VM's own stage-2.
> That's why a multiple of the VM's kvm_mmu_cache_min_pages() hits the
> WARN_ON_ONCE() with NV. IMO performance numbers are needed
> from NV for this, but if they are, could you help as I dont have
> hardware for it.
>

Ah, I get it now.
I think as long as your non-NV perf numbers are from real HW, it should
be fine. But sure, I can test it if it's relevant to anyone.

Thanks!
Leo