[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 5/8] pci/iommu: Check that IOMMU supports removing devices
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
- Date: Mon, 9 Mar 2026 11:08:27 +0000
- Accept-language: en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YOUp/hM8Mfho1OBtuL27ZRMzjlpOJY9US27a6WY94g4=; b=eOF7p8Mp5YP0DvPVx71TGejxYorK5R30noHdTP8m+QukpePE/vJqHekPltSuZ9dSbaLMFq0EknZidAk5pS8vlryI/ZZsaGsnZSL9ddD7RBOAGGBqAXYpiqBW/FoaIhpR3OJv9MmP6M1QuQawXjz/wJQjy7RAlN/UwHb/eNxZQdSdshLM6UR+oeOWwromGi72KJGozZVWuslHBAEg1EPK3YiIAiE3WEFW3HVyVxuIoCgctKauqLRuTWHRd8H7YviL+g3NzXxxgziFrXaEEPEf2YtidNGLeYCABewmJxDgQTQI+TGCXM+x7GB0jeP9R+grd5h+T82BUMp5MnHcxPZdVw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=umqdO+OX5PucfeKcvu4wVdnZsYjWf+IqS49sNdKVg+VPg7B90AQayl2p+Hh3hB+Pvxf/ifgBaRrUEeK4R3vcn/WHuByk69QzfUA4phNjmpGDscaC53D8afyoElkTW22zPMnruz29Q4Oe8mc2mAqWVIHGAqeI4vTDBFjojoKtMz08ZuVThlq7oYokrLWvWWqG26k0FSjDjpRnwZSPEmZfsIvEIaaOnTRdC2xPOVB3OncBTRoQ1MYhj0FRhNwdHKH8wQw9f5pesRN+Y/EMk5ZGUiL4e/cWOMPddtdhcHFa5NA8TjKQcRA4UXH2lMzqM01OTx4Kj2w++i97S5pW0siGrA==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
- Cc: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Delivery-date: Mon, 09 Mar 2026 11:08:43 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHcr7UOnGwu40XXHUWWV8IGnIja1A==
- Thread-topic: [PATCH v2 5/8] pci/iommu: Check that IOMMU supports removing devices
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 <mykyta_poturai@xxxxxxxx>
---
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
|