Skip to contentSkip to conversation

MSI/MSIX injection for Xen HVM guests

PATCH New Stefano Stabellini 1 participant 3 messages Apr 12, 2012 Kbuild

lore
Share & tools
lore
#0 lore raw

v2 cover MSI/MSIX injection for Xen HVM guests

Hi all,
this patch series by Wei Liu implements a simple Xen APIC module and use it to deliver MSI/MSIX for Xen HVM guests.

The second version of this series includes the "or later" copyright clause for xen_apic.c and a fix to the return value of xen_apic_mem_read (thanks Peter for finding it out).

Stefano Stabellini (2):
Xen: basic HVM MSI injection support.
Xen: Add xen-apic support and hook it up.

 Makefile.target |    2 +-
 hw/pc.c         |    8 +++++
 hw/xen.h        |    1 +
 hw/xen_apic.c   |   90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 xen-all.c       |    5 +++
 xen-stub.c      |    4 ++
 6 files changed, 109 insertions(+), 1 deletions(-)

Cheers,

Stefano

#1 lore raw

PATCH v2 1/2 Xen: basic HVM MSI injection support.

From: "Wei Liu" <[email protected]>

---
 hw/xen.h   |    1 +
 xen-all.c  |    5 +++++
 xen-stub.c |    4 ++++
 3 files changed, 10 insertions(+), 0 deletions(-)
hw/xen.h +1 -0
index b46879c..e5926b7 100644
@@ -34,6 +34,7 @@ static inline int xen_enabled(void)
 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num);
 void xen_piix3_set_irq(void *opaque, int irq_num, int level);
 void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len);
+void xen_hvm_inject_msi(uint64_t addr, uint32_t data);
 void xen_cmos_set_s3_resume(void *opaque, int irq, int level);
 
 qemu_irq *xen_interrupt_controller_init(void);
xen-all.c +5 -0
index 3e6de41..abd2b2d 100644
@@ -122,6 +122,11 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
     }
 }
 
+void xen_hvm_inject_msi(uint64_t addr, uint32_t data)
+{
+    xc_hvm_inject_msi(xen_xc, xen_domid, addr, data);
+}
+
 static void xen_suspend_notifier(Notifier *notifier, void *data)
 {
     xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 3);
xen-stub.c +4 -0
index 9ea02d4..8ff2b79 100644
@@ -29,6 +29,10 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
 {
 }
 
+void xen_hvm_inject_msi(uint64_t addr, uint32_t data)
+{
+}
+
 void xen_cmos_set_s3_resume(void *opaque, int irq, int level)
 {
 }
Signature · 1 line
1.7.2.5
#2 lore raw

PATCH v2 2/2 Xen: Add xen-apic support and hook it up.

In reply to Stefano Stabellini

From: "Wei Liu" <[email protected]>

---
 Makefile.target |    2 +-
 hw/pc.c         |    8 +++++
 hw/xen_apic.c   |   90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 99 insertions(+), 1 deletions(-)
 create mode 100644 hw/xen_apic.c
Makefile.target +1 -1
index 14c8fa1..0c2d865 100644
@@ -236,7 +236,7 @@ QEMU_CFLAGS += $(VNC_PNG_CFLAGS)
 obj-$(CONFIG_XEN) += xen-all.o xen_machine_pv.o xen_domainbuild.o xen-mapcache.o
 obj-$(CONFIG_NO_XEN) += xen-stub.o
 
-obj-i386-$(CONFIG_XEN) += xen_platform.o
+obj-i386-$(CONFIG_XEN) += xen_platform.o xen_apic.o
 
 # Inter-VM PCI shared memory
 CONFIG_IVSHMEM =
hw/pc.c +8 -0
index 67f0479..1f5aacb 100644
@@ -42,6 +42,7 @@
 #include "sysbus.h"
 #include "sysemu.h"
 #include "kvm.h"
+#include "xen.h"
 #include "blockdev.h"
 #include "ui/qemu-spice.h"
 #include "memory.h"
@@ -891,9 +892,12 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)
 
     if (kvm_irqchip_in_kernel()) {
         dev = qdev_create(NULL, "kvm-apic");
+    } else if (xen_enabled()) {
+        dev = qdev_create(NULL, "xen-apic");
     } else {
         dev = qdev_create(NULL, "apic");
     }
+
     qdev_prop_set_uint8(dev, "id", apic_id);
     qdev_prop_set_ptr(dev, "cpu_env", env);
     qdev_init_nofail(dev);
@@ -912,6 +916,10 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)
         msi_supported = true;
     }
 
+    if (xen_enabled()) {
+        msi_supported = true;
+    }
+
     return dev;
 }
 
hw/xen_apic.c new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
1.7.2.5