Skip to contentSkip to conversation

vpci/header: cope with devices not having vpci allocated

PATCH In review Roger Pau Monne 2 participants 3 messages May 25, 2023 – May 29, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 vpci/header: cope with devices not having vpci allocated

When traversing the list of pci devices assigned to a domain cope with some of them not having the vpci struct allocated. It should be possible for the hardware domain to have read-only devices assigned that are not handled by vPCI, such support will be added by further patches.

---
Changes since v1:
- Do not mention domU plans.

---
 xen/drivers/vpci/header.c | 8 ++++++++
 1 file changed, 8 insertions(+)
xen/drivers/vpci/header.c +8 -0
index ec2e978a4e6b..766fd98b2196 100644
@@ -289,6 +289,14 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
      */
     for_each_pdev ( pdev->domain, tmp )
     {
+        if ( !tmp->vpci )
+            /*
+             * For the hardware domain it's possible to have devices assigned
+             * to it that are not handled by vPCI, either because those are
+             * read-only devices, or because vPCI setup has failed.
+             */
+            continue;
+
         if ( tmp == pdev )
         {
             /*
Signature · 1 line
2.40.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Roger Pau Monne

When traversing the list of pci devices assigned to a domain cope with some of them not having the vpci struct allocated. It should be possible for the hardware domain to have read-only devices assigned that are not handled by vPCI, such support will be added by further patches.

I was wondering whether to put an assertion in (permitting both DomXEN and hwdom, i.e. slightly more relaxed than I had it).

Jan

#2 lore raw
Quoted 10 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monne

When traversing the list of pci devices assigned to a domain cope with some of them not having the vpci struct allocated. It should be possible for the hardware domain to have read-only devices assigned that are not handled by vPCI, such support will be added by further patches.

Thanks.

Quoted 2 lines

I was wondering whether to put an assertion in (permitting both DomXEN and hwdom, i.e. slightly more relaxed than I had it).

I also wondered it, but didn't think it was very helpful, but that was back when I had the comment about how I envisioned this to work for domUs.

Let me know if you want me to add it.

Thanks, Roger.