• David Matlack's avatar
    KVM: Allow for different capacities in kvm_mmu_memory_cache structs · 837f66c7
    David Matlack authored
    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: default avatarMarc Zyngier <maz@kernel.org>
    Signed-off-by: default avatarDavid Matlack <dmatlack@google.com>
    Message-Id: <20220516232138.1783324-22-dmatlack@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    837f66c7
mmu.c 48.4 KB