Skip to content

Commit d1ebdbf

Browse files
jfsullivbonzini
authored andcommitted
kvm: x86: Deliver MSI IRQ to only lowest prio cpu if msi_redir_hint is true
An MSI interrupt should only be delivered to the lowest priority CPU when it has RH=1, regardless of the delivery mode. Modified kvm_is_dm_lowest_prio() to check for either irq->delivery_mode == APIC_DM_LOWPRI or irq->msi_redir_hint. Moved kvm_is_dm_lowest_prio() into lapic.h and renamed to kvm_lowest_prio_delivery(). Changed a check in kvm_irq_delivery_to_apic_fast() from irq->delivery_mode == APIC_DM_LOWPRI to kvm_is_dm_lowest_prio(). Signed-off-by: James Sullivan <sullivan.james.f@gmail.com> Reviewed-by: Radim Krčmář <rkrcmar@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 93bbf0b commit d1ebdbf

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

arch/x86/kvm/irq_comm.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
#include "ioapic.h"
3333

34+
#include "lapic.h"
35+
3436
static int kvm_set_pic_irq(struct kvm_kernel_irq_routing_entry *e,
3537
struct kvm *kvm, int irq_source_id, int level,
3638
bool line_status)
@@ -48,19 +50,14 @@ static int kvm_set_ioapic_irq(struct kvm_kernel_irq_routing_entry *e,
4850
line_status);
4951
}
5052

51-
inline static bool kvm_is_dm_lowest_prio(struct kvm_lapic_irq *irq)
52-
{
53-
return irq->delivery_mode == APIC_DM_LOWEST;
54-
}
55-
5653
int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src,
5754
struct kvm_lapic_irq *irq, unsigned long *dest_map)
5855
{
5956
int i, r = -1;
6057
struct kvm_vcpu *vcpu, *lowest = NULL;
6158

6259
if (irq->dest_mode == 0 && irq->dest_id == 0xff &&
63-
kvm_is_dm_lowest_prio(irq)) {
60+
kvm_lowest_prio_delivery(irq)) {
6461
printk(KERN_INFO "kvm: apic: phys broadcast and lowest prio\n");
6562
irq->delivery_mode = APIC_DM_FIXED;
6663
}
@@ -76,7 +73,7 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src,
7673
irq->dest_id, irq->dest_mode))
7774
continue;
7875

79-
if (!kvm_is_dm_lowest_prio(irq)) {
76+
if (!kvm_lowest_prio_delivery(irq)) {
8077
if (r < 0)
8178
r = 0;
8279
r += kvm_apic_set_irq(vcpu, irq, dest_map);

arch/x86/kvm/lapic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src,
728728

729729
dst = map->logical_map[cid];
730730

731-
if (irq->delivery_mode == APIC_DM_LOWEST) {
731+
if (kvm_lowest_prio_delivery(irq)) {
732732
int l = -1;
733733
for_each_set_bit(i, &bitmap, 16) {
734734
if (!dst[i])

arch/x86/kvm/lapic.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ static inline bool kvm_apic_has_events(struct kvm_vcpu *vcpu)
153153
return vcpu->arch.apic->pending_events;
154154
}
155155

156+
static inline bool kvm_lowest_prio_delivery(struct kvm_lapic_irq *irq)
157+
{
158+
return (irq->delivery_mode == APIC_DM_LOWEST ||
159+
irq->msi_redir_hint);
160+
}
161+
156162
bool kvm_apic_pending_eoi(struct kvm_vcpu *vcpu, int vector);
157163

158164
void wait_lapic_expire(struct kvm_vcpu *vcpu);

0 commit comments

Comments
 (0)