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 1334CC48260 for ; Thu, 8 Feb 2024 16:37:37 +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=BeU3+oOw5IMBsLQ/4chidcSWxghYtCkvd65w/Oe5iwk=; b=Kl+Uk+/5ow9uK9 sDDlUyGaRD4bQjUVZyCLBu0X/DQEHy7Pi8L333w7VQUitYcWjS9hrnImk+IBes1FFdLzCZCmy5ifc AEbRgNkHsRrMGXKyduo4NAdMyK7jLgyEy2mQ0w49ALdHnAN7vM2RyrX3CKoY4dz7LCx1Gnfik7Z+4 38D5ZjoPtfvPVmHmzQ+mwWRAq7v0WbG7tajkOaPdvSQpxEsYD2sB7wu8mXq8Rtm2vwxkfJCEOPoeS LzivxrG1hwt82sN7Sf6TPagpVEL99R0pYMDDE26H2jcsgLcV04WShrd4Mk/ZXd/dWP9ieqgHaPj1o IznLOA5nmNYugLawMl2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rY7On-0000000EJwa-1Erd; Thu, 08 Feb 2024 16:37:17 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rY7Ok-0000000EJvA-1HTD for linux-arm-kernel@lists.infradead.org; Thu, 08 Feb 2024 16:37:15 +0000 Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4TW2bz5zqxz6K5vk; Fri, 9 Feb 2024 00:33:35 +0800 (CST) Received: from lhrpeml100002.china.huawei.com (unknown [7.191.160.241]) by mail.maildlp.com (Postfix) with ESMTPS id DCCB4140595; Fri, 9 Feb 2024 00:36:57 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by lhrpeml100002.china.huawei.com (7.191.160.241) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 8 Feb 2024 16:36:57 +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.035; Thu, 8 Feb 2024 16:36:57 +0000 From: Shameerali Kolothum Thodi To: Jason Gunthorpe CC: "kvmarm@lists.linux.dev" , "iommu@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , Linuxarm , "kevin.tian@intel.com" , "alex.williamson@redhat.com" , "maz@kernel.org" , "oliver.upton@linux.dev" , "will@kernel.org" , "robin.murphy@arm.com" , "jean-philippe@linaro.org" , Jonathan Cameron Subject: RE: [RFC PATCH v2 6/7] iommu/arm-smmu-v3: Use KVM VMID for s2 stage Thread-Topic: [RFC PATCH v2 6/7] iommu/arm-smmu-v3: Use KVM VMID for s2 stage Thread-Index: AQHaWqKqc1WLEJmeWESanxfd3VFGjLEAmkKAgAABL7CAAAZQgIAAAKSg Date: Thu, 8 Feb 2024 16:36:57 +0000 Message-ID: References: <20240208151837.35068-1-shameerali.kolothum.thodi@huawei.com> <20240208151837.35068-7-shameerali.kolothum.thodi@huawei.com> <20240208155915.GR31743@ziepe.ca> <8bfca4c5bfe7424691efdae0f686ece4@huawei.com> <20240208162605.GU31743@ziepe.ca> In-Reply-To: <20240208162605.GU31743@ziepe.ca> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.227.28] MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240208_083714_676542_4DB3C90D X-CRM114-Status: GOOD ( 22.75 ) 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: Jason Gunthorpe > Sent: Thursday, February 8, 2024 4:26 PM > To: Shameerali Kolothum Thodi > Cc: kvmarm@lists.linux.dev; iommu@lists.linux.dev; linux-arm- > kernel@lists.infradead.org; Linuxarm ; > kevin.tian@intel.com; alex.williamson@redhat.com; maz@kernel.org; > oliver.upton@linux.dev; will@kernel.org; robin.murphy@arm.com; jean- > philippe@linaro.org; Jonathan Cameron > Subject: Re: [RFC PATCH v2 6/7] iommu/arm-smmu-v3: Use KVM VMID for s2 > stage > > On Thu, Feb 08, 2024 at 04:14:07PM +0000, Shameerali Kolothum Thodi wrote: > > > > #include > > > > @@ -2399,9 +2400,13 @@ int arm_smmu_domain_alloc_id(struct > > > arm_smmu_device *smmu, > > > > } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S2) { > > > > int vmid; > > > > > > > > - /* Reserve VMID 0 for stage-2 bypass STEs */ > > > > - vmid = ida_alloc_range(&smmu->vmid_map, 1, > > > > - (1 << smmu->vmid_bits) - 1, GFP_KERNEL); > > > > + if (smmu_domain->kvm) { > > > > + vmid = kvm_pinned_vmid_get(smmu_domain->kvm); > > > > + } else { > > > > + /* Reserve VMID 0 for stage-2 bypass STEs */ > > > > + vmid = ida_alloc_range(&smmu->vmid_map, 1, > > > > + (1 << smmu->vmid_bits) - 1, > > > GFP_KERNEL); > > > > + } > > > > > > We cannot allow the two different STEs to be programmed with the same > > > VMID but different translations, so somehow the two allocators have to > > > work together. > > > > My idea was, we only set smmu_domain->kvm in the nested parent case > > and that means SMMUv3 supports both S1 & S2. So all the non-nested > domains > > are using S1. > > Okay, that is what I was thinking to get to. > > The logic needs to reflect this directly though: > > /* > * There can only be one allocator for VMIDs active at once. If BTM is > * turned on then KVM's allocator always supplies the VMID, and the > * VMID is matched by CPU invalidation of the KVM S2. Right now there > * is no API to get an unused VMID from KVM so this also means BTM systems > * cannot support S2 without an associated KVM. > */ > if ((smmu->feature & ARM_SMMU_FEAT_BTM)) { > if (!smmu_domain->kvm) > vmid = -EOPNOTSUPP; > else > vmid = kvm_pinned_vmid_get(smmu_domain->kvm); > } else { > /* Reserve VMID 0 for stage-2 bypass STEs */ > vmid = ida_alloc_range(&smmu->vmid_map, 1, > (1 << smmu->vmid_bits) - 1, GFP_KERNEL); > } > > (and matching change to the free side) > > > This is what I was trying to do. But not sure we have systems out there where > > only S2 is supported and that may require a private VMID without KVM. > > iommufd can ask for a nesting parent without supplying a KVM fd, which > would cause vmid aliasing between the two allocators. That needs to be > blocked as above Ah..That's right. Missed that case where KVM can be NULL, but still there is a request for nested domain. Thanks, Shameer _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel