aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/lapic.c
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2009-07-27 22:41:01 -0400
committerAvi Kivity <avi@redhat.com>2009-09-10 01:33:17 -0400
commit1444885a045fe3b1905a14ea1b52540bf556578b (patch)
tree204bbcfa479942245d957fd9d2dbe94ecbcfbc9d /arch/x86/kvm/lapic.c
parent5f0269f5d72f622514daec9af158c32e933800b6 (diff)
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: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/lapic.c')
-rw-r--r--arch/x86/kvm/lapic.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 66122bfc74a9..5b9d1ae09cad 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -670,6 +670,15 @@ static void start_apic_timer(struct kvm_lapic *apic)
670 670
671 if (!apic->lapic_timer.period) 671 if (!apic->lapic_timer.period)
672 return; 672 return;
673 /*
674 * Do not allow the guest to program periodic timers with small
675 * interval, since the hrtimers are not throttled by the host
676 * scheduler.
677 */
678 if (apic_lvtt_period(apic)) {
679 if (apic->lapic_timer.period < NSEC_PER_MSEC/2)
680 apic->lapic_timer.period = NSEC_PER_MSEC/2;
681 }
673 682
674 hrtimer_start(&apic->lapic_timer.timer, 683 hrtimer_start(&apic->lapic_timer.timer,
675 ktime_add_ns(now, apic->lapic_timer.period), 684 ktime_add_ns(now, apic->lapic_timer.period),