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.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index 64f74bd7093a..5efa6c0276c6 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -185,8 +185,10 @@ int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu)
185} 185}
186EXPORT_SYMBOL_GPL(kvm_lapic_find_highest_irr); 186EXPORT_SYMBOL_GPL(kvm_lapic_find_highest_irr);
187 187
188int kvm_apic_set_irq(struct kvm_lapic *apic, u8 vec, u8 trig) 188int kvm_apic_set_irq(struct kvm_vcpu *vcpu, u8 vec, u8 trig)
189{ 189{
190 struct kvm_lapic *apic = vcpu->apic;
191
190 if (!apic_test_and_set_irr(vec, apic)) { 192 if (!apic_test_and_set_irr(vec, apic)) {
191 /* a new pending irq is set in IRR */ 193 /* a new pending irq is set in IRR */
192 if (trig) 194 if (trig)
@@ -394,7 +396,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
394 return result; 396 return result;
395} 397}
396 398
397struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector, 399static struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
398 unsigned long bitmap) 400 unsigned long bitmap)
399{ 401{
400 int last; 402 int last;
@@ -422,6 +424,17 @@ struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
422 return apic; 424 return apic;
423} 425}
424 426
427struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector,
428 unsigned long bitmap)
429{
430 struct kvm_lapic *apic;
431
432 apic = kvm_apic_round_robin(kvm, vector, bitmap);
433 if (apic)
434 return apic->vcpu;
435 return NULL;
436}
437
425static void apic_set_eoi(struct kvm_lapic *apic) 438static void apic_set_eoi(struct kvm_lapic *apic)
426{ 439{
427 int vector = apic_find_highest_isr(apic); 440 int vector = apic_find_highest_isr(apic);
@@ -453,7 +466,7 @@ static void apic_send_ipi(struct kvm_lapic *apic)
453 unsigned int delivery_mode = icr_low & APIC_MODE_MASK; 466 unsigned int delivery_mode = icr_low & APIC_MODE_MASK;
454 unsigned int vector = icr_low & APIC_VECTOR_MASK; 467 unsigned int vector = icr_low & APIC_VECTOR_MASK;
455 468
456 struct kvm_lapic *target; 469 struct kvm_vcpu *target;
457 struct kvm_vcpu *vcpu; 470 struct kvm_vcpu *vcpu;
458 unsigned long lpr_map = 0; 471 unsigned long lpr_map = 0;
459 int i; 472 int i;
@@ -480,9 +493,9 @@ static void apic_send_ipi(struct kvm_lapic *apic)
480 } 493 }
481 494
482 if (delivery_mode == APIC_DM_LOWEST) { 495 if (delivery_mode == APIC_DM_LOWEST) {
483 target = kvm_apic_round_robin(vcpu->kvm, vector, lpr_map); 496 target = kvm_get_lowest_prio_vcpu(vcpu->kvm, vector, lpr_map);
484 if (target != NULL) 497 if (target != NULL)
485 __apic_accept_irq(target, delivery_mode, 498 __apic_accept_irq(target->apic, delivery_mode,
486 vector, level, trig_mode); 499 vector, level, trig_mode);
487 } 500 }
488} 501}