Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1453316ybb; Sat, 4 Apr 2020 04:40:01 -0700 (PDT) X-Google-Smtp-Source: APiQypKQhAqjicEXVzl26gMlpY6n1kTbinp8UVCovmkonrhCPcAu41/CTxXZ+fP9uYt9BD27O1Yw X-Received: by 2002:a4a:2cc6:: with SMTP id o189mr10399150ooo.20.1586000401445; Sat, 04 Apr 2020 04:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586000401; cv=none; d=google.com; s=arc-20160816; b=BZ4gLWczbfsHn5GWlc0RrWow2SZGFrgHb+f5TxFhh+9vzPoA2P6qwNTQ1M6ziO0/9X 5JmlElSACX6+fFnReqDiGpQs5Q3gCtmwxMBqyX9pBK+sMaedFm/49kEuLm/faaJ1U7ov uKrgC0aw0xuGrT1K+xNX7/XBUS8eKe340DtWh0qVKvqEPWG0R9C78nlP+c1OWdMgvfpH j58yvjWlwYnES1YcNWyeC/NcXMIfzNpVeHYv1pJS417zMGr4HKpN4vH2VpzKAPwtkKvu FAuTeOc789GJwdmU9AxegZZby85YMGVU5ngN1ntdOeDo6yA4iFpbQpDSU9IZba9xMGiY J4cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=P3iur6SpBDx35+1bpZ4iL0vyjOVSSJDQhVTSXTe4734=; b=Td8KshEycp5aPeWUQitzgeWQPWc0vCP2t/oJmDvzoCg+kSRTX3P+TvvTq7JJ1vcS1/ fq+GfBeSnBwL6vHkHwMF52tsFX2W55bXF4frDV2i5UTh7GmLqx7vAPebPChIBEmunB1U zAZyoSJuiEkyH5OMY2YIMgdI95DTtrFg36aOU0VsRYPnehsJit2eB228TA7d3Vt2SEmH okl5oOlEbk5D5z5BseFb1aPi08e/XapDULqXBK+aFUEWrbeiDcbOQYb7NXEjltea3/iZ Y3BpOjyRv4EDiWTIyKJL4Jfk0xwWLYd3n45qt60XSxAZ6IolEdPsh02A2aK7FuNQGEBB Ipzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id y29si5727967ote.208.2020.04.04.04.39.19; Sat, 04 Apr 2020 04:40:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726019AbgDDLgN convert rfc822-to-8bit (ORCPT + 99 others); Sat, 4 Apr 2020 07:36:13 -0400 Received: from mga14.intel.com ([192.55.52.115]:56642 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725872AbgDDLgN (ORCPT ); Sat, 4 Apr 2020 07:36:13 -0400 IronPort-SDR: WUN5SoA+jJ1DLr1mWa97sXjX2oEYPgZR8owb+PMDxT1I/O6q991SzLtI/CBAgQnav309ghgM6U 7cs1gEXhy2Ow== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Apr 2020 04:36:12 -0700 IronPort-SDR: 2eP0Nt9qDX4mdk6GECzSVxxk+t0i2u3uat50f2AR8lOiwfkAnoRYsiMOQvmhVG4XY9TIOpcVrs VQTg5Oe3Crng== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,343,1580803200"; d="scan'208";a="253628078" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga006.jf.intel.com with ESMTP; 04 Apr 2020 04:36:11 -0700 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 4 Apr 2020 04:36:11 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 4 Apr 2020 04:36:10 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.225]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.146]) with mapi id 14.03.0439.000; Sat, 4 Apr 2020 19:36:07 +0800 From: "Liu, Yi L" To: Alex Williamson CC: "eric.auger@redhat.com" , "Tian, Kevin" , "jacob.jun.pan@linux.intel.com" , "joro@8bytes.org" , "Raj, Ashok" , "Tian, Jun J" , "Sun, Yi Y" , "jean-philippe@linaro.org" , "peterx@redhat.com" , "iommu@lists.linux-foundation.org" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Wu, Hao" Subject: RE: [PATCH v1 3/8] vfio/type1: Report PASID alloc/free support to userspace Thread-Topic: [PATCH v1 3/8] vfio/type1: Report PASID alloc/free support to userspace Thread-Index: AQHWAEUdmZ6qeWVhq0GPreoHiPHgtahlqq4AgAF03/CAABRGgIABtdZg Date: Sat, 4 Apr 2020 11:36:07 +0000 Message-ID: References: <1584880325-10561-1-git-send-email-yi.l.liu@intel.com> <1584880325-10561-4-git-send-email-yi.l.liu@intel.com> <20200402120100.19e43c72@w520.home> <20200403112807.30a56c48@w520.home> In-Reply-To: <20200403112807.30a56c48@w520.home> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alex, > From: Alex Williamson > Sent: Saturday, April 4, 2020 1:28 AM > To: Liu, Yi L > Cc: eric.auger@redhat.com; Tian, Kevin ; > jacob.jun.pan@linux.intel.com; joro@8bytes.org; Raj, Ashok ; > Tian, Jun J ; Sun, Yi Y ; jean- > philippe@linaro.org; peterx@redhat.com; iommu@lists.linux-foundation.org; > kvm@vger.kernel.org; linux-kernel@vger.kernel.org; Wu, Hao > Subject: Re: [PATCH v1 3/8] vfio/type1: Report PASID alloc/free support to > userspace > > On Fri, 3 Apr 2020 08:17:44 +0000 > "Liu, Yi L" wrote: > > > > From: Alex Williamson < alex.williamson@redhat.com > > > > Sent: Friday, April 3, 2020 2:01 AM > > > To: Liu, Yi L > > > Subject: Re: [PATCH v1 3/8] vfio/type1: Report PASID alloc/free > > > support to userspace > > > > > > On Sun, 22 Mar 2020 05:32:00 -0700 > > > "Liu, Yi L" wrote: > > > > > > > From: Liu Yi L > > > > > > > > This patch reports PASID alloc/free availability to userspace (e.g. > > > > QEMU) thus userspace could do a pre-check before utilizing this feature. > > > > > > > > Cc: Kevin Tian > > > > CC: Jacob Pan > > > > Cc: Alex Williamson > > > > Cc: Eric Auger > > > > Cc: Jean-Philippe Brucker > > > > Signed-off-by: Liu Yi L > > > > --- > > > > drivers/vfio/vfio_iommu_type1.c | 28 ++++++++++++++++++++++++++++ > > > > include/uapi/linux/vfio.h | 8 ++++++++ > > > > 2 files changed, 36 insertions(+) > > > > > > > > diff --git a/drivers/vfio/vfio_iommu_type1.c > > > > b/drivers/vfio/vfio_iommu_type1.c index e40afc0..ddd1ffe 100644 > > > > --- a/drivers/vfio/vfio_iommu_type1.c > > > > +++ b/drivers/vfio/vfio_iommu_type1.c > > > > @@ -2234,6 +2234,30 @@ static int > > > > vfio_iommu_type1_pasid_free(struct > > > vfio_iommu *iommu, > > > > return ret; > > > > } > > > > > > > > +static int vfio_iommu_info_add_nesting_cap(struct vfio_iommu *iommu, > > > > + struct vfio_info_cap *caps) { > > > > + struct vfio_info_cap_header *header; > > > > + struct vfio_iommu_type1_info_cap_nesting *nesting_cap; > > > > + > > > > + header = vfio_info_cap_add(caps, sizeof(*nesting_cap), > > > > + VFIO_IOMMU_TYPE1_INFO_CAP_NESTING, 1); > > > > + if (IS_ERR(header)) > > > > + return PTR_ERR(header); > > > > + > > > > + nesting_cap = container_of(header, > > > > + struct vfio_iommu_type1_info_cap_nesting, > > > > + header); > > > > + > > > > + nesting_cap->nesting_capabilities = 0; > > > > + if (iommu->nesting) { > > > > + /* nesting iommu type supports PASID requests (alloc/free) */ > > > > + nesting_cap->nesting_capabilities |= VFIO_IOMMU_PASID_REQS; > > > > + } > > > > + > > > > + return 0; > > > > +} > > > > + > > > > static long vfio_iommu_type1_ioctl(void *iommu_data, > > > > unsigned int cmd, unsigned long arg) { @@ - > > > 2283,6 +2307,10 @@ > > > > static long vfio_iommu_type1_ioctl(void *iommu_data, > > > > if (ret) > > > > return ret; > > > > > > > > + ret = vfio_iommu_info_add_nesting_cap(iommu, &caps); > > > > + if (ret) > > > > + return ret; > > > > + > > > > if (caps.size) { > > > > info.flags |= VFIO_IOMMU_INFO_CAPS; > > > > > > > > diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h > > > > index 298ac80..8837219 100644 > > > > --- a/include/uapi/linux/vfio.h > > > > +++ b/include/uapi/linux/vfio.h > > > > @@ -748,6 +748,14 @@ struct vfio_iommu_type1_info_cap_iova_range { > > > > struct vfio_iova_range iova_ranges[]; > > > > }; > > > > > > > > +#define VFIO_IOMMU_TYPE1_INFO_CAP_NESTING 2 > > > > + > > > > +struct vfio_iommu_type1_info_cap_nesting { > > > > + struct vfio_info_cap_header header; > > > > +#define VFIO_IOMMU_PASID_REQS (1 << 0) > > > > + __u32 nesting_capabilities; > > > > +}; > > > > + > > > > #define VFIO_IOMMU_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12) > > > > > > > > /** > > > > > > I think this answers my PROBE question on patch 1/. > > yep. > > > Should the quota/usage be exposed to the user here? Thanks, > > > > Do you mean report the quota available for this user in this cap info as well? > > Yes. Would it be useful? I think so. > > For usage, do you mean the alloc and free or others? > > I mean how many of the quota are currently in allocated, or alternatively, how > many remain. Thanks, ok, got it, maybe report the remain. thanks. Regards, Yi Liu