Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4000937pxj; Tue, 11 May 2021 17:26:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmn7Cn975MDek+HIdssLWyjm9/GPSRvhhKwnkKEnkcMH9apQYXSYc9rh7yVAyV1M3RDgjP X-Received: by 2002:a17:906:4a13:: with SMTP id w19mr34469565eju.533.1620779194232; Tue, 11 May 2021 17:26:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1620779194; cv=pass; d=google.com; s=arc-20160816; b=SIaQXCifk0U9kE1sbJExhYM+Xk8Qh6NixAW75XFrHQgSKvBQ01UVoo+udxQYN/Jgqo k5QCRNSQz1MlFLgji5nIgWkLRrHRAIf2cqiAqIxDd7279ztxwabByLMDtKMgGCxMPZvo VgR0k+krPfjtkBXLWpl0xbll2FSIJFyhtXxZ6h6guaoYeLMDIYL55OJiRq0N6hYD2t7v nlLsoT8PRVU9ewUBdnaWH58g50hgfudOiv1wYlxiPkjP1JLwjgdOD4PiBvN37bvREibW DVay55RPuik88b0X6GoueSGRDBphgsniXgCHiHGjl3x/NXGsQ/SpVQaNGx2RfYPXIqeQ tx7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :dlp-reaction:dlp-product:dlp-version:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:ironport-sdr :ironport-sdr; bh=4OHOCCzWfjeTLJO++P6b1F+xs1LwTd11q0EmTgb8ww4=; b=1CjjfrGn+z1equE10Z/A+17Ljm19Asz2mx4IZ1Z/w9FFTla0zfw5akF8hwR7LS4n2h Jmecp9bhHkoW5NyrSlv4mBlOh64WFNdFJXEUa1zHMP7/Dk5V3tjrUC/4BRJld8Jyt3zc kwGtaxvCBQB22rgO/pAQKA+80G7TTphhHky3O/IMxwTdukQFJ8RL8OYTgCU4YhTbCk2K whAHX00uY9JGby00J0bTrCDqY18qb1f+UclX/lvXkUEwVpCqz8T7NKknzFlsviDw6HsS aTvKvTElEK4IvlL88MMk2Lmx8Q9Yx2KDPvkePgzJQ4PrFWFQw13uFiEoYDGREA/JdKu1 QVnQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=ZR8guL5V; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u20si12599277edv.439.2021.05.11.17.26.10; Tue, 11 May 2021 17:26:34 -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=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=ZR8guL5V; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230139AbhELAWk (ORCPT + 99 others); Tue, 11 May 2021 20:22:40 -0400 Received: from mga14.intel.com ([192.55.52.115]:13618 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbhELAWi (ORCPT ); Tue, 11 May 2021 20:22:38 -0400 IronPort-SDR: C2Sg/73Hd0AFf2XUEHcRlh2NOjXYxtDah2nymdgBheBKh5PpN1CNb1v6Rjsb6XLidpmJlJ4c48 BjCPaQmmE8pQ== X-IronPort-AV: E=McAfee;i="6200,9189,9981"; a="199264489" X-IronPort-AV: E=Sophos;i="5.82,292,1613462400"; d="scan'208";a="199264489" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 17:21:30 -0700 IronPort-SDR: rM7zeb9+stx+bgPkZ2OaWPPFKRgQubvw+1mQDheiayUvSaOInIZ50YHbi/JNnS0WhENyCrrA0H RXyVpmoTAmRw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,292,1613462400"; d="scan'208";a="622066382" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga006.fm.intel.com with ESMTP; 11 May 2021 17:21:30 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 11 May 2021 17:21:30 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Tue, 11 May 2021 17:21:30 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.108) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Tue, 11 May 2021 17:21:29 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cqIjJwibx+I8amnUHus9gxVOPw3E+0qelTDbASlh9wjxEt5mN+YlCVI6bTYR48nqs83c9LR9QYb/Kybr7nP1kZ0lp9DiC6eiB6YRFkMdKndJX+oCks6+cE4GIVpQpue5eYTVOwr/fU4k/dyDlFvhx3AxUT3g2ivVSYjr4cUlnUdqM2b5DYTnGbvYENT2Sl5R9ARTeuMGwr/gg7UZTAZRVkkQPilwlPzv0OMtAFv23Kp40y/svyUIaRzcNm2/HBN3nMB0oexWJVJlmzUPy2Ezib9lpwPedzlAOOnD5/ilBbEBiBuQUO5Hw7abWRpHPIFwqtYsfSGnSiQMbJVqZ+NEOg== 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=4OHOCCzWfjeTLJO++P6b1F+xs1LwTd11q0EmTgb8ww4=; b=NHfPUxVCUJ3hrG0IPdbPonisz5cKVOK0u0pCHldmp5NWwOarrc8Hsoe3sj8nM62f0jQ3P6DYPThYTGUat1NimoCkXfN9eruun9SIzlnYsBUtQ8c3gbO4TPp1Qw+oBGZ41ClLHZybb1/JeDjRC56ki+dFMuLYrqMpssV8DD08qIKhL9f3U8z3AFvqEuoRVqJ/AxoMYazaOGNAKN9Lx4XP51UJl0RvVY0K/ZZn8azZwUbr+OwY8lZ3Dq2MS21L4fY6rtJ+liKl8qzIvsRYRg5Q65NAE9IBFZfmRDYT+EOUQb1w97ts2ZKxKkFd/xZpXk2eOc6pYlHO46YH8wLzcbeBRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4OHOCCzWfjeTLJO++P6b1F+xs1LwTd11q0EmTgb8ww4=; b=ZR8guL5VR9yjD8FtuQmYH6U7QhhMNh/EEgH8vj4pf1kHHIT+QmP9PiFDYm2sBLiZRnb929eWsV24xydrHfOXw/MtqQS95ix9XL5+pWzjCgW6eFfzsLqHUBn+YdNGiCJ2zrV2AgGyYKHPrOIZ9MscDYCJ556Tm9zD8N8VUMd1P6Q= Received: from MWHPR11MB1886.namprd11.prod.outlook.com (2603:10b6:300:110::9) by MWHPR11MB1839.namprd11.prod.outlook.com (2603:10b6:300:10e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Wed, 12 May 2021 00:21:24 +0000 Received: from MWHPR11MB1886.namprd11.prod.outlook.com ([fe80::75b0:a8e9:60cb:7a29]) by MWHPR11MB1886.namprd11.prod.outlook.com ([fe80::75b0:a8e9:60cb:7a29%9]) with mapi id 15.20.4108.032; Wed, 12 May 2021 00:21:24 +0000 From: "Tian, Kevin" To: Jason Gunthorpe CC: Jean-Philippe Brucker , Li Zefan , "Jiang, Dave" , "Raj, Ashok" , Jonathan Corbet , "Jean-Philippe Brucker" , LKML , "iommu@lists.linux-foundation.org" , "Alex Williamson" , Johannes Weiner , Tejun Heo , "cgroups@vger.kernel.org" , "Wu, Hao" , David Woodhouse Subject: RE: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs Thread-Topic: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs Thread-Index: AQHXDZub0CDG82VGXUmLEYgvMuPs4KqKkLIAgACg94CAAC72gIAAD04AgAADogCAAErUgIAETQEAgAOaswCAB7C3gIAAhxQwgADYDACAATCSAIAAVGMAgAELsQCAACiXgIAAVBgAgAAaMwCAAAESAIAABy2AgAAgOYCAFdCAgIAAppUAgADsNgCAACqygIAHsmaAgAAzsYCAAAjdgIAAD/yAgAAcQgCAADqggIAAk6nQgABIUACAASsnkIAAYWwAgALs9qCAAdeZgIACip7wgAo7TwCAACbZAIAARiUAgAARxQCAAS/XgIAACnOAgAAiwQCAAL24AIAAVNoAgABEgACAAo33AIADeaeAgAESCjCAAKImAIAAgzaAgAAT/gCAAAjoUA== Date: Wed, 12 May 2021 00:21:24 +0000 Message-ID: References: <20210505180023.GJ1370958@nvidia.com> <20210505130446.3ee2fccd@jacob-builder> <20210506122730.GQ1370958@nvidia.com> <20210506163240.GA9058@otc-nc-03> <20210510123729.GA1002214@nvidia.com> <20210511143840.GL1002214@nvidia.com> <20210511233950.GQ1002214@nvidia.com> In-Reply-To: <20210511233950.GQ1002214@nvidia.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: nvidia.com; dkim=none (message not signed) header.d=none;nvidia.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.218] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2ceb8081-8c4d-4567-47cb-08d914dbe041 x-ms-traffictypediagnostic: MWHPR11MB1839: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr 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: 114AIOE0F80iq/EyBcnssPzEvuucjqLBJQKKKs0xJToQis9bfcumMKWXVpNP5hNfrz/2CYQOE5a8TKjx17hE11Njho40IbsvR6r/4+RbOx1KYRXcFS+dNGqEtYHpnMLiYyAoomIzg1UixVTwegY8sfTdH2Y0e7q88oSRTEBwJxD+FFsnFqg1DNsm6nCB+rIEKAouWtab9V/3XuL1DTsS7r41B7XGhEFF3sKjhimNY1U85JuJODELzjhmI/dtTBAp0ALw3+62ItvuOWTUHTuLfQRCvqDEHSWZGiJ/iC0+q1ySNmX/o53qm2u4uLmGRIeIJghBDOZSfYBtXkB17YV25jK6l34bMNVXroP2SBbU6PQftyL9kKqaAAooz/d/YiZWsvdNiXHwtzU3BQvX1Ju1cI54HbpxZB3S6s4cdkPXniDSKwo2+2xAxg7e1pReEbheAwk6wqBOPAHbBs6Z8THyTDHdbwd4xKHMwajIEJZUInkTwKuI88cii5vj6KzYIxlWNXXwbiw/VTC5gLuKbUGXacNXYCOgKqH8MWxcuRq7ytNNc2WN4neO1IJFxvl6i0Wm/Y15h+A8ExKKHb223TyPlblrjqJznWHIM5qaz3qDhKA= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR11MB1886.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(376002)(346002)(136003)(396003)(366004)(39860400002)(8936002)(7696005)(76116006)(66556008)(64756008)(478600001)(66446008)(186003)(52536014)(66476007)(6506007)(66946007)(316002)(54906003)(55016002)(4326008)(6916009)(71200400001)(122000001)(2906002)(9686003)(38100700002)(5660300002)(7416002)(33656002)(8676002)(26005)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?o5IDbt0hLLvxGknoI64cEu2eGi0jHq+A9Kq8Qg3vcbtZt1HKRqWp9rW95my0?= =?us-ascii?Q?53dVTYTcgKIK7j1r+BL42IbN4Ii9/y7eQvAqISDaZI6QIogDtzS1/y20Wob8?= =?us-ascii?Q?9Yve1uKqD9+lxfzBiTyLxjBVz98lvgeizUvcmolaCg2h4RV2apwVP7mxr1S4?= =?us-ascii?Q?6W9EfC9zNkVGBTonwdcJ+O/XE7EpfQk48SHtkZh29Ev3J9a+N1x3sf43z9rj?= =?us-ascii?Q?J0c9Y7jT5Mk5YeQaMsLWDVGBjOVGC4WXhxT28orbahtx4k1C9A9iaFiPYv20?= =?us-ascii?Q?jhgqExF14hIIYN7k+PY1HOGH8UdZ1nbf6qO5ZneaArzOPppNLyPKPpmYs9o8?= =?us-ascii?Q?2jPnFTb/u5EbIiUhYw9n3bqB9RLraFJS/aBISEylqL8VtKm2FlNoWXpBDmYe?= =?us-ascii?Q?XBRFLoo5624wlxWXeLHZOr+AR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VcNx+/6Mbz8/CAf+tKqWMSYR?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1886.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ceb8081-8c4d-4567-47cb-08d914dbe041 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 May 2021 00:21:24.1594 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: hkTdt3Pw0N88QBVk+2bpXxr1R9lPXPC0OvKqSpx2eHiFgSeoo60ejC20sCBBlAdd5jvBM+Oz6gqAbsudEYJ9qQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1839 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Jason Gunthorpe > Sent: Wednesday, May 12, 2021 7:40 AM >=20 > On Tue, May 11, 2021 at 10:51:40PM +0000, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Tuesday, May 11, 2021 10:39 PM > > > > > > On Tue, May 11, 2021 at 09:10:03AM +0000, Tian, Kevin wrote: > > > > > > > 3) SRIOV, ENQCMD (Intel): > > > > - "PASID global" with host-allocated PASIDs; > > > > - PASID table managed by host (in HPA space); > > > > - all RIDs bound to this ioasid_fd use the global pool; > > > > - however, exposing global PASID into guest breaks migration; > > > > - hybrid scheme: split local PASID range and global PASID range; > > > > - force guest to use only local PASID range (through vIOMMU); > > > > - for ENQCMD, configure CPU to translate local->global; > > > > - for non-ENQCMD, setup both local/global pasid entries; > > > > - uAPI for range split and CPU pasid mapping: > > > > > > > > // set to "PASID global" > > > > ioctl(ioasid_fd, IOASID_SET_HWID_MODE, IOASID_HWID_GLOBAL); > > > > > > > > // split local/global range, applying to all RIDs in this fd > > > > // Example: local [0, 1024), global [1024, max) > > > > // local PASID range is managed by guest and migrated as VM sta= te > > > > // global PASIDs are re-allocated and mapped to local PASIDs po= st > > > migration > > > > ioctl(ioasid_fd, IOASID_HWID_SET_GLOBAL_MIN, 1024); > > > > > > I'm still not sold that ranges are the best idea here, it just adds > > > more state that has to match during migration. Keeping the > > > global/local split per RID seems much cleaner to me > > > > With ENQCMD the PASID is kept in CPU MSR, making it a process > > context within the guest. When a guest process is bound to two > > devices, the same local PASID must be usable on both devices. > > Having per RID split cannot guarantee it. >=20 > That is only for ENQCMD. All drivers know if they are ENQCMD > compatible drivers and can ensure they use the global allocator > consistently for their RIDs. >=20 > Basically each RID knows based on its kernel drivers if it is a local > or global RID and the ioasid knob can further fine tune this for any > other specialty cases. It's fine if you insist on this way. Then we leave it to userspace to ensure same split range is used across devices when vIOMMU is concerned. Please note such range split has to be enforced through vIOMMU which (e.g. on VT-d) includes a register to report available PASID space size (applying to all devices behind this vIOMMU) to=20 the guest. The kernel just follows per-RID split info. If anything broken, the userspace just shoots its own foot. >=20 > > > It does need some user visible difference because SIOV/mdev is not > > > migratable. Only the kernel can select a PASID, userspace (and hence > > > the guest) shouldn't have the option to force a specific PASID as the > > > PASID space is shared across the entire RID to all VMs using the mdev= . > > > > not migratable only when you choose exposing host-allocated PASID > > into guest. However in the entire this proposal we actually virtualize > > PASIDs, letting the guest manage its own PASID space in all > > scenarios >=20 > PASID cannot be virtualized without also using ENQCMD. >=20 > A mdev that is using PASID without ENQCMD is non-migratable and this > needs to be make visiable in the uAPI. >=20 No. without ENQCMD the PASID must be programmed to a mdev MMIO register. This operation is mediated then mdev driver can translate the PASID from virtual to real. Thanks Kevin