mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 01:53:29 +02:00
KVM: VMX: Dedup code for removing MSR from VMCS's auto-load list
Add a helper to remove an MSR from an auto-{load,store} list to dedup the
msr_autoload code, and in anticipation of adding similar functionality for
msr_autostore.
No functional change intended.
Tested-by: Manali Shukla <manali.shukla@amd.com>
Link: https://patch.msgid.link/20251206001720.468579-38-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
58f21a0141
commit
0bd2937911
|
|
@ -1040,9 +1040,22 @@ static int vmx_find_loadstore_msr_slot(struct vmx_msrs *m, u32 msr)
|
|||
return -ENOENT;
|
||||
}
|
||||
|
||||
static void clear_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr)
|
||||
static void vmx_remove_auto_msr(struct vmx_msrs *m, u32 msr,
|
||||
unsigned long vmcs_count_field)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = vmx_find_loadstore_msr_slot(m, msr);
|
||||
if (i < 0)
|
||||
return;
|
||||
|
||||
--m->nr;
|
||||
m->val[i] = m->val[m->nr];
|
||||
vmcs_write32(vmcs_count_field, m->nr);
|
||||
}
|
||||
|
||||
static void clear_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr)
|
||||
{
|
||||
struct msr_autoload *m = &vmx->msr_autoload;
|
||||
|
||||
switch (msr) {
|
||||
|
|
@ -1063,21 +1076,9 @@ static void clear_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr)
|
|||
}
|
||||
break;
|
||||
}
|
||||
i = vmx_find_loadstore_msr_slot(&m->guest, msr);
|
||||
if (i < 0)
|
||||
goto skip_guest;
|
||||
--m->guest.nr;
|
||||
m->guest.val[i] = m->guest.val[m->guest.nr];
|
||||
vmcs_write32(VM_ENTRY_MSR_LOAD_COUNT, m->guest.nr);
|
||||
|
||||
skip_guest:
|
||||
i = vmx_find_loadstore_msr_slot(&m->host, msr);
|
||||
if (i < 0)
|
||||
return;
|
||||
|
||||
--m->host.nr;
|
||||
m->host.val[i] = m->host.val[m->host.nr];
|
||||
vmcs_write32(VM_EXIT_MSR_LOAD_COUNT, m->host.nr);
|
||||
vmx_remove_auto_msr(&m->guest, msr, VM_ENTRY_MSR_LOAD_COUNT);
|
||||
vmx_remove_auto_msr(&m->host, msr, VM_EXIT_MSR_LOAD_COUNT);
|
||||
}
|
||||
|
||||
static __always_inline void add_atomic_switch_msr_special(struct vcpu_vmx *vmx,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user