| From 1444885a045fe3b1905a14ea1b52540bf556578b Mon Sep 17 00:00:00 2001 |
| From: Marcelo Tosatti <mtosatti@redhat.com> |
| Date: Mon, 27 Jul 2009 23:41:01 -0300 |
| Subject: KVM: limit lapic periodic timer frequency |
| |
| From: Marcelo Tosatti <mtosatti@redhat.com> |
| |
| commit 1444885a045fe3b1905a14ea1b52540bf556578b upstream. |
| |
| Otherwise its possible to starve the host by programming lapic timer |
| with a very high frequency. |
| |
| Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> |
| Signed-off-by: Avi Kivity <avi@redhat.com> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> |
| |
| --- |
| arch/x86/kvm/lapic.c | 9 +++++++++ |
| 1 file changed, 9 insertions(+) |
| |
| --- a/arch/x86/kvm/lapic.c |
| +++ b/arch/x86/kvm/lapic.c |
| @@ -573,6 +573,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), |