This should probably to go lib/

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm/arch/x86/kvm/i8254.c
===================================================================
--- kvm.orig/arch/x86/kvm/i8254.c
+++ kvm/arch/x86/kvm/i8254.c
@@ -45,26 +45,6 @@
 #define RW_STATE_WORD0 3
 #define RW_STATE_WORD1 4
 
-/* Compute with 96 bit intermediate result: (a*b)/c */
-static u64 muldiv64(u64 a, u32 b, u32 c)
-{
-       union {
-               u64 ll;
-               struct {
-                       u32 low, high;
-               } l;
-       } u, res;
-       u64 rl, rh;
-
-       u.ll = a;
-       rl = (u64)u.l.low * (u64)b;
-       rh = (u64)u.l.high * (u64)b;
-       rh += (rl >> 32);
-       res.l.high = div64_u64(rh, c);
-       res.l.low = div64_u64(((mod_64(rh, c) << 32) + (rl & 0xffffffff)), c);
-       return res.ll;
-}
-
 static void pit_set_gate(struct kvm *kvm, int channel, u32 val)
 {
        struct kvm_kpit_channel_state *c =
Index: kvm/arch/x86/kvm/x86.c
===================================================================
--- kvm.orig/arch/x86/kvm/x86.c
+++ kvm/arch/x86/kvm/x86.c
@@ -4116,3 +4116,30 @@ void kvm_vcpu_kick(struct kvm_vcpu *vcpu
                smp_call_function_single(ipi_pcpu, vcpu_kick_intr, vcpu, 0, 0);
        put_cpu();
 }
+
+#ifndef CONFIG_X86_64
+#define mod_64(x, y) ((x) - (y) * div64_u64(x, y))
+#else
+#define mod_64(x, y) ((x) % (y))
+#endif
+
+/* Compute with 96 bit intermediate result: (a*b)/c */
+u64 muldiv64(u64 a, u32 b, u32 c)
+{
+       union {
+               u64 ll;
+               struct {
+                       u32 low, high;
+               } l;
+       } u, res;
+       u64 rl, rh;
+
+       u.ll = a;
+       rl = (u64)u.l.low * (u64)b;
+       rh = (u64)u.l.high * (u64)b;
+       rh += (rl >> 32);
+       res.l.high = div64_u64(rh, c);
+       res.l.low = div64_u64(((mod_64(rh, c) << 32) + (rl & 0xffffffff)), c);
+       return res.ll;
+}
+EXPORT_SYMBOL(muldiv64);
Index: kvm/include/asm-x86/kvm_host.h
===================================================================
--- kvm.orig/include/asm-x86/kvm_host.h
+++ kvm/include/asm-x86/kvm_host.h
@@ -660,6 +660,8 @@ static inline void kvm_inject_gp(struct 
        kvm_queue_exception_e(vcpu, GP_VECTOR, error_code);
 }
 
+u64 muldiv64(u64, u32, u32);
+
 #define ASM_VMX_VMCLEAR_RAX       ".byte 0x66, 0x0f, 0xc7, 0x30"
 #define ASM_VMX_VMLAUNCH          ".byte 0x0f, 0x01, 0xc2"
 #define ASM_VMX_VMRESUME          ".byte 0x0f, 0x01, 0xc3"

-- 

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to