Re: [PATCH v3 31/40] KVM: x86: Move MMU helper declarations from kvm_host.h => mmu.h

From: Huang, Kai

Date: Mon Jun 08 2026 - 07:22:25 EST


On Fri, 2026-06-05 at 13:55 -0700, Sean Christopherson wrote:
> On Fri, Jun 05, 2026, Sean Christopherson wrote:
> > On Fri, Jun 05, 2026, Kai Huang wrote:
> > > #define KVM_HPAGE_GFN_SHIFT(x) (((x) - 1) * 9)
> > > #define KVM_HPAGE_SHIFT(x) (PAGE_SHIFT + KVM_HPAGE_GFN_SHIFT(x))
> > > #define KVM_HPAGE_SIZE(x) (1UL << KVM_HPAGE_SHIFT(x))
> > > #define KVM_HPAGE_MASK(x) (~(KVM_HPAGE_SIZE(x) - 1))
> > > #define KVM_PAGES_PER_HPAGE(x) (KVM_HPAGE_SIZE(x) / PAGE_SIZE)
> >
> > Huh. Oh, /facepalm. I looked at these, but saw there were references in kvm_host.h
> > and moved on. But they're all "self" references. So yeah, I agree moving these
> > and INVALID_PAGE+VALID_PAGE makes sense.
>
> Never mind, I was right the first time. KVM_NR_PAGE_SIZES is used in several
> locations, and I don't want to isolate that one.

Right. That's why I thought you probably wouldn't like moving the rest to
"mmu.h".

I feel KVM_MMU_ROOT_INFO_INVALID and INVALID_PAGE are not quite tied to
KVM_MMU_NUM_PREV_ROOTS and KVM_MMU_ROOT_*, though, but yeah let's handle them in
the future.