Skip to content

Commit 9770404

Browse files
committed
KVM: SVM: fix trashing of MSR_TSC_AUX
I don't know what I was thinking when I wrote commit 46896c7 ("KVM: svm: add support for RDTSCP", 2015-11-12); I missed write_rdtscp_aux which obviously uses MSR_TSC_AUX. Therefore we do need to save/restore MSR_TSC_AUX in svm_vcpu_run. Cc: [email protected] Cc: Borislav Petkov <[email protected]> Fixes: 46896c7 ("KVM: svm: add support for RDTSCP") Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 30b072c commit 9770404

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/x86/kvm/svm.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <asm/desc.h>
4242
#include <asm/debugreg.h>
4343
#include <asm/kvm_para.h>
44+
#include <asm/vgtod.h>
4445

4546
#include <asm/virtext.h>
4647
#include "trace.h"
@@ -1530,9 +1531,6 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
15301531
wrmsrl(MSR_AMD64_TSC_RATIO, tsc_ratio);
15311532
}
15321533
}
1533-
/* This assumes that the kernel never uses MSR_TSC_AUX */
1534-
if (static_cpu_has(X86_FEATURE_RDTSCP))
1535-
wrmsrl(MSR_TSC_AUX, svm->tsc_aux);
15361534

15371535
avic_vcpu_load(vcpu, cpu);
15381536
}
@@ -4474,6 +4472,8 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
44744472
svm->vmcb->save.cr2 = vcpu->arch.cr2;
44754473

44764474
clgi();
4475+
if (static_cpu_has(X86_FEATURE_RDTSCP))
4476+
wrmsrl(MSR_TSC_AUX, svm->tsc_aux);
44774477

44784478
local_irq_enable();
44794479

@@ -4550,6 +4550,8 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
45504550
#endif
45514551
);
45524552

4553+
if (static_cpu_has(X86_FEATURE_RDTSCP))
4554+
wrmsrl(MSR_TSC_AUX, __getcpu());
45534555
#ifdef CONFIG_X86_64
45544556
wrmsrl(MSR_GS_BASE, svm->host.gs_base);
45554557
#else

0 commit comments

Comments
 (0)