All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] KVM: x86: skip gfn_track allocation when possible
@ 2021-09-21  8:10 David Stevens
  2021-09-21  8:10 ` [PATCH 1/3] KVM: x86: add config for non-kvm users of page tracking David Stevens
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: David Stevens @ 2021-09-21  8:10 UTC (permalink / raw)
  To: kvm
  Cc: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
	Jim Mattson, Joerg Roedel, David Stevens

From: David Stevens <stevensd@chromium.org>

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-21 10:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-21  8:10 [PATCH 0/3] KVM: x86: skip gfn_track allocation when possible David Stevens
2021-09-21  8:10 ` [PATCH 1/3] KVM: x86: add config for non-kvm users of page tracking David Stevens
2021-09-21  8:10 ` [PATCH 2/3] KVM: x86/mmu: skip page tracking when possible David Stevens
2021-09-21  8:10 ` [PATCH 3/3] KVM: VMX: skip page tracking based on cpuid David Stevens
2021-09-21 10:27 ` [PATCH 0/3] KVM: x86: skip gfn_track allocation when possible Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.