pci/ats: do not allow broken devices to be assigned to guests
authorRoger Pau Monné <roger.pau@citrix.com>
Mon, 14 Mar 2022 09:30:02 +0000 (10:30 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 14 Mar 2022 09:30:02 +0000 (10:30 +0100)
commit7b4b36fcbabaa616b301edce8491ebbe002a71f3
tree2c353199335c46084f6dbf77cb09c58efc98894d
parent3f809886988767fff46f440f4fc6d252fb586ace
pci/ats: do not allow broken devices to be assigned to guests

Introduce a new field to mark devices as broken: having it set prevents
the device from being assigned to guests. Use the field in order to mark
ATS devices that have failed a flush when using VT-d as broken, thus
preventing them to be assigned to any guest.

This allows the device IOMMU context entry to be cleaned up properly, as
calling _pci_hide_device will just change the ownership of the device,
but the IOMMU context entry of the device would be left as-is. It would
also leak a VT-d Domain ID if using one, as removing the device from
its previous owner will allow releasing the IOMMU DID used by the device
without having cleaned up the context entry.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
xen/drivers/passthrough/pci.c
xen/drivers/passthrough/vtd/qinval.c
xen/include/xen/pci.h