Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp722922pxj; Fri, 11 Jun 2021 09:49:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwktE+IHyDCdIMAQdHhF7h1hEGTqvCJpQ3SJl1KA71xzyR/k8d9+Hs71XfOA1f8/HDw0ThR X-Received: by 2002:a50:fd89:: with SMTP id o9mr4756632edt.336.1623430144116; Fri, 11 Jun 2021 09:49:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1623430144; cv=pass; d=google.com; s=arc-20160816; b=pvdcDDhDzFjZkdN/KNy9fD2uyRx+prsqv4EALNNei0s7uUPSH3UHP77v9SQgU7dsYo GrAcOEQE5LtOv+JIlal6cYMXkbFXpkwCdub9C/ri2BBlKwagONecXknyICMzOAascNCi mxghlR570R8/TWdPH/6u0O43GbegE+HlDiRXw0DjDq7vIEUvJhh/Xmxkz2ilRsZDScE6 PsfZye9ch/0W/PLLDtDMZ4P4Wd3c6l+wFRxBWbgnSrb57ru6Y6Fh3zVQzWwskB82Afcs /KyrVp/zFUOhOl40aA/Z8xbIRkEURccWj1GIhStTNzSgRz6mBtGIkkLBkygPh3+Z2oAD HFzg== 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=Y9B53J/hvrrshyeIyGq53SElfGuNmstjH0Ya/Tac7r0=; b=vUsKFY8+GSJ2D3V4LEszGMzWDy809Y91pw3zY5S5+vM5udcJ6b3RIAiLnGS6dSmL7z 5SJR2djbsi1PcxUuxXGcNG6W9cgSKcFCPj4N0BwHk3znOkie3c39EtNGqGAbwKmgVPPN msg+zEkbColXhsBaVnf/j5MdC6t6SIP/SZ3hdJjx0jrvTwmkFDENO+8rMcjnP65qVOMi 0rn03jlB8rEstfZWVd4K22oYLIdOBjo3ftfyZO1E7Y8Y4+uQGEsqyEnsClLQkTfKhSy7 yr1WkuXLdHj3NdlZQKGD8Hxb1Sba5Ky2brM9WDYIZOPlrZdUAvPUo5ds+YVGpaJHCwIa msQg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=atlfpZCG; 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 a4si5358955ejs.331.2021.06.11.09.48.41; Fri, 11 Jun 2021 09:49:04 -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=atlfpZCG; 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 S231817AbhFKQse (ORCPT + 99 others); Fri, 11 Jun 2021 12:48:34 -0400 Received: from mail-dm6nam12on2055.outbound.protection.outlook.com ([40.107.243.55]:53633 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231860AbhFKQrb (ORCPT ); Fri, 11 Jun 2021 12:47:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KvqJ+PlrI7xQwoE5qDqazK1bD6IrUM13PvOgPXIDlaIxt87lrvsK22+8gIrJQf0FMhAsmzhd0ePuVZqKoZSBJ/UVBO/lfnKNyKAsW3p7zo5M+2yJ566lgr52THolJV0xpVRJg25P5rYo7gQ7EYIv/dFWwqLCS01MFJIy7rf8eX8ktHfD7nBnFIAUFaGYm6HOVnAYr+1A4x+SMUaW83jvWy374ZpH+l05c9cd2QZ3WDI71S9WpnrsuexVz2xyl0Lf5vK7nlRscjic++CbzbFLpmO9E+6r46jQVBc1MSMa3cMiW4X5LdEGozN7+Hni9jAwY4ZB8G37VdOFnkQjOnY7ZA== 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=Y9B53J/hvrrshyeIyGq53SElfGuNmstjH0Ya/Tac7r0=; b=GRWO8L4cbJ+MWcLywWe2mCyRJXcwfQ6saGrUutsWNsz7b+KxrUO450jybBayh8+/2q79yy40QsB+iriUJuwFS9ndIfMVTzBP7T0jCmDbh2dmLOrjb8Kzjr7WxnvoV1SVEBBvG5D+kNpwye94zQrPHBR1FWyku9E6GskX300A65FLmA1ZOWxHWBi1uZJEQRnf6MCVRxz5+JD40KktrpUsUA9YxP8/zYfW7IvTqNXrdGlsRtHU9YhSVhWFMdaIsXDtyJjt1bDqS+wDWnZclRWv94DibZZiLVerzN09QokjSzzr+lDdFexDdn63R4b3NM/j/sh9Fz85bqQdpZ8eR2h0IQ== 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=Y9B53J/hvrrshyeIyGq53SElfGuNmstjH0Ya/Tac7r0=; b=atlfpZCGGYodfXrgn0UlH7heja8r7DjSUZX0eZrtrPfGUqjwrHGWBu4MSbHkzDgWvv3cKnemwmdU5PW+SK/NH9oAkIeygz56qXAkiT4tSYaqG+qQzjtyAsgAyQ0zhI7JkU4UERwm0OL3PPngiRg31oEyC6SdEZX6XSPyIXAZIxZBoSX/w4pkEfrDNgXECSvFXu2KBqw7/RZc8M4AxCRu/ecFRe7/HL63/axgNn7xBkrKvdi6Q95qqP3DlHLo9NJRtvW6v2H/3U1n5J2Uvh5Qq52L7/W4vXcs+5jQ29jtA51tEvgD7u7xwb751Ng/8ZMiiMCF6TakR4GfFyRbTc8N1Q== Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=nvidia.com; Received: from BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) by BL1PR12MB5189.namprd12.prod.outlook.com (2603:10b6:208:308::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.20; Fri, 11 Jun 2021 16:45:31 +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.4219.021; Fri, 11 Jun 2021 16:45:31 +0000 Date: Fri, 11 Jun 2021 13:45:29 -0300 From: Jason Gunthorpe To: Alex Williamson Cc: Joerg Roedel , "Tian, Kevin" , Jean-Philippe Brucker , David Gibson , Jason Wang , "parav@mellanox.com" , "Enrico Weigelt, metux IT consult" , Paolo Bonzini , Shenming Lu , Eric Auger , Jonathan Corbet , "Raj, Ashok" , "Liu, Yi L" , "Wu, Hao" , "Jiang, Dave" , Jacob Pan , Kirti Wankhede , Robin Murphy , "kvm@vger.kernel.org" , "iommu@lists.linux-foundation.org" , David Woodhouse , LKML , Lu Baolu Subject: Re: Plan for /dev/ioasid RFC v2 Message-ID: <20210611164529.GR1002214@nvidia.com> References: <20210609123919.GA1002214@nvidia.com> <20210609150009.GE1002214@nvidia.com> <20210609101532.452851eb.alex.williamson@redhat.com> <20210609102722.5abf62e1.alex.williamson@redhat.com> <20210609184940.GH1002214@nvidia.com> <20210610093842.6b9a4e5b.alex.williamson@redhat.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210610093842.6b9a4e5b.alex.williamson@redhat.com> X-Originating-IP: [47.55.113.94] X-ClientProxiedBy: MN2PR10CA0024.namprd10.prod.outlook.com (2603:10b6:208:120::37) 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 MN2PR10CA0024.namprd10.prod.outlook.com (2603:10b6:208:120::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Fri, 11 Jun 2021 16:45:30 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lrkHh-005geW-Gw; Fri, 11 Jun 2021 13:45:29 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2430d3b0-f480-448e-1d1a-08d92cf85323 X-MS-TrafficTypeDiagnostic: BL1PR12MB5189: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tWBOsGxa73UD6Eo8Uh9QBVI3x2SPnP+/TS/1Hj0V23Iz3w3IXrfENZnmQRmBzq7iLzlienK0+GLr9/JSMJJ191FxgMBvMp0fEAm/FiyQ+xqIes1crqB1+zXmdpLKICzGxjGewHJAJu7PoinAXeLa+QyMiX4NpC9vOqMh/RA8oGW6l6QtjZZIAT2XLKu8kst8+M831FPaEF4Ja3Hf1iyZTIVh0pxMPuX7KlIJY49Ez3IoaSClBV++3wWSC6OWxVeD5Glxfo9Y7cx4aYT4Jlybu8tfjfbaXKW+HcohUe/V/2ZQJwaNhHqRxMvrT4btrt6uAZY6gsWVsi+YYDKBchB2KxRcrPZBOY2fWWCeGg/NoIjDAxEwZAgG44WwrQZEWeWT47xVVtW1M2x/xHSnW65lE5QP3RuaynU+so6ka8ZmzqW1wxbEZ5zqfN5Ua4lI0yLOeTMECPDh0O9My3bQL+IXlISJUrbLwqF/LDEW2IJmujcQWsgpyrfvTRn3NKqtovvQDfA8idO7zVHiN3bbwMZOc4tQwRTQ7fQ4ZeFd7zUwUuuwNBG9ewPaS8qwxueyvWd64qFyw6wg48ezrzLXak+5ae3O4CUpHKtuDw2Mfo5ysuo= 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)(396003)(376002)(136003)(366004)(346002)(39860400002)(83380400001)(8936002)(7416002)(1076003)(6916009)(8676002)(5660300002)(26005)(4326008)(36756003)(478600001)(38100700002)(86362001)(316002)(426003)(9746002)(9786002)(2616005)(66556008)(66946007)(2906002)(54906003)(186003)(33656002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?n/5xLWjPmx0tmi+MUV4SpCetkyPOozTdNZzqCsA2zRvFTEyFiTTj8OnxWDgV?= =?us-ascii?Q?fpEyQiP9iOiN/4YeoblnG2nOeNXVhl1VY3Bcx0HVC5HxKtM/ETXYq3yWocDh?= =?us-ascii?Q?bk0W647JhiyBksCgaTVkUzceDqHxlV92lk5AryltH9gwQ+27EFODC02enWAD?= =?us-ascii?Q?18X1laVum9dbLD2rn2koUMHgdoKQBzFSboJt2/kkhfWaYwJIs8z3nBneCC2h?= =?us-ascii?Q?49Na9wiQq/h+HifZ1fr1y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qmtK?= =?us-ascii?Q?30YMG2J8QetX4Nn4LS2dK1jNoMRZ//bWWp8rZoIgMeq9EKDWsBm5ILoWsRdh?= =?us-ascii?Q?yUxwoO3q1v0n9L2yb6iOQQqOPoxIpot7DlSvwl9C4jO2xl3aGrBk+YP574vK?= =?us-ascii?Q?CMpCeEIgXBQ9XTVot49fHNYniTPwmkhN06onmX1pG8uftiST3mCYKsGfH/zT?= =?us-ascii?Q?H2nfZbfOhjL5IbX1QldsiGqP?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2430d3b0-f480-448e-1d1a-08d92cf85323 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB5506.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2021 16:45:31.1472 (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: M0zuAQqqFJEVYtrovxh5EBzvoC7FiUuv+EIvGitHjCBS6w4cyGoxNoVn7jLDZr+I X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5189 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 10, 2021 at 09:38:42AM -0600, Alex Williamson wrote: > Opening the group is not the extent of the security check currently > required, the group must be added to a container and an IOMMU model > configured for the container *before* the user can get a devicefd. > Each devicefd creates a reference to this security context, therefore > access to a device does not exist without such a context. Okay, I missed that detail in the organization.. So, if we have an independent vfio device fd then it needs to be kept disable until the user joins it to an ioasid that provides the security proof to allow it to work? > What happens on detach? As we've discussed elsewhere in this thread, > revoking access is more difficult than holding a reference to the > secure context, but I'm under the impression that moving a device > between IOASIDs could be standard practice in this new model. A device > that's detached from a secure context, even temporarily, is a > problem. This is why I think the single iommu FD is critical, it is the FD, not the IOASID that has to authorize the security. You shouldn't move devices between FDs, but you can move them between IOASIDs inside the same FD. > How to label a device seems like a relatively mundane issue relative to > ownership and isolated contexts of groups and devices. The label is > essentially just creating an identifier to device mapping, where the > identifier (label) will be used in the IOASID interface, right? It looks that way > As I note above, that makes it difficult for vfio to maintain that a > user only accesses a device in a secure context. This is exactly > why vfio has the model of getting a devicefd from a groupfd only > when that group is in a secure context and maintaining references to > that secure context for each device. Split ownership of the secure > context in IOASID vs device access in vfio and exposing devicefds > outside the group is still a big question mark for me. Thanks, I think the protection model becomes different once we allow individual devices inside a group to be attached to different IOASID's. Now we just want some general authorization that the user is allowed to operate the device_fd. To keep a fairly similar model to the way vfio does things today.. - The device_fd is single open, so only one fd exists globally - Upon first joining the iommu_fd the group is obtained inside the iommu_fd. This is only possible if no other iommu_fd has obtained the group - If the group can not be obtained then the device_fd is left inoperable and cannot control the device - If multiple devices in the same group are joined then they all refcount the group It is simple, and gives semantics similar to VFIO with the notable difference that process can obtain a device FD, it is just inoperable until the iommu_fd is attached. Removal is OK as if you remove the device_fd from the iommu_fd (only allowed by closing it) then a newly opened FD is inoperable. Jason