KVM: fix LAPIC timer period overflow
authorAurelien Jarno <aurelien@aurel32.net>
Fri, 25 Sep 2009 09:09:37 +0000 (11:09 +0200)
committerAvi Kivity <avi@redhat.com>
Sun, 4 Oct 2009 11:57:23 +0000 (13:57 +0200)
Don't overflow when computing the 64-bit period from 32-bit registers.

Fixes sourceforge bug #2826486.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Cc: stable@kernel.org
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/lapic.c

index 1ae5ceb..7024224 100644 (file)
@@ -664,7 +664,7 @@ static void start_apic_timer(struct kvm_lapic *apic)
 {
        ktime_t now = apic->lapic_timer.timer.base->get_time();
 
-       apic->lapic_timer.period = apic_get_reg(apic, APIC_TMICT) *
+       apic->lapic_timer.period = (u64)apic_get_reg(apic, APIC_TMICT) *
                    APIC_BUS_CYCLE_NS * apic->divide_count;
        atomic_set(&apic->lapic_timer.pending, 0);