public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: Fix build error due to 64-bit division in nsec_to_cycles()
@ 2010-08-26 10:38 Avi Kivity
  2010-08-26 18:46 ` Marcelo Tosatti
  0 siblings, 1 reply; 2+ messages in thread
From: Avi Kivity @ 2010-08-26 10:38 UTC (permalink / raw)
  To: Marcelo Tosatti, kvm

Use do_div() instead.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/x86.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 524bd3f..1de377f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -56,6 +56,7 @@
 #include <asm/i387.h>
 #include <asm/xcr.h>
 #include <asm/pvclock.h>
+#include <asm/div64.h>
 
 #define MAX_IO_MSRS 256
 #define CR0_RESERVED_BITS						\
@@ -907,11 +908,15 @@ static inline int kvm_tsc_changes_freq(void)
 
 static inline u64 nsec_to_cycles(u64 nsec)
 {
+	u64 ret;
+
 	WARN_ON(preemptible());
 	if (kvm_tsc_changes_freq())
 		printk_once(KERN_WARNING
 		 "kvm: unreliable cycle conversion on adjustable rate TSC\n");
-	return (nsec * __get_cpu_var(cpu_tsc_khz)) / USEC_PER_SEC;
+	ret = nsec * __get_cpu_var(cpu_tsc_khz);
+	do_div(ret, USEC_PER_SEC);
+	return ret;
 }
 
 void kvm_write_tsc(struct kvm_vcpu *vcpu, u64 data)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: Fix build error due to 64-bit division in nsec_to_cycles()
  2010-08-26 10:38 [PATCH] KVM: Fix build error due to 64-bit division in nsec_to_cycles() Avi Kivity
@ 2010-08-26 18:46 ` Marcelo Tosatti
  0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2010-08-26 18:46 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

On Thu, Aug 26, 2010 at 01:38:03PM +0300, Avi Kivity wrote:
> Use do_div() instead.
> 
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>  arch/x86/kvm/x86.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)

Applied, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-26 19:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-26 10:38 [PATCH] KVM: Fix build error due to 64-bit division in nsec_to_cycles() Avi Kivity
2010-08-26 18:46 ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox