Skip to content

Commit 84ac000

Browse files
committed
KVM: VMX: Drop unused @entry_only param from add_atomic_switch_msr()
Drop the "on VM-Enter only" parameter from add_atomic_switch_msr() as it is no longer used, and for all intents and purposes was never used. The functionality was added, under embargo, by commit 989e399 ("x86/KVM/VMX: Extend add_atomic_switch_msr() to allow VMENTER only MSRs"), and then ripped out by commit 2f05594 ("x86/kvm: Drop L1TF MSR list approach") just a few commits later. 2f05594 x86/kvm: Drop L1TF MSR list approach 72c6d2d x86/litf: Introduce vmx status variable 215af54 cpu/hotplug: Online siblings when SMT control is turned on 390d975 x86/KVM/VMX: Use MSR save list for IA32_FLUSH_CMD if required 989e399 x86/KVM/VMX: Extend add_atomic_switch_msr() to allow VMENTER only MSRs Furthermore, it's extremely unlikely KVM will ever _need_ to load an MSR value via the auto-load lists only on VM-Enter. MSRs writes via the lists aren't optimized in any way, and so the only reason to use the lists instead of a WRMSR are for cases where the MSR _must_ be load atomically with respect to VM-Enter (and/or VM-Exit). While one could argue that command MSRs, e.g. IA32_FLUSH_CMD, "need" to be done exact at VM-Enter, in practice doing such flushes within a few instructons of VM-Enter is more than sufficient. Note, the shortlog and changelog for commit 390d975 ("x86/KVM/VMX: Use MSR save list for IA32_FLUSH_CMD if required") are misleading and wrong. That commit added MSR_IA32_FLUSH_CMD to the VM-Enter _load_ list, not the VM-Enter save list (which doesn't exist, only VM-Exit has a store/save list). Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Tested-by: Manali Shukla <manali.shukla@amd.com> Link: https://patch.msgid.link/20251206001720.468579-39-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 0bd2937 commit 84ac000

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

arch/x86/kvm/vmx/vmx.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ static __always_inline void add_atomic_switch_msr_special(struct vcpu_vmx *vmx,
10941094
}
10951095

10961096
static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,
1097-
u64 guest_val, u64 host_val, bool entry_only)
1097+
u64 guest_val, u64 host_val)
10981098
{
10991099
int i, j = 0;
11001100
struct msr_autoload *m = &vmx->msr_autoload;
@@ -1132,8 +1132,7 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,
11321132
}
11331133

11341134
i = vmx_find_loadstore_msr_slot(&m->guest, msr);
1135-
if (!entry_only)
1136-
j = vmx_find_loadstore_msr_slot(&m->host, msr);
1135+
j = vmx_find_loadstore_msr_slot(&m->host, msr);
11371136

11381137
if ((i < 0 && m->guest.nr == MAX_NR_LOADSTORE_MSRS) ||
11391138
(j < 0 && m->host.nr == MAX_NR_LOADSTORE_MSRS)) {
@@ -1148,9 +1147,6 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,
11481147
m->guest.val[i].index = msr;
11491148
m->guest.val[i].value = guest_val;
11501149

1151-
if (entry_only)
1152-
return;
1153-
11541150
if (j < 0) {
11551151
j = m->host.nr++;
11561152
vmcs_write32(VM_EXIT_MSR_LOAD_COUNT, m->host.nr);
@@ -1190,8 +1186,7 @@ static bool update_transition_efer(struct vcpu_vmx *vmx)
11901186
if (!(guest_efer & EFER_LMA))
11911187
guest_efer &= ~EFER_LME;
11921188
if (guest_efer != kvm_host.efer)
1193-
add_atomic_switch_msr(vmx, MSR_EFER,
1194-
guest_efer, kvm_host.efer, false);
1189+
add_atomic_switch_msr(vmx, MSR_EFER, guest_efer, kvm_host.efer);
11951190
else
11961191
clear_atomic_switch_msr(vmx, MSR_EFER);
11971192
return false;
@@ -7350,7 +7345,7 @@ static void atomic_switch_perf_msrs(struct vcpu_vmx *vmx)
73507345
clear_atomic_switch_msr(vmx, msrs[i].msr);
73517346
else
73527347
add_atomic_switch_msr(vmx, msrs[i].msr, msrs[i].guest,
7353-
msrs[i].host, false);
7348+
msrs[i].host);
73547349
}
73557350

73567351
static void vmx_update_hv_timer(struct kvm_vcpu *vcpu, bool force_immediate_exit)

0 commit comments

Comments
 (0)