From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3301606A337 for ; Fri, 4 Dec 2026 07:22:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=iKNNO6c2; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Nh05oKB4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=SW/UpV9hiZg78QPG8mB8JNqFcm8kEGOgrMfBa5Z45+U=; b=iKNNO6c2VAh9q8 cHOiWptaHq5yFLxuKfAhE7+HuPOi1Tq2WQfGNVM0Hxny4BTIoOPUEeFh+M20OVUHmClfoFzgZGIPO d4qzJQBRzJA67NATUtI43/acguvneaGiwmkbtHhWLU8Awdoyogl6AFLjYCP67FdUxLHjUe2X06JOQ 9qnBGge8ISUwjjuUcVhsr8xz9sgiJ9uVP32yqCrqPp+fkPLQl0ouWxnrESOYx8p/RCQxwVBYfPoNi 6mNH7ghKIRV0GjougNvQk7WAAN6fYDg7yn7XDrxgxzZtTE7wkg4+Mov368eeVyL/1W6IT7tqoWRo2 Ewobvs/6Eq7oKlRmEWyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZNcH-0000000GuvI-0rtt; Fri, 04 Dec 2026 07:22:09 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZNc5-0000000Gurc-0DJC for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 07:21:49 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 123606013A; Fri, 4 Dec 2026 07:21:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B78091F000C2; Fri, 4 Dec 2026 07:21:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796368907; bh=SW/UpV9hiZg78QPG8mB8JNqFcm8kEGOgrMfBa5Z45+U=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=Nh05oKB4qYNYocZS+Mz4lrU8LAvjwZYKLpkLKNVXYyXgilnLOBkKr/rK0i5b5ORpG ck0KgrohVsUce8y2s1nNWT+n4SsCmIbEBB0hAv4avhjC07HiaWPkIuAaihrT0OE+Mz 7PPOHYQf8TVoFtOYEVjvTysX/60Cyfe2Yw8+oxX5zECxLkAPAR80vYd+BW/UOvkhoH VCSspwwTKDsqVJZHbuejdHfRd1TC05e17pLMtyB23War7CRNbFc0Ikc2ogTpVkBeuw 3mTqH1Ocv0DWB9fFGSWZWSLjTqog+V92IGwpBPKrG7x/ugS9Sp/P3AFWiaZYFuFN1n ugyuKqH/aVwKQ== X-Mailer: emacs 31.1 (via feedmail 11-beta-1 I) From: Aneesh Kumar K.V To: "Tian, Kevin" , "linux-coco@lists.linux.dev" Cc: Alex Williamson , Alexey Kardashevskiy , Bjorn Helgaas , Catalin Marinas , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Jonathan Cameron , Jonathan Hunter , Krishna Reddy , Lukas Wunner , Nicolin Chen , Robin Murphy , Samuel Ortiz , Shameer Kolothum , Steven Price , Suravee Suthikulpanit , Suzuki K Poulose , Thierry Reding , Vasant Hegde , Will Deacon , Xu Yilun , Ashish Kalra , Herbert Xu , Jonathan Cameron , Tom Lendacky , "kvm@vger.kernel.org" , "iommu@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "linux-pci@vger.kernel.org" , "linux-tegra@vger.kernel.org" , "patches@lists.linux.dev" Subject: RE: [PATCH v10 14/18] iommufd/viommu: Identify physical IOMMU backing with a tag In-Reply-To: References: <20261125081121.379481-1-aneesh.kumar@kernel.org> <20261125081121.379481-15-aneesh.kumar@kernel.org> Date: Fri, 04 Dec 2026 12:51:34 +0530 Message-ID: X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-6.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 "Tian, Kevin" writes: >> From: Aneesh Kumar K.V (Arm) >> Sent: Wednesday, November 25, 2026 4:11 PM >>=20 >> When allocating a vDEVICE or nested HWPT, IOMMUFD checks that the >> device >> and its vIOMMU use the same physical IOMMU. >>=20 >> The next patch adds vIOMMUs implemented by a TSM. These store a TSM >> pointer instead of a physical IOMMU pointer, so the same comparison >> cannot be used. >>=20 >> Add a backing field to identify vIOMMUs that use a physical IOMMU, and >> perform the comparison only for those vIOMMUs. All existing vIOMMUs >> select that value, so their behavior is unchanged. >>=20 > > something behind this needs more consideration. > > currently the uapi description includes below for viommu: > > * Allocate a virtual IOMMU object, representing the underlying physical I= OMMU's > * virtualization support that is a security-isolated slice of the real I= OMMU HW > > it implies that all vdevices behind a viommu must belong to a same physic= al > iommu. This is the reason why we have "viommu->iommu_dev !=3D iommu_dev " > check today. > > this patch and next intend to put that constraint only on the legacy usag= e, > probably based on the observation that there is only one tsm in a platform > so one tsm viommu can support all kinds of devices behind different physi= cal > IOMMUs. > > it's probably true for tdx. I didn't see an obvious gap on that assumptio= n. > > but looking at your cca repo, cca_vdevice_init() has an internal check on > " params.psmmu_phys !=3D psmmu->phys ". so it actually has the same > constraint, but you just move the check from iommufd core to the tsm > driver which doesn't sound correct. > > not sure about AMD. > > We have two options here. One is to inherit the current uapi definition > for tsm then abandon this patch. otherwise to not break the existing uapi > we'd better introduce a new viommu_alloc flag to explicitly mark the > viommu as CC type which then can be defined with a different semantics > from legacy. > > an explicit flag also changes the fallback scheme when selecting the > viommu provider, i.e. calling tsm_get_device() only when the flag is set > instead of calling it in all cases. For TSM-backed vIOMMUs, the current code leaves device compatibility validation to the TSM backend rather than requiring a physical-IOMMU association in the IOMMUFD core. This follows the earlier discussion: https://lore.kernel.org/all/20260924192054.GA16465@ziepe.ca/ The TSM driver involves the physical IOMMU as needed. For example, CCA checks both the device=E2=80=99s TSM association and its pSMMU. we could generalize this by moving the physical-IOMMU association check from iommufd_vdevice_alloc_ioctl() into the existing drivers=E2=80=99 vdevice_init() callbacks. Those drivers would retain their current 1:1 restriction, while TSM backends would enforce their own compatibility requirements. Something like static int arm_vsmmu_vdevice_init(struct iommufd_vdevice *vdev) { struct device *dev =3D iommufd_vdevice_to_device(vdev); - struct arm_smmu_master *master =3D dev_iommu_priv_get(dev); + struct arm_smmu_master *master; + int ret; + + ret =3D iommufd_vdevice_validate_iommu(vdev); + if (ret) + return ret; + + master =3D dev_iommu_priv_get(dev); -aneesh