From: David Stevens <stevensd@xxxxxxxxxxxx> Skip allocating gfn_track arrays when tracking of guest write access to pages is not required. For VMs where the allocation can be avoided, this saves 2 bytes per 4KB of guest memory. Write tracking is used to manage shadow page tables in three cases - when tdp is not supported, when nested virtualization is used, and for GVT-g. By combining the existing tdp_enable flag and nested module param with a new config that indicates when something outside of KVM (i.e. GVT-g) needs write tracking, KVM can determine when initializing a VM if gfn_track arrays are definitely not necessary. This straightforward approach has the downside that for VMs where nested virtualization is enabled but never used, gfn_track arrays are still allocated. Instead of going so far as to try to initialize things on demand, key off of whether or not X86_FEATURE_VMX is set in the guest's cpuid to support per-VM configuration instead of system wide configuration based on the nested module param. David Stevens (3): KVM: x86: add config for non-kvm users of page tracking KVM: x86/mmu: skip page tracking when possible KVM: VMX: skip page tracking based on cpuid arch/x86/include/asm/kvm-x86-ops.h | 1 + arch/x86/include/asm/kvm_host.h | 4 +- arch/x86/include/asm/kvm_page_track.h | 7 ++- arch/x86/kvm/Kconfig | 3 ++ arch/x86/kvm/cpuid.c | 55 +++++++++++++++----- arch/x86/kvm/mmu/page_track.c | 74 +++++++++++++++++++++++++-- arch/x86/kvm/svm/svm.c | 10 +++- arch/x86/kvm/vmx/vmx.c | 13 ++++- arch/x86/kvm/x86.c | 5 +- drivers/gpu/drm/i915/Kconfig | 1 + 10 files changed, 150 insertions(+), 23 deletions(-) -- 2.33.0.464.g1972c5931b-goog