GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / x86 / kvm / timer.c
blob0f2519fb5afd85f903ce6f0f1b4dcf5a28408387
1 /*
2 * Kernel-based Virtual Machine driver for Linux
4 * This module enables machines with Intel VT-x extensions to run virtual
5 * machines without emulation or binary translation.
7 * timer support
9 * Copyright 2010 Red Hat, Inc. and/or its affilates.
11 * This work is licensed under the terms of the GNU GPL, version 2. See
12 * the COPYING file in the top-level directory.
15 #include <linux/kvm_host.h>
16 #include <linux/kvm.h>
17 #include <linux/hrtimer.h>
18 #include <asm/atomic.h>
19 #include "kvm_timer.h"
21 static int __kvm_timer_fn(struct kvm_vcpu *vcpu, struct kvm_timer *ktimer)
23 int restart_timer = 0;
24 wait_queue_head_t *q = &vcpu->wq;
27 * There is a race window between reading and incrementing, but we do
28 * not care about potentially loosing timer events in the !reinject
29 * case anyway. Note: KVM_REQ_PENDING_TIMER is implicitly checked
30 * in vcpu_enter_guest.
32 if (ktimer->reinject || !atomic_read(&ktimer->pending)) {
33 atomic_inc(&ktimer->pending);
34 kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu);
37 if (waitqueue_active(q))
38 wake_up_interruptible(q);
40 if (ktimer->t_ops->is_periodic(ktimer)) {
41 hrtimer_add_expires_ns(&ktimer->timer, ktimer->period);
42 restart_timer = 1;
45 return restart_timer;
48 enum hrtimer_restart kvm_timer_fn(struct hrtimer *data)
50 int restart_timer;
51 struct kvm_vcpu *vcpu;
52 struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer);
54 vcpu = ktimer->vcpu;
55 if (!vcpu)
56 return HRTIMER_NORESTART;
58 restart_timer = __kvm_timer_fn(vcpu, ktimer);
59 if (restart_timer)
60 return HRTIMER_RESTART;
61 else
62 return HRTIMER_NORESTART;