kvm: x86: Extended struct kvm_lapic_irq with msi_redir_hint for MSI delivery
authorJames Sullivan <sullivan.james.f@gmail.com>
Thu, 19 Mar 2015 01:26:03 +0000 (19:26 -0600)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 7 May 2015 09:29:44 +0000 (11:29 +0200)
Extended struct kvm_lapic_irq with bool msi_redir_hint, which will
be used to determine if the delivery of the MSI should target only
the lowest priority CPU in the logical group specified for delivery.
(In physical dest mode, the RH bit is not relevant). Initialized the value
of msi_redir_hint to true when RH=1 in kvm_set_msi_irq(), and initialized
to false in all other cases.

Added value of msi_redir_hint to a debug message dump of an IRQ in
apic_send_ipi().

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>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/ioapic.c
arch/x86/kvm/irq_comm.c
arch/x86/kvm/lapic.c
arch/x86/kvm/x86.c

index dc83b43d08503f53915c581e1f9e92a264784c0a..8b661d1946b54af709250d61324ae7772fdb3ce3 100644 (file)
@@ -695,6 +695,7 @@ struct kvm_lapic_irq {
        u16 trig_mode;
        u32 shorthand;
        u32 dest_id;
+       bool msi_redir_hint;
 };
 
 struct kvm_x86_ops {
index 28146f03c51421ce12f728d69613ded0a65699fd..274663496f7a283bee8acc601b2cd895cf43d798 100644 (file)
@@ -349,6 +349,7 @@ static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status)
        irqe.delivery_mode = entry->fields.delivery_mode << 8;
        irqe.level = 1;
        irqe.shorthand = 0;
+       irqe.msi_redir_hint = false;
 
        if (irqe.trig_mode == IOAPIC_EDGE_TRIG)
                ioapic->irr_delivered |= 1 << irq;
index 72298b3ac025a8dc820f4593e5c7f2278f3bb35a..80c10af2bf46e1b06996682f65b6d9b792867deb 100644 (file)
@@ -106,9 +106,10 @@ static inline void kvm_set_msi_irq(struct kvm_kernel_irq_routing_entry *e,
        irq->dest_mode = (1 << MSI_ADDR_DEST_MODE_SHIFT) & e->msi.address_lo;
        irq->trig_mode = (1 << MSI_DATA_TRIGGER_SHIFT) & e->msi.data;
        irq->delivery_mode = e->msi.data & 0x700;
+       irq->msi_redir_hint = ((e->msi.address_lo
+               & MSI_ADDR_REDIRECTION_LOWPRI) > 0);
        irq->level = 1;
        irq->shorthand = 0;
-       /* TODO Deal with RH bit of MSI message address */
 }
 
 int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
index ba585d0c42c5ed3d3126745f7a401ce7e0da6aa7..2573b29bbbb39da529e4798ba03f85d043041dfd 100644 (file)
@@ -917,6 +917,7 @@ static void apic_send_ipi(struct kvm_lapic *apic)
        irq.level = (icr_low & APIC_INT_ASSERT) != 0;
        irq.trig_mode = icr_low & APIC_INT_LEVELTRIG;
        irq.shorthand = icr_low & APIC_SHORT_MASK;
+       irq.msi_redir_hint = false;
        if (apic_x2apic_mode(apic))
                irq.dest_id = icr_high;
        else
@@ -926,10 +927,11 @@ static void apic_send_ipi(struct kvm_lapic *apic)
 
        apic_debug("icr_high 0x%x, icr_low 0x%x, "
                   "short_hand 0x%x, dest 0x%x, trig_mode 0x%x, level 0x%x, "
-                  "dest_mode 0x%x, delivery_mode 0x%x, vector 0x%x\n",
+                  "dest_mode 0x%x, delivery_mode 0x%x, vector 0x%x, "
+                  "msi_redir_hint 0x%x\n",
                   icr_high, icr_low, irq.shorthand, irq.dest_id,
                   irq.trig_mode, irq.level, irq.dest_mode, irq.delivery_mode,
-                  irq.vector);
+                  irq.vector, irq.msi_redir_hint);
 
        kvm_irq_delivery_to_apic(apic->vcpu->kvm, apic, &irq, NULL);
 }
index 755a79fabfc1f63977475c8222d8f57cdd6cfc72..bf80ce7656b71861e36a01b82cdf9060d2c1e564 100644 (file)
@@ -5984,6 +5984,7 @@ static void kvm_pv_kick_cpu_op(struct kvm *kvm, unsigned long flags, int apicid)
        lapic_irq.shorthand = 0;
        lapic_irq.dest_mode = 0;
        lapic_irq.dest_id = apicid;
+       lapic_irq.msi_redir_hint = false;
 
        lapic_irq.delivery_mode = APIC_DM_REMRD;
        kvm_irq_delivery_to_apic(kvm, NULL, &lapic_irq, NULL);