diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2011-03-25 04:44:50 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-05-11 07:57:05 -0400 |
commit | 857e40999e35906baa367a79137019912cfb5434 (patch) | |
tree | eacae3e4ccffd38b3e6a55b9bc6afdc7ae2c5e9a /arch/x86/kvm/svm.c | |
parent | 4051b18801f5b47bb0369feefdc80e57819d0ddf (diff) |
KVM: X86: Delegate tsc-offset calculation to architecture code
With TSC scaling in SVM the tsc-offset needs to be
calculated differently. This patch propagates this
calculation into the architecture specific modules so that
this complexity can be handled there.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/svm.c')
-rw-r--r-- | arch/x86/kvm/svm.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index a39fde4f5fe8..8c4549bef4ed 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c | |||
@@ -943,6 +943,15 @@ static void svm_adjust_tsc_offset(struct kvm_vcpu *vcpu, s64 adjustment) | |||
943 | mark_dirty(svm->vmcb, VMCB_INTERCEPTS); | 943 | mark_dirty(svm->vmcb, VMCB_INTERCEPTS); |
944 | } | 944 | } |
945 | 945 | ||
946 | static u64 svm_compute_tsc_offset(struct kvm_vcpu *vcpu, u64 target_tsc) | ||
947 | { | ||
948 | u64 tsc; | ||
949 | |||
950 | tsc = svm_scale_tsc(vcpu, native_read_tsc()); | ||
951 | |||
952 | return target_tsc - tsc; | ||
953 | } | ||
954 | |||
946 | static void init_vmcb(struct vcpu_svm *svm) | 955 | static void init_vmcb(struct vcpu_svm *svm) |
947 | { | 956 | { |
948 | struct vmcb_control_area *control = &svm->vmcb->control; | 957 | struct vmcb_control_area *control = &svm->vmcb->control; |
@@ -4194,6 +4203,7 @@ static struct kvm_x86_ops svm_x86_ops = { | |||
4194 | .set_tsc_khz = svm_set_tsc_khz, | 4203 | .set_tsc_khz = svm_set_tsc_khz, |
4195 | .write_tsc_offset = svm_write_tsc_offset, | 4204 | .write_tsc_offset = svm_write_tsc_offset, |
4196 | .adjust_tsc_offset = svm_adjust_tsc_offset, | 4205 | .adjust_tsc_offset = svm_adjust_tsc_offset, |
4206 | .compute_tsc_offset = svm_compute_tsc_offset, | ||
4197 | 4207 | ||
4198 | .set_tdp_cr3 = set_tdp_cr3, | 4208 | .set_tdp_cr3 = set_tdp_cr3, |
4199 | 4209 | ||