From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2696EC61DA4 for ; Thu, 9 Mar 2023 15:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bFXqO3Wg8d1zb3OwNaTdC6uhxDcqJ1jy2SetMMO+kyk=; b=wyQ8kHCrWb4pJJ xYOAlsAoRTS4x4vEFt45WM+UcZ7mbwu6DJxOrALQ0tYPEljym1UGkQFyY8qtyvdWDhfARI6Fd3ezT LiNMuP+Eb7yTK6jnLnUfhqUAxbzaZ2HK+15O5F11qpndGZughIN7v1imlp9AL8DeGgaaaOIENpszG g5YaJ6LrQiPthDXCwJEwo4YRL72LXu5epr6Lq1yz9fdyxChB2EyjrMsAZpcEVdQBQhXcyCLegvWWY W5Bkx0J5yhqrpIX7aPLsas3Luq+/52xHSUJWEe6aUBtSpJ5a2SSbx0Yixsd4I9Wkkw/oOHC0d10KH SBthkFXwDPETY/OxECPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1paIRb-00Azxx-Q7; Thu, 09 Mar 2023 15:44:40 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1paIB8-00At9T-I2 for linux-arm-kernel@lists.infradead.org; Thu, 09 Mar 2023 15:27:40 +0000 Received: from lhrpeml500006.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4PXY186fLvz6J7Xn; Thu, 9 Mar 2023 23:26:04 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by lhrpeml500006.china.huawei.com (7.191.161.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 9 Mar 2023 15:26:12 +0000 Received: from lhrpeml500005.china.huawei.com ([7.191.163.240]) by lhrpeml500005.china.huawei.com ([7.191.163.240]) with mapi id 15.01.2507.021; Thu, 9 Mar 2023 15:26:12 +0000 From: Shameerali Kolothum Thodi To: Jean-Philippe Brucker , Nicolin Chen CC: "jgg@nvidia.com" , "robin.murphy@arm.com" , "will@kernel.org" , "eric.auger@redhat.com" , "kevin.tian@intel.com" , "baolu.lu@linux.intel.com" , "joro@8bytes.org" , "linux-arm-kernel@lists.infradead.org" , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "yi.l.liu@intel.com" Subject: RE: [PATCH v1 02/14] iommufd: Add nesting related data structures for ARM SMMUv3 Thread-Topic: [PATCH v1 02/14] iommufd: Add nesting related data structures for ARM SMMUv3 Thread-Index: AQHZUnWTVXhuXoh0OkWPSyQY1srSfq7ydQKAgAAVzLA= Date: Thu, 9 Mar 2023 15:26:12 +0000 Message-ID: <213a05ef06944a55a148995053b187f8@huawei.com> References: <364cfbe5b228ab178093db2de13fa3accf7a6120.1678348754.git.nicolinc@nvidia.com> <20230309134217.GA1673607@myrica> In-Reply-To: <20230309134217.GA1673607@myrica> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.227.178] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230309_072738_906433_BC62C2FA X-CRM114-Status: GOOD ( 17.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org > -----Original Message----- > From: Jean-Philippe Brucker [mailto:jean-philippe@linaro.org] > Sent: 09 March 2023 13:42 > To: Nicolin Chen > Cc: jgg@nvidia.com; robin.murphy@arm.com; will@kernel.org; > eric.auger@redhat.com; kevin.tian@intel.com; baolu.lu@linux.intel.com; > joro@8bytes.org; Shameerali Kolothum Thodi > ; > linux-arm-kernel@lists.infradead.org; iommu@lists.linux.dev; > linux-kernel@vger.kernel.org; yi.l.liu@intel.com > Subject: Re: [PATCH v1 02/14] iommufd: Add nesting related data structures > for ARM SMMUv3 > > Hi Nicolin, > > On Thu, Mar 09, 2023 at 02:53:38AM -0800, Nicolin Chen wrote: > > Add the following data structures for corresponding ioctls: > > iommu_hwpt_arm_smmuv3 => > IOMMUFD_CMD_HWPT_ALLOC > > iommu_hwpt_invalidate_arm_smmuv3 => > IOMMUFD_CMD_HWPT_INVALIDATE > > > > Also, add IOMMU_HW_INFO_TYPE_ARM_SMMUV3 and > IOMMU_PGTBL_TYPE_ARM_SMMUV3_S1 > > to the header and corresponding type/size arrays. > > > > Signed-off-by: Nicolin Chen > > > +/** > > + * struct iommu_hwpt_arm_smmuv3 - ARM SMMUv3 specific page table > data > > + * > > + * @flags: page table entry attributes > > + * @s2vmid: Virtual machine identifier > > + * @s1ctxptr: Stage-1 context descriptor pointer > > + * @s1cdmax: Number of CDs pointed to by s1ContextPtr > > + * @s1fmt: Stage-1 Format > > + * @s1dss: Default substream > > + */ > > +struct iommu_hwpt_arm_smmuv3 { > > +#define IOMMU_SMMUV3_FLAG_S2 (1 << 0) /* if unset, stage-1 */ > > I don't understand the purpose of this flag, since the structure only > provides stage-1 configuration fields > > > +#define IOMMU_SMMUV3_FLAG_VMID (1 << 1) /* vmid override */ > > Doesn't this break isolation? The VMID space is global for the SMMU, so > the guest could access cached mappings of another device On platforms that supports BTM [1], we may need the VMID allocated by KVM. But again getting that from user pace doesn't look safe. I have attempted to revise the earlier RFC to pin and use the KVM VMID from SMMUv3 here[2]. But the problem is getting the KVM instance associated with the device. Currently I am going through the VFIO layer to retrieve the KVM instance(vfio_device->kvm). On the previous RFC discussion thread[3], Jean has proposed, " In the new design we can require from the start that creating a nesting IOMMU container through /dev/iommu *must* come with a KVM context, that way we're sure to reuse the existing VMID. " Is that something we can still do or there is a better way to handle this now? Thanks, Shameer 1. https://lore.kernel.org/linux-arm-kernel/YEEUocRn3IfIDpLj@myrica/T/#m478f7e7d5dcb729e02721beda35efa12c1d20707 2. https://github.com/hisilicon/kernel-dev/commits/iommufd-v6.2-rc4-nesting-arm-btm-v2 3. https://lore.kernel.org/linux-arm-kernel/YEEUocRn3IfIDpLj@myrica/T/#m11cde7534943ea7cf35f534cb809a023eabd9da3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel