aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/kvm/kvm.h1
-rw-r--r--drivers/kvm/lapic.c33
2 files changed, 29 insertions, 5 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index f8fe87d3ddbd..dbb929d8a31e 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -413,6 +413,7 @@ struct kvm {
413 struct kvm_io_bus pio_bus; 413 struct kvm_io_bus pio_bus;
414 struct kvm_pic *vpic; 414 struct kvm_pic *vpic;
415 struct kvm_ioapic *vioapic; 415 struct kvm_ioapic *vioapic;
416 int round_robin_prev_vcpu;
416}; 417};
417 418
418static inline struct kvm_pic *pic_irqchip(struct kvm *kvm) 419static inline struct kvm_pic *pic_irqchip(struct kvm *kvm)
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index 01e769672dcc..ca1db3852ace 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -371,12 +371,35 @@ struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
371 unsigned long bitmap) 371 unsigned long bitmap)
372{ 372{
373 int vcpu_id; 373 int vcpu_id;
374 int last;
375 int next;
376 struct kvm_lapic *apic;
377
378 last = kvm->round_robin_prev_vcpu;
379 next = last;
380
381 do {
382 if (++next == KVM_MAX_VCPUS)
383 next = 0;
384 if (kvm->vcpus[next] == NULL || !test_bit(next, &bitmap))
385 continue;
386 apic = kvm->vcpus[next]->apic;
387 if (apic && apic_enabled(apic))
388 break;
389 apic = NULL;
390 } while (next != last);
391 kvm->round_robin_prev_vcpu = next;
392
393 if (!apic) {
394 vcpu_id = ffs(bitmap) - 1;
395 if (vcpu_id < 0) {
396 vcpu_id = 0;
397 printk(KERN_DEBUG "vcpu not ready for apic_round_robin\n");
398 }
399 apic = kvm->vcpus[vcpu_id]->apic;
400 }
374 401
375 /* TODO for real round robin */ 402 return apic;
376 vcpu_id = fls(bitmap) - 1;
377 if (vcpu_id < 0)
378 printk(KERN_DEBUG "vcpu not ready for apic_round_robin\n");
379 return kvm->vcpus[vcpu_id]->apic;
380} 403}
381 404
382static void apic_set_eoi(struct kvm_lapic *apic) 405static void apic_set_eoi(struct kvm_lapic *apic)