Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1444885a authored by Marcelo Tosatti's avatar Marcelo Tosatti Committed by Avi Kivity
Browse files

KVM: limit lapic periodic timer frequency



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

Cc: stable@kernel.org
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 5f0269f5
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -670,6 +670,15 @@ static void start_apic_timer(struct kvm_lapic *apic)

	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),