Skip to contentSkip to conversation

hw/xen: pass PCI domain to xc_physdev_map_pirq_msi()

PATCH In review Roger Pau Monne 5 participants 6 messages Oct 17, 2025 – Oct 23, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/xen: pass PCI domain to xc_physdev_map_pirq_msi()

It's currently impossible for passthrough devices on segment different than 0 to work correctly, as the PCI domain is not provided to xc_physdev_map_pirq_msi(), and hence it's unconditionally assumed that all devices are on segment 0.

Adjust the call to xc_physdev_map_pirq_msi() to pass the PCI domain in the high 16bits of the bus parameter. On versions of Xen where this is not supported the passed segment will be ignored and assume to be 0, no worse than the current state.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony PERARD <[email protected]>
Cc: Paul Durrant <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: [email protected]

---
 hw/xen/xen_pt_msi.c | 1 +
 1 file changed, 1 insertion(+)
hw/xen/xen_pt_msi.c +1 -0
index e9ba17317aba..df15ccf0d030 100644
@@ -138,6 +138,7 @@ static int msi_msix_setup(XenPCIPassthroughState *s,
         rc = xc_physdev_map_pirq_msi(xen_xc, xen_domid, XEN_PT_AUTO_ASSIGN,
                                      ppirq, PCI_DEVFN(s->real_device.dev,
                                                       s->real_device.func),
+                                     ((uint32_t)s->real_device.domain << 16) |
                                      s->real_device.bus,
                                      msix_entry, table_base);
         if (rc) {
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Roger Pau Monne

It's currently impossible for passthrough devices on segment different than 0 to work correctly, as the PCI domain is not provided to xc_physdev_map_pirq_msi(), and hence it's unconditionally assumed that all devices are on segment 0.

Adjust the call to xc_physdev_map_pirq_msi() to pass the PCI domain in the high 16bits of the bus parameter. On versions of Xen where this is not supported the passed segment will be ignored and assume to be 0, no worse

typo: assumed

Quoted 18 lines

than the current state.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony PERARD <[email protected]>
Cc: Paul Durrant <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: [email protected]

---
 hw/xen/xen_pt_msi.c | 1 +
 1 file changed, 1 insertion(+)
hw/xen/xen_pt_msi.c +0 -0
index e9ba17317aba..df15ccf0d030 100644

hw/xen/xen_pt_msi.c static int msi_msix_setup(XenPCIPassthroughState *s, · line 144

Quoted 7 lines
hw/xen/xen_pt_msi.c +1 -0
@@ -138,6 +138,7 @@ static int msi_msix_setup(XenPCIPassthroughState *s,
         rc = xc_physdev_map_pirq_msi(xen_xc, xen_domid, XEN_PT_AUTO_ASSIGN,
                                      ppirq, PCI_DEVFN(s->real_device.dev,
                                                       s->real_device.func),
+                                     ((uint32_t)s->real_device.domain << 16) |
                                      s->real_device.bus,
                                      msix_entry, table_base);
         if (rc) {

This was tested on a real machine.

Frediano

Reviewed-by on v1 1/1
#2 lore raw
In reply to Roger Pau Monne
Quoted 11 lines · Roger Pau Monne

It's currently impossible for passthrough devices on segment different than 0 to work correctly, as the PCI domain is not provided to xc_physdev_map_pirq_msi(), and hence it's unconditionally assumed that all devices are on segment 0.

Adjust the call to xc_physdev_map_pirq_msi() to pass the PCI domain in the high 16bits of the bus parameter. On versions of Xen where this is not supported the passed segment will be ignored and assume to be 0, no worse than the current state.

Thanks,

Signature · 1 line
Anthony PERARD
Reviewed-by on v1 1/1
#3 lore raw
In reply to Roger Pau Monne
Quoted 5 lines · Roger Pau Monne

It's currently impossible for passthrough devices on segment different than 0 to work correctly, as the PCI domain is not provided to xc_physdev_map_pirq_msi(), and hence it's unconditionally assumed that all devices are on segment 0.

Quoted 7 lines

Adjust the call to xc_physdev_map_pirq_msi() to pass the PCI domain in the high 16bits of the bus parameter. On versions of Xen where this is not supported the passed segment will be ignored and assume to be 0, no worse than the current state.

#4 lore raw
In reply to Roger Pau Monne
Quoted 26 lines · Roger Pau Monne

It's currently impossible for passthrough devices on segment different than 0 to work correctly, as the PCI domain is not provided to xc_physdev_map_pirq_msi(), and hence it's unconditionally assumed that all devices are on segment 0.

Adjust the call to xc_physdev_map_pirq_msi() to pass the PCI domain in the high 16bits of the bus parameter. On versions of Xen where this is not supported the passed segment will be ignored and assume to be 0, no worse than the current state.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony PERARD <[email protected]>
Cc: Paul Durrant <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: [email protected]

---
  hw/xen/xen_pt_msi.c | 1 +
  1 file changed, 1 insertion(+)
hw/xen/xen_pt_msi.c +0 -0
index e9ba17317aba..df15ccf0d030 100644

hw/xen/xen_pt_msi.c static int msi_msix_setup(XenPCIPassthroughState *s, · line 142

Quoted 5 lines
hw/xen/xen_pt_msi.c +1 -0
@@ -138,6 +138,7 @@ static int msi_msix_setup(XenPCIPassthroughState *s,
          rc = xc_physdev_map_pirq_msi(xen_xc, xen_domid, XEN_PT_AUTO_ASSIGN,
                                       ppirq, PCI_DEVFN(s->real_device.dev,
                                                        s->real_device.func),
+                                     ((uint32_t)s->real_device.domain << 16) |
                                       s->real_device.bus,

Alternatively:

deposit32(s->real_device.bus, 16, 16, s->real_device.domain)

hw/xen/xen_pt_msi.c static int msi_msix_setup(XenPCIPassthroughState *s, · line 144

Quoted 2 lines
hw/xen/xen_pt_msi.c +0 -0
                                       msix_entry, table_base);
          if (rc) {

Patch queued, thanks!

#5 lore raw
Quoted 35 lines · Philippe Mathieu-Daudé
Quoted 26 lines · Roger Pau Monne

It's currently impossible for passthrough devices on segment different than 0 to work correctly, as the PCI domain is not provided to xc_physdev_map_pirq_msi(), and hence it's unconditionally assumed that all devices are on segment 0.

Adjust the call to xc_physdev_map_pirq_msi() to pass the PCI domain in the high 16bits of the bus parameter. On versions of Xen where this is not supported the passed segment will be ignored and assume to be 0, no worse than the current state.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony PERARD <[email protected]>
Cc: Paul Durrant <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: [email protected]

---
  hw/xen/xen_pt_msi.c | 1 +
  1 file changed, 1 insertion(+)
hw/xen/xen_pt_msi.c +0 -0
index e9ba17317aba..df15ccf0d030 100644

hw/xen/xen_pt_msi.c static int msi_msix_setup(XenPCIPassthroughState *s, · line 142

Quoted 5 lines
hw/xen/xen_pt_msi.c +1 -0
@@ -138,6 +138,7 @@ static int msi_msix_setup(XenPCIPassthroughState *s,
          rc = xc_physdev_map_pirq_msi(xen_xc, xen_domid, XEN_PT_AUTO_ASSIGN,
                                       ppirq, PCI_DEVFN(s->real_device.dev,
                                                        s->real_device.func),
+                                     ((uint32_t)s->real_device.domain << 16) |
                                       s->real_device.bus,

Alternatively:

Quoted 1 line

deposit32(s->real_device.bus, 16, 16, s->real_device.domain)

Oh, I have to admit I'm not that well versed in QEMU, so didn't even knew this existed.

Thanks for picking it up.