]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/x86/kvm/lapic.c
hrtimer: convert kvm to the new hrtimer apis
[linux-2.6-omap-h63xx.git] / arch / x86 / kvm / lapic.c
index ebc03f5ae162e2702974c122e27a580fa6556ac2..a5b61de6adf1c7cb4e8b43cef1fe0dfaca0b4e20 100644 (file)
@@ -356,8 +356,9 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
        case APIC_DM_SMI:
                printk(KERN_DEBUG "Ignoring guest SMI\n");
                break;
+
        case APIC_DM_NMI:
-               printk(KERN_DEBUG "Ignoring guest NMI\n");
+               kvm_inject_nmi(vcpu);
                break;
 
        case APIC_DM_INIT:
@@ -572,6 +573,8 @@ static u32 __apic_read(struct kvm_lapic *apic, unsigned int offset)
 {
        u32 val = 0;
 
+       KVMTRACE_1D(APIC_ACCESS, apic->vcpu, (u32)offset, handler);
+
        if (offset >= LAPIC_MMIO_LENGTH)
                return 0;
 
@@ -695,6 +698,8 @@ static void apic_mmio_write(struct kvm_io_device *this,
 
        offset &= 0xff0;
 
+       KVMTRACE_1D(APIC_ACCESS, apic->vcpu, (u32)offset, handler);
+
        switch (offset) {
        case APIC_ID:           /* Local APIC ID */
                apic_set_reg(apic, APIC_ID, val);
@@ -780,7 +785,8 @@ static void apic_mmio_write(struct kvm_io_device *this,
 
 }
 
-static int apic_mmio_range(struct kvm_io_device *this, gpa_t addr)
+static int apic_mmio_range(struct kvm_io_device *this, gpa_t addr,
+                          int len, int size)
 {
        struct kvm_lapic *apic = (struct kvm_lapic *)this->private;
        int ret = 0;
@@ -939,17 +945,15 @@ static int __apic_timer_fn(struct kvm_lapic *apic)
        int result = 0;
        wait_queue_head_t *q = &apic->vcpu->wq;
 
-       atomic_inc(&apic->timer.pending);
-       set_bit(KVM_REQ_PENDING_TIMER, &apic->vcpu->requests);
+       if(!atomic_inc_and_test(&apic->timer.pending))
+               set_bit(KVM_REQ_PENDING_TIMER, &apic->vcpu->requests);
        if (waitqueue_active(q)) {
                apic->vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
                wake_up_interruptible(q);
        }
        if (apic_lvtt_period(apic)) {
                result = 1;
-               apic->timer.dev.expires = ktime_add_ns(
-                                       apic->timer.dev.expires,
-                                       apic->timer.period);
+               hrtimer_add_expires_ns(&apic->timer.dev, apic->timer.period);
        }
        return result;
 }
@@ -1118,7 +1122,7 @@ void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu)
 
        timer = &apic->timer.dev;
        if (hrtimer_cancel(timer))
-               hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS);
+               hrtimer_start_expires(timer, HRTIMER_MODE_ABS);
 }
 
 void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu)