Skip to content

Commit 704ec48

Browse files
committed
KVM: SVM: Use sev_es_host_save_area() helper when initializing tsc_aux
Use sev_es_host_save_area() instead of open coding an equivalent when setting the MSR_TSC_AUX field during setup. No functional change intended. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 34830b3 commit 704ec48

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

arch/x86/kvm/svm/svm.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,11 @@ static void __svm_write_tsc_multiplier(u64 multiplier)
569569
__this_cpu_write(current_tsc_ratio, multiplier);
570570
}
571571

572+
static __always_inline struct sev_es_save_area *sev_es_host_save_area(struct svm_cpu_data *sd)
573+
{
574+
return page_address(sd->save_area) + 0x400;
575+
}
576+
572577
static inline void kvm_cpu_svm_disable(void)
573578
{
574579
uint64_t efer;
@@ -673,12 +678,9 @@ static int svm_hardware_enable(void)
673678
* TSC_AUX field now to avoid a RDMSR on every vCPU run.
674679
*/
675680
if (boot_cpu_has(X86_FEATURE_V_TSC_AUX)) {
676-
struct sev_es_save_area *hostsa;
677681
u32 __maybe_unused msr_hi;
678682

679-
hostsa = (struct sev_es_save_area *)(page_address(sd->save_area) + 0x400);
680-
681-
rdmsr(MSR_TSC_AUX, hostsa->tsc_aux, msr_hi);
683+
rdmsr(MSR_TSC_AUX, sev_es_host_save_area(sd)->tsc_aux, msr_hi);
682684
}
683685

684686
return 0;
@@ -1495,11 +1497,6 @@ static void svm_vcpu_free(struct kvm_vcpu *vcpu)
14951497
__free_pages(virt_to_page(svm->msrpm), get_order(MSRPM_SIZE));
14961498
}
14971499

1498-
static __always_inline struct sev_es_save_area *sev_es_host_save_area(struct svm_cpu_data *sd)
1499-
{
1500-
return page_address(sd->save_area) + 0x400;
1501-
}
1502-
15031500
static void svm_prepare_switch_to_guest(struct kvm_vcpu *vcpu)
15041501
{
15051502
struct vcpu_svm *svm = to_svm(vcpu);

0 commit comments

Comments
 (0)