Skip to content

Commit 0c4ff08

Browse files
committed
KVM: VMX: Set MSR index auto-load entry if and only if entry is "new"
When adding an MSR to the auto-load lists, update the MSR index in the list entry if and only if a new entry is being inserted, as 'i' can only be non-negative if vmx_find_loadstore_msr_slot() found an entry with the MSR's index. Unnecessarily setting the index is benign, but it makes it harder to see that updating the value is necessary even when an existing entry for the MSR was found. No functional change intended. Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Tested-by: Manali Shukla <manali.shukla@amd.com> Link: https://patch.msgid.link/20251206001720.468579-41-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 2ed57bb commit 0c4ff08

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

arch/x86/kvm/vmx/vmx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,16 +1141,16 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,
11411141

11421142
if (i < 0) {
11431143
i = m->guest.nr++;
1144+
m->guest.val[i].index = msr;
11441145
vmcs_write32(VM_ENTRY_MSR_LOAD_COUNT, m->guest.nr);
11451146
}
1146-
m->guest.val[i].index = msr;
11471147
m->guest.val[i].value = guest_val;
11481148

11491149
if (j < 0) {
11501150
j = m->host.nr++;
1151+
m->host.val[j].index = msr;
11511152
vmcs_write32(VM_EXIT_MSR_LOAD_COUNT, m->host.nr);
11521153
}
1153-
m->host.val[j].index = msr;
11541154
m->host.val[j].value = host_val;
11551155
}
11561156

0 commit comments

Comments
 (0)