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 E4173C2BD09 for ; Mon, 24 Jun 2024 19:13:16 +0000 (UTC) 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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1lWRzQyS6SGE+ZNKc0Gm6FgpgNB7yNGcXEh7JqMG4qc=; b=Pxyr+zGFp4s5IIfSr4pUpWt2ui Toh3rMxv9JabOpj7VdjwAISd4VQKcfriByV+k2CejBe/i0alz1lOnlr7O7A1KlUt7ZkRtk2XX3z44 A3LeklhHyjZ7CF6CfxAYbNER/u/1GlcBirowU6O1sWK16hN/vHdKUsgTD1wfabO+OMW6PSZOfbtg5 vhqenVRy5iTKW0s1AkNVB/XRSEgWL2Tg70tBTHnjfKZlbXCHpFZX8chfrKVRSkAnY1KDF1dx6J3FL A1VwxeDrOdCVc03zNHrZ1TtUHhnweei4VrQbAP5dBH0UZxH9aF+s7q18q9R70BH6yHcySuDtpdzS5 IR0Av77Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLp7j-00000000OUe-39W0; Mon, 24 Jun 2024 19:13:07 +0000 Received: from out-177.mta0.migadu.com ([91.218.175.177]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLp7d-00000000OSu-0NdW for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 19:13:02 +0000 X-Envelope-To: jgg@ziepe.ca DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1719256376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1lWRzQyS6SGE+ZNKc0Gm6FgpgNB7yNGcXEh7JqMG4qc=; b=xi4wGQFRBQouM0fIJVPZkD9y5l/1C3Zo2fbVLeW2oXwZ63YCx2q12HUisD9GalY3U3/r4k WaST3mGuP6Nf5Sm6shP7Mt/ba+Bfw8uR01SGpZJy/4aFnRROXLNsH0cbF4FrOTJqYDA6di QryorGYdWT42vyL3wQQfKvy81tMISak= X-Envelope-To: seanjc@google.com X-Envelope-To: shameerali.kolothum.thodi@huawei.com X-Envelope-To: kvmarm@lists.linux.dev X-Envelope-To: iommu@lists.linux.dev X-Envelope-To: linux-arm-kernel@lists.infradead.org X-Envelope-To: linuxarm@huawei.com X-Envelope-To: kevin.tian@intel.com X-Envelope-To: alex.williamson@redhat.com X-Envelope-To: maz@kernel.org X-Envelope-To: will@kernel.org X-Envelope-To: robin.murphy@arm.com X-Envelope-To: jean-philippe@linaro.org X-Envelope-To: jonathan.cameron@huawei.com Date: Mon, 24 Jun 2024 12:12:48 -0700 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Jason Gunthorpe Cc: Sean Christopherson , Shameer Kolothum , kvmarm@lists.linux.dev, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linuxarm@huawei.com, kevin.tian@intel.com, alex.williamson@redhat.com, maz@kernel.org, will@kernel.org, robin.murphy@arm.com, jean-philippe@linaro.org, jonathan.cameron@huawei.com Subject: Re: [RFC PATCH v2 4/7] iommufd: Associate kvm pointer to iommufd ctx Message-ID: References: <20240208151837.35068-1-shameerali.kolothum.thodi@huawei.com> <20240208151837.35068-5-shameerali.kolothum.thodi@huawei.com> <20240208154210.GP31743@ziepe.ca> <20240624170747.GA1515249@ziepe.ca> <20240624180148.GV791043@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240624180148.GV791043@ziepe.ca> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240624_121301_517159_F83DA49C X-CRM114-Status: GOOD ( 28.43 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 24, 2024 at 03:01:48PM -0300, Jason Gunthorpe wrote: > On Mon, Jun 24, 2024 at 10:54:37AM -0700, Sean Christopherson wrote: > > > > And assuming that pinnable VMIDs are a somewhat scarce resource, it wouldn't > > > > suprise me if someone wanted to add cgroup integration, e.g. similar to the > > > > misc cgroup that's used to manage SEV(-ES) ASIDs on KVM AMD (IIUC, an SEV ASID > > > > is analagous to an ARM VMID). > > > > > > Yeah, but if someone is using such a cgroup then I expect they will > > > also have an up to date VMM that doesn't trigger this VMID allocation > > > in the first place... > > > > I suspect we're talking about two different things. Either that, or I am really > > lost. > > I mean KVM will have already allocated and charged the cgroup for it's > use of the VMID. The IOMMU side just has to match it, no second > allocation of a VMID. > > We wouldn't charge a cgroup for iommu and kvm sharing the same vmid. I think the concern remains that an operator may want to limit the blast radius of some runaway VMID allocation in a system. But you're right, a well-intentioned VMM should wind up with a single charge for all the stage-2's that used the VMID allocation. > > > When a KVM is present then the iommu needs to adopt the VMID of KVM, > > > and that should have a mechanism to ensure the VMID is valid so long > > > as the IOMMU is using it (eg because the KVM FD is open) > > > > Right, and that's what I'm referring to as "on-demand pinning". For the IOMMU > > to adopt a KVM VMID, the VMID needs to be pinned (or KVM would need to notify > > the IOMMU every time the VMID changed), i.e. every KVM+IOMMU pair pins a VMID > > that is managed by KVM. > > Ok, right, yes, the expectation is that KVM allocates a VMID at some > point and it stays fixed for the life of that kvm. > > If KVM can change VMID on the fly then that is a further complication > :\ > > > Hmm, kvm_arm_pinned_vmid_get() doesn't fail, it just falls back to VMID=0. Which > > seems odd. This is bleeding a bit of implementation detail where VMID=0 is known to be reserved (thus invalid), it'd probably be better if the implementation actually just returned an error. VMID=0 is associated with the host's MMU context, which is relevant when running {n,h}VHE mode, as the VMID tags TLB entries even if stage-2 translation is disabled (HCR_EL2.VM = 0). -- Thanks, Oliver