Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 329825
b: refs/heads/master
c: e9d90d4
h: refs/heads/master
i:
  329823: 5d77b50
v: v3
  • Loading branch information
Avi Kivity authored and Marcelo Tosatti committed Aug 1, 2012
1 parent 2c5ae83 commit f5275c8
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 74 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4a4541a40e1fe145c72c4b959fac524a5600d9fb
refs/heads/master: e9d90d472da97e1b1560bffb89578ba082c88a69
2 changes: 1 addition & 1 deletion trunk/arch/x86/kvm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kvm-$(CONFIG_IOMMU_API) += $(addprefix ../../../virt/kvm/, iommu.o)
kvm-$(CONFIG_KVM_ASYNC_PF) += $(addprefix ../../../virt/kvm/, async_pf.o)

kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \
i8254.o timer.o cpuid.o pmu.o
i8254.o cpuid.o pmu.o
kvm-intel-y += vmx.o
kvm-amd-y += svm.o

Expand Down
8 changes: 4 additions & 4 deletions trunk/arch/x86/kvm/i8254.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,14 @@ static void destroy_pit_timer(struct kvm_pit *pit)
flush_kthread_work(&pit->expired);
}

static bool kpit_is_periodic(struct kvm_timer *ktimer)
static bool kpit_is_periodic(struct kvm_pit_timer *ktimer)
{
struct kvm_kpit_state *ps = container_of(ktimer, struct kvm_kpit_state,
pit_timer);
return ps->is_periodic;
}

static struct kvm_timer_ops kpit_ops = {
static struct kvm_pit_timer_ops kpit_ops = {
.is_periodic = kpit_is_periodic,
};

Expand Down Expand Up @@ -322,7 +322,7 @@ static void pit_do_work(struct kthread_work *work)

static enum hrtimer_restart pit_timer_fn(struct hrtimer *data)
{
struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer);
struct kvm_pit_timer *ktimer = container_of(data, struct kvm_pit_timer, timer);
struct kvm_pit *pt = ktimer->kvm->arch.vpit;

if (ktimer->reinject || !atomic_read(&ktimer->pending)) {
Expand All @@ -340,7 +340,7 @@ static enum hrtimer_restart pit_timer_fn(struct hrtimer *data)
static void create_pit_timer(struct kvm *kvm, u32 val, int is_period)
{
struct kvm_kpit_state *ps = &kvm->arch.vpit->pit_state;
struct kvm_timer *pt = &ps->pit_timer;
struct kvm_pit_timer *pt = &ps->pit_timer;
s64 interval;

if (!irqchip_in_kernel(kvm) || ps->flags & KVM_PIT_FLAGS_HPET_LEGACY)
Expand Down
18 changes: 17 additions & 1 deletion trunk/arch/x86/kvm/i8254.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,26 @@ struct kvm_kpit_channel_state {
ktime_t count_load_time;
};

struct kvm_pit_timer {
struct hrtimer timer;
s64 period; /* unit: ns */
u32 timer_mode_mask;
u64 tscdeadline;
atomic_t pending; /* accumulated triggered timers */
bool reinject;
struct kvm_pit_timer_ops *t_ops;
struct kvm *kvm;
struct kvm_vcpu *vcpu;
};

struct kvm_pit_timer_ops {
bool (*is_periodic)(struct kvm_pit_timer *);
};

struct kvm_kpit_state {
struct kvm_kpit_channel_state channels[3];
u32 flags;
struct kvm_timer pit_timer;
struct kvm_pit_timer pit_timer;
bool is_periodic;
u32 speaker_data_on;
struct mutex lock;
Expand Down
18 changes: 0 additions & 18 deletions trunk/arch/x86/kvm/kvm_timer.h

This file was deleted.

30 changes: 29 additions & 1 deletion trunk/arch/x86/kvm/lapic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,34 @@ static const struct kvm_io_device_ops apic_mmio_ops = {
.write = apic_mmio_write,
};

static enum hrtimer_restart apic_timer_fn(struct hrtimer *data)
{
struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer);
struct kvm_vcpu *vcpu = ktimer->vcpu;
wait_queue_head_t *q = &vcpu->wq;

/*
* There is a race window between reading and incrementing, but we do
* not care about potentially losing timer events in the !reinject
* case anyway. Note: KVM_REQ_PENDING_TIMER is implicitly checked
* in vcpu_enter_guest.
*/
if (ktimer->reinject || !atomic_read(&ktimer->pending)) {
atomic_inc(&ktimer->pending);
/* FIXME: this code should not know anything about vcpus */
kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu);
}

if (waitqueue_active(q))
wake_up_interruptible(q);

if (ktimer->t_ops->is_periodic(ktimer)) {
hrtimer_add_expires_ns(&ktimer->timer, ktimer->period);
return HRTIMER_RESTART;
} else
return HRTIMER_NORESTART;
}

int kvm_create_lapic(struct kvm_vcpu *vcpu)
{
struct kvm_lapic *apic;
Expand All @@ -1285,7 +1313,7 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu)

hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC,
HRTIMER_MODE_ABS);
apic->lapic_timer.timer.function = kvm_timer_fn;
apic->lapic_timer.timer.function = apic_timer_fn;
apic->lapic_timer.t_ops = &lapic_timer_ops;
apic->lapic_timer.kvm = vcpu->kvm;
apic->lapic_timer.vcpu = vcpu;
Expand Down
17 changes: 16 additions & 1 deletion trunk/arch/x86/kvm/lapic.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@
#define __KVM_X86_LAPIC_H

#include "iodev.h"
#include "kvm_timer.h"

#include <linux/kvm_host.h>

struct kvm_timer {
struct hrtimer timer;
s64 period; /* unit: ns */
u32 timer_mode_mask;
u64 tscdeadline;
atomic_t pending; /* accumulated triggered timers */
bool reinject;
struct kvm_timer_ops *t_ops;
struct kvm *kvm;
struct kvm_vcpu *vcpu;
};

struct kvm_timer_ops {
bool (*is_periodic)(struct kvm_timer *);
};

struct kvm_lapic {
unsigned long base_address;
struct kvm_io_device dev;
Expand Down
47 changes: 0 additions & 47 deletions trunk/arch/x86/kvm/timer.c

This file was deleted.

0 comments on commit f5275c8

Please sign in to comment.