Blame SOURCES/kvm-e1000e-Prevent-MSI-MSI-X-storms.patch

357786
From 77782045cff9546feaf8863c0e7552343a488c6e Mon Sep 17 00:00:00 2001
357786
From: Xiao Wang <jasowang@redhat.com>
357786
Date: Thu, 16 Aug 2018 06:09:03 +0200
357786
Subject: [PATCH 2/5] e1000e: Prevent MSI/MSI-X storms
357786
357786
RH-Author: Xiao Wang <jasowang@redhat.com>
357786
Message-id: <1534399743-23973-3-git-send-email-jasowang@redhat.com>
357786
Patchwork-id: 81849
357786
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 2/2] e1000e: Prevent MSI/MSI-X storms
357786
Bugzilla: 1596010
357786
RH-Acked-by: wexu@redhat.com
357786
RH-Acked-by: Thomas Huth <thuth@redhat.com>
357786
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
357786
357786
From: Jan Kiszka <jan.kiszka@siemens.com>
357786
357786
Only signal MSI/MSI-X events on rising edges. So far we re-triggered the
357786
interrupt sources even if the guest did no consumed the pending one,
357786
easily causing interrupt storms.
357786
357786
Issue was observable with Linux 4.16 e1000e driver when MSI-X was used.
357786
Vector 2 was causing interrupt storms after the driver activated the
357786
device.
357786
357786
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
357786
Signed-off-by: Jason Wang <jasowang@redhat.com>
357786
(cherry picked from commit 4712c158c5276fd3c401152f4bb5c3fccf185946)
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 hw/net/e1000e_core.c | 11 +++++++++++
357786
 hw/net/e1000e_core.h |  2 ++
357786
 2 files changed, 13 insertions(+)
357786
357786
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
357786
index 9504891..2a221c2 100644
357786
--- a/hw/net/e1000e_core.c
357786
+++ b/hw/net/e1000e_core.c
357786
@@ -2023,6 +2023,7 @@ e1000e_msix_notify_one(E1000ECore *core, uint32_t cause, uint32_t int_cfg)
357786
     effective_eiac = core->mac[EIAC] & cause;
357786
 
357786
     core->mac[ICR] &= ~effective_eiac;
357786
+    core->msi_causes_pending &= ~effective_eiac;
357786
 
357786
     if (!(core->mac[CTRL_EXT] & E1000_CTRL_EXT_IAME)) {
357786
         core->mac[IMS] &= ~effective_eiac;
357786
@@ -2119,6 +2120,13 @@ e1000e_send_msi(E1000ECore *core, bool msix)
357786
 {
357786
     uint32_t causes = core->mac[ICR] & core->mac[IMS] & ~E1000_ICR_ASSERTED;
357786
 
357786
+    core->msi_causes_pending &= causes;
357786
+    causes ^= core->msi_causes_pending;
357786
+    if (causes == 0) {
357786
+        return;
357786
+    }
357786
+    core->msi_causes_pending |= causes;
357786
+
357786
     if (msix) {
357786
         e1000e_msix_notify(core, causes);
357786
     } else {
357786
@@ -2156,6 +2164,9 @@ e1000e_update_interrupt_state(E1000ECore *core)
357786
     core->mac[ICS] = core->mac[ICR];
357786
 
357786
     interrupts_pending = (core->mac[IMS] & core->mac[ICR]) ? true : false;
357786
+    if (!interrupts_pending) {
357786
+        core->msi_causes_pending = 0;
357786
+    }
357786
 
357786
     trace_e1000e_irq_pending_interrupts(core->mac[ICR] & core->mac[IMS],
357786
                                         core->mac[ICR], core->mac[IMS]);
357786
diff --git a/hw/net/e1000e_core.h b/hw/net/e1000e_core.h
357786
index 7d8ff41..63a1551 100644
357786
--- a/hw/net/e1000e_core.h
357786
+++ b/hw/net/e1000e_core.h
357786
@@ -109,6 +109,8 @@ struct E1000Core {
357786
     NICState *owner_nic;
357786
     PCIDevice *owner;
357786
     void (*owner_start_recv)(PCIDevice *d);
357786
+
357786
+    uint32_t msi_causes_pending;
357786
 };
357786
 
357786
 void
357786
-- 
357786
1.8.3.1
357786