diff options
Diffstat (limited to 'arch/x86/kvm/lapic.c')
-rw-r--r-- | arch/x86/kvm/lapic.c | 43 |
1 files changed, 6 insertions, 37 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 998862a3c267..814466f455d9 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c | |||
@@ -338,8 +338,9 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode, | |||
338 | struct kvm_vcpu *vcpu = apic->vcpu; | 338 | struct kvm_vcpu *vcpu = apic->vcpu; |
339 | 339 | ||
340 | switch (delivery_mode) { | 340 | switch (delivery_mode) { |
341 | case APIC_DM_FIXED: | ||
342 | case APIC_DM_LOWEST: | 341 | case APIC_DM_LOWEST: |
342 | vcpu->arch.apic_arb_prio++; | ||
343 | case APIC_DM_FIXED: | ||
343 | /* FIXME add logic for vcpu on reset */ | 344 | /* FIXME add logic for vcpu on reset */ |
344 | if (unlikely(!apic_enabled(apic))) | 345 | if (unlikely(!apic_enabled(apic))) |
345 | break; | 346 | break; |
@@ -416,43 +417,9 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode, | |||
416 | return result; | 417 | return result; |
417 | } | 418 | } |
418 | 419 | ||
419 | static struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector, | 420 | int kvm_apic_compare_prio(struct kvm_vcpu *vcpu1, struct kvm_vcpu *vcpu2) |
420 | unsigned long *bitmap) | ||
421 | { | 421 | { |
422 | int last; | 422 | return vcpu1->arch.apic_arb_prio - vcpu2->arch.apic_arb_prio; |
423 | int next; | ||
424 | struct kvm_lapic *apic = NULL; | ||
425 | |||
426 | last = kvm->arch.round_robin_prev_vcpu; | ||
427 | next = last; | ||
428 | |||
429 | do { | ||
430 | if (++next == KVM_MAX_VCPUS) | ||
431 | next = 0; | ||
432 | if (kvm->vcpus[next] == NULL || !test_bit(next, bitmap)) | ||
433 | continue; | ||
434 | apic = kvm->vcpus[next]->arch.apic; | ||
435 | if (apic && apic_enabled(apic)) | ||
436 | break; | ||
437 | apic = NULL; | ||
438 | } while (next != last); | ||
439 | kvm->arch.round_robin_prev_vcpu = next; | ||
440 | |||
441 | if (!apic) | ||
442 | printk(KERN_DEBUG "vcpu not ready for apic_round_robin\n"); | ||
443 | |||
444 | return apic; | ||
445 | } | ||
446 | |||
447 | struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector, | ||
448 | unsigned long *bitmap) | ||
449 | { | ||
450 | struct kvm_lapic *apic; | ||
451 | |||
452 | apic = kvm_apic_round_robin(kvm, vector, bitmap); | ||
453 | if (apic) | ||
454 | return apic->vcpu; | ||
455 | return NULL; | ||
456 | } | 423 | } |
457 | 424 | ||
458 | static void apic_set_eoi(struct kvm_lapic *apic) | 425 | static void apic_set_eoi(struct kvm_lapic *apic) |
@@ -908,6 +875,8 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu) | |||
908 | vcpu->arch.apic_base |= MSR_IA32_APICBASE_BSP; | 875 | vcpu->arch.apic_base |= MSR_IA32_APICBASE_BSP; |
909 | apic_update_ppr(apic); | 876 | apic_update_ppr(apic); |
910 | 877 | ||
878 | vcpu->arch.apic_arb_prio = 0; | ||
879 | |||
911 | apic_debug(KERN_INFO "%s: vcpu=%p, id=%d, base_msr=" | 880 | apic_debug(KERN_INFO "%s: vcpu=%p, id=%d, base_msr=" |
912 | "0x%016" PRIx64 ", base_address=0x%0lx.\n", __func__, | 881 | "0x%016" PRIx64 ", base_address=0x%0lx.\n", __func__, |
913 | vcpu, kvm_apic_id(apic), | 882 | vcpu, kvm_apic_id(apic), |