Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3459969pxj; Tue, 1 Jun 2021 05:58:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDN8/e0Yycz+tLGdPtkF9+Cmn5LQhd1aaJWgVEr/87xQHqjLJJ1DvWbU+gRB7qmSDIodDl X-Received: by 2002:a05:6e02:1c25:: with SMTP id m5mr22271868ilh.295.1622552329432; Tue, 01 Jun 2021 05:58:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1622552329; cv=pass; d=google.com; s=arc-20160816; b=W1L1FL596EcjB1jxDhlggbCwtwZddaA5Yhsgdt2Z/WWk7pn4N3htpTkJC8d3NcjOFS CDZMHgVCvg0LezQhN26LujAekxb8ylDTa7hBQrJ8SdT8MyGtENd3IRAGrgxe/SulbhtX PYzDV3CQdhUrWiOMe7UF8KKKbqieMNZa46wyatzdmTTHuNBJ0xKh8IXtK6DukRhYc6w4 vXsWYWmGLtD17iwX7SUi3CK0hSIVAhRNpw1yrKpc3k7sG/o2pdR1HjSI4IADrjogfqu8 xoloa8sbPZ0CM4Tc0YG3menJOkOBYg0IbGx2np60+zFhGu+cGu3z9yKznnvl63QU0ebq UAkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7gyZlwmlHYU/ZmUOvs3ehKHXbCDvmkOMT92IXgOjuI0=; b=SCQu6pMTl/HybeY9wY5VqnF+j6d7o7xNFoalnK27mdNI5xiVpNllzUfUUPSbAIbpsy NylQiArGE+SoJmdmD0XBRzVqE4gSLDeiqdmfdwGF8iYFXTocUvMDH+yl0SVAu2Slxpk7 ghigh5R/yaKwj8qjIlsmmrCm1gGL/m4npvm9M3oq28vqr+Zh48E2wTQoAScZ+n6X5rdY REm7XMrp5rvLbYof86yHh78Rw9pGOfDgVTld44y9vZdlUVX/GVlU8Ia88dUDdlsCttlo CJzNwtrazeMepXzDQ7wCrXJJBic8A9xyMJiHsACCLzW+agZuWrHrFoYlzRBqQNq6r9UD HNmQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=EsSoLP4v; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u5si8148919ill.118.2021.06.01.05.58.36; Tue, 01 Jun 2021 05:58:49 -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=@Nvidia.com header.s=selector2 header.b=EsSoLP4v; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233933AbhFAM7G (ORCPT + 99 others); Tue, 1 Jun 2021 08:59:06 -0400 Received: from mail-sn1anam02on2082.outbound.protection.outlook.com ([40.107.96.82]:32943 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233909AbhFAM64 (ORCPT ); Tue, 1 Jun 2021 08:58:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e4gVOC4bVFt3QZdDDPPRxH0yLs4fJnMcbaqdBVu5S5iTkSekh1du0NsB6xBI8Jlq16ryxUnIA8ib4YEwsJYKy4Eo9j+1p4aYRqakUDDv/6OTMnM20CWOavexGOjrRq0GIVf9s4cu2F9X0MSBEpa7W0mpPZieqh/FZsrcT7cJMIolC31uWRygv4/0/W/2dUeOWEQ558soW9weGj6sXShG03Vsls6hv1jJlT9AQhoG1iyj8ebnlwQvWUwpxfnDy3nHSWG/wFdaEMNAURDarciAVlJ//Cz1+sgRCF/r/m1mkzCUorJxlagcaGfSuA7E9fmpykBLsSzgDi4sK36/GppP6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7gyZlwmlHYU/ZmUOvs3ehKHXbCDvmkOMT92IXgOjuI0=; b=JSzDU8etqvrtlXAFOCYjC7lel0VCKjapa6gM7WIUmOXZV1SAaKKvp5TkddFNnuitEO7XcUnAm/p6GyEITZoXMzQVRl+Bf3HwsRuA3CcdeB9cHFN+pEBO0p1TlWBNss8mPL1k3ILVaYJOcCxgtXfPd58TMyReWEu1yYJ6nqp6Xi/aiu90kScF+1YxGUY1l3KYYb1/D3KVwai+MwVz6mUd3AnPnm1S/fDYSGQD67LLqLXz5uDko0mREcDzLw0xbG5LJCVbyzurqa4PE99gPpLrPCZz+LYLGt9+YW+pTXOUPSNtHDcYSo/5fRhlgAg/mvjAZOzStZ4Lzw2F70e5zKlixw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7gyZlwmlHYU/ZmUOvs3ehKHXbCDvmkOMT92IXgOjuI0=; b=EsSoLP4vmT+VbVjBbyAbsIPlGxQoQjktFVEadP3SD9bFG6jR/sdNZfPNmdr9bssK6kW1FYOfFBhDeQ+9ECvCjiNL5vNcM7aA0oelso6zG0Hkr2rkDYvn8vI0cpPjzTG4BGsZfbVqq+ijn4rZuzG6pLtldPzDvF0Jzb/P0XmKltmUqmZM1xNP+/lNseY+M9WIWDKdFuLBDdN5jul+hDbysqGEoH2lpgcr+HCwKViigqaF7nyaupKTIBIj1GUlrOFIWwAnIDgmDdvnGPt9wnOXVyoyh7pwKtaXQTTcTlU8x4J0JBgeY/w+WAvOKxRTdL7U9c0uwCtQg2YiZjwiqmryLA== Authentication-Results: gibson.dropbear.id.au; dkim=none (message not signed) header.d=none;gibson.dropbear.id.au; dmarc=none action=none header.from=nvidia.com; Received: from BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) by BL1PR12MB5253.namprd12.prod.outlook.com (2603:10b6:208:30b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.21; Tue, 1 Jun 2021 12:57:13 +0000 Received: from BL0PR12MB5506.namprd12.prod.outlook.com ([fe80::3d51:a3b9:8611:684e]) by BL0PR12MB5506.namprd12.prod.outlook.com ([fe80::3d51:a3b9:8611:684e%7]) with mapi id 15.20.4173.030; Tue, 1 Jun 2021 12:57:13 +0000 Date: Tue, 1 Jun 2021 09:57:12 -0300 From: Jason Gunthorpe To: David Gibson Cc: Kirti Wankhede , Alex Williamson , "Liu, Yi L" , Jacob Pan , Auger Eric , Jean-Philippe Brucker , "Tian, Kevin" , LKML , Joerg Roedel , Lu Baolu , David Woodhouse , "iommu@lists.linux-foundation.org" , "cgroups@vger.kernel.org" , Tejun Heo , Li Zefan , Johannes Weiner , Jean-Philippe Brucker , Jonathan Corbet , "Raj, Ashok" , "Wu, Hao" , "Jiang, Dave" , Alexey Kardashevskiy Subject: Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs Message-ID: <20210601125712.GA4157739@nvidia.com> References: <20210503161518.GM1370958@nvidia.com> <20210513135938.GG1002214@nvidia.com> <20210524233744.GT1002214@nvidia.com> <20210525195257.GG1002214@nvidia.com> <20210527184847.GI1002214@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Originating-IP: [47.55.113.94] X-ClientProxiedBy: MN2PR01CA0013.prod.exchangelabs.com (2603:10b6:208:10c::26) To BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (47.55.113.94) by MN2PR01CA0013.prod.exchangelabs.com (2603:10b6:208:10c::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.21 via Frontend Transport; Tue, 1 Jun 2021 12:57:13 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lo3xI-00HS9p-3m; Tue, 01 Jun 2021 09:57:12 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d9db6468-e9f6-4ad5-04b7-08d924fcc6a1 X-MS-TrafficTypeDiagnostic: BL1PR12MB5253: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dyTd9IF7sCTPcGng9yvoSm4sxvbz3irRaF7bKcgAFFsqXLRX2p+Ad+YGm9VTEbpTIedr3k3SUGRWOQXGF+MH1bVmcW1dDNlc3n2h7HrnZhr9l0VKDjSGBNBpafL5Ga/pg4mtFn5rWp9yQUylccGGWUT2QUsSFFCneXQHQJN1LOglrc9tLgFtlQe1RDhyaJW2WWRixcN8vyD3BuwdEyOGmoPIsgoI2brlYvPgAuBYM8N6NZ7qPfHb927iQNueVrJrJhnC4QMwZYUEsF97AtSrPzxm8oT3dMlUOfVZbaSWe5LTUboV5YOJ1PhR9lgQlvpbPKU1G75nAFyoRzH86JSzuQuEf+ybMl/OYsDuLMazAaMl6tfkBri77Ye9AQ5lIB523llKCtkcPmrBfZp25eM8+dbRVrhQK0+OkxIUvk4cSSdGG3TZ3ThLOZlETFH1MmzoRo0FosiBFI/BOOAllW8ZVWjKu87JsdQMWKM0RPqlMgX0CwFMdwZiC78LgA1epsUxw+khph8jvkPdRT/pvu8zYtoSo0AI/+EUA0PKNNqGSU2h+8tK/lHzgoU2tVB3Z/EZM4NK6I1K1gLYexDnUMO2fogbScIdU1adEMuckz4E6yG4aUYLj76PQDzv/7XrArKSqANfFMzhFwGQmo7E7YlK1tM1GKV2MgEGj1xAa8AJLnhGccONBIIMMpLGhTXxInDDtEUPx+PQDtGWkqT8L2J3Rh4UPJJ09cnWTE6yhzSWlpA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL0PR12MB5506.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(346002)(136003)(376002)(39860400002)(396003)(83380400001)(6916009)(966005)(26005)(4326008)(8676002)(2616005)(36756003)(186003)(9746002)(2906002)(478600001)(54906003)(7416002)(8936002)(38100700002)(426003)(66476007)(316002)(5660300002)(45080400002)(66946007)(66556008)(33656002)(86362001)(1076003)(9786002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?zwUlqhOsSyXd5CkgHA86Hn7oVn7eFae8H0YqvN1QoFwvpsKrS6lGyJjzCt9p?= =?us-ascii?Q?s8wSZBH/i2fkPxYQ2RpM7Nsu/Ag49GBjC9UU5LL+x7m7rkoz9MP93E0zdkNj?= =?us-ascii?Q?g6QbJWMBzDouXaidz0J/nSqUSWu8XbM7vyF0Lvg5e2cIdoXFm1/iuPE5t6r+?= =?us-ascii?Q?w9o483dPJkINLrbbELuzzHol9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?us-ascii?Q?WFCaWzsw0mirc+sSQ99d/hT8LDZrPQgmAPVjNFFOAud5/knACVjTc3OqtnXY?= =?us-ascii?Q?e0kcmZ8u0E/R9dxErThlkvlW3G7sg3wuDIohruhIWqGFR8XmFaLw1EVQy+Vp?= =?us-ascii?Q?CC2wBOjVOT0xjYVoBrqRb+HmYP8bxB6m2TszM0TPZsB6e6poLgf9U4VrpU2Z?= =?us-ascii?Q?6HkvfS+0PgxI/PPjJB3tcsc/HM8yNPu5BR4xmMTtVM5rw9Ng3m9JdhZQHttr?= =?us-ascii?Q?583NYcktpGNb+Ku8nbyu+nkR?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d9db6468-e9f6-4ad5-04b7-08d924fcc6a1 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB5506.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2021 12:57:13.5780 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EQLiNuU6v+wRKllp52/T9oCFQ/nMABooxoinU15V4UtOMrPTlkc4rZfZIpwiMio0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5253 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 01, 2021 at 02:03:33PM +1000, David Gibson wrote: > On Thu, May 27, 2021 at 03:48:47PM -0300, Jason Gunthorpe wrote: > > On Thu, May 27, 2021 at 02:58:30PM +1000, David Gibson wrote: > > > On Tue, May 25, 2021 at 04:52:57PM -0300, Jason Gunthorpe wrote: > > > > On Wed, May 26, 2021 at 12:56:30AM +0530, Kirti Wankhede wrote: > > > > > > > > > 2. iommu backed mdev devices for SRIOV where mdev device is created per > > > > > VF (mdev device == VF device) then that mdev device has same iommu > > > > > protection scope as VF associated to it. > > > > > > > > This doesn't require, and certainly shouldn't create, a fake group. > > > > > > It's only fake if you start with a narrow view of what a group is. > > > > A group is connected to drivers/iommu. A group object without *any* > > relation to drivers/iommu is just a complete fiction, IMHO. > > That might be where we differ. As I've said, my group I'm primarily > meaning the fundamental hardware unit of isolation. *Usually* that's > determined by the capabilities of an IOMMU, but in some cases it might > not be. In either case, the boundaries still matter. As in my other email we absolutely need a group concept, it is just a question of how the user API is designed around it. > > The group mdev implicitly creates is just a fake proxy that comes > > along with mdev API. It doesn't do anything and it doesn't mean > > anything. > > But.. the case of multiple mdevs managed by a single PCI device with > an internal IOMMU also exists, and then the mdev groups are *not* > proxies but true groups independent of the parent device. Which means > that the group structure of mdevs can vary, which is an argument *for* > keeping it, not against. If VFIO becomes more "vfio_device" centric then the vfio_device itself has some properties. One of those can be "is it inside a drivers/iommu group, or not?". If the vfio_device is not using a drivers/iommu IOMMU interface then it can just have no group at all - no reason to lie. This would mean that the device has perfect isolation. What I don't like is forcing certain things depending on how the vfio_device was created - for instance forcing a IOMMU group as part and forcing an ugly "SW IOMMU" mode in the container only as part of mdev_device. These should all be properties of the vfio_device itself. Again this is all about the group fd - and how to fit in with the /dev/ioasid proposal from Kevin: https://lore.kernel.org/kvm/MWHPR11MB1886422D4839B372C6AB245F8C239@MWHPR11MB1886.namprd11.prod.outlook.com/ Focusing on vfio_device and skipping the group fd smooths out some rough edges. Code wise we are not quite there, but I have mapped out eliminating the group from the vfio_device centric API and a few other places it has crept in. The group can exist in the background to enforce security without being a cornerstone of the API design. Jason