aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/lapic.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/kvm/lapic.c')
-rw-r--r--drivers/kvm/lapic.c33
1 files changed, 28 insertions, 5 deletions
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)