]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
KVM: SVM: Fix tsc offset adjustment when running nested
authorJoerg Roedel <joerg.roedel@amd.com>
Mon, 12 Oct 2009 09:41:51 +0000 (11:41 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 12 Oct 2009 19:40:18 +0000 (12:40 -0700)
commit 77b1ab1732feb5e3dcbaf31d2f7547c5229f5f3a upstream.

When svm_vcpu_load is called while the vcpu is running in
guest mode the tsc adjustment made there is lost on the next
emulated #vmexit. This causes the tsc running backwards in
the guest. This patch fixes the issue by also adjusting the
tsc_offset in the emulated hsave area so that it will not
get lost.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/kvm/svm.c

index b1f658ad2f06b673d489ec825a4676a176df6b04..aafd8bf47e774c4c4b4c32170a1029be432cebca 100644 (file)
@@ -709,6 +709,8 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
                rdtscll(tsc_this);
                delta = vcpu->arch.host_tsc - tsc_this;
                svm->vmcb->control.tsc_offset += delta;
+               if (is_nested(svm))
+                       svm->hsave->control.tsc_offset += delta;
                vcpu->cpu = cpu;
                kvm_migrate_timers(vcpu);
                svm->asid_generation = 0;