[PATCH v13 1/2] arm/pci: add pci_passhtrough_enabled check to pci_device_reset

Mykyta Poturai posted 2 patches 3 months, 2 weeks ago
There is a newer version of this series
[PATCH v13 1/2] arm/pci: add pci_passhtrough_enabled check to pci_device_reset
Posted by Mykyta Poturai 3 months, 2 weeks ago
Without pci-passthrough=on Xen does not know anything about present PCI
devices due to PHYSDEVOP_pci_device_add not executing. This causes
PHYSDEVOP_pci_device_reset to fail when trying to find the device that
is being reset and return ENODEV.

Add explicit is_pci_passthrough_enabled check to return a more
meaningful EOPNOTSUPP code.

Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
---
 xen/drivers/pci/physdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/drivers/pci/physdev.c b/xen/drivers/pci/physdev.c
index 0161a85e1e..78de67ec64 100644
--- a/xen/drivers/pci/physdev.c
+++ b/xen/drivers/pci/physdev.c
@@ -74,6 +74,9 @@ ret_t pci_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         struct pci_dev *pdev;
         pci_sbdf_t sbdf;
 
+        if ( !is_pci_passthrough_enabled() )
+            return -EOPNOTSUPP;
+
         ret = -EFAULT;
         if ( copy_from_guest(&dev_reset, arg, 1) != 0 )
             break;
-- 
2.34.1
Re: [PATCH v13 1/2] arm/pci: add pci_passhtrough_enabled check to pci_device_reset
Posted by Jan Beulich 3 months, 2 weeks ago
On 16.07.2025 09:43, Mykyta Poturai wrote:
> Without pci-passthrough=on Xen does not know anything about present PCI
> devices due to PHYSDEVOP_pci_device_add not executing.

While the latter half of the sentence is true, Xen may know of PCI devices
be other means. It scans the bus itself after all on x86, under certain
conditions. Furthermore "pci-passthrough" is an Arm-only option, when the
change here affects x86 as much. The description therefore will need some
improvement; the code change itself is okay (on the assumption that it can
be justified properly).

Jan
Re: [PATCH v13 1/2] arm/pci: add pci_passhtrough_enabled check to pci_device_reset
Posted by Mykyta Poturai 3 months, 2 weeks ago
On 16.07.25 11:36, Jan Beulich wrote:
> On 16.07.2025 09:43, Mykyta Poturai wrote:
>> Without pci-passthrough=on Xen does not know anything about present PCI
>> devices due to PHYSDEVOP_pci_device_add not executing.
> 
> While the latter half of the sentence is true, Xen may know of PCI devices
> be other means. It scans the bus itself after all on x86, under certain
> conditions. Furthermore "pci-passthrough" is an Arm-only option, when the
> change here affects x86 as much. The description therefore will need some
> improvement; the code change itself is okay (on the assumption that it can
> be justified properly).
> 
> Jan

Will adding an additional note that all of this only relates to Arm and 
will not change x86 functionality be sufficient? As far as I understand, 
this sentence is completely true for Arm, even the yet-to-be-upstreamed 
bus scanning routines in Xen are guarded by is_pci_passthroug_enabled in 
the latest patches I've seen them in.

-- 
Mykyta
Re: [PATCH v13 1/2] arm/pci: add pci_passhtrough_enabled check to pci_device_reset
Posted by Jan Beulich 3 months, 2 weeks ago
On 18.07.2025 13:52, Mykyta Poturai wrote:
> On 16.07.25 11:36, Jan Beulich wrote:
>> On 16.07.2025 09:43, Mykyta Poturai wrote:
>>> Without pci-passthrough=on Xen does not know anything about present PCI
>>> devices due to PHYSDEVOP_pci_device_add not executing.
>>
>> While the latter half of the sentence is true, Xen may know of PCI devices
>> be other means. It scans the bus itself after all on x86, under certain
>> conditions. Furthermore "pci-passthrough" is an Arm-only option, when the
>> change here affects x86 as much. The description therefore will need some
>> improvement; the code change itself is okay (on the assumption that it can
>> be justified properly).
> 
> Will adding an additional note that all of this only relates to Arm and 
> will not change x86 functionality be sufficient?

Probably.

Jan

> As far as I understand, 
> this sentence is completely true for Arm, even the yet-to-be-upstreamed 
> bus scanning routines in Xen are guarded by is_pci_passthroug_enabled in 
> the latest patches I've seen them in.
>