pci: fix pci_get_pdev() to always account for the segment
PATCH 1/1 pci: fix pci_get_pdev() to always account for the segment
When a domain parameter is provided to pci_get_pdev() the search function would match against the bdf, without taking the segment into account.
Fix this and also account for the passed segment.
---
There's no mention in 8cf6e0738906 that avoiding the segment check is fine, and hence I assume it's an oversight, as it should be possible to have devices from multiple segments assigned to the same domain.
--- xen/drivers/passthrough/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/pci.c +1 -1
@@ -552,7 +552,7 @@ struct pci_dev *pci_get_pdev(const struct domain *d, pci_sbdf_t sbdf) }else list_for_each_entry ( pdev, &d->pdev_list, domain_list ) -if ( pdev->sbdf.bdf == sbdf.bdf ) +if ( pdev->sbdf.sbdf == sbdf.sbdf )return pdev;return NULL ;
Signature · 1 line
2.40.0
Hi Roger,
Quoted 10 lines · Roger Pau Monne
When a domain parameter is provided to
pci_get_pdev()the search function would match against the bdf, without taking the segment into account.Fix this and also account for the passed segment.
Fixes 8cf6e0738906 ('PCI: simplify (and thus correct) pci_get_pdev{,_by_domain}()')Signed-off-by Roger Pau Monné <[email protected]>
I think the correct fixes tag is:
With that:
Regards,
Rahul
Quoted 8 lines · Rahul Singh
Hi Roger,
Quoted 6 lines · Roger Pau Monne
When a domain parameter is provided to
pci_get_pdev()the search function would match against the bdf, without taking the segment into account.
Quoted 7 lines
Quoted 4 lines
Fix this and also account for the passed segment.
Fixes 8cf6e0738906 ('PCI: simplify (and thus correct) pci_get_pdev{,_by_domain}()')Signed-off-by Roger Pau Monné <[email protected]>I think the correct fixes tag is:
Fixes a37f9ea7a651 ("PCI: fold pci_get_pdev{,_by_domain}()")
I don't think so, a37f9ea7a651 just changed:
list_for_each_entry ( pdev, &d->pdev_list, domain_list )
- if ( pdev->bus == bus && pdev->devfn == devfn )
+ if ( pdev->sbdf.bdf == sbdf.bdf )
return pdev;That code was already wrong, a37f9ea7a651 simply switched it to use the sbdf struct field.
Thanks, Roger.
Quoted 4 lines · Roger Pau Monne
When a domain parameter is provided to
pci_get_pdev()the search function would match against the bdf, without taking the segment into account.
Quoted 8 lines
Fix this and also account for the passed segment.
Fixes 8cf6e0738906 ('PCI: simplify (and thus correct) pci_get_pdev{,_by_domain}()')Signed-off-by Roger Pau Monné <[email protected]>---
There's no mention in8cf6e0738906that avoiding the segment check is fine, and hence I assume it's an oversight, as it should be possible to have devices from multiple segments assigned to the same domain.
Oh, absolutely - skipping the segment check is very much not fine.
Quoted 13 lines · Andrew Cooper
Quoted 4 lines · Roger Pau Monne
When a domain parameter is provided to
pci_get_pdev()the search function would match against the bdf, without taking the segment into account.Quoted 8 lines
Fix this and also account for the passed segment.
Fixes 8cf6e0738906 ('PCI: simplify (and thus correct) pci_get_pdev{,_by_domain}()')Signed-off-by Roger Pau Monné <[email protected]>---
There's no mention in8cf6e0738906that avoiding the segment check is fine, and hence I assume it's an oversight, as it should be possible to have devices from multiple segments assigned to the same domain.
Quoted 4 lines
Oh, absolutely - skipping the segment check is very much not fine.
Reviewed-by Andrew Cooper <[email protected]>
Sorry, I should go on to say. Xen has had code for segments for years and years and years, but I've seen plenty of evidence of Xen not having any kind of regular testing in multi-segment systems.
Sapphire Rapids is the first platform I'm aware of which is multi-segment in its base configuration and is going to see routine testing with Xen.
I don't expect this to be the final bugfix before multi-segment works properly...
~Andrew
Quoted 23 lines · Andrew Cooper
Quoted 13 lines · Andrew Cooper
Quoted 4 lines · Roger Pau Monne
When a domain parameter is provided to
pci_get_pdev()the search function would match against the bdf, without taking the segment into account.Quoted 8 lines
Fix this and also account for the passed segment.
Fixes 8cf6e0738906 ('PCI: simplify (and thus correct) pci_get_pdev{,_by_domain}()')Signed-off-by Roger Pau Monné <[email protected]>---
There's no mention in8cf6e0738906that avoiding the segment check is fine, and hence I assume it's an oversight, as it should be possible to have devices from multiple segments assigned to the same domain.Quoted 4 lines
Oh, absolutely - skipping the segment check is very much not fine.
Reviewed-by Andrew Cooper <[email protected]>Sorry, I should go on to say. Xen has had code for segments for years and years and years, but I've seen plenty of evidence of Xen not having any kind of regular testing in multi-segment systems.
Quoted 6 lines
Sapphire Rapids is the first platform I'm aware of which is multi-segment in its base configuration and is going to see routine testing with Xen.
I don't expect this to be the final bugfix before multi-segment works properly...
I just found this by code inspection while looking at something else, it wasn't related to any testing on multi segments systems. IOW:
don't take this fix as me having done any kind of testing on multi segment systems.
Thanks, Roger.
Quoted 8 lines · Roger Pau Monne
When a domain parameter is provided to
pci_get_pdev()the search function would match against the bdf, without taking the segment into account.Fix this and also account for the passed segment.
Fixes 8cf6e0738906 ('PCI: simplify (and thus correct) pci_get_pdev{,_by_domain}()')Signed-off-by Roger Pau Monné <[email protected]>
Quoted 4 lines
---
There's no mention in8cf6e0738906that avoiding the segment check is fine, and hence I assume it's an oversight, as it should be possible to have devices from multiple segments assigned to the same domain.
I guess this was a lack of editing after copy-and-paste from the loops iterating over pseg->alldevs_list. Thanks much for spotting!
Jan