]> xenbits.xensource.com Git - xen.git/commit
PCI: simplify (and thus correct) pci_get_pdev{,_by_domain}()
authorJan Beulich <jbeulich@suse.com>
Mon, 15 Aug 2022 13:36:56 +0000 (15:36 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 15 Aug 2022 13:36:56 +0000 (15:36 +0200)
commit2abe83f9d91e6411b5b42a3d5d01593e83c2bf9f
treebb45afdf84cd9bb405a487d7d87c5936587146cc
parent3fd9a7d59523fb0555d0e89b11eeea5d53d2c54c
PCI: simplify (and thus correct) pci_get_pdev{,_by_domain}()

The last "wildcard" use of either function went away with f591755823a7
("IOMMU/PCI: don't let domain cleanup continue when device de-assignment
failed"). Don't allow them to be called this way anymore. Besides
simplifying the code this also fixes two bugs:

1) When seg != -1, the outer loops should have been terminated after the
   first iteration, or else a device with the same BDF but on another
   segment could be found / returned.

Reported-by: Rahul Singh <rahul.singh@arm.com>
2) When seg == -1 calling get_pseg() is bogus. The function (taking a
   u16) would look for segment 0xffff, which might exist. If it exists,
   we might then find / return a wrong device.

In pci_get_pdev_by_domain() also switch from using the per-segment list
to using the per-domain one, with the exception of the hardware domain
(see the code comment there).

While there also constify "pseg" and drop "pdev"'s already previously
unnecessary initializer.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Rahul Singh <rahul.singh@arm.com>
Tested-by: Rahul Singh <rahul.singh@arm.com>
master commit: 8cf6e0738906fc269af40135ed82a07815dd3b9c
master date: 2022-08-12 08:34:33 +0200
xen/drivers/passthrough/pci.c
xen/include/xen/pci.h