[PATCH v1 4/8] xen/pci: disable pci_device_{add,remove} when hwdom uses vpci on arm

Mykyta Poturai posted 8 patches 4 months, 2 weeks ago
[PATCH v1 4/8] xen/pci: disable pci_device_{add,remove} when hwdom uses vpci on arm
Posted by Mykyta Poturai 4 months, 2 weeks ago
From: Luca Fancellu <luca.fancellu@arm.com>

On ARM, if the hardware domain is using the emulated bus, it should not
be allowed to add/remove pci devices, so return EOPNOTSUPP in that case.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
---
 xen/drivers/pci/physdev.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/xen/drivers/pci/physdev.c b/xen/drivers/pci/physdev.c
index d46501b884..5b3f8dde14 100644
--- a/xen/drivers/pci/physdev.c
+++ b/xen/drivers/pci/physdev.c
@@ -19,6 +19,9 @@ ret_t pci_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         struct pci_dev_info pdev_info;
         nodeid_t node = NUMA_NO_NODE;
 
+        if ( hwdom_uses_vpci() )
+            return -EOPNOTSUPP;
+
         if ( !is_pci_passthrough_enabled() && !arch_pci_device_physdevop() )
             return -EOPNOTSUPP;
 
@@ -57,6 +60,9 @@ ret_t pci_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
     case PHYSDEVOP_pci_device_remove: {
         struct physdev_pci_device dev;
 
+        if ( hwdom_uses_vpci() )
+            return -EOPNOTSUPP;
+
         if ( !is_pci_passthrough_enabled() && !arch_pci_device_physdevop() )
             return -EOPNOTSUPP;
 
-- 
2.34.1
Re: [PATCH v1 4/8] xen/pci: disable pci_device_{add,remove} when hwdom uses vpci on arm
Posted by Jan Beulich 3 months, 4 weeks ago
On 24.09.2025 09:59, Mykyta Poturai wrote:
> From: Luca Fancellu <luca.fancellu@arm.com>
> 
> On ARM, if the hardware domain is using the emulated bus, it should not
> be allowed to add/remove pci devices, so return EOPNOTSUPP in that case.

And how exactly would PCI hotplug be made work then?

> --- a/xen/drivers/pci/physdev.c
> +++ b/xen/drivers/pci/physdev.c
> @@ -19,6 +19,9 @@ ret_t pci_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
>          struct pci_dev_info pdev_info;
>          nodeid_t node = NUMA_NO_NODE;
>  
> +        if ( hwdom_uses_vpci() )
> +            return -EOPNOTSUPP;
> +
>          if ( !is_pci_passthrough_enabled() && !arch_pci_device_physdevop() )
>              return -EOPNOTSUPP;
>  
> @@ -57,6 +60,9 @@ ret_t pci_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
>      case PHYSDEVOP_pci_device_remove: {
>          struct physdev_pci_device dev;
>  
> +        if ( hwdom_uses_vpci() )
> +            return -EOPNOTSUPP;
> +
>          if ( !is_pci_passthrough_enabled() && !arch_pci_device_physdevop() )
>              return -EOPNOTSUPP;
>  

Along the lines of my comment on patch 3, these uses are clearly _visually_
wrong for x86; they're correct from a functional perspective simply because
the predicate returns the (apparently) wrong value there right now.

Jan