Re: [PATCH v3 31/40] KVM: x86: Move MMU helper declarations from kvm_host.h => mmu.h
From: Sean Christopherson
Date: Fri Jun 05 2026 - 16:56:26 EST
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.
#define KVM_MAX_HUGEPAGE_LEVEL PG_LEVEL_1G
#define KVM_NR_PAGE_SIZES (KVM_MAX_HUGEPAGE_LEVEL - PG_LEVEL_4K + 1) <===
#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)