From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796368908; b=BMKcfPuvCyy8dgQSDoVm2oidbwt9Wu72paKrFxgmk9C77W7WWPK+0v/ZhGAX4CglZMnY oIeBSM+f1h8ob6YoQbRmWndwd/0EwkQMORiUhaeMRnGRpj49s703EqFrXUheXQIK5GHJC kqZ5fKnKuZEjl1rQlAgL/gSubBT1AMGSWRzVC6WJQtNZGOVDOyDTzUji33mka++KXTGyp hINgC17UWxfQFkECyP85lhPR8Monhkk+43hWzW3Q9ojRQ9skX4BCpHcyMx6m0/laV22No 4Qn9Taa+4w8E6vNRxiC7QlOaqhz67rxg4GuaMN/BZMpdhsSjfHHBGt+2c1vlWkh5N9Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796368908; h=Received:DKIM-Signature:X-Mailer:From:To:Cc:Subject:In-Reply-To: References:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=SW/UpV9hiZg78QPG8mB8JNqFcm8kEGOgrMfBa5Z45+U=; b=CIpOxT/zKs4w/66xXv/38XlFlzLSpDfZWSiI2ZkPRXLrCCE53HuOTFUMmJNqIMZAxsSS 11e+zs4DZAp9WBnS/XEX1urClegXr4PVqMHRpbVbEBqK9X6EYsllldM1F0M2kyL1C22TU HrTNSjlN+3d/foCeYiCNgk5/0ocQJNIf+2EoCLsQLXlXeLz3sPvlNBm+3rc/CUEMOS3hC t3UXtGAn3Zs/aVF0fdCRxAi5IkdCm/kQlHEV0ymmgw0i2Pu/uWRg9pFq4aD5mjIrJzcgq jNQaqKZn0fFsJmePZRTeL6BUc6AF6Zp+N4YosAkRbyiFKsI/NAzjEVSRWIkIunSblvw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Nh05oKB4; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39978606A322; Fri, 4 Dec 2026 07:21:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Nh05oKB4 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-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable "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