public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org
Subject: [PATCH 2/2] KVM: Fix 64-bit division in kvm_write_tsc()
Date: Thu, 16 Feb 2012 15:48:03 +0200	[thread overview]
Message-ID: <1329400083-22070-3-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1329400083-22070-1-git-send-email-avi@redhat.com>

Breaks i386 build.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 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


  parent reply	other threads:[~2012-02-16 13:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-16 13:48 [PATCH 0/2] Fix build on i386 due to the latest tsc changes Avi Kivity
2012-02-16 13:48 ` [PATCH 1/2] KVM: Fix 64-bit division in kvm_set_tsc_khz() Avi Kivity
2012-02-16 13:48 ` Avi Kivity [this message]
2012-02-16 13:53 ` [PATCH 0/2] Fix build on i386 due to the latest tsc changes Avi Kivity
2012-02-18 12:46   ` Marcelo Tosatti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1329400083-22070-3-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox