Skip to contentSkip to conversation

s390x/pci: set kvm_msi_via_irqfd_allowed

PATCH In review Matthew Rosato 4 participants 4 messages Oct 8, 2025 – Oct 13, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 s390x/pci: set kvm_msi_via_irqfd_allowed

Allow irqfd to be used for virtio-pci on s390x if the kernel supports it. This improves s390x virtio-pci performance when using kvm acceleration by allowing kvm to deliver interrupts instead of QEMU.

---
v3:
- Fix builds when !KVM (Thomas). Tested build on x86 and s390.
- Note: Dropped all review tags due to the code re-organization.

---
 hw/s390x/s390-pci-bus.c         | 1 +
 include/hw/s390x/s390-pci-kvm.h | 7 +++++++
 2 files changed, 8 insertions(+)
hw/s390x/s390-pci-bus.c +1 -0
index e8e41c8a9a..52820894fa 100644
@@ -900,6 +900,7 @@ static void s390_pcihost_realize(DeviceState *dev, Error **errp)
     s390_pci_init_default_group();
     css_register_io_adapters(CSS_IO_ADAPTER_PCI, true, false,
                              S390_ADAPTER_SUPPRESSIBLE, errp);
+    s390_pcihost_kvm_realize();
 }
 
 static void s390_pcihost_unrealize(DeviceState *dev)
include/hw/s390x/s390-pci-kvm.h +7 -0
index 933814a402..c33f2833a3 100644
@@ -14,12 +14,19 @@
 
 #include "hw/s390x/s390-pci-bus.h"
 #include "hw/s390x/s390-pci-inst.h"
+#include "system/kvm.h"
 
 #ifdef CONFIG_KVM
+static inline void s390_pcihost_kvm_realize(void)
+{
+    kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled();
+}
+
 bool s390_pci_kvm_interp_allowed(void);
 int s390_pci_kvm_aif_enable(S390PCIBusDevice *pbdev, ZpciFib *fib, bool assist);
 int s390_pci_kvm_aif_disable(S390PCIBusDevice *pbdev);
 #else
+static inline void s390_pcihost_kvm_realize(void) {}
 static inline bool s390_pci_kvm_interp_allowed(void)
 {
     return false;
Signature · 1 line
2.51.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 9 lines · Matthew Rosato

Allow irqfd to be used for virtio-pci on s390x if the kernel supports it. This improves s390x virtio-pci performance when using kvm acceleration by allowing kvm to deliver interrupts instead of QEMU.

---
v3:
- Fix builds when !KVM (Thomas). Tested build on x86 and s390.
- Note: Dropped all review tags due to the code re-organization.

Ah, my apologies for missing the !KVM case before.

Reviewed-by on v3 1/1
#2 lore raw
In reply to Matthew Rosato
Quoted 50 lines · Matthew Rosato

Allow irqfd to be used for virtio-pci on s390x if the kernel supports it. This improves s390x virtio-pci performance when using kvm acceleration by allowing kvm to deliver interrupts instead of QEMU.

---
v3:
- Fix builds when !KVM (Thomas). Tested build on x86 and s390.
- Note: Dropped all review tags due to the code re-organization.

---
  hw/s390x/s390-pci-bus.c         | 1 +
  include/hw/s390x/s390-pci-kvm.h | 7 +++++++
  2 files changed, 8 insertions(+)
hw/s390x/s390-pci-bus.c +1 -0
index e8e41c8a9a..52820894fa 100644
@@ -900,6 +900,7 @@ static void s390_pcihost_realize(DeviceState *dev, Error **errp)
      s390_pci_init_default_group();
      css_register_io_adapters(CSS_IO_ADAPTER_PCI, true, false,
                               S390_ADAPTER_SUPPRESSIBLE, errp);
+    s390_pcihost_kvm_realize();
  }
 
  static void s390_pcihost_unrealize(DeviceState *dev)
include/hw/s390x/s390-pci-kvm.h +7 -0
index 933814a402..c33f2833a3 100644
@@ -14,12 +14,19 @@
 
  #include "hw/s390x/s390-pci-bus.h"
  #include "hw/s390x/s390-pci-inst.h"
+#include "system/kvm.h"
 
  #ifdef CONFIG_KVM
+static inline void s390_pcihost_kvm_realize(void)
+{
+    kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled();
+}
+
  bool s390_pci_kvm_interp_allowed(void);
  int s390_pci_kvm_aif_enable(S390PCIBusDevice *pbdev, ZpciFib *fib, bool assist);
  int s390_pci_kvm_aif_disable(S390PCIBusDevice *pbdev);
  #else
+static inline void s390_pcihost_kvm_realize(void) {}
  static inline bool s390_pci_kvm_interp_allowed(void)
  {
      return false;