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

Mykyta Poturai posted 2 patches 3 months ago
[PATCH v14 1/2] arm/pci: add pci_passhtrough_enabled check to pci_device_reset
Posted by Mykyta Poturai 3 months ago
On Arm 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.
This change should not affect x86 behavior as pci-passthrough is always
enabled there.

Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
---
v13->v14:
* clarify the commit message

v13:
* new patch
---
 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 v14 1/2] arm/pci: add pci_passhtrough_enabled check to pci_device_reset
Posted by Jan Beulich 3 months ago
On 24.07.2025 11:44, Mykyta Poturai wrote:
> On Arm 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.

I.e. just like PHYSDEVOP_pci_device_{add,remove} already have it. Which
also helps ...

> This change should not affect x86 behavior as pci-passthrough is always
> enabled there.

... proving the no-effect aspect for x86 here.

> Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

However, the subject prefix is entirely misleading. The change helps Arm,
but is in arch-neutral code. Without "physdev" or "physdevop" anywhere in
the subject, whether "pci_device_reset" refers to a function (and you
merely omitted the parentheses) or something else doesn't become clear.

Also, nit: "is_pci_passthrough_enabled()" or "pci-passthrough-enabled" in
the subject, both to correct spelling and to make clear that either you
explicitly mean an existing predicate, or you merely mean to describe that
verbally.

Jan