Re: [PATCH] KVM: arm64: Reduce the stage-2 page cache on 64 KiB hosts

From: Lorenzo Stoakes (ARM)

Date: Fri Nov 27 2026 - 08:29:44 EST


On Thu, Nov 26, 2026 at 06:25:43PM +0000, Leonardo Bras wrote:
> > > > diff --git a/arch/arm64/include/asm/kvm_types.h b/arch/arm64/include/asm/kvm_types.h
> > > > index 9a126b9e2d7c99..5b61285d317e28 100644
> > > > --- a/arch/arm64/include/asm/kvm_types.h
> > > > +++ b/arch/arm64/include/asm/kvm_types.h
> > > > @@ -2,7 +2,12 @@
> > > > #ifndef _ASM_ARM64_KVM_TYPES_H
> > > > #define _ASM_ARM64_KVM_TYPES_H
> > > >
> > > > -#define KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE 40
> > > > +#define KVM_PGTABLE_FIRST_LEVEL -1
> > > > +#define KVM_PGTABLE_LAST_LEVEL 3
> > > > +
> >
> > The -1 isn't needed here at all right? So why not just import
> > KVM_PGTABLE_LAST_LEVEL and do:
> >
> > #define KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE KVM_PGTABLE_LAST_LEVEL
> >
> > ?
>
> Well, it kind of is :)
> The lowest level we have in a PGTABLE is level -1. (See RKSBQV)
>
> It could now be mathematically correct, but it could break in the future if
> we got a level-2, for instance. We could have (LAST - FIRST - 1), if that
> one page makes any diference.

Yup it's level -1 but isn't that only something meaningful for stage-1 I believe
due to concatenation? As per stage2_pgtable_levels() [where ipa is the number of
bits not the ipa... :)].

But you make a good point re: future changes!

Anyway, Marc has made it clear he wants something based on
kvm_mmu_cache_min_pages() at runtime, so it's all moot anyway, this needs to be
reworked for that.

Usama - I assume you are looking at that now?

--
Cheers, Lorenzo