From: Jan Kiszka <[email protected]>

Recent Linux versions initialize MSI with a placeholder vector,
MANAGED_IRQ_SHUTDOWN_VECTOR, but keep them masked. As we ignored the
mask so far, we injected this vector on handover. That caused and
spurious interrupt warning and, worse, blocking of vectors with equal or
lower priority because Linux does not ack unused vectors anymore (an
issue of its own).

We can avoid the issue by evaluating the mask state, if any, prior to
injection.

Signed-off-by: Jan Kiszka <[email protected]>
---
 hypervisor/arch/x86/pci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/hypervisor/arch/x86/pci.c b/hypervisor/arch/x86/pci.c
index 560c5697..0cbb2f3d 100644
--- a/hypervisor/arch/x86/pci.c
+++ b/hypervisor/arch/x86/pci.c
@@ -289,6 +289,7 @@ void arch_pci_suppress_msi(struct pci_device *device,
        unsigned int n, vectors = pci_enabled_msi_vectors(device);
        const struct jailhouse_pci_device *info = device->info;
        struct apic_irq_message irq_msg;
+       unsigned int mask_pos, mask = 0;
        union x86_msi_vector msi = {
                .native.dest_logical = 1,
                .native.redir_hint = 1,
@@ -312,11 +313,15 @@ void arch_pci_suppress_msi(struct pci_device *device,
                 * Inject MSI vectors to avoid losing events while suppressed.
                 * Linux can handle rare spurious interrupts.
                 */
+               if (info->msi_maskable) {
+                       mask_pos = cap->start + (info->msi_64bits ? 0x10 : 0xc);
+                       mask = pci_read_config(info->bdf, mask_pos, 4);
+               }
                msi = pci_get_x86_msi_vector(device);
                for (n = 0; n < vectors; n++) {
                        irq_msg = x86_pci_translate_msi(device, n, vectors,
                                                        msi);
-                       if (irq_msg.valid)
+                       if ((mask & (1 << n)) == 0 && irq_msg.valid)
                                apic_send_irq(irq_msg);
                }
        }
-- 
2.16.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/243a7537af27a963c00e936462b705dcde7cb970.1561357723.git.jan.kiszka%40siemens.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to