Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3945907pxf; Tue, 6 Apr 2021 04:29:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHhSO+tgnXlOsf6Qu1mdV+byXGjQJiR/AwG1O6DY4Z2FxWLP/6JcMdecfzf8SGfeoma+f7 X-Received: by 2002:a05:6402:270e:: with SMTP id y14mr37321720edd.283.1617708544638; Tue, 06 Apr 2021 04:29:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1617708544; cv=pass; d=google.com; s=arc-20160816; b=XKvagTTGztDfestPLaL0sFcj7upZhfH4qWezmisocTuDjw/7nEAxN/yJWesaQh9hfo JBLDLrxd6whATLGfcwh8oxeGjX9C5FH1RyG4/yxtcSzAKmk7PKu5uPvUvHwiaDBJ6/nV tySata8mmLuhNMy/1bpeMcnLt1F29mYddHWxkEXTo02OOc2UrC+esPC8OeSNqImCOyni 4y3nLJwkvbKNP/dG9mV0kZY3YpNrxJ7+tQWYFRGaIjuOHaw+vPpKzGx7G+ddgWtBsM6Y D7uY4NRnSlpLI0BDbJB0/IBindl/yt2RFPjWQpzC7tlBgcNeyaRamh5dy2qzc6OmOZF+ aJzA== 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=O1RQeoDaVVHz6tzdTwIHAww8PRvtuS0cmUnaKDvh6LI=; b=R8WTQUS1+Au03Hs1PvGi8kV2xvmV1fDeyDwYVO830gFO+ZbwbSJmzJvVkoYpotARse 9IeMIDp50HWt+jA2WSLZrRthpWC/TCVnDeHJ4bI/9gvkrFWSJ8ujxNPAA8zbvc5vh7UL k3XEZLeC0hrYNddy8ZI74+Orzoos5dyd9yDkc7BAIn2S47mkIXPEdCUh+YoHY3abd9d5 WWP1p79jNCk8AUiDF5ECtgalua3v/LJznaA8QjrPY3OITJW04brUCiSoDpNvDyLAwQN3 utei7APv/HL6irYc/3e8E1lPKL7ryVgHmaJ70tlfp+Gsc8yKfY+RVc/Kzdb1zdR/tMar ll/A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=j2KiEIyw; 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 o14si16334746edz.409.2021.04.06.04.28.41; Tue, 06 Apr 2021 04:29: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=j2KiEIyw; 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 S241967AbhDEXml (ORCPT + 99 others); Mon, 5 Apr 2021 19:42:41 -0400 Received: from mail-dm6nam10on2059.outbound.protection.outlook.com ([40.107.93.59]:53063 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241925AbhDEXmj (ORCPT ); Mon, 5 Apr 2021 19:42:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DiphAT2sMPvLUqUBflUlUuVVM9pCLisYnkd6nvjNCkxDwPH6jk+JItWoQMwAFSPIj8Mwm2I9LwVI6jpX03B2Q2wCeunW3IQvePaoN4a/QTFnxLv/TJBSqkFhJ5sb6LMhk2D22a2BqIIUF4tnhwQD0lHtNn0jv+99k5FM0nC+RqXbdp8lvAnDJN7eveqmBMUHrx4gyinN4d22E/eiTdrwKhXT/fLgkkt0ZbKvZfC8KJNCdaacPb4ee3o82b9PtPuX+6KfeFI/qNpBy6eaOmzrWR+ndh0xQl08H1VKTqQqTMbDg+4YTStc0yrD5BXZeZh90vZMpHJ2IOmEhFkMbT8Jjg== 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=O1RQeoDaVVHz6tzdTwIHAww8PRvtuS0cmUnaKDvh6LI=; b=V99GDD6HWPFD7FQfcirsR4qdCCvdQi/fGU3+t4PcfC4lM7mWWwCsQT1vzljQNwXnyOj3djwdKyWTZQNMM6dTwKA+dJh/JU7BJqSQXS+Hzn2P1bieFF4HI2Kl+BR7MepIFy7P6gaijVo2SdqNtMvK6HAjONv6010MeM7FK7BrPahE+C38d4rG/MuZ8yFcAzhey6ujZJ6wgsCeN67MH7VOhTkiuLlZX/GqIjtOi7veWCYnPqLdqsEUUw2twlUIAGS2cMSjxPtlR1iWtIEnuVr/lxNoIwSqGN8AEBTdDWF7deTtNlNtmVYi3Im3qvH6gEMyLCuGJYK1US8+PXWvnrQzpA== 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=O1RQeoDaVVHz6tzdTwIHAww8PRvtuS0cmUnaKDvh6LI=; b=j2KiEIywQUSWO8QrYNXGpMwyJOLyKsl1OUQBMKwUEYz/30kn60QGFk59gpe/Uz6EjA0wgNMGrLgVFADl0pbnD3q48Q0q8gCEddCCZBweEM9ulugWwSDUVZvcmXLQuRev26XroeDcQGNHLeIMOolY9NIR6vOC+Z8saqgVS5SfwkzZT3ODIWLKvACvw0W+QdmRICh7geqVPYbwJDFa23CvTiOC1xVyI25vu45F6Ejv/bbXCTxorNdIOKlrYaWLP0OBZRb9Vdu5gbv9NPXxXakMLWEB15SEkz6UMRsXW0Tj+YYR6OqcMk7N0gm+o3aHF/JQf/q8mfmEMwAIj21F8IyiHA== Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) by DM6PR12MB4356.namprd12.prod.outlook.com (2603:10b6:5:2aa::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Mon, 5 Apr 2021 23:42:32 +0000 Received: from DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::1c62:7fa3:617b:ab87]) by DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::1c62:7fa3:617b:ab87%6]) with mapi id 15.20.3999.032; Mon, 5 Apr 2021 23:42:32 +0000 Date: Mon, 5 Apr 2021 20:42:30 -0300 From: Jason Gunthorpe To: "Tian, Kevin" Cc: Jacob Pan , 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 , Alex Williamson , Eric Auger , Jonathan Corbet , "Raj, Ashok" , "Liu, Yi L" , "Wu, Hao" , "Jiang, Dave" , Jason Wang Subject: Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs Message-ID: <20210405234230.GF7405@nvidia.com> References: <20210319124645.GP2356281@nvidia.com> <20210319135432.GT2356281@nvidia.com> <20210319112221.5123b984@jacob-builder> <20210322120300.GU2356281@nvidia.com> <20210324120528.24d82dbd@jacob-builder> <20210329163147.GG2356281@nvidia.com> <20210330132830.GO2356281@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Originating-IP: [142.162.115.133] X-ClientProxiedBy: MN2PR07CA0016.namprd07.prod.outlook.com (2603:10b6:208:1a0::26) 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 (142.162.115.133) by MN2PR07CA0016.namprd07.prod.outlook.com (2603:10b6:208:1a0::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.27 via Frontend Transport; Mon, 5 Apr 2021 23:42:31 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lTYrW-000x33-Hj; Mon, 05 Apr 2021 20:42:30 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5942bc92-b181-45a9-4a62-08d8f88c7b2a X-MS-TrafficTypeDiagnostic: DM6PR12MB4356: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LBZbXnu1+CjH0yP01nCiJq1cJOQWVqqDAjIbU3w1EW3BUOoLcfyvXzX2RtSBCExsUmqekgguyVS9M6hpFaZiZA6t/pzpjvVEen/jn7DEScfnq5AdLIzF72SD9DCX4Lpp9E0xetSRsBcFKymyQDL2DQn+NtgQ6i2lGcon/eref5Ydcc2s+mOriVOAe3d2B7QG4sbb93mmaAgSjkQQqX5LtHbNRrAqG6O1DXx5m3h4uGHL3lm/msm4oaJSrdQxt6mlXpfPYyWO+1kjt8bmcTVXimqX9/qWIxc/Co4iZ2FIcmuusCsXSNGadAAzLdKDqUSCvYX/OV0Q544+GkI+fs5T2r8kEeWuGmSjaVsX93jF9jMZF12BSDYBjTgQQPqMWDscQAgFMqF7LYmKFhWeD6m6yQhYUgzKfBdR2Mdb+E6Llb1tZo7XVdBNCIIAbLn/Yz4Wt5B3/oM95cNnIol4W8eQgLDHOIw75rSCYliTfv+5yGtOMeYhi3FaP3h7PNGwoEt+5AJOZPR+IBKpxskxX5om/GXM2gjqswZnf91ffZWxXHF4LniUD6lvTf5SZ8d4ExGW+gUaFmPORR2sfzP7Q8VJCn9jMvisXY/P7nN1CXaGapdFMXgriP4vWowck6w+07KhwitVCNAyGDPuJsDitDPscA+GHAxQH+r1SD9ngvMoRuc= 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)(39860400002)(396003)(346002)(136003)(366004)(376002)(8936002)(86362001)(6916009)(4326008)(38100700001)(66476007)(8676002)(1076003)(186003)(33656002)(9746002)(5660300002)(66556008)(426003)(26005)(66946007)(316002)(2616005)(2906002)(36756003)(83380400001)(54906003)(9786002)(7416002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?SOwpEA0nUgW528J3Y33UHixOc4m0HIuLdL3gSRpZ4GvMfmZ8xOm8ZjizXaAk?= =?us-ascii?Q?M+KGCU+2QsHSCwEwLhtuUzgvUddBtGf4LPYFLOT4wbsQI8Oq4sw5GppDmV+C?= =?us-ascii?Q?pKVB50sDXcT5fE1RGXqSgVBQJEhZ7JqU2pF1hhLC4M/EF9cUO/IWeaU5R6wi?= =?us-ascii?Q?evaToxhqKtQpxrKwY9tEadz21pLeA6TTfn3MVBsLXKNGaTptw8iJXghPbh9j?= =?us-ascii?Q?4x8AdFk4UjaJMkZ9lKDiNoFQeZJ/jNY3kYSWQySWT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+HVYF/ejocJzrwumhhMlkMjlV+BpMlrxsbYjXjYbAC+mFQ2K02orbCCfS?= =?us-ascii?Q?4mcAX1X99PzEhadPHdJLorlkAwqHgd+p88YFzbJTz74rspmQNT3dpxF4mnfF?= =?us-ascii?Q?haOa0y5JP5itPqoik1mtSp8VQPxqZDwt0YXBuYvnYi3lrS47qan7UzLdhMev?= =?us-ascii?Q?nmdFCbxEW5NRl5gcZSpdL8BVk1Zxnle+VOeZHsc6bt9Lqw=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5942bc92-b181-45a9-4a62-08d8f88c7b2a X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3834.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2021 23:42:32.2361 (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: +O+ywaV+Txz5L8s6xItXS0yIEW5Cr/C3011yCPztVxMT+VlnGTIAgXfV78O3n1w5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4356 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 02, 2021 at 08:22:28AM +0000, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Tuesday, March 30, 2021 9:29 PM > > > > > > > > First, userspace may use ioasid in a non-SVA scenario where ioasid is > > > bound to specific security context (e.g. a control vq in vDPA) instead of > > > tying to mm. In this case there is no pgtable binding initiated from user > > > space. Instead, ioasid is allocated from /dev/ioasid and then programmed > > > to the intended security context through specific passthrough framework > > > which manages that context. > > > > This sounds like the exact opposite of what I'd like to see. > > > > I do not want to see every subsystem gaining APIs to program a > > PASID. All of that should be consolidated in *one place*. > > > > I do not want to see VDPA and VFIO have two nearly identical sets of > > APIs to control the PASID. > > > > Drivers consuming a PASID, like VDPA, should consume the PASID and do > > nothing more than authorize the HW to use it. > > > > quemu should have general code under the viommu driver that drives > > /dev/ioasid to create PASID's and manage the IO mapping according to > > the guest's needs. > > > > Drivers like VDPA and VFIO should simply accept that PASID and > > configure/authorize their HW to do DMA's with its tag. > > > > I agree with you on consolidating things in one place (especially for the > general SVA support). But here I was referring to an usage without > pgtable binding (Possibly Jason. W can say more here), where the > userspace just wants to allocate PASIDs, program/accept PASIDs to > various workqueues (device specific), and then use MAP/UNMAP > interface to manage address spaces associated with each PASID. > I just wanted to point out that the latter two steps are through > VFIO/VDPA specific interfaces. No, don't do that. VFIO and VDPA has no buisness having map/unmap interfaces once we have /dev/ioasid. That all belongs in the iosaid side. I know they have those interfaces today, but that doesn't mean we have to keep using them for PASID use cases, they should be replaced with a 'do dma from this pasid on /dev/ioasid' interface certainly not a 'here is a pasid from /dev/ioasid, go ahead and configure it youself' interface This is because PASID is *complicated* in the general case! For instance all the two level stuff you are talking about must not leak into every user! Jason