aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/svm.c
diff options
context:
space:
mode:
authorZachary Amsden <zamsden@redhat.com>2010-08-20 04:07:17 -0400
committerAvi Kivity <avi@redhat.com>2010-10-24 04:51:22 -0400
commit99e3e30aee1a326a98bf3a5f47b8622219c685f3 (patch)
tree1b67fc70af33988080784d32725f72b5ce7c07d1 /arch/x86/kvm/svm.c
parentf4e1b3c8bd2a044cd0ccf80595bfd088a49fe60b (diff)
KVM: x86: Move TSC offset writes to common code
Also, ensure that the storing of the offset and the reading of the TSC are never preempted by taking a spinlock. While the lock is overkill now, it is useful later in this patch series. Signed-off-by: Zachary Amsden <zamsden@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/svm.c')
-rw-r--r--arch/x86/kvm/svm.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index e06f00d1f15c..ea41c551fa44 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -915,7 +915,7 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
915 svm->vmcb_pa = page_to_pfn(page) << PAGE_SHIFT; 915 svm->vmcb_pa = page_to_pfn(page) << PAGE_SHIFT;
916 svm->asid_generation = 0; 916 svm->asid_generation = 0;
917 init_vmcb(svm); 917 init_vmcb(svm);
918 svm_write_tsc_offset(&svm->vcpu, 0-native_read_tsc()); 918 kvm_write_tsc(&svm->vcpu, 0);
919 919
920 err = fx_init(&svm->vcpu); 920 err = fx_init(&svm->vcpu);
921 if (err) 921 if (err)
@@ -2581,7 +2581,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
2581 2581
2582 switch (ecx) { 2582 switch (ecx) {
2583 case MSR_IA32_TSC: 2583 case MSR_IA32_TSC:
2584 svm_write_tsc_offset(vcpu, data - native_read_tsc()); 2584 kvm_write_tsc(vcpu, data);
2585 break; 2585 break;
2586 case MSR_STAR: 2586 case MSR_STAR:
2587 svm->vmcb->save.star = data; 2587 svm->vmcb->save.star = data;
@@ -3551,6 +3551,8 @@ static struct kvm_x86_ops svm_x86_ops = {
3551 .set_supported_cpuid = svm_set_supported_cpuid, 3551 .set_supported_cpuid = svm_set_supported_cpuid,
3552 3552
3553 .has_wbinvd_exit = svm_has_wbinvd_exit, 3553 .has_wbinvd_exit = svm_has_wbinvd_exit,
3554
3555 .write_tsc_offset = svm_write_tsc_offset,
3554}; 3556};
3555 3557
3556static int __init svm_init(void) 3558static int __init svm_init(void)