Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp845863pxy; Wed, 5 May 2021 15:40:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVAXpuKV3fzG5Z0ou7HcHfD3TXa+VcWKRRb2GowS/RJ0ivfindWO94qPsmU8T0KDokpj6s X-Received: by 2002:a17:906:6ace:: with SMTP id q14mr1056210ejs.79.1620254445112; Wed, 05 May 2021 15:40:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1620254445; cv=pass; d=google.com; s=arc-20160816; b=y0rWyq6jaQ2BgFNccIGhFhePLNBwphqKZYu2f8SB96Chc9chlYJCbHlp9fzXGOYS/9 qqmr6LfrF3YCNw8VuEPMI7s7MOLzW1NjyqpS+2iAST7KSq83kIFPb1g4OD22nSMeQL2b 4aRiEQu0obihhh+SU9tYyaoV6dY7CN0sZ10P86+JHDGYAJQEv7x3htwpYLs/9394LVZI qDDwDaFF7t90XQq/OLnDEREMhwIaZ1ihsS5Halu2GEu/dQWQhCn9kH8b1qs8RLytI+jV GkN66etsStjc0fSYtMLwHPLaghuJKPSYP1pgaHpnFssjOOodR4UktmFSZaEo0EqDr/Oc MyZg== 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=l2Dr2AfpdUpdq9csMR9KxAzmzXD1M2n3+AilvtRKQzI=; b=b2DHuUM6sRx/H/Qvoan+bWecUShbEj8kIWUZYcdMd70iEZvkqIoXPdSjgpJaBPLB3G CTi/lbORyO9bvQCQiYEjS+tUmg/4Yqum4bs/DwBqrYB0623z7iEr5ZDPYl2c/7c/lebu k8kaJN2k0QxfANExxFrKJebrCj4yL/GTizie5P+4pYLAZFdynjHI85SzHajNSFfXyRb2 GoW9JZTouWqlce7dyR2c9dinJm80MAqqVavHAekIM66zlnzBQfp5z2FqcL4qAmEMPhj4 qABQUcTX6merKnw/8vOjsNPP+Z2+lm1MzEPtB65whU9cAfKe1WYIiSdPeXb2FCCHgien KMVQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=msOlANKY; 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 gg8si521001ejb.649.2021.05.05.15.40.13; Wed, 05 May 2021 15:40:45 -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=msOlANKY; 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 S233784AbhEEWWV (ORCPT + 99 others); Wed, 5 May 2021 18:22:21 -0400 Received: from mail-dm6nam08on2053.outbound.protection.outlook.com ([40.107.102.53]:36992 "EHLO NAM04-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229870AbhEEWWT (ORCPT ); Wed, 5 May 2021 18:22:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EOD76tAo0mMmmL21NZe2LxfYajQJEnvmGZbW5JXNgD2Az6L5waUEXiilJsV6W7pdGxOMWH3Ee/0AEV0qdVvLJ10kSlqkvrbofUNZZ9CkZZnFwuyvGmp9OGHFJmS4GPKuwFkAlWCAfsrab04c0nMRcIU9H3zW4hByi8ivpbkoBhQK/Kg0Lw6pW38qAOeSgAwy/S1HkqOobnh9e9e7YRc8DI+mBvmIq1WjdKL1cGl1MehAslOthTgYD8GAbHEYu7GL/HNC6VWO/s1vpMTZUT0Fl3NwWavfolqpKX0phs+TftPpJqGZhCWSNKYGVnnYzt9OEAiBKNo6k9hOnYcGOsfWXQ== 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=l2Dr2AfpdUpdq9csMR9KxAzmzXD1M2n3+AilvtRKQzI=; b=kCFecC0HSDSOXH1NRzdJjMYBNdfzHNB8WMhzHFun0lpL/q/cSMrmwEKkldaqrrNUkfPyYFGWxDHPKAuUkv74czTknjTPUnf0Hl8hs1MBXILugm0muVXokek05DNl/u3OcPDYAUrmMnkmk8s3aQaQdjfIsg9fdya4rfMMell3jy67F5iBs72RS7wVI2ApVOf9XgLvCN0/KtstZP00XZFJgyaDK0Lzsa5Mja3FQPbsnfAd3H7zQ6LwQttDLH97Ws6edm9+NNx275tHxjuH6VuhVf48Oi6g0srshXwxquy+2zYo8JZDRNdEjjQTLRafMZBPjNEZHjHzhjR8DDijpwHv4g== 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=l2Dr2AfpdUpdq9csMR9KxAzmzXD1M2n3+AilvtRKQzI=; b=msOlANKY0aCIEPYZdRVrnlIHSheRbMI2icZ13dCoTtKgHqlLzUI3lTyCUnJnhFY0/X+W6pBhFhNPHwy/vdhsO4vM/4deb8FmHInBn3r4FC3m8c+wgN5CeXZZM481YP4X8j56ucc09zpmGCGS8uwawnHJx5juUZTDfGDOiMO//2XVg8aX1p40wHUrKeFTeao27i4+Vc7DzSbq+r0OEnYw99Q1pXHI4jKCLVLIiSDOK+KbDjlKZn3nOkxDAbkYBVSMQFdebWuNRzF0ljpB299dV05B9DCt04w+sCair+x5Ysat1JWolniG/E3t4CzOoDRXMPDrl/XrjIQdAJu5S/C4vA== Authentication-Results: linux.intel.com; dkim=none (message not signed) header.d=none;linux.intel.com; dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) by DM6PR12MB4266.namprd12.prod.outlook.com (2603:10b6:5:21a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Wed, 5 May 2021 22:21:21 +0000 Received: from DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::ddb4:2cbb:4589:f039]) by DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::ddb4:2cbb:4589:f039%4]) with mapi id 15.20.4108.026; Wed, 5 May 2021 22:21:21 +0000 Date: Wed, 5 May 2021 19:21:20 -0300 From: Jason Gunthorpe To: Jacob Pan Cc: "Tian, Kevin" , Alex Williamson , "Liu, Yi L" , Auger Eric , Jean-Philippe Brucker , 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" Subject: Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs Message-ID: <20210505222120.GM1370958@nvidia.com> References: <20210426123817.GQ1370958@nvidia.com> <20210504084148.4f61d0b5@jacob-builder> <20210504180050.GB1370958@nvidia.com> <20210504151154.02908c63@jacob-builder> <20210504231530.GE1370958@nvidia.com> <20210505102259.044cafdf@jacob-builder> <20210505180023.GJ1370958@nvidia.com> <20210505130446.3ee2fccd@jacob-builder> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210505130446.3ee2fccd@jacob-builder> X-Originating-IP: [47.55.113.94] X-ClientProxiedBy: MN2PR10CA0016.namprd10.prod.outlook.com (2603:10b6:208:120::29) To DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (47.55.113.94) by MN2PR10CA0016.namprd10.prod.outlook.com (2603:10b6:208:120::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 22:21:21 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lePtQ-001Ze0-2N; Wed, 05 May 2021 19:21:20 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e1d6f957-0f4a-48e8-abeb-08d910141c6c X-MS-TrafficTypeDiagnostic: DM6PR12MB4266: 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: ywOqFuCDGCQFvXPrtksyIhy+2fP0MI8r574LNwarFmEfXXhgFjwKT9HYH4q+20QuR587a5mncTPb4qHtX4uwJnliyz59Of2kkakzXwJ3H7r/QexatrlpSUP7ck/yPOOqTz3jiijalCIJ84M71jVivaI7BmTY3XYUyBSbV59q1vju33v+l3t1ocW8po6SDI43rVnmuf+KQzdekDfKIgFnp4ndmvinYL/hAA3lch/v6413yHvlhpVD+ubsXeueP806/3dg+hZ4MiFrZb5nFwOxp/c0XywSrVN/TR4p0eMth5eL+K9EsrumP6mnW3IEaH2Hai6EVH7zxLeLBzj6JLmQw9HR5ZUMMyH/ab6olL5aYpSyKJMaQIWsfzkj6u9Mq8Ian6OA2d+OEfP3NsN6q/uKoRDUYa6cNw0xU6DjmRQnuU7xG2vPBe9bDy0eHWVVCE9BMm69E4PIxQH2AXrVW1Ov8OjB1CqNR11Lc7TcqeEKCbygr6pfNuawmy+NijYbMgcQruyireEA5ZYdbcHC5RkO4Pj9i8VEWvDYNxYvHDPVE8PyXf4p3negvVhvdA569XGZS+J9HpFxya38ja9nQo1xetqos4uuCLuu1wAYKLZA1HA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3834.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(346002)(396003)(39860400002)(136003)(366004)(1076003)(83380400001)(8936002)(36756003)(38100700002)(2906002)(478600001)(86362001)(316002)(4326008)(2616005)(66556008)(33656002)(54906003)(8676002)(6916009)(7416002)(186003)(5660300002)(66476007)(26005)(426003)(66946007)(9746002)(9786002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?WnVb0wxJXZ6wXAR/NdABVR+AOdJUqBbYfULZMAY34N8K1XMKGEpP9lKCmd5S?= =?us-ascii?Q?t7tI9nABbtr+288rsdIGqqrBAwmzrnL3xukodRU+EwU2SuW+B2BuCATW4gUR?= =?us-ascii?Q?GzWUkmRtSJ1jaOxzmNHVgVql1D7Cd/8VSJnDWMz4NkzypsSRliEMWGiuZkNt?= =?us-ascii?Q?wmlcCZSh61PLVWCpHLCkdOe4w+j3KRh6vgZKE/xjnyvsjxBWOgZvNaziOD7n?= =?us-ascii?Q?1y67mvSpmJLUVIoB0VW2dzq4AwMw+ejq5gUux878xQapgXXwNbocQj8KtKbK?= =?us-ascii?Q?cquOSmGgEwbbv15mBfeCPKmjoyoy6LvjWnV6NQ5o6OGLO8JGy42SUMCTQm27?= =?us-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Momhr4HoAvS7i3XI1aNGY8neG7oQDoJS?= =?us-ascii?Q?5c3XbpRCXBbDWC31gUQ90oaKvZggAUGrlSAiNSH5KQ4H+igI4I/pSMw7gjDC?= =?us-ascii?Q?7pd8MIVozWW5WOm1crSJ2i2N?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1d6f957-0f4a-48e8-abeb-08d910141c6c X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3834.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 22:21:21.6227 (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: zCY83/h/hneVtwqh6zCWZfDGfTGBj4LwjfgK52T+Oar37F+VEDZVUYKA3j4vVipp X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4266 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 05, 2021 at 01:04:46PM -0700, Jacob Pan wrote: > Hi Jason, > > On Wed, 5 May 2021 15:00:23 -0300, Jason Gunthorpe wrote: > > > On Wed, May 05, 2021 at 10:22:59AM -0700, Jacob Pan wrote: > > > > > Global and pluggable are for slightly separate reasons. > > > - We need global PASID on VT-d in that we need to support shared > > > workqueues (SWQ). E.g. One SWQ can be wrapped into two mdevs then > > > assigned to two VMs. Each VM uses its private guest PASID to submit > > > work but each guest PASID must be translated to a global (system-wide) > > > host PASID to avoid conflict. Also, since PASID table storage is per > > > PF, if two mdevs of the same PF are assigned to different VMs, the > > > PASIDs must be unique. > > > > From a protocol perspective each RID has a unique PASID table, and > > RIDs can have overlapping PASIDs. > > > True, per RID or per PF as I was referring to. > > > Since your SWQ is connected to a single RID the requirement that > > PASIDs are unique to the RID ensures they are sufficiently unique. > > > True, but one process can submit work to multiple mdevs from different > RIDs/PFs. One process uses one PASID and PASID translation table is per VM. > The same PASID is used for all the PASID tables of each RID. If the model is "assign this PASID to this RID" then yes, there is a big problem keeping everything straight that can only be solved with a global table. But if the model is "give me a PASID for this RID" then it isn't such a problem. Basically trying to enforce a uniform PASID for an IOASID across all RIDs attached to it is not such a nice choice. > > That is fine, but all this stuff should be inside the Intel vIOMMU > > driver not made into a global resource of the entire iommu subsystem. > > > Intel vIOMMU has to use a generic uAPI to allocate PASID so the generic > code need to have this option. I guess you are saying we should also have a > per RID allocation option in addition to global? There always has to be a RID involvement for the PASID, for security, this issue really boils down to where the PASID lives. If you need the PASID attached to the IOASID then it has to be global because the IOASID can be attached to any RID and must keep the same PASID. If the PASID is learned when the IOASID is attached to a RID then the PASID is more flexible and isn't attached to the IOASID. Honestly I'm a little leary to bake into a UAPI a specific HW choice that Intel made here. I would advise making the "attach a global PASID to this IOASID" operation explicit and opt into for case that actually need it. Which implies the API to the iommu driver should be more like: 'assign an IOASID to this RID and return the PASID' 'reserve a PASID from every RID' 'assign an IOASID to this RID and use this specific PASID' In all cases the scope of those operations are completely local to a certain IOMMU driver - 'reserver a PASID from every RID' is really every RID that driver can operate on. So it is hard to see why the allocator should be a global resource and not something that is part of the iommu driver exclusively. Jason