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(-) -- 2.21.0