before trying to remove them. Some IOMMU platforms, such as SMMU-V3 and IPMMU-VMSA don't support removing devices. Trying to call remove_device will result in a crash. So check that platform_ops have remove_device set before calling it.
Signed-off-by: Mykyta Poturai <[email protected]> --- v1->v2: * new patch --- xen/drivers/passthrough/pci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 464bb0fee4..704eb6e19f 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -1545,6 +1545,12 @@ static int iommu_remove_device(struct pci_dev *pdev) if ( !is_iommu_enabled(pdev->domain) ) return 0; + if ( !hd->platform_ops->remove_device ) + { + printk(XENLOG_ERR "IOMMU: remove_device not supported by platform\n"); + return -EOPNOTSUPP; + } + for ( devfn = pdev->devfn ; pdev->phantom_stride; ) { int rc; -- 2.51.2
