Skip to content

KVM: x86: Drop "caching" of always-available GPRs

Sean Christopherson kvm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3KVM: x86: Omit caching logic for always-available GPRsarch/x86/kvm/cpuid.c arch/x86/kvm/hyperv.c arch/x86/kvm/kvm_cache_regs.h +3 more+105 -800 replies
2/3KVM: x86: Prevent use of kvm_register_{read,write}() with known GPRsarch/x86/kvm/kvm_cache_regs.h arch/x86/kvm/svm.c arch/x86/kvm/vmx/nested.c +1 more+46 -192 replies
3/3KVM: VMX: Use accessors for GPRs outside of dedicated caching logicarch/x86/kvm/vmx/nested.c arch/x86/kvm/vmx/vmx.c+8 -100 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] KVM: x86: Drop "caching" of always-available GPRs

KVM's GPR caching logic is unconditionally emitted for all GPR accesses (that go through the accessors), even when the register being accessed is fixed and always available. This bloats KVM due to the instructions needed to test and set the available/dirty bitmaps, and to conditionally invoke the .cache_reg() callback. The latter is especially painful when compiling with retpolines.

Eliminate the unnecessary overhead by:

- Adding dedicated accessors for every GPR
- Omitting the caching logic for GPRs that are always available
- Preventing use of the unoptimized versions for fixed accesses

The last patch is an opportunistic clean up of VMX, which has gradually acquired a bad habit of sprinkling in direct access to GPRs.

Sean Christopherson (3):
KVM: x86: Omit caching logic for always-available GPRs
KVM: x86: Prevent use of kvm_register_{read,write}() with known GPRs
KVM: VMX: Use accessors for GPRs outside of dedicated caching logic

 arch/x86/kvm/cpuid.c          | 12 ++---
 arch/x86/kvm/hyperv.c         | 24 ++++-----
 arch/x86/kvm/kvm_cache_regs.h | 73 +++++++++++++++++++++++----
 arch/x86/kvm/svm.c            | 34 ++++++-------
 arch/x86/kvm/vmx/nested.c     | 18 +++----
 arch/x86/kvm/vmx/vmx.c        | 14 +++---
 arch/x86/kvm/x86.c            | 93 +++++++++++++++++------------------
 7 files changed, 159 insertions(+), 109 deletions(-)
Signature · 1 line
2.21.0