Skip to contentSkip to conversation

Xen PCI Passthrough

PATCH Superseded Anthony PERARD 5 participants 49 messages Jun 12, 2012 – Jun 14, 2012

v12 of 13 Superseded Latest is v13 →

lore
Share & tools
lore
#0 lore raw

v12 cover Xen PCI Passthrough

Hi all,

This patch series introduces the PCI passthrough for Xen.

Please ack the generic bits so that Stefano can send a pull request: patches 1, 2, 4 and 5.

Thanks,

Changes since the last time:
- new patch to export pci_parse_devaddr, so it can be used to parse a BDF in xen_pt.
# the other option would be to introduce a new function name in pci.c or to # copy/paste the function.
- few more comment in XenHostPCIDevice about the buffer size used.

Allen Kay (2):
Introduce Xen PCI Passthrough, qdevice (1/3) Introduce Xen PCI Passthrough, PCI config space helpers (2/3)

Anthony PERARD (6):
pci_ids: Add INTEL_82599_SFP_VF id.
configure: Introduce --enable-xen-pci-passthrough. Introduce XenHostPCIDevice to access a pci device on the host. pci.c: Add opaque argument to pci_for_each_device. Revert "pci: don't export an internal function" Introduce apic-msidef.h

Jiang Yunhong (1):
Introduce Xen PCI Passthrough, MSI (3/3)

 configure                |   29 +
 hw/apic-msidef.h         |   30 +
 hw/apic.c                |   11 +-
 hw/i386/Makefile.objs    |    2 +
 hw/pci.c                 |   13 +-
 hw/pci.h                 |    6 +-
 hw/pci_ids.h             |    1 +
 hw/xen-host-pci-device.c |  396 ++++++++++
 hw/xen-host-pci-device.h |   55 ++
 hw/xen_common.h          |    3 +
 hw/xen_platform.c        |    8 +-
 hw/xen_pt.c              |  854 +++++++++++++++++++++
 hw/xen_pt.h              |  301 ++++++++
 hw/xen_pt_config_init.c  | 1869 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_pt_msi.c          |  620 +++++++++++++++
 xen-all.c                |   12 +
 16 files changed, 4190 insertions(+), 20 deletions(-)
 create mode 100644 hw/apic-msidef.h
 create mode 100644 hw/xen-host-pci-device.c
 create mode 100644 hw/xen-host-pci-device.h
 create mode 100644 hw/xen_pt.c
 create mode 100644 hw/xen_pt.h
 create mode 100644 hw/xen_pt_config_init.c
 create mode 100644 hw/xen_pt_msi.c
Signature · 1 line
Anthony PERARD
#1 lore raw

PATCH v12 1/9 pci_ids: Add INTEL_82599_SFP_VF id.

We are using this in our quirk lookup provided by patch
titled: Introduce Xen PCI Passthrough, PCI config space helpers.

---
 hw/pci_ids.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
hw/pci_ids.h +1 -0
index e8235a7..649e6b3 100644
@@ -118,6 +118,7 @@
 #define PCI_DEVICE_ID_INTEL_82801I_UHCI6 0x2939
 #define PCI_DEVICE_ID_INTEL_82801I_EHCI1 0x293a
 #define PCI_DEVICE_ID_INTEL_82801I_EHCI2 0x293c
+#define PCI_DEVICE_ID_INTEL_82599_SFP_VF 0x10ed
 
 #define PCI_VENDOR_ID_XEN               0x5853
 #define PCI_DEVICE_ID_XEN_PLATFORM      0x0001
Signature · 1 line
Anthony PERARD
#2 lore raw

PATCH v12 1/9 pci_ids: Add INTEL_82599_SFP_VF id.

In reply to Anthony PERARD

We are using this in our quirk lookup provided by patch
titled: Introduce Xen PCI Passthrough, PCI config space helpers.

---
 hw/pci_ids.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
hw/pci_ids.h +1 -0
index e8235a7..649e6b3 100644
@@ -118,6 +118,7 @@
 #define PCI_DEVICE_ID_INTEL_82801I_UHCI6 0x2939
 #define PCI_DEVICE_ID_INTEL_82801I_EHCI1 0x293a
 #define PCI_DEVICE_ID_INTEL_82801I_EHCI2 0x293c
+#define PCI_DEVICE_ID_INTEL_82599_SFP_VF 0x10ed
 
 #define PCI_VENDOR_ID_XEN               0x5853
 #define PCI_DEVICE_ID_XEN_PLATFORM      0x0001
Signature · 1 line
Anthony PERARD
#3 lore raw

PATCH v12 2/9 configure: Introduce --enable-xen-pci-passthrough.

In reply to Anthony PERARD
---
 configure |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
configure +29 -0
index dd0d2b3..d9ecfe5 100755
@@ -137,6 +137,7 @@ vnc_png=""
 vnc_thread="no"
 xen=""
 xen_ctrl_version=""
+xen_pci_passthrough=""
 linux_aio=""
 cap_ng=""
 attr=""
@@ -685,6 +686,10 @@ for opt do
   ;;
   --enable-xen) xen="yes"
   ;;
+  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
+  ;;
+  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
+  ;;
   --disable-brlapi) brlapi="no"
   ;;
   --enable-brlapi) brlapi="yes"
@@ -1032,6 +1037,8 @@ echo "                           (affects only QEMU, not qemu-img)"
 echo "  --enable-mixemu          enable mixer emulation"
 echo "  --disable-xen            disable xen backend driver support"
 echo "  --enable-xen             enable xen backend driver support"
+echo "  --disable-xen-pci-passthrough"
+echo "  --enable-xen-pci-passthrough"
 echo "  --disable-brlapi         disable BrlAPI"
 echo "  --enable-brlapi          enable BrlAPI"
 echo "  --disable-vnc-tls        disable TLS encryption for VNC server"
@@ -1508,6 +1515,25 @@ EOF
   fi
 fi
 
+if test "$xen_pci_passthrough" != "no"; then
+  if test "$xen" = "yes" && test "$linux" = "yes" &&
+    test "$xen_ctrl_version" -ge 340; then
+    xen_pci_passthrough=yes
+  else
+    if test "$xen_pci_passthrough" = "yes"; then
+      echo "ERROR"
+      echo "ERROR: User requested feature Xen PCI Passthrough"
+      echo "ERROR: but this feature require /sys from Linux"
+      if test "$xen_ctrl_version" -lt 340; then
+        echo "ERROR: This feature does not work with Xen 3.3"
+      fi
+      echo "ERROR"
+      exit 1;
+    fi
+    xen_pci_passthrough=no
+  fi
+fi
+
 ##########################################
 # pkg-config probe
 
@@ -3698,6 +3724,9 @@ case "$target_arch2" in
     if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
       target_phys_bits=64
       echo "CONFIG_XEN=y" >> $config_target_mak
+      if test "$xen_pci_passthrough" = yes; then
+        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
+      fi
     else
       echo "CONFIG_NO_XEN=y" >> $config_target_mak
     fi
Signature · 1 line
Anthony PERARD
#4 lore raw

PATCH v12 2/9 configure: Introduce --enable-xen-pci-passthrough.

In reply to Anthony PERARD
---
 configure |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
configure +29 -0
index dd0d2b3..d9ecfe5 100755
@@ -137,6 +137,7 @@ vnc_png=""
 vnc_thread="no"
 xen=""
 xen_ctrl_version=""
+xen_pci_passthrough=""
 linux_aio=""
 cap_ng=""
 attr=""
@@ -685,6 +686,10 @@ for opt do
   ;;
   --enable-xen) xen="yes"
   ;;
+  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
+  ;;
+  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
+  ;;
   --disable-brlapi) brlapi="no"
   ;;
   --enable-brlapi) brlapi="yes"
@@ -1032,6 +1037,8 @@ echo "                           (affects only QEMU, not qemu-img)"
 echo "  --enable-mixemu          enable mixer emulation"
 echo "  --disable-xen            disable xen backend driver support"
 echo "  --enable-xen             enable xen backend driver support"
+echo "  --disable-xen-pci-passthrough"
+echo "  --enable-xen-pci-passthrough"
 echo "  --disable-brlapi         disable BrlAPI"
 echo "  --enable-brlapi          enable BrlAPI"
 echo "  --disable-vnc-tls        disable TLS encryption for VNC server"
@@ -1508,6 +1515,25 @@ EOF
   fi
 fi
 
+if test "$xen_pci_passthrough" != "no"; then
+  if test "$xen" = "yes" && test "$linux" = "yes" &&
+    test "$xen_ctrl_version" -ge 340; then
+    xen_pci_passthrough=yes
+  else
+    if test "$xen_pci_passthrough" = "yes"; then
+      echo "ERROR"
+      echo "ERROR: User requested feature Xen PCI Passthrough"
+      echo "ERROR: but this feature require /sys from Linux"
+      if test "$xen_ctrl_version" -lt 340; then
+        echo "ERROR: This feature does not work with Xen 3.3"
+      fi
+      echo "ERROR"
+      exit 1;
+    fi
+    xen_pci_passthrough=no
+  fi
+fi
+
 ##########################################
 # pkg-config probe
 
@@ -3698,6 +3724,9 @@ case "$target_arch2" in
     if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
       target_phys_bits=64
       echo "CONFIG_XEN=y" >> $config_target_mak
+      if test "$xen_pci_passthrough" = yes; then
+        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
+      fi
     else
       echo "CONFIG_NO_XEN=y" >> $config_target_mak
     fi
Signature · 1 line
Anthony PERARD
#5 lore raw

PATCH v12 3/9 Introduce XenHostPCIDevice to access a pci device on the host.

In reply to Anthony PERARD
---
 hw/i386/Makefile.objs    |    1 +
 hw/xen-host-pci-device.c |  396 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen-host-pci-device.h |   55 +++++++
 3 files changed, 452 insertions(+), 0 deletions(-)
 create mode 100644 hw/xen-host-pci-device.c
 create mode 100644 hw/xen-host-pci-device.h
hw/i386/Makefile.objs +1 -0
index d43f1df..b719d8e 100644
@@ -7,6 +7,7 @@ obj-y += debugcon.o multiboot.o
 obj-y += pc_piix.o
 obj-y += pc_sysfw.o
 obj-$(CONFIG_XEN) += xen_platform.o xen_apic.o
+obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o
 obj-$(CONFIG_KVM) += kvm/clock.o kvm/apic.o kvm/i8259.o kvm/ioapic.o kvm/i8254.o
 obj-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o
 
hw/xen-host-pci-device.c new file +396 -0

396 lines not on this page · raw message

hw/xen-host-pci-device.h new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
Anthony PERARD
#6 lore raw

PATCH v12 4/9 pci.c: Add opaque argument to pci_for_each_device.

In reply to Anthony PERARD

The purpose is to have a more generic pci_for_each_device by passing an extra argument to the function called on every device.

This patch will be used in a next patch.

---
 hw/pci.c          |   11 +++++++----
 hw/pci.h          |    4 +++-
 hw/xen_platform.c |    8 ++++----
 3 files changed, 14 insertions(+), 9 deletions(-)
hw/pci.c +7 -4
index c1ebdde..eec106a 100644
@@ -1127,7 +1127,9 @@ static const pci_class_desc pci_class_descriptions[] =
 };
 
 static void pci_for_each_device_under_bus(PCIBus *bus,
-                                          void (*fn)(PCIBus *b, PCIDevice *d))
+                                          void (*fn)(PCIBus *b, PCIDevice *d,
+                                                     void *opaque),
+                                          void *opaque)
 {
     PCIDevice *d;
     int devfn;
@@ -1135,18 +1137,19 @@ static void pci_for_each_device_under_bus(PCIBus *bus,
     for(devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
         d = bus->devices[devfn];
         if (d) {
-            fn(bus, d);
+            fn(bus, d, opaque);
         }
     }
 }
 
 void pci_for_each_device(PCIBus *bus, int bus_num,
-                         void (*fn)(PCIBus *b, PCIDevice *d))
+                         void (*fn)(PCIBus *b, PCIDevice *d, void *opaque),
+                         void *opaque)
 {
     bus = pci_find_bus_nr(bus, bus_num);
 
     if (bus) {
-        pci_for_each_device_under_bus(bus, fn);
+        pci_for_each_device_under_bus(bus, fn, opaque);
     }
 }
 
hw/pci.h +3 -1
index c3cacce..ecf37fd 100644
@@ -312,7 +312,9 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
 PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,
                                const char *default_devaddr);
 int pci_bus_num(PCIBus *s);
-void pci_for_each_device(PCIBus *bus, int bus_num, void (*fn)(PCIBus *bus, PCIDevice *d));
+void pci_for_each_device(PCIBus *bus, int bus_num,
+                         void (*fn)(PCIBus *bus, PCIDevice *d, void *opaque),
+                         void *opaque);
 PCIBus *pci_find_root_bus(int domain);
 int pci_find_domain(const PCIBus *bus);
 PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
hw/xen_platform.c +4 -4
index 0214f37..c1fe984 100644
@@ -83,7 +83,7 @@ static void log_writeb(PCIXenPlatformState *s, char val)
 #define UNPLUG_ALL_NICS 2
 #define UNPLUG_AUX_IDE_DISKS 4
 
-static void unplug_nic(PCIBus *b, PCIDevice *d)
+static void unplug_nic(PCIBus *b, PCIDevice *d, void *o)
 {
     if (pci_get_word(d->config + PCI_CLASS_DEVICE) ==
             PCI_CLASS_NETWORK_ETHERNET) {
@@ -96,10 +96,10 @@ static void unplug_nic(PCIBus *b, PCIDevice *d)
 
 static void pci_unplug_nics(PCIBus *bus)
 {
-    pci_for_each_device(bus, 0, unplug_nic);
+    pci_for_each_device(bus, 0, unplug_nic, NULL);
 }
 
-static void unplug_disks(PCIBus *b, PCIDevice *d)
+static void unplug_disks(PCIBus *b, PCIDevice *d, void *o)
 {
     if (pci_get_word(d->config + PCI_CLASS_DEVICE) ==
             PCI_CLASS_STORAGE_IDE) {
@@ -109,7 +109,7 @@ static void unplug_disks(PCIBus *b, PCIDevice *d)
 
 static void pci_unplug_disks(PCIBus *bus)
 {
-    pci_for_each_device(bus, 0, unplug_disks);
+    pci_for_each_device(bus, 0, unplug_disks, NULL);
 }
 
 static void platform_fixed_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
Signature · 1 line
Anthony PERARD
#7 lore raw

PATCH v12 4/9 pci.c: Add opaque argument to pci_for_each_device.

In reply to Anthony PERARD

The purpose is to have a more generic pci_for_each_device by passing an extra argument to the function called on every device.

This patch will be used in a next patch.

---
 hw/pci.c          |   11 +++++++----
 hw/pci.h          |    4 +++-
 hw/xen_platform.c |    8 ++++----
 3 files changed, 14 insertions(+), 9 deletions(-)
hw/pci.c +7 -4
index c1ebdde..eec106a 100644
@@ -1127,7 +1127,9 @@ static const pci_class_desc pci_class_descriptions[] =
 };
 
 static void pci_for_each_device_under_bus(PCIBus *bus,
-                                          void (*fn)(PCIBus *b, PCIDevice *d))
+                                          void (*fn)(PCIBus *b, PCIDevice *d,
+                                                     void *opaque),
+                                          void *opaque)
 {
     PCIDevice *d;
     int devfn;
@@ -1135,18 +1137,19 @@ static void pci_for_each_device_under_bus(PCIBus *bus,
     for(devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
         d = bus->devices[devfn];
         if (d) {
-            fn(bus, d);
+            fn(bus, d, opaque);
         }
     }
 }
 
 void pci_for_each_device(PCIBus *bus, int bus_num,
-                         void (*fn)(PCIBus *b, PCIDevice *d))
+                         void (*fn)(PCIBus *b, PCIDevice *d, void *opaque),
+                         void *opaque)
 {
     bus = pci_find_bus_nr(bus, bus_num);
 
     if (bus) {
-        pci_for_each_device_under_bus(bus, fn);
+        pci_for_each_device_under_bus(bus, fn, opaque);
     }
 }
 
hw/pci.h +3 -1
index c3cacce..ecf37fd 100644
@@ -312,7 +312,9 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
 PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,
                                const char *default_devaddr);
 int pci_bus_num(PCIBus *s);
-void pci_for_each_device(PCIBus *bus, int bus_num, void (*fn)(PCIBus *bus, PCIDevice *d));
+void pci_for_each_device(PCIBus *bus, int bus_num,
+                         void (*fn)(PCIBus *bus, PCIDevice *d, void *opaque),
+                         void *opaque);
 PCIBus *pci_find_root_bus(int domain);
 int pci_find_domain(const PCIBus *bus);
 PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
hw/xen_platform.c +4 -4
index 0214f37..c1fe984 100644
@@ -83,7 +83,7 @@ static void log_writeb(PCIXenPlatformState *s, char val)
 #define UNPLUG_ALL_NICS 2
 #define UNPLUG_AUX_IDE_DISKS 4
 
-static void unplug_nic(PCIBus *b, PCIDevice *d)
+static void unplug_nic(PCIBus *b, PCIDevice *d, void *o)
 {
     if (pci_get_word(d->config + PCI_CLASS_DEVICE) ==
             PCI_CLASS_NETWORK_ETHERNET) {
@@ -96,10 +96,10 @@ static void unplug_nic(PCIBus *b, PCIDevice *d)
 
 static void pci_unplug_nics(PCIBus *bus)
 {
-    pci_for_each_device(bus, 0, unplug_nic);
+    pci_for_each_device(bus, 0, unplug_nic, NULL);
 }
 
-static void unplug_disks(PCIBus *b, PCIDevice *d)
+static void unplug_disks(PCIBus *b, PCIDevice *d, void *o)
 {
     if (pci_get_word(d->config + PCI_CLASS_DEVICE) ==
             PCI_CLASS_STORAGE_IDE) {
@@ -109,7 +109,7 @@ static void unplug_disks(PCIBus *b, PCIDevice *d)
 
 static void pci_unplug_disks(PCIBus *bus)
 {
-    pci_for_each_device(bus, 0, unplug_disks);
+    pci_for_each_device(bus, 0, unplug_disks, NULL);
 }
 
 static void platform_fixed_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
Signature · 1 line
Anthony PERARD
#8 lore raw

PATCH v12 5/9 Revert "pci: don't export an internal function"

In reply to Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

---
 hw/pci.c |    2 +-
 hw/pci.h |    2 ++
 2 files changed, 3 insertions(+), 1 deletions(-)
hw/pci.c +1 -1
index eec106a..5bddf7a 100644
@@ -479,7 +479,7 @@ static void pci_set_default_subsystem_id(PCIDevice *pci_dev)
  * Parse [[<domain>:]<bus>:]<slot>, return -1 on error if funcp == NULL
  *       [[<domain>:]<bus>:]<slot>.<func>, return -1 on error
  */
-static int pci_parse_devaddr(const char *addr, int *domp, int *busp,
+int pci_parse_devaddr(const char *addr, int *domp, int *busp,
                       unsigned int *slotp, unsigned int *funcp)
 {
     const char *p;
hw/pci.h +2 -0
index ecf37fd..b169c0b 100644
@@ -321,6 +321,8 @@ PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
 int pci_qdev_find_device(const char *id, PCIDevice **pdev);
 PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr);
 
+int pci_parse_devaddr(const char *addr, int *domp, int *busp,
+                      unsigned int *slotp, unsigned int *funcp);
 int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
                      unsigned *slotp);
 
Signature · 1 line
Anthony PERARD
#9 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

Quoted 33 lines
---
 hw/pci.c |    2 +-
 hw/pci.h |    2 ++
 2 files changed, 3 insertions(+), 1 deletions(-)
hw/pci.c +1 -1
index eec106a..5bddf7a 100644
@@ -479,7 +479,7 @@ static void pci_set_default_subsystem_id(PCIDevice *pci_dev)
  * Parse [[<domain>:]<bus>:]<slot>, return -1 on error if funcp == NULL
  *       [[<domain>:]<bus>:]<slot>.<func>, return -1 on error
  */
-static int pci_parse_devaddr(const char *addr, int *domp, int *busp,
+int pci_parse_devaddr(const char *addr, int *domp, int *busp,
                       unsigned int *slotp, unsigned int *funcp)
 {
     const char *p;
hw/pci.h +2 -0
index ecf37fd..b169c0b 100644
@@ -321,6 +321,8 @@ PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
 int pci_qdev_find_device(const char *id, PCIDevice **pdev);
 PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr);
 
+int pci_parse_devaddr(const char *addr, int *domp, int *busp,
+                      unsigned int *slotp, unsigned int *funcp);
 int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
                      unsigned *slotp);
 
Signature · 1 line
Anthony PERARD
#10 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

Aside from this minor comment, do you have any objections to this series?

It has been outstanding for 9 months now, and the last few versions have been without any major changes.
Considering that a new QEMU release cycle has just opened, I think that now would be the perfect time to get the series in.

#11 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Michael S. Tsirkin
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

Aside from this minor comment, do you have any objections to this series?

It has been outstanding for 9 months now, and the last few versions have been without any major changes.
Considering that a new QEMU release cycle has just opened, I think that now would be the perfect time to get the series in.

#12 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

Aside from this minor comment, do you have any objections to this series?

Aside from this, there are minor pci core changes and these are all fine.
I can't say I looked at the device itself too deeply
but seems mergeable.

Quoted 4 lines

It has been outstanding for 9 months now, and the last few versions have been without any major changes.
Considering that a new QEMU release cycle has just opened, I think that now would be the perfect time to get the series in.

#13 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Stefano Stabellini
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

Aside from this minor comment, do you have any objections to this series?

Aside from this, there are minor pci core changes and these are all fine.
I can't say I looked at the device itself too deeply
but seems mergeable.

Quoted 4 lines

It has been outstanding for 9 months now, and the last few versions have been without any major changes.
Considering that a new QEMU release cycle has just opened, I think that now would be the perfect time to get the series in.

#14 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Michael S. Tsirkin
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#15 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Michael S. Tsirkin
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#16 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

Quoted 13 lines · Jan Kiszka
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

Quoted 5 lines

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

I agree, actually it looks like patch 10 and 11 would be enough.

Maybe you could extract them and send them out separately?

#17 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Jan Kiszka
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

Also rename pci_parse_devaddr to pci_parse_legacy_devaddr to stress it's not something others should reuse.

Quoted 8 lines

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#18 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Jan Kiszka
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

Quoted 5 lines
Quoted 2 lines

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

Also rename pci_parse_devaddr to pci_parse_legacy_devaddr to stress it's not something others should reuse.

That depends on what pci_parse_devaddr will do in the end. If it will become as general as my qemu_parse_pci_devaddr, "legacy" would be inappropriate.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#19 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Michael S. Tsirkin
Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Jan Kiszka
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

Quoted 5 lines
Quoted 2 lines

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

Also rename pci_parse_devaddr to pci_parse_legacy_devaddr to stress it's not something others should reuse.

That depends on what pci_parse_devaddr will do in the end. If it will become as general as my qemu_parse_pci_devaddr, "legacy" would be inappropriate.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#20 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

Quoted 18 lines · Jan Kiszka
Quoted 17 lines · Michael S. Tsirkin
Quoted 15 lines · Jan Kiszka
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

Quoted 8 lines
Quoted 2 lines

Also rename pci_parse_devaddr to pci_parse_legacy_devaddr to stress it's not something others should reuse.

That depends on what pci_parse_devaddr will do in the end. If it will become as general as my qemu_parse_pci_devaddr, "legacy" would be inappropriate.

Jan

I'd rather keep it separate than adding OPT_LEGACY.

Quoted 3 lines
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#21 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Jan Kiszka
Quoted 18 lines · Jan Kiszka
Quoted 17 lines · Michael S. Tsirkin
Quoted 15 lines · Jan Kiszka
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

Quoted 8 lines
Quoted 2 lines

Also rename pci_parse_devaddr to pci_parse_legacy_devaddr to stress it's not something others should reuse.

That depends on what pci_parse_devaddr will do in the end. If it will become as general as my qemu_parse_pci_devaddr, "legacy" would be inappropriate.

Jan

I'd rather keep it separate than adding OPT_LEGACY.

Quoted 3 lines
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#22 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Jan Kiszka
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

Also rename pci_parse_devaddr to pci_parse_legacy_devaddr to stress it's not something others should reuse.

Quoted 8 lines

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#23 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Jan Kiszka
Quoted 13 lines · Jan Kiszka
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

Quoted 5 lines

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

I agree, actually it looks like patch 10 and 11 would be enough.

Maybe you could extract them and send them out separately?

#24 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

Quoted 17 lines · Stefano Stabellini
Quoted 16 lines · Jan Kiszka
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

Quoted 6 lines
Quoted 2 lines

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

I agree, actually it looks like patch 10 and 11 would be enough.

Maybe you could extract them and send them out separately?

They are still under discussion and waiting for some QOM refactorings to be merged.

Will you be able to use an address parser via some device property?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#25 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Stefano Stabellini
Quoted 17 lines · Stefano Stabellini
Quoted 16 lines · Jan Kiszka
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

Quoted 6 lines
Quoted 2 lines

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

I agree, actually it looks like patch 10 and 11 would be enough.

Maybe you could extract them and send them out separately?

They are still under discussion and waiting for some QOM refactorings to be merged.

Will you be able to use an address parser via some device property?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#26 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

Am 13.06.2012 14:00, schrieb Jan Kiszka:

Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Jan Kiszka
Quoted 5 lines

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

Quoted 6 lines
Quoted 3 lines

I agree, actually it looks like patch 10 and 11 would be enough.

Maybe you could extract them and send them out separately?

They are still under discussion and waiting for some QOM refactorings to be merged.

The first qom-next PULL is already merged into qemu.git (you should've been cc'ed) and I'm actually waiting for you to rebase and send out a v2 and/or to let me know what your/mst's merge time frame is so that we can coordinate the next PULLs.
Currently the semantics discussion looks like we won't merge Paolo's qdev-properties.c movement, so the preview I posted is all that one of us will have to rebase (on).

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#27 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Jan Kiszka

Am 13.06.2012 14:00, schrieb Jan Kiszka:

Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Jan Kiszka
Quoted 5 lines

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

Quoted 6 lines
Quoted 3 lines

I agree, actually it looks like patch 10 and 11 would be enough.

Maybe you could extract them and send them out separately?

They are still under discussion and waiting for some QOM refactorings to be merged.

The first qom-next PULL is already merged into qemu.git (you should've been cc'ed) and I'm actually waiting for you to rebase and send out a v2 and/or to let me know what your/mst's merge time frame is so that we can coordinate the next PULLs.
Currently the semantics discussion looks like we won't merge Paolo's qdev-properties.c movement, so the preview I posted is all that one of us will have to rebase (on).

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#28 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

Quoted 16 lines · Andreas Färber

Am 13.06.2012 14:00, schrieb Jan Kiszka:

Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Jan Kiszka
Quoted 5 lines

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

Quoted 6 lines
Quoted 3 lines

I agree, actually it looks like patch 10 and 11 would be enough.

Maybe you could extract them and send them out separately?

They are still under discussion and waiting for some QOM refactorings to be merged.

Quoted 7 lines

The first qom-next PULL is already merged into qemu.git (you should've been cc'ed) and I'm actually waiting for you to rebase and send out a v2 and/or to let me know what your/mst's merge time frame is so that we can coordinate the next PULLs.
Currently the semantics discussion looks like we won't merge Paolo's qdev-properties.c movement, so the preview I posted is all that one of us will have to rebase (on).

Thanks for the update! I didn't follow the latest details due to local overload.

I would say, give us one or two days to define how v2 of that pci address property should look like. If we cannot agree, you should bypass with your next step.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#29 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Andreas Färber
Quoted 16 lines · Andreas Färber

Am 13.06.2012 14:00, schrieb Jan Kiszka:

Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Jan Kiszka
Quoted 5 lines

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

Quoted 6 lines
Quoted 3 lines

I agree, actually it looks like patch 10 and 11 would be enough.

Maybe you could extract them and send them out separately?

They are still under discussion and waiting for some QOM refactorings to be merged.

Quoted 7 lines

The first qom-next PULL is already merged into qemu.git (you should've been cc'ed) and I'm actually waiting for you to rebase and send out a v2 and/or to let me know what your/mst's merge time frame is so that we can coordinate the next PULLs.
Currently the semantics discussion looks like we won't merge Paolo's qdev-properties.c movement, so the preview I posted is all that one of us will have to rebase (on).

Thanks for the update! I didn't follow the latest details due to local overload.

I would say, give us one or two days to define how v2 of that pci address property should look like. If we cannot agree, you should bypass with your next step.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#30 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Jan Kiszka
Quoted 21 lines · Jan Kiszka
Quoted 20 lines · Stefano Stabellini
Quoted 18 lines · Jan Kiszka
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

Quoted 8 lines
Quoted 3 lines

I agree, actually it looks like patch 10 and 11 would be enough.

Maybe you could extract them and send them out separately?

They are still under discussion and waiting for some QOM refactorings to be merged.

Will you be able to use an address parser via some device property?

Yes. Actually, the address is already a device property.

Signature · 1 line
Anthony PERARD
#31 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Jan Kiszka
Quoted 21 lines · Jan Kiszka
Quoted 20 lines · Stefano Stabellini
Quoted 18 lines · Jan Kiszka
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

Quoted 8 lines
Quoted 3 lines

I agree, actually it looks like patch 10 and 11 would be enough.

Maybe you could extract them and send them out separately?

They are still under discussion and waiting for some QOM refactorings to be merged.

Will you be able to use an address parser via some device property?

Yes. Actually, the address is already a device property.

Signature · 1 line
Anthony PERARD
#32 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

Quoted 24 lines · Anthony PERARD
Quoted 23 lines · Jan Kiszka
Quoted 22 lines · Stefano Stabellini
Quoted 13 lines · Jan Kiszka
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

Quoted 5 lines

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

I agree, actually it looks like patch 10 and 11 would be enough.

Quoted 9 lines
Quoted 6 lines
Quoted 1 line

Maybe you could extract them and send them out separately?

They are still under discussion and waiting for some QOM refactorings to be merged.

Will you be able to use an address parser via some device property?

Yes. Actually, the address is already a device property.

Great. Then we should try to come up with a common pci-host-devaddr property everyone can use.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#33 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Anthony PERARD
Quoted 24 lines · Anthony PERARD
Quoted 23 lines · Jan Kiszka
Quoted 22 lines · Stefano Stabellini
Quoted 13 lines · Jan Kiszka
Quoted 11 lines · Michael S. Tsirkin
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

Quoted 5 lines

We should really consolidate over one parser for Xen, KVM device assignment and VFIO. It looks like they all have very similar requirements.

For those how didn't follow the discussion, see patches 10-13 in
http://thread.gmane.org/gmane.comp.emulators.qemu/153728.

I agree, actually it looks like patch 10 and 11 would be enough.

Quoted 9 lines
Quoted 6 lines
Quoted 1 line

Maybe you could extract them and send them out separately?

They are still under discussion and waiting for some QOM refactorings to be merged.

Will you be able to use an address parser via some device property?

Yes. Actually, the address is already a device property.

Great. Then we should try to come up with a common pci-host-devaddr property everyone can use.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#34 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

Quoted 6 lines · Jan Kiszka
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Will you be able to use an address parser via some device property?

Yes. Actually, the address is already a device property.

Great. Then we should try to come up with a common pci-host-devaddr property everyone can use.

Is this patch would be a good common property?

It's probably close to the patch you send earlier Jan.

If it's good, I'll resend my passthrough patch series with this patch.

hw/qdev-properties.c +98 -0
index b7b5597..9c7a271 100644
@@ -928,6 +928,104 @@ PropertyInfo qdev_prop_blocksize = {
     .max   = 65024,
 };
 
+/* --- pci host address --- */
+
+static void get_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+    char buffer[4 + 2 + 2 + 2 + 1];
+    char *p = buffer;
+
+    snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%d",
+             addr->domain, addr->bus, addr->slot, addr->function);
+
+    visit_type_str(v, &p, name, errp);
+}
+
+/*
+ * Parse [<domain>:]<bus>:<slot>.<func>
+ *   if <domain> is not supplied, it's assumed to be 0.
+ */
+static void set_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+    Error *local_err = NULL;
+    char *str, *p;
+    char *e;
+    unsigned long val;
+    unsigned long dom = 0, bus = 0;
+    unsigned int slot = 0, func = 0;
+
+    if (dev->state != DEV_STATE_CREATED) {
+        error_set(errp, QERR_PERMISSION_DENIED);
+        return;
+    }
+
+    visit_type_str(v, &str, name, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+
+    p = str;
+    val = strtoul(p, &e, 16);
+    if (e == p || *e != ':')
+        goto inval;
+    bus = val;
+
+    p = e + 1;
+    val = strtoul(p, &e, 16);
+    if (e == p)
+        goto inval;
+    if (*e == ':') {
+        dom = bus;
+        bus = val;
+        p = e + 1;
+        val = strtoul(p, &e, 16);
+        if (e == p)
+            goto inval;
+    }
+    slot = val;
+
+    if (*e != '.')
+        goto inval;
+    p = e + 1;
+    val = strtoul(p, &e, 10);
+    if (e == p)
+        goto inval;
+    func = val;
+
+    if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7)
+        goto inval;
+
+    if (*e)
+        goto inval;
+
+    addr->domain = dom;
+    addr->bus = bus;
+    addr->slot = slot;
+    addr->function = func;
+
+    g_free(str);
+    return;
+
+inval:
+    error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
+    g_free(str);
+}
+
+PropertyInfo qdev_prop_pci_host_devaddr = {
+    .name = "pci-host-devaddr",
+    .get = get_pci_host_devaddr,
+    .set = set_pci_host_devaddr,
+};
+
 /* --- public helpers --- */
 
 static Property *qdev_prop_walk(Property *props, const char *name)
hw/qdev.h +3 -0
index 4e90119..9a54ebe 100644
@@ -225,6 +225,7 @@ extern PropertyInfo qdev_prop_netdev;
 extern PropertyInfo qdev_prop_vlan;
 extern PropertyInfo qdev_prop_pci_devfn;
 extern PropertyInfo qdev_prop_blocksize;
+extern PropertyInfo qdev_prop_pci_host_devaddr;
 
 #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
         .name      = (_name),                                    \
@@ -288,6 +289,8 @@ extern PropertyInfo qdev_prop_blocksize;
                         LostTickPolicy)
 #define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
     DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t)
+#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
 
 #define DEFINE_PROP_END_OF_LIST()               \
     {}
qemu-common.h +7 -0
index 91e0562..0d6e51c 100644
@@ -274,6 +274,13 @@ typedef enum LostTickPolicy {
     LOST_TICK_MAX
 } LostTickPolicy;
 
+typedef struct PCIHostDeviceAddress {
+    unsigned int domain;
+    unsigned int bus;
+    unsigned int slot;
+    unsigned int function;
+} PCIHostDeviceAddress;
+
 void tcg_exec_init(unsigned long tb_size);
 bool tcg_enabled(void);
 
Signature · 1 line
Anthony PERARD
#35 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Jan Kiszka
Quoted 6 lines · Jan Kiszka
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Will you be able to use an address parser via some device property?

Yes. Actually, the address is already a device property.

Great. Then we should try to come up with a common pci-host-devaddr property everyone can use.

Is this patch would be a good common property?

It's probably close to the patch you send earlier Jan.

If it's good, I'll resend my passthrough patch series with this patch.

hw/qdev-properties.c +98 -0
index b7b5597..9c7a271 100644
@@ -928,6 +928,104 @@ PropertyInfo qdev_prop_blocksize = {
     .max   = 65024,
 };
 
+/* --- pci host address --- */
+
+static void get_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+    char buffer[4 + 2 + 2 + 2 + 1];
+    char *p = buffer;
+
+    snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%d",
+             addr->domain, addr->bus, addr->slot, addr->function);
+
+    visit_type_str(v, &p, name, errp);
+}
+
+/*
+ * Parse [<domain>:]<bus>:<slot>.<func>
+ *   if <domain> is not supplied, it's assumed to be 0.
+ */
+static void set_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+    Error *local_err = NULL;
+    char *str, *p;
+    char *e;
+    unsigned long val;
+    unsigned long dom = 0, bus = 0;
+    unsigned int slot = 0, func = 0;
+
+    if (dev->state != DEV_STATE_CREATED) {
+        error_set(errp, QERR_PERMISSION_DENIED);
+        return;
+    }
+
+    visit_type_str(v, &str, name, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+
+    p = str;
+    val = strtoul(p, &e, 16);
+    if (e == p || *e != ':')
+        goto inval;
+    bus = val;
+
+    p = e + 1;
+    val = strtoul(p, &e, 16);
+    if (e == p)
+        goto inval;
+    if (*e == ':') {
+        dom = bus;
+        bus = val;
+        p = e + 1;
+        val = strtoul(p, &e, 16);
+        if (e == p)
+            goto inval;
+    }
+    slot = val;
+
+    if (*e != '.')
+        goto inval;
+    p = e + 1;
+    val = strtoul(p, &e, 10);
+    if (e == p)
+        goto inval;
+    func = val;
+
+    if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7)
+        goto inval;
+
+    if (*e)
+        goto inval;
+
+    addr->domain = dom;
+    addr->bus = bus;
+    addr->slot = slot;
+    addr->function = func;
+
+    g_free(str);
+    return;
+
+inval:
+    error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
+    g_free(str);
+}
+
+PropertyInfo qdev_prop_pci_host_devaddr = {
+    .name = "pci-host-devaddr",
+    .get = get_pci_host_devaddr,
+    .set = set_pci_host_devaddr,
+};
+
 /* --- public helpers --- */
 
 static Property *qdev_prop_walk(Property *props, const char *name)
hw/qdev.h +3 -0
index 4e90119..9a54ebe 100644
@@ -225,6 +225,7 @@ extern PropertyInfo qdev_prop_netdev;
 extern PropertyInfo qdev_prop_vlan;
 extern PropertyInfo qdev_prop_pci_devfn;
 extern PropertyInfo qdev_prop_blocksize;
+extern PropertyInfo qdev_prop_pci_host_devaddr;
 
 #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
         .name      = (_name),                                    \
@@ -288,6 +289,8 @@ extern PropertyInfo qdev_prop_blocksize;
                         LostTickPolicy)
 #define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
     DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t)
+#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
 
 #define DEFINE_PROP_END_OF_LIST()               \
     {}
qemu-common.h +7 -0
index 91e0562..0d6e51c 100644
@@ -274,6 +274,13 @@ typedef enum LostTickPolicy {
     LOST_TICK_MAX
 } LostTickPolicy;
 
+typedef struct PCIHostDeviceAddress {
+    unsigned int domain;
+    unsigned int bus;
+    unsigned int slot;
+    unsigned int function;
+} PCIHostDeviceAddress;
+
 void tcg_exec_init(unsigned long tb_size);
 bool tcg_enabled(void);
 
Signature · 1 line
Anthony PERARD
#36 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

Quoted 5 lines · Anthony PERARD
Quoted 4 lines · Jan Kiszka
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Will you be able to use an address parser via some device property?

Yes. Actually, the address is already a device property.

Quoted 8 lines
Quoted 2 lines

Great. Then we should try to come up with a common pci-host-devaddr property everyone can use.

Is this patch would be a good common property?

It's probably close to the patch you send earlier Jan.

If it's good, I'll resend my passthrough patch series with this patch.

Looks generally OK to me, let's try to move forward with this. Please fix the coding style issues before sending.

Quoted 9 lines
hw/qdev-properties.c +0 -0
index b7b5597..9c7a271 100644
@@ -928,6 +928,104 @@ PropertyInfo qdev_prop_blocksize = {
      .max   = 65024,
  };

hw/qdev-properties.c PropertyInfo qdev_prop_blocksize = { · line 939

Quoted 10 lines
hw/qdev-properties.c +9 -0
 
+/* --- pci host address --- */
+
+static void get_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+    char buffer[4 + 2 + 2 + 2 + 1];

Buffer is too small.

Quoted 123 lines
hw/qdev-properties.c +89 -0
+    char *p = buffer;
+
+    snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%d",
+             addr->domain, addr->bus, addr->slot, addr->function);
+
+    visit_type_str(v, &p, name, errp);
+}
+
+/*
+ * Parse [<domain>:]<bus>:<slot>.<func>
+ *   if <domain> is not supplied, it's assumed to be 0.
+ */
+static void set_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+    Error *local_err = NULL;
+    char *str, *p;
+    char *e;
+    unsigned long val;
+    unsigned long dom = 0, bus = 0;
+    unsigned int slot = 0, func = 0;
+
+    if (dev->state != DEV_STATE_CREATED) {
+        error_set(errp, QERR_PERMISSION_DENIED);
+        return;
+    }
+
+    visit_type_str(v, &str, name, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+
+    p = str;
+    val = strtoul(p, &e, 16);
+    if (e == p || *e != ':')
+        goto inval;
+    bus = val;
+
+    p = e + 1;
+    val = strtoul(p, &e, 16);
+    if (e == p)
+        goto inval;
+    if (*e == ':') {
+        dom = bus;
+        bus = val;
+        p = e + 1;
+        val = strtoul(p, &e, 16);
+        if (e == p)
+            goto inval;
+    }
+    slot = val;
+
+    if (*e != '.')
+        goto inval;
+    p = e + 1;
+    val = strtoul(p, &e, 10);
+    if (e == p)
+        goto inval;
+    func = val;
+
+    if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7)
+        goto inval;
+
+    if (*e)
+        goto inval;
+
+    addr->domain = dom;
+    addr->bus = bus;
+    addr->slot = slot;
+    addr->function = func;
+
+    g_free(str);
+    return;
+
+inval:
+    error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
+    g_free(str);
+}
+
+PropertyInfo qdev_prop_pci_host_devaddr = {
+    .name = "pci-host-devaddr",
+    .get = get_pci_host_devaddr,
+    .set = set_pci_host_devaddr,
+};
+
  /* --- public helpers --- */
 
  static Property *qdev_prop_walk(Property *props, const char *name)
hw/qdev.h +3 -0
index 4e90119..9a54ebe 100644
@@ -225,6 +225,7 @@ extern PropertyInfo qdev_prop_netdev;
  extern PropertyInfo qdev_prop_vlan;
  extern PropertyInfo qdev_prop_pci_devfn;
  extern PropertyInfo qdev_prop_blocksize;
+extern PropertyInfo qdev_prop_pci_host_devaddr;
 
  #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
          .name      = (_name),                                    \
@@ -288,6 +289,8 @@ extern PropertyInfo qdev_prop_blocksize;
                          LostTickPolicy)
  #define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
      DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t)
+#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, 
 PCIHostDeviceAddress)
 
  #define DEFINE_PROP_END_OF_LIST()               \
      {}
qemu-common.h +0 -0
index 91e0562..0d6e51c 100644
@@ -274,6 +274,13 @@ typedef enum LostTickPolicy {
      LOST_TICK_MAX
  } LostTickPolicy;
 

qemu-common.h typedef enum LostTickPolicy { · line 286

Quoted 10 lines
qemu-common.h +7 -0
+typedef struct PCIHostDeviceAddress {
+    unsigned int domain;
+    unsigned int bus;
+    unsigned int slot;
+    unsigned int function;
+} PCIHostDeviceAddress;
+
  void tcg_exec_init(unsigned long tb_size);
  bool tcg_enabled(void);
 

Thanks,
Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#37 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Anthony PERARD
Quoted 5 lines · Anthony PERARD
Quoted 4 lines · Jan Kiszka
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Will you be able to use an address parser via some device property?

Yes. Actually, the address is already a device property.

Quoted 8 lines
Quoted 2 lines

Great. Then we should try to come up with a common pci-host-devaddr property everyone can use.

Is this patch would be a good common property?

It's probably close to the patch you send earlier Jan.

If it's good, I'll resend my passthrough patch series with this patch.

Looks generally OK to me, let's try to move forward with this. Please fix the coding style issues before sending.

Quoted 9 lines
hw/qdev-properties.c +0 -0
index b7b5597..9c7a271 100644
@@ -928,6 +928,104 @@ PropertyInfo qdev_prop_blocksize = {
      .max   = 65024,
  };

hw/qdev-properties.c PropertyInfo qdev_prop_blocksize = { · line 939

Quoted 10 lines
hw/qdev-properties.c +9 -0
 
+/* --- pci host address --- */
+
+static void get_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+    char buffer[4 + 2 + 2 + 2 + 1];

Buffer is too small.

Quoted 123 lines
hw/qdev-properties.c +89 -0
+    char *p = buffer;
+
+    snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%d",
+             addr->domain, addr->bus, addr->slot, addr->function);
+
+    visit_type_str(v, &p, name, errp);
+}
+
+/*
+ * Parse [<domain>:]<bus>:<slot>.<func>
+ *   if <domain> is not supplied, it's assumed to be 0.
+ */
+static void set_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+    Error *local_err = NULL;
+    char *str, *p;
+    char *e;
+    unsigned long val;
+    unsigned long dom = 0, bus = 0;
+    unsigned int slot = 0, func = 0;
+
+    if (dev->state != DEV_STATE_CREATED) {
+        error_set(errp, QERR_PERMISSION_DENIED);
+        return;
+    }
+
+    visit_type_str(v, &str, name, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+
+    p = str;
+    val = strtoul(p, &e, 16);
+    if (e == p || *e != ':')
+        goto inval;
+    bus = val;
+
+    p = e + 1;
+    val = strtoul(p, &e, 16);
+    if (e == p)
+        goto inval;
+    if (*e == ':') {
+        dom = bus;
+        bus = val;
+        p = e + 1;
+        val = strtoul(p, &e, 16);
+        if (e == p)
+            goto inval;
+    }
+    slot = val;
+
+    if (*e != '.')
+        goto inval;
+    p = e + 1;
+    val = strtoul(p, &e, 10);
+    if (e == p)
+        goto inval;
+    func = val;
+
+    if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7)
+        goto inval;
+
+    if (*e)
+        goto inval;
+
+    addr->domain = dom;
+    addr->bus = bus;
+    addr->slot = slot;
+    addr->function = func;
+
+    g_free(str);
+    return;
+
+inval:
+    error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
+    g_free(str);
+}
+
+PropertyInfo qdev_prop_pci_host_devaddr = {
+    .name = "pci-host-devaddr",
+    .get = get_pci_host_devaddr,
+    .set = set_pci_host_devaddr,
+};
+
  /* --- public helpers --- */
 
  static Property *qdev_prop_walk(Property *props, const char *name)
hw/qdev.h +3 -0
index 4e90119..9a54ebe 100644
@@ -225,6 +225,7 @@ extern PropertyInfo qdev_prop_netdev;
  extern PropertyInfo qdev_prop_vlan;
  extern PropertyInfo qdev_prop_pci_devfn;
  extern PropertyInfo qdev_prop_blocksize;
+extern PropertyInfo qdev_prop_pci_host_devaddr;
 
  #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
          .name      = (_name),                                    \
@@ -288,6 +289,8 @@ extern PropertyInfo qdev_prop_blocksize;
                          LostTickPolicy)
  #define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
      DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t)
+#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, 
 PCIHostDeviceAddress)
 
  #define DEFINE_PROP_END_OF_LIST()               \
      {}
qemu-common.h +0 -0
index 91e0562..0d6e51c 100644
@@ -274,6 +274,13 @@ typedef enum LostTickPolicy {
      LOST_TICK_MAX
  } LostTickPolicy;
 

qemu-common.h typedef enum LostTickPolicy { · line 286

Quoted 10 lines
qemu-common.h +7 -0
+typedef struct PCIHostDeviceAddress {
+    unsigned int domain;
+    unsigned int bus;
+    unsigned int slot;
+    unsigned int function;
+} PCIHostDeviceAddress;
+
  void tcg_exec_init(unsigned long tb_size);
  bool tcg_enabled(void);
 

Thanks,
Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#38 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

Quoted 7 lines · Jan Kiszka
Quoted 5 lines

Is this patch would be a good common property?

It's probably close to the patch you send earlier Jan.

If it's good, I'll resend my passthrough patch series with this patch.

Looks generally OK to me, let's try to move forward with this. Please fix the coding style issues before sending.

I fix the patch a resend the series.

Thanks,

Signature · 1 line
Anthony PERARD
#39 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Jan Kiszka
Quoted 7 lines · Jan Kiszka
Quoted 5 lines

Is this patch would be a good common property?

It's probably close to the patch you send earlier Jan.

If it's good, I'll resend my passthrough patch series with this patch.

Looks generally OK to me, let's try to move forward with this. Please fix the coding style issues before sending.

I fix the patch a resend the series.

Thanks,

Signature · 1 line
Anthony PERARD
#40 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Anthony PERARD
Quoted 22 lines · Anthony PERARD
Quoted 6 lines · Jan Kiszka
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Will you be able to use an address parser via some device property?

Yes. Actually, the address is already a device property.

Great. Then we should try to come up with a common pci-host-devaddr property everyone can use.

Is this patch would be a good common property?

It's probably close to the patch you send earlier Jan.

If it's good, I'll resend my passthrough patch series with this patch.

hw/qdev-properties.c +0 -0
index b7b5597..9c7a271 100644
@@ -928,6 +928,104 @@ PropertyInfo qdev_prop_blocksize = {
     .max   = 65024,
 };

hw/qdev-properties.c PropertyInfo qdev_prop_blocksize = { · line 939

Quoted 10 lines
hw/qdev-properties.c +9 -0
 
+/* --- pci host address --- */
+
+static void get_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+    char buffer[4 + 2 + 2 + 2 + 1];

One trick is this:

    char buffer[] = "XXXX:XX:XX.X";

And comparing with the above, your buffer looks too short, doesn't it?

hw/qdev-properties.c PropertyInfo qdev_prop_blocksize = { · line 943

Quoted 4 lines
hw/qdev-properties.c +4 -0
+    char *p = buffer;
+
+    snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%d",
+             addr->domain, addr->bus, addr->slot, addr->function);

A good idea might be to check the return code. assert(ret <= sizeof buf).

Quoted 131 lines
hw/qdev-properties.c +85 -0
+
+    visit_type_str(v, &p, name, errp);
+}
+
+/*
+ * Parse [<domain>:]<bus>:<slot>.<func>
+ *   if <domain> is not supplied, it's assumed to be 0.
+ */
+static void set_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+    Error *local_err = NULL;
+    char *str, *p;
+    char *e;
+    unsigned long val;
+    unsigned long dom = 0, bus = 0;
+    unsigned int slot = 0, func = 0;
+
+    if (dev->state != DEV_STATE_CREATED) {
+        error_set(errp, QERR_PERMISSION_DENIED);
+        return;
+    }
+
+    visit_type_str(v, &str, name, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+
+    p = str;
+    val = strtoul(p, &e, 16);
+    if (e == p || *e != ':')
+        goto inval;
+    bus = val;
+
+    p = e + 1;
+    val = strtoul(p, &e, 16);
+    if (e == p)
+        goto inval;
+    if (*e == ':') {
+        dom = bus;
+        bus = val;
+        p = e + 1;
+        val = strtoul(p, &e, 16);
+        if (e == p)
+            goto inval;
+    }
+    slot = val;
+
+    if (*e != '.')
+        goto inval;
+    p = e + 1;
+    val = strtoul(p, &e, 10);
+    if (e == p)
+        goto inval;
+    func = val;
+
+    if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7)
+        goto inval;
+
+    if (*e)
+        goto inval;
+
+    addr->domain = dom;
+    addr->bus = bus;
+    addr->slot = slot;
+    addr->function = func;
+
+    g_free(str);
+    return;
+
+inval:
+    error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
+    g_free(str);
+}
+
+PropertyInfo qdev_prop_pci_host_devaddr = {
+    .name = "pci-host-devaddr",
+    .get = get_pci_host_devaddr,
+    .set = set_pci_host_devaddr,
+};
+
 /* --- public helpers --- */
 
 static Property *qdev_prop_walk(Property *props, const char *name)
hw/qdev.h +3 -0
index 4e90119..9a54ebe 100644
@@ -225,6 +225,7 @@ extern PropertyInfo qdev_prop_netdev;
 extern PropertyInfo qdev_prop_vlan;
 extern PropertyInfo qdev_prop_pci_devfn;
 extern PropertyInfo qdev_prop_blocksize;
+extern PropertyInfo qdev_prop_pci_host_devaddr;
 
 #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
         .name      = (_name),                                    \
@@ -288,6 +289,8 @@ extern PropertyInfo qdev_prop_blocksize;
                         LostTickPolicy)
 #define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
     DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t)
+#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr,
 PCIHostDeviceAddress)
 
 #define DEFINE_PROP_END_OF_LIST()               \
     {}
qemu-common.h +7 -0
index 91e0562..0d6e51c 100644
@@ -274,6 +274,13 @@ typedef enum LostTickPolicy {
     LOST_TICK_MAX
 } LostTickPolicy;
 
+typedef struct PCIHostDeviceAddress {
+    unsigned int domain;
+    unsigned int bus;
+    unsigned int slot;
+    unsigned int function;
+} PCIHostDeviceAddress;
+
 void tcg_exec_init(unsigned long tb_size);
 bool tcg_enabled(void);
 
Signature · 2 lines
-- 
Anthony PERARD
#41 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Anthony PERARD
Quoted 22 lines · Anthony PERARD
Quoted 6 lines · Jan Kiszka
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Will you be able to use an address parser via some device property?

Yes. Actually, the address is already a device property.

Great. Then we should try to come up with a common pci-host-devaddr property everyone can use.

Is this patch would be a good common property?

It's probably close to the patch you send earlier Jan.

If it's good, I'll resend my passthrough patch series with this patch.

hw/qdev-properties.c +0 -0
index b7b5597..9c7a271 100644
@@ -928,6 +928,104 @@ PropertyInfo qdev_prop_blocksize = {
     .max   = 65024,
 };

hw/qdev-properties.c PropertyInfo qdev_prop_blocksize = { · line 939

Quoted 10 lines
hw/qdev-properties.c +9 -0
 
+/* --- pci host address --- */
+
+static void get_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+    char buffer[4 + 2 + 2 + 2 + 1];

One trick is this:

    char buffer[] = "XXXX:XX:XX.X";

And comparing with the above, your buffer looks too short, doesn't it?

hw/qdev-properties.c PropertyInfo qdev_prop_blocksize = { · line 943

Quoted 4 lines
hw/qdev-properties.c +4 -0
+    char *p = buffer;
+
+    snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%d",
+             addr->domain, addr->bus, addr->slot, addr->function);

A good idea might be to check the return code. assert(ret <= sizeof buf).

Quoted 131 lines
hw/qdev-properties.c +85 -0
+
+    visit_type_str(v, &p, name, errp);
+}
+
+/*
+ * Parse [<domain>:]<bus>:<slot>.<func>
+ *   if <domain> is not supplied, it's assumed to be 0.
+ */
+static void set_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+    Error *local_err = NULL;
+    char *str, *p;
+    char *e;
+    unsigned long val;
+    unsigned long dom = 0, bus = 0;
+    unsigned int slot = 0, func = 0;
+
+    if (dev->state != DEV_STATE_CREATED) {
+        error_set(errp, QERR_PERMISSION_DENIED);
+        return;
+    }
+
+    visit_type_str(v, &str, name, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+
+    p = str;
+    val = strtoul(p, &e, 16);
+    if (e == p || *e != ':')
+        goto inval;
+    bus = val;
+
+    p = e + 1;
+    val = strtoul(p, &e, 16);
+    if (e == p)
+        goto inval;
+    if (*e == ':') {
+        dom = bus;
+        bus = val;
+        p = e + 1;
+        val = strtoul(p, &e, 16);
+        if (e == p)
+            goto inval;
+    }
+    slot = val;
+
+    if (*e != '.')
+        goto inval;
+    p = e + 1;
+    val = strtoul(p, &e, 10);
+    if (e == p)
+        goto inval;
+    func = val;
+
+    if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7)
+        goto inval;
+
+    if (*e)
+        goto inval;
+
+    addr->domain = dom;
+    addr->bus = bus;
+    addr->slot = slot;
+    addr->function = func;
+
+    g_free(str);
+    return;
+
+inval:
+    error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
+    g_free(str);
+}
+
+PropertyInfo qdev_prop_pci_host_devaddr = {
+    .name = "pci-host-devaddr",
+    .get = get_pci_host_devaddr,
+    .set = set_pci_host_devaddr,
+};
+
 /* --- public helpers --- */
 
 static Property *qdev_prop_walk(Property *props, const char *name)
hw/qdev.h +3 -0
index 4e90119..9a54ebe 100644
@@ -225,6 +225,7 @@ extern PropertyInfo qdev_prop_netdev;
 extern PropertyInfo qdev_prop_vlan;
 extern PropertyInfo qdev_prop_pci_devfn;
 extern PropertyInfo qdev_prop_blocksize;
+extern PropertyInfo qdev_prop_pci_host_devaddr;
 
 #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
         .name      = (_name),                                    \
@@ -288,6 +289,8 @@ extern PropertyInfo qdev_prop_blocksize;
                         LostTickPolicy)
 #define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
     DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t)
+#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr,
 PCIHostDeviceAddress)
 
 #define DEFINE_PROP_END_OF_LIST()               \
     {}
qemu-common.h +7 -0
index 91e0562..0d6e51c 100644
@@ -274,6 +274,13 @@ typedef enum LostTickPolicy {
     LOST_TICK_MAX
 } LostTickPolicy;
 
+typedef struct PCIHostDeviceAddress {
+    unsigned int domain;
+    unsigned int bus;
+    unsigned int slot;
+    unsigned int function;
+} PCIHostDeviceAddress;
+
 void tcg_exec_init(unsigned long tb_size);
 bool tcg_enabled(void);
 
Signature · 2 lines
-- 
Anthony PERARD
#42 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

Quoted 24 lines · Michael S. Tsirkin
Quoted 15 lines
Quoted 15 lines

Is this patch would be a good common property?

It's probably close to the patch you send earlier Jan.

If it's good, I'll resend my passthrough patch series with this patch.

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index b7b5597..9c7a271 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c

 @@ -928,6 +928,104 @@ PropertyInfo qdev_prop_blocksize = {
       .max   = 65024,

};

Quoted 9 lines
Quoted 9 lines

+/* --- pci host address --- */
+
+static void get_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{

 +    DeviceState *dev = DEVICE(obj);
 +    Property *prop = opaque;
 +    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
 +    char buffer[4 + 2 + 2 + 2 + 1];
Quoted 2 lines

One trick is this:

     char buffer[] = "XXXX:XX:XX.X";

I love this trick, even if it use a bit of space in the binary, I think. I will use it.

Quoted 1 line

And comparing with the above, your buffer looks too short, doesn't it?

Yes, I think I forgot to count the ':'s and '.'.

Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

+ char *p = buffer;
+
+ snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%d",
+ addr->domain, addr->bus, addr->slot, addr->function);

A good idea might be to check the return code. assert(ret<= sizeof buf).

I will.

Thanks,

Signature · 1 line
Anthony PERARD
#43 lore raw

Re: [Qemu-devel] [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Michael S. Tsirkin
Quoted 24 lines · Michael S. Tsirkin
Quoted 15 lines
Quoted 15 lines

Is this patch would be a good common property?

It's probably close to the patch you send earlier Jan.

If it's good, I'll resend my passthrough patch series with this patch.

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index b7b5597..9c7a271 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c

 @@ -928,6 +928,104 @@ PropertyInfo qdev_prop_blocksize = {
       .max   = 65024,

};

Quoted 9 lines
Quoted 9 lines

+/* --- pci host address --- */
+
+static void get_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{

 +    DeviceState *dev = DEVICE(obj);
 +    Property *prop = opaque;
 +    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
 +    char buffer[4 + 2 + 2 + 2 + 1];
Quoted 2 lines

One trick is this:

     char buffer[] = "XXXX:XX:XX.X";

I love this trick, even if it use a bit of space in the binary, I think. I will use it.

Quoted 1 line

And comparing with the above, your buffer looks too short, doesn't it?

Yes, I think I forgot to count the ':'s and '.'.

Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

+ char *p = buffer;
+
+ snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%d",
+ addr->domain, addr->bus, addr->slot, addr->function);

A good idea might be to check the return code. assert(ret<= sizeof buf).

I will.

Thanks,

Signature · 1 line
Anthony PERARD
#44 lore raw

Re: [PATCH V12 5/9] Revert "pci: don't export an internal function"

In reply to Anthony PERARD
Quoted 6 lines · Anthony PERARD

This reverts commit 94a09e2c846374a96719cda2b4e1312d8c4b08a7.

This function is used by a later patch to parse the BDF of the device to passthrough.

You probably want to parse the host address? You don't want to copy the bugs in pci_parse_devaddr - write your own that has sane semantics for host. E.g. you need to support ARI etc.

Quoted 33 lines
---
 hw/pci.c |    2 +-
 hw/pci.h |    2 ++
 2 files changed, 3 insertions(+), 1 deletions(-)
hw/pci.c +1 -1
index eec106a..5bddf7a 100644
@@ -479,7 +479,7 @@ static void pci_set_default_subsystem_id(PCIDevice *pci_dev)
  * Parse [[<domain>:]<bus>:]<slot>, return -1 on error if funcp == NULL
  *       [[<domain>:]<bus>:]<slot>.<func>, return -1 on error
  */
-static int pci_parse_devaddr(const char *addr, int *domp, int *busp,
+int pci_parse_devaddr(const char *addr, int *domp, int *busp,
                       unsigned int *slotp, unsigned int *funcp)
 {
     const char *p;
hw/pci.h +2 -0
index ecf37fd..b169c0b 100644
@@ -321,6 +321,8 @@ PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
 int pci_qdev_find_device(const char *id, PCIDevice **pdev);
 PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr);
 
+int pci_parse_devaddr(const char *addr, int *domp, int *busp,
+                      unsigned int *slotp, unsigned int *funcp);
 int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
                      unsigned *slotp);
 
Signature · 1 line
Anthony PERARD
#45 lore raw

PATCH v12 6/9 Introduce Xen PCI Passthrough, qdevice (1/3)

In reply to Anthony PERARD

From: Allen Kay <[email protected]>

A more complete history can be found here:
git://xenbits.xensource.com/qemu-xen-unstable.git

---
 hw/i386/Makefile.objs   |    1 +
 hw/xen_common.h         |    3 +
 hw/xen_pt.c             |  815 +++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_pt.h             |  248 ++++++++++++++
 hw/xen_pt_config_init.c |   11 +
 xen-all.c               |   12 +
 6 files changed, 1090 insertions(+), 0 deletions(-)
 create mode 100644 hw/xen_pt.c
 create mode 100644 hw/xen_pt.h
 create mode 100644 hw/xen_pt_config_init.c
hw/i386/Makefile.objs +1 -0
index b719d8e..e361a92 100644
@@ -8,6 +8,7 @@ obj-y += pc_piix.o
 obj-y += pc_sysfw.o
 obj-$(CONFIG_XEN) += xen_platform.o xen_apic.o
 obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o
+obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o
 obj-$(CONFIG_KVM) += kvm/clock.o kvm/apic.o kvm/i8259.o kvm/ioapic.o kvm/i8254.o
 obj-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o
 
hw/xen_common.h +3 -0
index fe7f227..03b0bb1 100644
@@ -150,4 +150,7 @@ static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom,
 
 void destroy_hvm_domain(bool reboot);
 
+/* shutdown/destroy current domain because of an error */
+void xen_shutdown_fatal_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+
 #endif /* QEMU_HW_XEN_COMMON_H */
hw/xen_pt.c new file +815 -0

815 lines not on this page · raw message

hw/xen_pt.h new file +248 -0

248 lines not on this page · raw message

hw/xen_pt_config_init.c new file +11 -0
new file mode 100644
index 0000000..64d22e8
@@ -0,0 +1,11 @@
+#include "xen_pt.h"
+
+XenPTRegGroup *xen_pt_find_reg_grp(XenPCIPassthroughState *s, uint32_t address)
+{
+    return NULL;
+}
+
+XenPTReg *xen_pt_find_reg(XenPTRegGroup *reg_grp, uint32_t address)
+{
+    return NULL;
+}
xen-all.c +12 -0
index b5220cc..59f2323 100644
@@ -1191,3 +1191,15 @@ void xen_register_framebuffer(MemoryRegion *mr)
 {
     framebuffer = mr;
 }
+
+void xen_shutdown_fatal_error(const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    vfprintf(stderr, fmt, ap);
+    va_end(ap);
+    fprintf(stderr, "Will destroy the domain.\n");
+    /* destroy the domain */
+    qemu_system_shutdown_request();
+}
Signature · 1 line
Anthony PERARD
#46 lore raw

PATCH v12 7/9 Introduce Xen PCI Passthrough, PCI config space helpers (2/3)

In reply to Anthony PERARD

From: Allen Kay <[email protected]>

A more complete history can be found here:
git://xenbits.xensource.com/qemu-xen-unstable.git

---
 hw/xen_pt.c             |   10 +
 hw/xen_pt.h             |    2 +
 hw/xen_pt_config_init.c | 1387 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1399 insertions(+), 0 deletions(-)
hw/xen_pt.c +10 -0
index c4c5dc3..6fad7ff 100644
@@ -676,6 +676,13 @@ static int xen_pt_initfn(PCIDevice *d)
     /* Handle real device's MMIO/PIO BARs */
     xen_pt_register_regions(s);
 
+    /* reinitialize each config register to be emulated */
+    if (xen_pt_config_init(s)) {
+        XEN_PT_ERR(d, "PCI Config space initialisation failed.\n");
+        xen_host_pci_device_put(&s->real_device);
+        return -1;
+    }
+
     /* Bind interrupt */
     if (!s->dev.config[PCI_INTERRUPT_PIN]) {
         XEN_PT_LOG(d, "no pin interrupt\n");
@@ -774,6 +781,9 @@ static int xen_pt_unregister_device(PCIDevice *d)
         }
     }
 
+    /* delete all emulated config registers */
+    xen_pt_config_delete(s);
+
     xen_pt_unregister_regions(s);
     memory_listener_unregister(&s->memory_listener);
 
hw/xen_pt.h +2 -0
index f029841..4bb8cb6 100644
@@ -62,6 +62,8 @@ typedef int (*xen_pt_conf_byte_read)
 #define XEN_PT_BAR_ALLF 0xFFFFFFFF
 #define XEN_PT_BAR_UNMAPPED (-1)
 
+#define PCI_CAP_MAX 48
+
 
 typedef enum {
     XEN_PT_GRP_TYPE_HARDWIRED = 0,  /* 0 Hardwired reg group */
hw/xen_pt_config_init.c +1387 -0

1,398 lines not on this page · raw message

Signature · 1 line
Anthony PERARD
#47 lore raw

PATCH v12 8/9 Introduce apic-msidef.h

In reply to Anthony PERARD

This patch move the msi definition from apic.c to apic-msidef.h. So it can be used also by other .c files.

---
 hw/apic-msidef.h |   30 ++++++++++++++++++++++++++++++
 hw/apic.c        |   11 +----------
 2 files changed, 31 insertions(+), 10 deletions(-)
 create mode 100644 hw/apic-msidef.h
hw/apic-msidef.h new file +30 -0
new file mode 100644
index 0000000..6e2eb71
@@ -0,0 +1,30 @@
+#ifndef HW_APIC_MSIDEF_H
+#define HW_APIC_MSIDEF_H
+
+/*
+ * Intel APIC constants: from include/asm/msidef.h
+ */
+
+/*
+ * Shifts for MSI data
+ */
+
+#define MSI_DATA_VECTOR_SHIFT           0
+#define  MSI_DATA_VECTOR_MASK           0x000000ff
+
+#define MSI_DATA_DELIVERY_MODE_SHIFT    8
+#define MSI_DATA_LEVEL_SHIFT            14
+#define MSI_DATA_TRIGGER_SHIFT          15
+
+/*
+ * Shift/mask fields for msi address
+ */
+
+#define MSI_ADDR_DEST_MODE_SHIFT        2
+
+#define MSI_ADDR_REDIRECTION_SHIFT      3
+
+#define MSI_ADDR_DEST_ID_SHIFT          12
+#define  MSI_ADDR_DEST_ID_MASK          0x00ffff0
+
+#endif /* HW_APIC_MSIDEF_H */
hw/apic.c +1 -10
index 5fbf01c..60552df 100644
@@ -23,19 +23,10 @@
 #include "host-utils.h"
 #include "trace.h"
 #include "pc.h"
+#include "apic-msidef.h"
 
 #define MAX_APIC_WORDS 8
 
-/* Intel APIC constants: from include/asm/msidef.h */
-#define MSI_DATA_VECTOR_SHIFT		0
-#define MSI_DATA_VECTOR_MASK		0x000000ff
-#define MSI_DATA_DELIVERY_MODE_SHIFT	8
-#define MSI_DATA_TRIGGER_SHIFT		15
-#define MSI_DATA_LEVEL_SHIFT		14
-#define MSI_ADDR_DEST_MODE_SHIFT	2
-#define MSI_ADDR_DEST_ID_SHIFT		12
-#define	MSI_ADDR_DEST_ID_MASK		0x00ffff0
-
 #define SYNC_FROM_VAPIC                 0x1
 #define SYNC_TO_VAPIC                   0x2
 #define SYNC_ISR_IRR_TO_VAPIC           0x4
Signature · 1 line
Anthony PERARD
#48 lore raw

PATCH v12 9/9 Introduce Xen PCI Passthrough, MSI (3/3)

In reply to Anthony PERARD

From: Jiang Yunhong <[email protected]>

A more complete history can be found here:
git://xenbits.xensource.com/qemu-xen-unstable.git

---
 hw/i386/Makefile.objs   |    2 +-
 hw/xen_pt.c             |   31 +++-
 hw/xen_pt.h             |   51 ++++
 hw/xen_pt_config_init.c |  471 +++++++++++++++++++++++++++++++++++
 hw/xen_pt_msi.c         |  620 +++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 1173 insertions(+), 2 deletions(-)
 create mode 100644 hw/xen_pt_msi.c
hw/i386/Makefile.objs +1 -1
index e361a92..d364c37 100644
@@ -8,7 +8,7 @@ obj-y += pc_piix.o
 obj-y += pc_sysfw.o
 obj-$(CONFIG_XEN) += xen_platform.o xen_apic.o
 obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o
-obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o
+obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_msi.o
 obj-$(CONFIG_KVM) += kvm/clock.o kvm/apic.o kvm/i8259.o kvm/ioapic.o kvm/i8254.o
 obj-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o
 
hw/xen_pt.c +30 -1
index 6fad7ff..458b8cc 100644
@@ -36,6 +36,20 @@
  *
  *     Write '1'
  *       - Set real bit to '1'.
+ *
+ * MSI interrupt:
+ *   Initialize MSI register(xen_pt_msi_setup, xen_pt_msi_update)
+ *     Bind MSI(xc_domain_update_msi_irq)
+ *       <fail>
+ *         - Unmap MSI.
+ *         - Set dev->msi->pirq to '-1'.
+ *
+ * MSI-X interrupt:
+ *   Initialize MSI-X register(xen_pt_msix_update_one)
+ *     Bind MSI-X(xc_domain_update_msi_irq)
+ *       <fail>
+ *         - Unmap MSI-X.
+ *         - Set entry->pirq to '-1'.
  */
 
 #include <sys/ioctl.h>
@@ -534,7 +548,15 @@ static void xen_pt_region_update(XenPCIPassthroughState *s,
     };
 
     bar = xen_pt_bar_from_region(s, mr);
-    if (bar == -1) {
+    if (bar == -1 && (!s->msix || &s->msix->mmio != mr)) {
+        return;
+    }
+
+    if (s->msix && &s->msix->mmio == mr) {
+        if (adding) {
+            s->msix->mmio_base_addr = sec->offset_within_address_space;
+            rc = xen_pt_msix_update_remap(s, s->msix->bar_index);
+        }
         return;
     }
 
@@ -767,6 +789,13 @@ static int xen_pt_unregister_device(PCIDevice *d)
         }
     }
 
+    if (s->msi) {
+        xen_pt_msi_disable(s);
+    }
+    if (s->msix) {
+        xen_pt_msix_disable(s);
+    }
+
     if (machine_irq) {
         xen_pt_mapped_machine_irq[machine_irq]--;
 
hw/xen_pt.h +51 -0

67 lines not on this page · raw message

hw/xen_pt_config_init.c +471 -0

501 lines not on this page · raw message

hw/xen_pt_msi.c new file +620 -0

620 lines not on this page · raw message

Signature · 1 line
Anthony PERARD