Skip to contentSkip to conversation

KVM: limit lapic periodic timer frequency

PATCH Applied Marcelo Tosatti 2 participants 2 messages Jul 28, 2009 – Aug 3, 2009

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

Otherwise its possible to starve the host by programming lapic timer with a very high frequency.

arch/x86/kvm/lapic.c +9 -0
Index: kvm/arch/x86/kvm/lapic.c
===================================================================
@@ -667,6 +667,15 @@ static void start_apic_timer(struct kvm_
 
 	if (!apic->lapic_timer.period)
 		return;
+	/*
+ 	 * Do not allow the guest to program periodic timers with small
+ 	 * interval, since the hrtimers are not throttled by the host
+	 * scheduler.
+	 */
+	if (apic_lvtt_period(apic)) {
+        	if (apic->lapic_timer.period < NSEC_PER_MSEC/2)
+                	apic->lapic_timer.period = NSEC_PER_MSEC/2;
+	}
 
 	hrtimer_start(&apic->lapic_timer.timer,
 		      ktime_add_ns(now, apic->lapic_timer.period),
Applied
#1 lore raw
Quoted 3 lines · Marcelo Tosatti

Otherwise its possible to starve the host by programming lapic timer with a very high frequency.

Applied, thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function