From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH 3/6] KVM: X86: Make tsc_delta calculation a function of guest tsc Date: Sat, 16 Apr 2011 18:09:17 +0200 Message-ID: <4DA9BF2D.7010804@web.de> References: <1301042691-22929-1-git-send-email-joerg.roedel@amd.com> <1301042691-22929-4-git-send-email-joerg.roedel@amd.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigDF7879ADE57E2BA4A0AF5E9F" Cc: Avi Kivity , Marcelo Tosatti , Zachary Amsden , kvm@vger.kernel.org To: Joerg Roedel Return-path: Received: from fmmailgate01.web.de ([217.72.192.221]:44811 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755769Ab1DPQJd (ORCPT ); Sat, 16 Apr 2011 12:09:33 -0400 In-Reply-To: <1301042691-22929-4-git-send-email-joerg.roedel@amd.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigDF7879ADE57E2BA4A0AF5E9F Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable On 2011-03-25 09:44, Joerg Roedel wrote: > The calculation of the tsc_delta value to ensure a > forward-going tsc for the guest is a function of the > host-tsc. This works as long as the guests tsc_khz is equal > to the hosts tsc_khz. With tsc-scaling hardware support this > is not longer true and the tsc_delta needs to be calculated > using guest_tsc values. >=20 > Signed-off-by: Joerg Roedel > --- > arch/x86/kvm/x86.c | 9 +++++++-- > 1 files changed, 7 insertions(+), 2 deletions(-) >=20 > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 1e7af86..47dd6ed 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -2126,8 +2126,13 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, i= nt cpu) > kvm_x86_ops->vcpu_load(vcpu, cpu); > if (unlikely(vcpu->cpu !=3D cpu) || check_tsc_unstable()) { > /* Make sure TSC doesn't go backwards */ > - s64 tsc_delta =3D !vcpu->arch.last_host_tsc ? 0 : > - native_read_tsc() - vcpu->arch.last_host_tsc; > + s64 tsc_delta; > + u64 tsc; > + > + kvm_get_msr(vcpu, MSR_IA32_TSC, &tsc); > + tsc_delta =3D !vcpu->arch.last_guest_tsc ? 0 : > + tsc - vcpu->arch.last_guest_tsc; > + > if (tsc_delta < 0) > mark_tsc_unstable("KVM discovered backwards TSC"); > if (check_tsc_unstable()) { This patch appears to cause troubles to Linux guests on TSC clocksource and APIC highres timer. The first boot after qemu start is always fine, but after a reboot the guest timer appears to fire incorrectly or even not at all. Was this patch tested with a guest reboot scenario as well? Does it account for the TSC being reset to 0 on reboot? I'm using a 2.6.38 host + kvm-kmod, but I don't see that this could be the reason. Going back one kernel commit while keeping kvm-kmod unchanged resolves the issue. Jan --------------enigDF7879ADE57E2BA4A0AF5E9F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iEYEARECAAYFAk2pvzUACgkQitSsb3rl5xTPOQCfZSjvcvRLWkWC2/9H2PnfUk84 vBYAn1VrT8QaVn7yhAMUfuA7p9Ui68Ww =wHoK -----END PGP SIGNATURE----- --------------enigDF7879ADE57E2BA4A0AF5E9F--