KVM: SVM: Adjust tsc_offset only if tsc_unstable

The tsc_offset adjustment in svm_vcpu_load is executed
unconditionally even if Linux considers the host tsc as
stable. This causes a Linux guest detecting an unstable tsc
in any case.
This patch removes the tsc_offset adjustment if the host tsc
is stable. The guest will now get the benefit of a stable
tsc too.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
Joerg Roedel 2009-12-14 12:22:20 +01:00 committed by Marcelo Tosatti
parent 4e47c7a6d7
commit 953899b659
1 changed files with 10 additions and 8 deletions

View File

@ -765,6 +765,7 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
if (unlikely(cpu != vcpu->cpu)) { if (unlikely(cpu != vcpu->cpu)) {
u64 delta; u64 delta;
if (check_tsc_unstable()) {
/* /*
* Make sure that the guest sees a monotonically * Make sure that the guest sees a monotonically
* increasing TSC. * increasing TSC.
@ -773,6 +774,7 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
svm->vmcb->control.tsc_offset += delta; svm->vmcb->control.tsc_offset += delta;
if (is_nested(svm)) if (is_nested(svm))
svm->nested.hsave->control.tsc_offset += delta; svm->nested.hsave->control.tsc_offset += delta;
}
vcpu->cpu = cpu; vcpu->cpu = cpu;
kvm_migrate_timers(vcpu); kvm_migrate_timers(vcpu);
svm->asid_generation = 0; svm->asid_generation = 0;