Skip to content

Commit 462f092

Browse files
committed
KVM: VMX: Drop intermediate "guest" field from msr_autostore
Drop the intermediate "guest" field from vcpu_vmx.msr_autostore as the value saved on VM-Exit isn't guaranteed to be the guest's value, it's purely whatever is in hardware at the time of VM-Exit. E.g. KVM's only use of the store list at the momemnt is to snapshot TSC at VM-Exit, and the value saved is always the raw TSC even if TSC-offseting and/or TSC-scaling is enabled for the guest. And unlike msr_autoload, there is no need differentiate between "on-entry" and "on-exit". No functional change intended. Cc: Jim Mattson <jmattson@google.com> Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Tested-by: Manali Shukla <manali.shukla@amd.com> Link: https://patch.msgid.link/20251206001720.468579-36-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent b0b6a8d commit 462f092

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

arch/x86/kvm/vmx/nested.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,11 +1076,11 @@ static bool nested_vmx_get_vmexit_msr_value(struct kvm_vcpu *vcpu,
10761076
* VM-exit in L0, use the more accurate value.
10771077
*/
10781078
if (msr_index == MSR_IA32_TSC) {
1079-
int i = vmx_find_loadstore_msr_slot(&vmx->msr_autostore.guest,
1079+
int i = vmx_find_loadstore_msr_slot(&vmx->msr_autostore,
10801080
MSR_IA32_TSC);
10811081

10821082
if (i >= 0) {
1083-
u64 val = vmx->msr_autostore.guest.val[i].value;
1083+
u64 val = vmx->msr_autostore.val[i].value;
10841084

10851085
*data = kvm_read_l1_tsc(vcpu, val);
10861086
return true;
@@ -1167,7 +1167,7 @@ static void prepare_vmx_msr_autostore_list(struct kvm_vcpu *vcpu,
11671167
u32 msr_index)
11681168
{
11691169
struct vcpu_vmx *vmx = to_vmx(vcpu);
1170-
struct vmx_msrs *autostore = &vmx->msr_autostore.guest;
1170+
struct vmx_msrs *autostore = &vmx->msr_autostore;
11711171
bool in_vmcs12_store_list;
11721172
int msr_autostore_slot;
11731173
bool in_autostore_list;
@@ -2366,7 +2366,7 @@ static void prepare_vmcs02_constant_state(struct vcpu_vmx *vmx)
23662366
* addresses are constant (for vmcs02), the counts can change based
23672367
* on L2's behavior, e.g. switching to/from long mode.
23682368
*/
2369-
vmcs_write64(VM_EXIT_MSR_STORE_ADDR, __pa(vmx->msr_autostore.guest.val));
2369+
vmcs_write64(VM_EXIT_MSR_STORE_ADDR, __pa(vmx->msr_autostore.val));
23702370
vmcs_write64(VM_EXIT_MSR_LOAD_ADDR, __pa(vmx->msr_autoload.host.val));
23712371
vmcs_write64(VM_ENTRY_MSR_LOAD_ADDR, __pa(vmx->msr_autoload.guest.val));
23722372

@@ -2704,7 +2704,7 @@ static void prepare_vmcs02_rare(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
27042704
*/
27052705
prepare_vmx_msr_autostore_list(&vmx->vcpu, MSR_IA32_TSC);
27062706

2707-
vmcs_write32(VM_EXIT_MSR_STORE_COUNT, vmx->msr_autostore.guest.nr);
2707+
vmcs_write32(VM_EXIT_MSR_STORE_COUNT, vmx->msr_autostore.nr);
27082708
vmcs_write32(VM_EXIT_MSR_LOAD_COUNT, vmx->msr_autoload.host.nr);
27092709
vmcs_write32(VM_ENTRY_MSR_LOAD_COUNT, vmx->msr_autoload.guest.nr);
27102710

arch/x86/kvm/vmx/vmx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6567,7 +6567,7 @@ void dump_vmcs(struct kvm_vcpu *vcpu)
65676567
if (vmcs_read32(VM_ENTRY_MSR_LOAD_COUNT) > 0)
65686568
vmx_dump_msrs("guest autoload", &vmx->msr_autoload.guest);
65696569
if (vmcs_read32(VM_EXIT_MSR_STORE_COUNT) > 0)
6570-
vmx_dump_msrs("guest autostore", &vmx->msr_autostore.guest);
6570+
vmx_dump_msrs("autostore", &vmx->msr_autostore);
65716571

65726572
if (vmentry_ctl & VM_ENTRY_LOAD_CET_STATE)
65736573
pr_err("S_CET = 0x%016lx, SSP = 0x%016lx, SSP TABLE = 0x%016lx\n",

arch/x86/kvm/vmx/vmx.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,7 @@ struct vcpu_vmx {
245245
struct vmx_msrs host;
246246
} msr_autoload;
247247

248-
struct msr_autostore {
249-
struct vmx_msrs guest;
250-
} msr_autostore;
248+
struct vmx_msrs msr_autostore;
251249

252250
struct {
253251
int vm86_active;

0 commit comments

Comments
 (0)