Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp29564pxj; Wed, 2 Jun 2021 23:31:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyDVVGJvcu6ZQ3voZmGvwMC9qlxQFwWGsEKvLpG5L0+uN0pNEw+TaH0kAjymyKG96oq+G/ X-Received: by 2002:a50:eb8f:: with SMTP id y15mr35594917edr.285.1622701882264; Wed, 02 Jun 2021 23:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622701882; cv=none; d=google.com; s=arc-20160816; b=r2+ze/KGOp/QnlUX6KWZ9spkRWT2oMq+Keyl7VxXoQ9nitM9O9nzh9OOu7gdXybiWk IvGbqUmdYTY1PS2/FujPzT9H9oxMg4u8CSAS5cuCCkW61SXKuGKnlGJVBdtlzFFlVv9h WyRzm3SnmiZ5Cx4v0FoDRinhEtKj4hdUvIaCPSmGGKNjAJX1IhwzAck+pvMLlOvrI8lX 9bP2PDWLW5NXyKL2jOkF+4yddXFOlw/RDlxPogjuTuCGT+J5T2GHFQb/fn5rh9eWJn8N mydrhux4aT18YA5253J6xOsDdcSDVMzsEgA2gTORGMBrL6QLzQV/bZ1P0j31sgIi/etB MMhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VfcU77c+VtpkjJak5yLU/Pmh9WkmFk3Zyu15nMr6CFQ=; b=PxyBmi384juCmM9LYtb5kGXl3yb5ImQ3E2fIgzqscauI9QF676h0tUd439rx2VB55+ xUwO294/08TmBji0YLgT2oq0IMKKXrYIObu5tgnCAZqd14u3qPXLHJcEnFSDxnmTueyJ ZIThwxJZeaJsLKPP4ArdRN479cQv5Rd5+LU/2ugTf8izdt2XZEz2A1jezhL3x4/ejNge AdL2lHlmzsnQZ5QSlZA3JL7jGdRKCgp471t3K0NzavlLLzTeu6q7HuNFaBcZ0T3kmpLF tyDzgo97EFEpYqAvAahZ4iqPrpURDt1sltP8NMUMbQXGcV6DUSwKRpTSweriR5IN9/pW PKEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b=KIR+Gzyh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g3si1812825edv.12.2021.06.02.23.31.00; Wed, 02 Jun 2021 23:31:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b=KIR+Gzyh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229967AbhFCGaQ (ORCPT + 99 others); Thu, 3 Jun 2021 02:30:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229849AbhFCGaJ (ORCPT ); Thu, 3 Jun 2021 02:30:09 -0400 Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E97ABC061756; Wed, 2 Jun 2021 23:28:24 -0700 (PDT) Received: by ozlabs.org (Postfix, from userid 1007) id 4FwbYy4cPTz9s5R; Thu, 3 Jun 2021 16:28:22 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1622701702; bh=IEEiXT5ukbF9bVCRBbDqCX5LlE3sy5L+2Kdn6s28K58=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KIR+GzyhRu27toheHJDd50KhCPCJbP3gDGUuXZldNPxbTzZf7XO7iP7Va6FbAKtVw oMW2lSGDSJAAs3IwkPuecVOEzpLPFN5RrCse9tETBTjAv5q7b8inQprCzFkEGGT/7I jm7CC6cD+WQ8xfciulygEFE9O20QtHmyjblCEgeA= Date: Thu, 3 Jun 2021 15:23:17 +1000 From: David Gibson To: Jason Gunthorpe Cc: "Tian, Kevin" , LKML , Joerg Roedel , Lu Baolu , David Woodhouse , "iommu@lists.linux-foundation.org" , "kvm@vger.kernel.org" , "Alex Williamson (alex.williamson@redhat.com)" , Jason Wang , Eric Auger , Jonathan Corbet , "Raj, Ashok" , "Liu, Yi L" , "Wu, Hao" , "Jiang, Dave" , Jacob Pan , Jean-Philippe Brucker , Kirti Wankhede , Robin Murphy Subject: Re: [RFC] /dev/ioasid uAPI proposal Message-ID: References: <20210528195839.GO1002214@nvidia.com> <20210601175643.GQ1002214@nvidia.com> <20210602163753.GZ1002214@nvidia.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ct7l8sovhYah/GNA" Content-Disposition: inline In-Reply-To: <20210602163753.GZ1002214@nvidia.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --ct7l8sovhYah/GNA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 02, 2021 at 01:37:53PM -0300, Jason Gunthorpe wrote: > On Wed, Jun 02, 2021 at 04:57:52PM +1000, David Gibson wrote: >=20 > > I don't think presence or absence of a group fd makes a lot of > > difference to this design. Having a group fd just means we attach > > groups to the ioasid instead of individual devices, and we no longer > > need the bookkeeping of "partial" devices. >=20 > Oh, I think we really don't want to attach the group to an ioasid, or > at least not as a first-class idea. >=20 > The fundamental problem that got us here is we now live in a world > where there are many ways to attach a device to an IOASID: I'm not seeing that that's necessarily a problem. > - A RID binding > - A RID,PASID binding > - A RID,PASID binding for ENQCMD I have to admit I haven't fully grasped the differences between these modes. I'm hoping we can consolidate at least some of them into the same sort of binding onto different IOASIDs (which may be linked in parent/child relationships). > - A SW TABLE binding > - etc >=20 > The selection of which mode to use is based on the specific > driver/device operation. Ie the thing that implements the 'struct > vfio_device' is the thing that has to select the binding mode. I thought userspace selected the binding mode - although not all modes will be possible for all devices. > group attachment was fine when there was only one mode. As you say it > is fine to just attach every group member with RID binding if RID > binding is the only option. >=20 > When SW TABLE binding was added the group code was hacked up - now the > group logic is choosing between RID/SW TABLE in a very hacky and mdev > specific way, and this is just a mess. Sounds like it. What do you propose instead to handle backwards compatibility for group-based VFIO code? > The flow must carry the IOASID from the /dev/iommu to the vfio_device > driver and the vfio_device implementation must choose which binding > mode and parameters it wants based on driver and HW configuration. >=20 > eg if two PCI devices are in a group then it is perfectly fine that > one device uses RID binding and the other device uses RID,PASID > binding. Uhhhh... I don't see how that can be. They could well be in the same group because their RIDs cannot be distinguished from each other. > The only place I see for a "group bind" in the uAPI is some compat > layer for the vfio container, and the implementation would be quite > different, we'd have to call each vfio_device driver in the group and > execute the IOASID attach IOCTL. >=20 > > > I would say no on the container. /dev/ioasid =3D=3D the container, ha= ving > > > two competing objects at once in a single process is just a mess. > >=20 > > Right. I'd assume that for compatibility, creating a container would > > create a single IOASID under the hood with a compatiblity layer > > translating the container operations to iosaid operations. >=20 > It is a nice dream for sure >=20 > /dev/vfio could be a special case of /dev/ioasid just with a different > uapi and ending up with only one IOASID. They could be interchangable > from then on, which would simplify the internals of VFIO if it > consistently delt with these new ioasid objects everywhere. But last I > looked it was complicated enough to best be done later on >=20 > Jason >=20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --ct7l8sovhYah/GNA Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAmC4Z0UACgkQbDjKyiDZ s5JVmBAAvFLHQONjTSmYF0VpXWkFjszZDezpbL/wjXpuJp+d8d/JHfGH1jaP+UeJ dBm4x2+wg5ObhI1DY/Q8OTrTKud71LvN8FayexQ0SKkqzaFTyXvEzP2vr30N2Svc qzxReZfDkXPneWNb/IqdVO5KgxVgtNR+tgIlCiFAndJdOcjTPfC38zr3ceNbKn7Q kofsipS61OUwkj7X7mUEuzajdYDDQ3yfPGbuI6XY2dJbQd1+Bgv9yfA71yruIw3L 5JenqmBlO9oJcvU09Db8wZe7iT27Jh5Jl/LAAzSoaVOb8lZkVRKLETgKHRx9SfDf xwsIDCpOQ5jtClK4qpGmpATkNgd2q6S7uqb8GsXTXCVxV4GMHKLaDRTGCK4m3hx0 XPmTZDS3NDShGjeUVvrGNosIriXb0UaWzugtLpvGyRe6U53p9tL8khNUIUKZysrX uHH0SxwwK8+4ke8+zPVn48Y6CE1IYWKVHb3oeLmgYLF28W4Qo2FmoVHlO+Go+Z4C kh1yKIIm6phXqwIxVn4pFIi5A5u/pnsSVdod3Ll93xTf/Th3fmjAeAeOy9XU3Wf8 Qp9RmpMopPQARqDDY74Scbg2IxlzM/ks3rqGcKg/aUTaQl5Fhxzan7F5daKsHf1e 92Ou5VpiV0KKg4FDe160et4u4x/qAjq+ROSkB8I+HoGyZSw6Nsk= =6Lix -----END PGP SIGNATURE----- --ct7l8sovhYah/GNA--