From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.107.200.20 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796110490; b=fZBAxBRLmGFQ8cZKL60MhnsMJySpSJ1QVrcCWe46F8W6522MfM8HOKrpKCITz2+uhV74 Mido1lSWxZs9G+jKdVyusbIdK+1SOkSDn+wM0rm20ognvqaGbH7O7+NQUmYTURagIUxO7 W6F2d7OsuG2hQJGQ+axiXU/5rqwMPS2dwqCHJqSUO+Ib+T8K09ijcizNtjZf+d9G4aa87 rmO3MLB/Wq5KJWpAueKgiaVmLb+y8z9h+icVXwuZjUg11z5XzqfbferdoLaf+jSZs+l/l ocm8SLjYSi8wetnqG+DSCkxZfv5M/iwTi82oga38GzaZC1YC6fqiB8ryMBr9pNeFaLw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796110490; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:Received:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: Content-Type:X-NV-OnPremToCloud:X-EOPAttributedMessage: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=Q6piU8txSXuxzAQrN85kL/nxigQl84SLTSnSjMa3RC8=; b=lwt1ssIRhh5Rr0haz6n+4KjVsCRzly85ugrCtXjVmeELvgnjaMigSU04ijyUJMRDzytL tVFpYgoYgvfFSwVwedkP9gpHf6JzKG8X5+LLJE9mlDW97PlLoufIQc/uuieKGyCTpQegw 9xdopXv40eeUPeW6sBK6DIPlDf0deYFq4iQbmbXk4AIm8xKuJGik060sUlehU0qQYrS3t MA61El34HyPzFCZkLL1sW9ycG/4S0gbln47dPXw79KdtoQbJosr18tfFYvTWbgeBO8yL7 H2EpubNFrW2b1PZqnMQy5S+69Y2ABCkIKNg98np2qktlrFOwLEjrK5u7Vy6kaZHnA7w== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=jHFQWcKs; arc=pass header.oldest-pass=0 smtp.remote-ip=40.107.200.20 Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012020.outbound.protection.outlook.com [40.107.200.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 959D6606A681 for ; Tue, 1 Dec 2026 07:34:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 959D6606A681 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=jHFQWcKs ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JZnDnsULLNSlcA6Jq6C+FKbKIWP2In+8ub48jWUI+8rV2IwUpLMt0amxh3CfVFyEAKl/fvx+cw9s/LgUluS4Ary9VSbJdpkLbztMoW3VlyQUUQFJMELOTLl02w/mWevqKJYtB++RAePoH1A8SzPmhZg+6MBpjRg6/APPqvXQ5HeQ3z2UfplX87SL9Vw3/IQMAOnhHWwOSGlNnUIznlvcPqywedWtDW7NAq0IXaa+rlozcZ4e6uVCzPbK2yYgtK00Z3BE09P5gTHvsHa3tdm4fY9lbubi0kbnpfu83Xy3kkHLMR6sCNUsM2EtSydLV+wYy7zq5OneJKh4FoePwsqSTw== 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=Q6piU8txSXuxzAQrN85kL/nxigQl84SLTSnSjMa3RC8=; b=hFhYvAQlnW/hMFFZgfV97TQ/0Gw6IPtBDMiamOAdx04xhl84++0enruc6TKw+AcdZ9+vhwJalWnmGKM4Y70mdDm5lD21nnZRwPNpnng5BwN6VNo2IVpAprm+lDNgBYfaWvDGUxGF624P/qiRDkoP9EfunuDMcwnC0TU2wkHkXqrb+Fp4mpPitYUicdcKlFcBZUQGG1wJKsos2XsMxSGLPtcqfTRVfpdWcUAc68cbTORIwtS8hJMiLX8RzNdHbyT3OKK7um5m3LazEDbbhLpqRpisf/pqCxEw4qwZE8yT4kODW/Hd807ZxtdDxYgfC+qnhXU55buSuCTdJTh7lD43vw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=lists.linux.dev smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q6piU8txSXuxzAQrN85kL/nxigQl84SLTSnSjMa3RC8=; b=jHFQWcKsEQPgCoZicy2GKA0WisG2Zy5Ewafz7ynd52RpNbDcSa3SLt1FGt6Ngo0e6ZRn6BCXGbR1mWvsXFRz1qqH08QlOmB/IhEB+DDKRfCHM+pVy4/ocSLvyaP28bXrsEKruwCapoksfn+Wv9YbZYB9BY+YK9QetQ4iQew6KJl5HiN4JyjWW6xnDSM8bOrLdjejmwjk1N1uETHO+yVmVqxl9M1qfDzBSYwoAG+5SInU0FxL9+m6SthhgVIiZWtyfkiW19IBjTfw5CiXAs7lAuwO68Qa1Uj+Ab0xp0g/plW9HFalfW1/Di+Zd0CZccJ/tvtAuwjW9WwIZonVeQT3wQ== Received: from PH8PR07CA0017.namprd07.prod.outlook.com (2603:10b6:510:2cd::28) by IA1PR12MB9530.namprd12.prod.outlook.com (2603:10b6:208:593::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.12; Tue, 1 Dec 2026 07:34:39 +0000 Received: from MWH0EPF000A6732.namprd04.prod.outlook.com (2603:10b6:510:2cd:cafe::64) by PH8PR07CA0017.outlook.office365.com (2603:10b6:510:2cd::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.10 via Frontend Transport; Tue, 1 Dec 2026 07:34:39 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MWH0EPF000A6732.mail.protection.outlook.com (10.167.249.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Tue, 1 Dec 2026 07:34:39 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Mon, 30 Nov 2026 23:34:19 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Mon, 30 Nov 2026 23:34:18 -0800 Received: from Asurada-Nvidia.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.2562.57 via Frontend Transport; Mon, 30 Nov 2026 23:34:17 -0800 From: Nicolin Chen To: Jason Gunthorpe , , Will Deacon , Robin Murphy , Catalin Marinas , Greg Kroah-Hartman , , Danilo Krummrich , Johan Hovold , Marek Szyprowski , CC: Mark Rutland , Pranjal Shrivastava , Mostafa Saleh , , , , Sonang Patel , "Ankit Agrawal" , Subject: [PATCH v4 5/6] iommu: Use the blocking domain for a bypassed confidential vIOMMU Date: Mon, 30 Nov 2026 23:33:57 -0800 Message-ID: <940a7b791a0dd92686f885e0ade80cc75f9a9a58.1796069375.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6732:EE_|IA1PR12MB9530:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b3891f1-0099-47f2-f86c-08df4f7d8ed9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|36860700016|23010399003|82310400026|921020|10067099003|56012099006|11063799006|261021135927099003|261021121427099003|261021123027099003|261009223027099003|261026140227099003|261026121527099003|261022105027099003|261028144727099003|261102123227099003|261022075727099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: hDpi+eOzj/l/0TXSuho+rkuUAzaacQy97Mtom6Ciwe+ILL5hn/GEXpvS/RN/9fj7nFKdiJIO+9VK5yu5NfgR4v9sTNCySWozGVkW1B2HI65y/C/3vaejmLVvrhYU2T6/MZmkuPuEm09nRw4QZTTajfZKZzkJ58W0usdZYLOD237TogQfl1MQFW5SM18Fj7NLC8ZuiMs1GlwpjZeMcaStFIKQQjeXbeOghDq4U6a+xT92tG/xoUyCKjPWbEwooAOXXKlxwN9qkjmThPot9pYNeuX3Wo7ln3L2Cop0TJ/nP9JCzetQSYpRBi6mOjsP9iKSJp5phuxQG63QSAXyIwiHD4zbiApWqqKIEl8wuXLtXVzzo3XqlB0Us/O3VId4hKNvqkhvXhXX6a6L11BbRmv7p3AfYEke12NVNvypBQIr0RHPR2D5vr46s65sn8Zz28leYNGO7Gyt+tfl6FLPfMjpFGghozdJ7f85dCSWA7DR/zpQXu87k02/gI53cgJF4uTGckwfku+cw0WQ/IRUWe3UdKXjAmV1nGlF16IF8yu2gP0Xd0J/Twdrk1I8K+u6T7ofHx0k6M4r95iHxUYlzUdnsP4tuktUTEjY5pYmgx0xsnyWcWWyBTtjsvZT1l5B26JBHNvwuXwaDi4gLcMs1lvvX0q0B+YJjNy8otRzCLvYhN75luCFtR9qdnuP9X9fzrYprxvZA4yrI81OroyTf+fl9K7e3vT+hfQocg4img7OzIwxqcPXGRgTnkReEnRfjKDi X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(36860700016)(23010399003)(82310400026)(921020)(10067099003)(56012099006)(11063799006)(261021135927099003)(261021121427099003)(261021123027099003)(261009223027099003)(261026140227099003)(261026121527099003)(261022105027099003)(261028144727099003)(261102123227099003)(261022075727099003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: y47YOPwzeV/iprCmxgXg1HqGdsnwVfctIZrj/tr9yNZZ2HXBYU9yjq2Cosvo/1jezpkFy7fxbmpsrSTPK/L17o2luWpVn56pyg72poZGzfEUcU5zk4Au9GwgoEI6VXGrRjoRjpVzX2lgHdJmGxa0H50vI4Be2Xxj9ZzI0yF7n9pEOiB83KsRAuBI6S4tLTNacyZ10eGXG9E3T9rVN1hVmStPUYFOXez7tRuPDp+jjWrYQ086uyF70iMbm8L6MtMQamuSydwB+MoCK4w5cia2XPpSDusGssnPte/GSrBMdq7ChVEZxuG+oSIuHeSHr51x/Wm63xgZ6s9B2T3zKaq+s2CBU5xwuMOamuX08HCynK3ZueTtfS/z5W3WVhMW4WPWrPJ/SQJV1qAVV3RM+eOtd5YZY9C9merD0SsMdr+YBU62SKAzQcS+psv+6SOD2Udx X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 07:34:39.5066 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b3891f1-0099-47f2-f86c-08df4f7d8ed9 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6732.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB9530 Inside a confidential VM, a device stays associated with its confidential vIOMMU, even before it is accepted into T=1. Until then, its DMA bypasses the vIOMMU. The hypervisor translates that DMA through the T=0 stream. Without core support, such a device gets a translating default domain. The DMA API then hands out IOVAs that only the vIOMMU knows about, whereas the DMA of the device goes into the hypervisor. Also, dma-iommu keeps the DMA buffers in private memory, which the device cannot reach. Add iommu_cc_viommu_bypassed(). For now, every device behind a cc_private IOMMU bypasses it. Use the blocking domain as the default domain for such a device. This keeps the DMA API on dma-direct, which uses shared buffers and matches the DMA path set up by the hypervisor. Linux's model requires a device to either use T=0 or T=1. Aside from MSI, it cannot use T=0 for normal DMA once moved into T=1 mode, since the device will have IOVA's that are not valid in T=0. A strict IOMMU_RESV_DIRECT region sets require_direct for the device. One such region is the MSI doorbell RMR that the VMM creates for an accelerated vSMMU. The core then refuses the blocking domain for that device, and the IOMMU fails to register. At release, the core also moves such a device to an identity domain. Skip both for a device behind a bypassed vIOMMU. This vIOMMU is not in the DMA path of the device, so it needs no 1:1 mappings. Keep require_direct as reported by firmware, for a future paging domain. Reject sysfs domain changes, driver-managed group attachment, and any PASID attachments that would install a translating domain. The state is uniform across each group, since all devices on a confidential IOMMU bypass it now. The MSI of such a device always goes through T=0 and needs no MSI cookie. Check cc_private directly there, since MSI stays on T=0 even after a device moves into T=1. Suggested-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/iommu-priv.h | 11 +++++++ drivers/iommu/iommu.c | 60 ++++++++++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/iommu-priv.h b/drivers/iommu/iommu-priv.h index 1f9f886b2c107..1acff957e9f24 100644 --- a/drivers/iommu/iommu-priv.h +++ b/drivers/iommu/iommu-priv.h @@ -8,6 +8,17 @@ #include #include +/* + * A bypassed confidential vIOMMU does not translate the DMA of the device. The + * hypervisor sets up identity translation for the device instead. PCIe ATS on + * its own controls the ATS behavior. For now, every device behind a cc_private + * IOMMU bypasses it. + */ +static inline bool iommu_cc_viommu_bypassed(struct device *dev) +{ + return dev->iommu->iommu_dev->cc_private; +} + static inline const struct iommu_ops *dev_iommu_ops(struct device *dev) { /* diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 5ddb37236da11..c30eab2eca66a 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -598,10 +598,12 @@ static void iommu_deinit_device(struct device *dev) /* * If the device requires direct mappings then it should not * be parked on a BLOCKED domain during release as that would - * break the direct mappings. + * break the direct mappings. A bypassed confidential vIOMMU is + * not in the DMA path of the device. So it stays BLOCKED. */ if (dev->iommu->require_direct && ops->identity_domain && - release_domain == ops->blocked_domain) + release_domain == ops->blocked_domain && + !iommu_cc_viommu_bypassed(dev)) release_domain = ops->identity_domain; release_domain->ops->attach_dev(release_domain, dev, @@ -1777,11 +1779,24 @@ __iommu_group_alloc_default_domain(struct iommu_group *group, int req_type) static struct iommu_domain * iommu_group_alloc_default_domain(struct iommu_group *group, int req_type) { - const struct iommu_ops *ops = dev_iommu_ops(iommu_group_first_dev(group)); + struct device *first = iommu_group_first_dev(group); + const struct iommu_ops *ops = dev_iommu_ops(first); struct iommu_domain *dom; lockdep_assert_held(&group->mutex); + /* + * A bypassed confidential vIOMMU is not in the DMA path of the device. + * Attach the device to the blocking domain. This keeps the vIOMMU path + * closed. Also, it keeps the DMA API on dma-direct, which matches the + * DMA path set up by the hypervisor. + */ + if (iommu_cc_viommu_bypassed(first)) { + if (!ops->blocked_domain) + return ERR_PTR(-EINVAL); + return ops->blocked_domain; + } + /* * Allow legacy drivers to specify the domain that will be the default * domain. This should always be either an IDENTITY/BLOCKED/PLATFORM @@ -2386,6 +2401,10 @@ static int __iommu_attach_group(struct iommu_domain *domain, !domain_iommu_ops_compatible(dev_iommu_ops(dev), domain)) return -EINVAL; + /* No domain attachment while the confidential vIOMMU is bypassed */ + if (iommu_cc_viommu_bypassed(dev)) + return -EINVAL; + return __iommu_group_set_domain(group, domain); } @@ -2427,8 +2446,12 @@ static int __iommu_device_set_domain(struct iommu_group *group, * required 1:1 mapping. This test effectively excludes the device * being used with iommu_group_claim_dma_owner() which will block * vfio and iommufd as well. + * + * A bypassed confidential vIOMMU is not in the DMA path of the device. + * The hypervisor sets up the identity translation on that path. So the + * blocking domain cannot break any 1:1 mapping. */ - if (dev->iommu->require_direct && + if (dev->iommu->require_direct && !iommu_cc_viommu_bypassed(dev) && (new_domain->type == IOMMU_DOMAIN_BLOCKED || new_domain == group->blocking_domain)) { dev_warn(dev, @@ -3312,6 +3335,12 @@ static ssize_t iommu_group_store_type(struct iommu_group *group, goto out_unlock; } + /* No default domain change while the confidential vIOMMU is bypassed */ + if (iommu_cc_viommu_bypassed(iommu_group_first_dev(group))) { + ret = -EINVAL; + goto out_unlock; + } + ret = iommu_setup_default_domain(group, req_type); if (ret) goto out_unlock; @@ -3677,6 +3706,12 @@ int iommu_attach_device_pasid(struct iommu_domain *domain, goto out_unlock; } + /* PASID cannot be used while the confidential vIOMMU is bypassed */ + if (iommu_cc_viommu_bypassed(dev)) { + ret = -EINVAL; + goto out_unlock; + } + for_each_group_device(group, device) { /* * Skip PASID validation for devices without PASID support @@ -3770,6 +3805,12 @@ int iommu_replace_device_pasid(struct iommu_domain *domain, goto out_unlock; } + /* PASID cannot be used while the confidential vIOMMU is bypassed */ + if (iommu_cc_viommu_bypassed(dev)) { + ret = -EINVAL; + goto out_unlock; + } + entry = iommu_make_pasid_array_entry(domain, handle); curr = xa_cmpxchg(&group->pasid_array, pasid, NULL, XA_ZERO_ENTRY, GFP_KERNEL); @@ -4004,6 +4045,12 @@ int iommu_replace_group_handle(struct iommu_group *group, return -EINVAL; mutex_lock(&group->mutex); + /* Like attach, no replace while the confidential vIOMMU is bypassed */ + if (iommu_cc_viommu_bypassed(iommu_group_first_dev(group))) { + ret = -EINVAL; + goto err_unlock; + } + entry = iommu_make_pasid_array_entry(new_domain, handle); ret = xa_reserve(&group->pasid_array, IOMMU_NO_PASID, GFP_KERNEL); if (ret) @@ -4268,8 +4315,9 @@ int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr) return ret; mutex_lock(&group->mutex); - /* An IDENTITY domain must pass through */ - if (group->domain && group->domain->type != IOMMU_DOMAIN_IDENTITY) { + /* An IDENTITY domain or a confidential vIOMMU passes MSI through */ + if (group->domain && group->domain->type != IOMMU_DOMAIN_IDENTITY && + !dev->iommu->iommu_dev->cc_private) { switch (group->domain->cookie_type) { case IOMMU_COOKIE_DMA_MSI: case IOMMU_COOKIE_DMA_IOVA: -- 2.43.0