]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: Allow for different capacities in kvm_mmu_memory_cache structs
authorDavid Matlack <dmatlack@google.com>
Wed, 22 Jun 2022 19:27:08 +0000 (15:27 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 24 Jun 2022 08:52:00 +0000 (04:52 -0400)
commit7b120527ec5b5d43b240fbd6eba74ed133d025bf
tree3676dcfc4354048b5eb61133a5bf72081b7dc2d8
parent2bc35c7fc8d8b3820b18b69ee839b1db1edd6518
KVM: Allow for different capacities in kvm_mmu_memory_cache structs

Allow the capacity of the kvm_mmu_memory_cache struct to be chosen at
declaration time rather than being fixed for all declarations. This will
be used in a follow-up commit to declare an cache in x86 with a capacity
of 512+ objects without having to increase the capacity of all caches in
KVM.

This change requires each cache now specify its capacity at runtime,
since the cache struct itself no longer has a fixed capacity known at
compile time. To protect against someone accidentally defining a
kvm_mmu_memory_cache struct directly (without the extra storage), this
commit includes a WARN_ON() in kvm_mmu_topup_memory_cache().

In order to support different capacities, this commit changes the
objects pointer array to be dynamically allocated the first time the
cache is topped-up.

While here, opportunistically clean up the stack-allocated
kvm_mmu_memory_cache structs in riscv and arm64 to use designated
initializers.

No functional change intended.

Reviewed-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: David Matlack <dmatlack@google.com>
Message-Id: <20220516232138.1783324-22-dmatlack@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/arm64/kvm/mmu.c
arch/riscv/kvm/mmu.c
include/linux/kvm_host.h
include/linux/kvm_types.h
virt/kvm/kvm_main.c