Skip to contentSkip to conversation

tools/libxc: fix xc_physdev_map_pirq_msi() with PCI segments != 0

PATCH Superseded Roger Pau Monne 4 participants 7 messages Oct 17, 2025 – Oct 20, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/libxc: fix xc_physdev_map_pirq_msi() with PCI segments != 0

Otherwise it's not possible for device models to map IRQs of devices on segments different than 0. Keep the same function prototype and pass the segment in the high 16bits of the bus parameter, like it's done for the hypercall itself.

Fixes 7620c0cf9a4d ("PCI multi-seg: add new physdevop-s")

---
I think it's 4.21 material, as otherwise it's not possible to passthrough PCI devices on segments != 0.

---
 tools/libs/ctrl/xc_physdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libs/ctrl/xc_physdev.c +1 -1
index 25e686d7b389..1307d6836d72 100644
@@ -79,7 +79,7 @@ int xc_physdev_map_pirq_msi(xc_interface *xch,
     }
     memset(&map, 0, sizeof(struct physdev_map_pirq));
     map.domid = domid;
-    map.type = MAP_PIRQ_TYPE_MSI;
+    map.type = MAP_PIRQ_TYPE_MSI_SEG;
     map.index = index;
     map.pirq = *pirq;
     map.bus = bus;
Signature · 1 line
2.51.0
#1 lore raw
Quoted 10 lines · Roger Pau Monne

Otherwise it's not possible for device models to map IRQs of devices on segments different than 0. Keep the same function prototype and pass the segment in the high 16bits of the bus parameter, like it's done for the hypercall itself.

Fixes 7620c0cf9a4d ("PCI multi-seg: add new physdevop-s")

---
I think it's 4.21 material, as otherwise it's not possible to passthrough PCI devices on segments != 0.

Make sense to me:

Thanks.

~ Oleksii

Quoted 17 lines
---
  tools/libs/ctrl/xc_physdev.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/libs/ctrl/xc_physdev.c +1 -1
index 25e686d7b389..1307d6836d72 100644
@@ -79,7 +79,7 @@ int xc_physdev_map_pirq_msi(xc_interface *xch,
      }
      memset(&map, 0, sizeof(struct physdev_map_pirq));
      map.domid = domid;
-    map.type = MAP_PIRQ_TYPE_MSI;
+    map.type = MAP_PIRQ_TYPE_MSI_SEG;
      map.index = index;
      map.pirq = *pirq;
      map.bus = bus;
Reviewed-by on v1 1/1
#2 lore raw
In reply to Roger Pau Monne
Quoted 20 lines · Roger Pau Monne

Otherwise it's not possible for device models to map IRQs of devices on segments different than 0. Keep the same function prototype and pass the segment in the high 16bits of the bus parameter, like it's done for the hypercall itself.

Fixes 7620c0cf9a4d ("PCI multi-seg: add new physdevop-s")

---
I think it's 4.21 material, as otherwise it's not possible to passthrough PCI devices on segments != 0.

---
 tools/libs/ctrl/xc_physdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libs/ctrl/xc_physdev.c +0 -0
index 25e686d7b389..1307d6836d72 100644

tools/libs/ctrl/xc_physdev.c int xc_physdev_map_pirq_msi(xc_interface *xch, · line 85

Quoted 8 lines
tools/libs/ctrl/xc_physdev.c +1 -1
@@ -79,7 +79,7 @@ int xc_physdev_map_pirq_msi(xc_interface *xch,
     }
     memset(&map, 0, sizeof(struct physdev_map_pirq));
     map.domid = domid;
-    map.type = MAP_PIRQ_TYPE_MSI;
+    map.type = MAP_PIRQ_TYPE_MSI_SEG;
     map.index = index;
     map.pirq = *pirq;
     map.bus = bus;

This was tested on a real machine.

About MAP_PIRQ_TYPE_MSI and MAP_PIRQ_TYPE_MSI_SEG, do we need to keep ABI compatibility or we should just remove MAP_PIRQ_TYPE_MSI_SEG and make MAP_PIRQ_TYPE_MSI consider the segment ?

Frediano

#3 lore raw
Quoted 32 lines · Frediano Ziglio
Quoted 20 lines · Roger Pau Monne

Otherwise it's not possible for device models to map IRQs of devices on segments different than 0. Keep the same function prototype and pass the segment in the high 16bits of the bus parameter, like it's done for the hypercall itself.

Fixes 7620c0cf9a4d ("PCI multi-seg: add new physdevop-s")

---
I think it's 4.21 material, as otherwise it's not possible to passthrough PCI devices on segments != 0.

---
 tools/libs/ctrl/xc_physdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libs/ctrl/xc_physdev.c +0 -0
index 25e686d7b389..1307d6836d72 100644

tools/libs/ctrl/xc_physdev.c int xc_physdev_map_pirq_msi(xc_interface *xch, · line 85

Quoted 8 lines
tools/libs/ctrl/xc_physdev.c +1 -1
@@ -79,7 +79,7 @@ int xc_physdev_map_pirq_msi(xc_interface *xch,
     }
     memset(&map, 0, sizeof(struct physdev_map_pirq));
     map.domid = domid;
-    map.type = MAP_PIRQ_TYPE_MSI;
+    map.type = MAP_PIRQ_TYPE_MSI_SEG;
     map.index = index;
     map.pirq = *pirq;
     map.bus = bus;
Quoted 5 lines

This was tested on a real machine.

About MAP_PIRQ_TYPE_MSI and MAP_PIRQ_TYPE_MSI_SEG, do we need to keep ABI compatibility or we should just remove MAP_PIRQ_TYPE_MSI_SEG and make MAP_PIRQ_TYPE_MSI consider the segment ?

Assuming you talk about the hypervisor interface, could you explain how you see breaking ABI compatibility to not break anything? These aren't tools-only interfaces, after all.

Jan

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

Otherwise it's not possible for device models to map IRQs of devices on segments different than 0. Keep the same function prototype and pass the segment in the high 16bits of the bus parameter, like it's done for the hypercall itself.

While easiest, that's an odd interface, though. Should, at the very least the function parameter then be named e.g. "segbus", along the lines of "devfn"?

Quoted 1 line
Fixes 7620c0cf9a4d ("PCI multi-seg: add new physdevop-s")

This commit wasn't about tool stack uses of the interfaces at all.

Jan

#5 lore raw
Quoted 8 lines · Jan Beulich
Quoted 4 lines · Roger Pau Monne

Otherwise it's not possible for device models to map IRQs of devices on segments different than 0. Keep the same function prototype and pass the segment in the high 16bits of the bus parameter, like it's done for the hypercall itself.

While easiest, that's an odd interface, though. Should, at the very least the function parameter then be named e.g. "segbus", along the lines of "devfn"?

I certainly don't mind using segbus instead of plain bus, will adjust now.

Quoted 3 lines
Quoted 1 line
Fixes 7620c0cf9a4d ("PCI multi-seg: add new physdevop-s")

This commit wasn't about tool stack uses of the interfaces at all.

But there should have been a tools side change somewhere to make use of that interface, at the point that support for multi-segment was added to Xen? Otherwise the support feels like half done.

Would you prefer me to use the "Amends:" tag? Or no tag at all.

Thanks, Roger.

#6 lore raw
Quoted 13 lines · Roger Pau Monné
Quoted 8 lines · Jan Beulich
Quoted 4 lines · Roger Pau Monne

Otherwise it's not possible for device models to map IRQs of devices on segments different than 0. Keep the same function prototype and pass the segment in the high 16bits of the bus parameter, like it's done for the hypercall itself.

While easiest, that's an odd interface, though. Should, at the very least the function parameter then be named e.g. "segbus", along the lines of "devfn"?

I certainly don't mind using segbus instead of plain bus, will adjust now.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Fixes 7620c0cf9a4d ("PCI multi-seg: add new physdevop-s")

This commit wasn't about tool stack uses of the interfaces at all.

But there should have been a tools side change somewhere to make use of that interface, at the point that support for multi-segment was added to Xen? Otherwise the support feels like half done.

Perhaps. I was after kernel functionality only at that point, and I would really have liked toolstack folks to have picked up any work needed there.

Quoted 1 line

Would you prefer me to use the "Amends:" tag? Or no tag at all.

Both would be fine with me.

Jan