From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: [PATCH 2/2] KVM: Fix 64-bit division in kvm_write_tsc() Date: Thu, 16 Feb 2012 15:48:03 +0200 Message-ID: <1329400083-22070-3-git-send-email-avi@redhat.com> References: <1329400083-22070-1-git-send-email-avi@redhat.com> Cc: kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:14374 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752967Ab2BPNsR (ORCPT ); Thu, 16 Feb 2012 08:48:17 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1GDmHEZ010168 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 16 Feb 2012 08:48:17 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q1GDmGqg015074 for ; Thu, 16 Feb 2012 08:48:16 -0500 In-Reply-To: <1329400083-22070-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Breaks i386 build. Signed-off-by: Avi Kivity --- arch/x86/kvm/x86.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 1d71b13..c9d99e5 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1034,7 +1034,14 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu, u64 data) /* n.b - signed multiplication and division required */ nsdiff = data - kvm->arch.last_tsc_write; +#ifdef CONFIG_X86_64 nsdiff = (nsdiff * 1000) / vcpu->arch.virtual_tsc_khz; +#else + /* do_div() only does unsigned */ + asm("idiv %2; xor %%edx, %%edx" + : "=A"(nsdiff) + : "A"(nsdiff * 1000), "rm"(vcpu->arch.virtual_tsc_khz)); +#endif nsdiff -= elapsed; if (nsdiff < 0) nsdiff = -nsdiff; -- 1.7.9