This series attempts to clean up VMX's MSR namespacing, which is in unimitigated disaster (keeping things PG).
There are a variety of ways VMX saves and restores guest MSRs, all with unique properties and mechanisms, but with haphazard namespacing (assuming there is any namespacing at all). Some fun collisions: __find_msr_index(), find_msr_entry() and vmx_find_msr_index() vmx_set_guest_msr() and vmx_set_msr() structs vmx_msrs, vmx_msr_entry, shared_msr_entry, kvm_shared_msrs and kvm_shared_msrs_values vcpu_vmx fields guest_msrs, msr_autoload.guest and msr_autostore.guest Probably the most infurating/confusing nomenclature is "index", which can mean MSR's ECX index, index into one of several VMX arrays, or index into a common x86 array. __find_msr_index() even manages to mix at least three different meanings in about as many lines of code. The biggest change is to rename the "shared MSRs" mechanism to "user return MSRs" (details in patch 1), most everything else is either derived from that rename or is fairly straightforward cleanup. No true functional changes, although the update_transition_efer() change in patch 10 dances pretty close to being a functional change. Sean Christopherson (15): KVM: x86: Rename "shared_msrs" to "user_return_msrs" KVM: VMX: Prepend "MAX_" to MSR array size defines KVM: VMX: Rename "vmx_find_msr_index" to "vmx_find_loadstore_msr_slot" KVM: VMX: Rename the "shared_msr_entry" struct to "vmx_uret_msr" KVM: VMX: Rename vcpu_vmx's "nmsrs" to "nr_uret_msrs" KVM: VMX: Rename vcpu_vmx's "save_nmsrs" to "nr_active_uret_msrs" KVM: VMX: Rename vcpu_vmx's "guest_msrs_ready" to "guest_uret_msrs_loaded" KVM: VMX: Rename "__find_msr_index" to "__vmx_find_uret_msr" KVM: VMX: Check guest support for RDTSCP before processing MSR_TSC_AUX KVM: VMX: Move uret MSR lookup into update_transition_efer() KVM: VMX: Add vmx_setup_uret_msr() to handle lookup and swap KVM: VMX: Rename "find_msr_entry" to "vmx_find_uret_msr" KVM: VMX: Rename "vmx_set_guest_msr" to "vmx_set_guest_uret_msr" KVM: VMX: Rename "vmx_msr_index" to "vmx_uret_msrs_list" KVM: VMX: Rename vmx_uret_msr's "index" to "slot" arch/x86/include/asm/kvm_host.h | 4 +- arch/x86/kvm/vmx/nested.c | 22 ++-- arch/x86/kvm/vmx/vmx.c | 184 ++++++++++++++++---------------- arch/x86/kvm/vmx/vmx.h | 24 ++--- arch/x86/kvm/x86.c | 101 +++++++++--------- 5 files changed, 168 insertions(+), 167 deletions(-) -- 2.26.0