Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1794524pxy; Thu, 6 May 2021 16:29:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyP43PAfhpLv6Z1opPOkotHbv+U3eKcCwBqXOCDhqwWdgd7gyMspyRfMqpxqPi8JbjBSjJ3 X-Received: by 2002:a17:90b:e98:: with SMTP id fv24mr20802380pjb.216.1620343747475; Thu, 06 May 2021 16:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620343747; cv=none; d=google.com; s=arc-20160816; b=YuDGoch1w0rDtrgyqycLE2sRruynQ8PBuVB6fuM4PjB+ZJoQ1/k2n0xXK+AVPhfXjw IWHH7P30IIkVScgjo0dOFKvtIVmXHomKoM8Oq8glp9CehZ7Hdr4hkDpAoMwGL85KK9ZA nt2DxQBU7hUK83zygMRqSp0wMNBRL2zopop3oF60kDxvRs+FZ/eyeOYbpKW4IrACjLOa pgQ5X4NBSBbfa86axwKS2Bl7RzJQnnmmnYLiRckjm5e5UZ0LXVsloe9BfDjNkbWjFaVi 9b/RKvo0nKJVWLLJLOvMtQlZgp4b0U7S7yYlthCiepbhM4vDdn+RSAB8tpyLJylaDE1r Bo4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=jpTGSIFPaqgE0D2OvdylRtHFbgb4PqFyskWZn7+BD78=; b=BFJnwqDZmfdTLq5USOjL/0PKvFcT6sBkDCG5rvdCqwpr5H9pirKNgHtJe8MM3TNoNK 3l3u79jl97w0+wlJ3/m4IGiW77ROMJ2OPK6r/R1AzbDpXwcz16LIkcZvMbJQxYcIrXpq bEZK/4LG77f3FdpW380ncdeGIAN0hWSI5GVbEH4RTrPg2TrJomaNx2EDR5szNd/lVljT kpkQhuRxRSD9fGo/03M3/Z95M0e0fxAp0Q6cvCl6Fz3iIzFWQBc3gq/c3UZsymNFkboc KJfSS5oaGsH5X2gXBHjOFlKZ8yrToUyLdTrKp2s7GN/AxjG8ho/2CAE5y/GcOOxq0ILI hpkA== ARC-Authentication-Results: i=1; mx.google.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 v18si4510396ply.297.2021.05.06.16.28.25; Thu, 06 May 2021 16:29:07 -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; 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 S235913AbhEFQeS (ORCPT + 99 others); Thu, 6 May 2021 12:34:18 -0400 Received: from mga04.intel.com ([192.55.52.120]:40079 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235167AbhEFQeS (ORCPT ); Thu, 6 May 2021 12:34:18 -0400 IronPort-SDR: Ll81RRz0a55T72YKjx5In/GBjGClONGsGQk5pkxxpJU+vrosxZ71eLdQFtpL+rFwHbv+ePx0hR kPCY1Yti1mIA== X-IronPort-AV: E=McAfee;i="6200,9189,9976"; a="196495528" X-IronPort-AV: E=Sophos;i="5.82,278,1613462400"; d="scan'208";a="196495528" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2021 09:32:42 -0700 IronPort-SDR: wyPtzq1AlkC8XDzoyMUG3bfiBuyrMzsFN73gf9J8keEmp0nD/1ecblUB/ji3/061mupVrEkq5v gUQKN9QAVdPQ== X-IronPort-AV: E=Sophos;i="5.82,277,1613462400"; d="scan'208";a="428627255" Received: from otc-nc-03.jf.intel.com (HELO otc-nc-03) ([10.54.39.36]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2021 09:32:41 -0700 Date: Thu, 6 May 2021 09:32:40 -0700 From: "Raj, Ashok" To: Jason Gunthorpe Cc: Jean-Philippe Brucker , Jacob Pan , "Tian, Kevin" , Alex Williamson , "Liu, Yi L" , Auger Eric , 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 , "Wu, Hao" , "Jiang, Dave" , Ashok Raj Subject: Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs Message-ID: <20210506163240.GA9058@otc-nc-03> References: <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> <20210506122730.GQ1370958@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210506122730.GQ1370958@nvidia.com> User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jason On Thu, May 06, 2021 at 09:27:30AM -0300, Jason Gunthorpe wrote: > On Thu, May 06, 2021 at 09:23:48AM +0200, Jean-Philippe Brucker wrote: > > On Wed, May 05, 2021 at 01:04:46PM -0700, Jacob Pan wrote: > > > > > For ARM, since the guest owns the per device PASID table. There is no > > > > > need to allocate PASIDs from the host nor the hypervisor. Without SWQ, > > > > > there is no need for global PASID/SSID either. So PASID being global > > > > > for ARM is for simplicity in case of host PASID/SSID. > > > > > > > > It isn't clear how ARM can support PASID and mdev but that is an > > > > unrelated issue.. > > > > > > > AFAIK, the current SMMU device assignment is per RID, since only one stage2 > > > page tables per RID, not per PASID. This is equivalent to the older VT-d > > > spec. prior to scalable mode. > > > > Yes that's right. Since SMMUv3 has a single level-2 page table per RID, it > > doesn't support assigning level-1 page tables to guests for mdevs (sub-VF > > devices). So no PASIDs for mdevs, which also means each guest has its own > > PASID space and the host doesn't track guest PASIDs. > > Basically it means when the guest's top level IOASID is created for > nesting that IOASID claims all PASID's on the RID and excludes any > PASID IOASIDs from existing on the RID now or in future. The way to look at it this is as follows: For platforms that do not have a need to support shared work queue model support for ENQCMD or similar, PASID space is naturally per RID. There is no complication with this. Every RID has the full range of PASID's and no need for host to track which PASIDs are allocated now or in future in the guest. For platforms that support ENQCMD, it is required to mandate PASIDs are global across the entire system. Maybe its better to call them gPASID for guest and hPASID for host. Short reason being gPASID->hPASID is a guest wide mapping for ENQCMD and not a per-RID based mapping. (We covered that in earlier responses) In our current implementation we actually don't separate this space, and gPASID == hPASID. The iommu driver enforces that by using the custom allocator and the architected interface that allows all guest vIOMMU allocations to be proxied to host. Nothing but a glorified hypercall like interface. In fact some OS's do use hypercall to get a hPASID vs using the vCMD style interface. For cases where there is full PASID range for every RID and completely managed by the guest that requires no assist from host to ensure uniqueness, they don't need to have a custom allocator. Maybe the general allocator can have ways to ensure global uniqueness vs. RID wide uniqueness. This is still managed by the iommu driver (vIOMMU) + the backend for vCMD in the host IOMMU driver. > > Which would be a different behavior than something like Intel's top > level IOASID that doesn't claim all the PASIDs. isn't this simple, if we can say ioasid allocator can provide - system wide PASID - RID local PASID Based on platform capabilities that require such differentiation? And based on the other threads, if ioasid is just a pgtable representation, it doesn't need a PASID per-se. But when you want to use SVM or such, you can associate a PASID with it for the IOMMU to plumb things with hardware. Cheers, Ashok