KVM: x86/mmu: Dynamically allocate shadow MMU's hashed page list
authorSean Christopherson <seanjc@google.com>
Fri, 23 May 2025 00:11:36 +0000 (17:11 -0700)
committerSean Christopherson <seanjc@google.com>
Tue, 24 Jun 2025 19:50:34 +0000 (12:50 -0700)
commit039ef33e2f9346258fe2bd344f212c645942575e
treec0cd4e978b9153e703301938dbbe064d69297126
parent1f287a4e7b90595718167f93f850f0a08484ec81
KVM: x86/mmu: Dynamically allocate shadow MMU's hashed page list

Dynamically allocate the (massive) array of hashed lists used to track
shadow pages, as the array itself is 32KiB, i.e. is an order-3 allocation
all on its own, and is *exactly* an order-3 allocation.  Dynamically
allocating the array will allow allocating "struct kvm" using kvmalloc(),
and will also allow deferring allocation of the array until it's actually
needed, i.e. until the first shadow root is allocated.

Opportunistically use kvmalloc() for the hashed lists, as an order-3
allocation is (stating the obvious) less likely to fail than an order-4
allocation, and the overhead of vmalloc() is undesirable given that the
size of the allocation is fixed.

Cc: Vipin Sharma <vipinsh@google.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Link: https://lore.kernel.org/r/20250523001138.3182794-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/x86.c