Skip to contentSkip to conversation

KVM: fix LAPIC timer period overflow

PATCH Applied Aurelien Jarno 2 participants 2 messages Sep 25, 2009 – Sep 28, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: fix LAPIC timer period overflow

Don't overflow when computing the 64-bit period from 32-bit registers.

Fixes sourceforge bug #2826486.

---
 arch/x86/kvm/lapic.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kvm/lapic.c +1 -1
index 9c8f901..3ca7767 100644
@@ -658,7 +658,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);
 
Signature · 5 lines
1.6.4.3

-- 
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#1 lore raw
Quoted 14 lines · Aurelien Jarno

Don't overflow when computing the 64-bit period from 32-bit registers.

Fixes sourceforge bug #2826486.

---
 arch/x86/kvm/lapic.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kvm/lapic.c +0 -0
index 9c8f901..3ca7767 100644

arch/x86/kvm/lapic.c static void start_apic_timer(struct kvm_lapic *apic) · line 663

Quoted 7 lines
arch/x86/kvm/lapic.c +1 -1
@@ -658,7 +658,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);

Applied, thanks.