Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp547272pxb; Wed, 22 Sep 2021 07:55:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8w6mwZI4xKbewh5yOzDvfZgybLCuhJwy2V5yHDeAuSlj05owhoH3ibARwQIUWojrqpWtA X-Received: by 2002:a17:906:6dc1:: with SMTP id j1mr42328218ejt.324.1632322523153; Wed, 22 Sep 2021 07:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632322523; cv=none; d=google.com; s=arc-20160816; b=cRAqG6U1ZW33wMGuNNOPq1zQ4eRz8x2udJyQsqgmdl4oyByW4hkkBALc02qHFVUM2w gvlkielGDnuOA68FdXbMe85w2JhD9ycjXSbfQ7xNFUMRmnkhh2VYOXIiXDwpjt7IuzZH 7d2YwuiQm+DmSodMhCI3+f7wronHPfZ/zhlDMrl++JkPZeUcY+0Rpz94O34SGfyIoYXD UhTTeW/Y9VoY2ULHQvx0ustm7GtdBiIbHbKgcPGWbVOX3jlBBCU4a01bZE9tLT2LMm0b Yog4oeEzME/d0kni9oLDrkDiTo5s4Eg4yG4j4xflvGHwYY6cfV0NYKwW6EUZfOpWYnkO rsXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=TDrEpOj5z77SP2jdIw8cDIbvUad+t7NAXsCzDrXUEuo=; b=YUN3q/dIGB7Snxw+6rsfVyy56v/xoq5uxpg3swKBfloThq2ek7C8sBWVbbtWo6CDWE HVymJN+o4GqcqZAMCOXzBEE27DqJZt7wRmzXfHQRbCbut0ktRHinlC0cU3soSkkOIP8w ezzR8pKxYT8Dhx8SEHfVj1fdCOdaO975C8HZ6sIILA5rJMskdwca0wg2hHIz5wOHREUh kz84tfUftTEFnYx2HafFeuvOQ3W2Mrd5kFSA5xyCjfTbeIMmb5uupyHSOfxcMsMyHeCv 9Se2sqej2/KAzZgmfteU8/DRzoEbToDhlUqkrS4Ogwy54D0fSoNXjL/Q5ZRBNGxMciZd 0YRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ew0C8IKj; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d22si3447185ejj.387.2021.09.22.07.54.41; Wed, 22 Sep 2021 07:55:23 -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=@linaro.org header.s=google header.b=Ew0C8IKj; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236293AbhIVOvl (ORCPT + 99 others); Wed, 22 Sep 2021 10:51:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235464AbhIVOvk (ORCPT ); Wed, 22 Sep 2021 10:51:40 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DAD2C061574 for ; Wed, 22 Sep 2021 07:50:10 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id co2so10793126edb.8 for ; Wed, 22 Sep 2021 07:50:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=TDrEpOj5z77SP2jdIw8cDIbvUad+t7NAXsCzDrXUEuo=; b=Ew0C8IKjSewOIfs1ywupioINHT/n6wPGtq2fNW0XmEFgFckhAnNx18kVuxyeob5MSb cG6vPdVQgy2y/2wCxrRgFAVzYfZgiGTRAFY3tcx6CIPvOZav9+pzr2A0g2V9jt2k0cSq 9HHpBz6+Sfe0bQsurN4lUeiDAbqyklaJsw449YG114/qp9WKYRH5zxvga2tXVvb3mBga Cp+1KKZGvZQEC1wAnFvKoWVHGqnD2mGmydz+QUuPFHn2wQYUaZSi2A1opiUYI1VjnPGd EZHj0i05y8g9gyXadz3X1/RTTTyBrx7N4tTAhBK9sP7DGVVpXSKcFO8kZKq7qkBWjYyo S4Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=TDrEpOj5z77SP2jdIw8cDIbvUad+t7NAXsCzDrXUEuo=; b=aziC9c+z2BAUz8Oy+1SjXRFZkfsQnO+pSu7KJF4r3pr+EHqmAYaVXAIMYr6gmdz+iK SEWLKHkb9P1uuSPcq6nLwqrRfJTWFxbUgRD1GTlP/DZDj/MgrRVg8vEUip3wpDTKqo6e DLCtS8rhB6yTqBAH6CPUlQnMDMt+d51U00sVVnpZIvZGKU5pp/JREgJnM4xroUOep0nM Xy3971IfQKueRbkp2YDLNn71eeJm/34/ELv3BmgabJr+WGniyXSX7aO9UB21ar8avj10 XSv0lniO+mBC6vT4CTEkw5WkVjayWnpcnnXIlHlg/56LnrdjDnD5YYTRvSTJgeel7w82 X1eg== X-Gm-Message-State: AOAM532YEpfGUZAmPzMGsTyUrokQPUFdH8XKR9Mvz/RQRd7uql6m7IbU AuZ88fgvF6wRV1Faw+XELrH3nkFWRg+M6g== X-Received: by 2002:a5d:66c6:: with SMTP id k6mr11823034wrw.382.1632322167122; Wed, 22 Sep 2021 07:49:27 -0700 (PDT) Received: from myrica (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id z17sm2151265wml.24.2021.09.22.07.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 07:49:26 -0700 (PDT) Date: Wed, 22 Sep 2021 15:49:05 +0100 From: Jean-Philippe Brucker To: Liu Yi L Cc: alex.williamson@redhat.com, jgg@nvidia.com, hch@lst.de, jasowang@redhat.com, joro@8bytes.org, kevin.tian@intel.com, parav@mellanox.com, lkml@metux.net, pbonzini@redhat.com, lushenming@huawei.com, eric.auger@redhat.com, corbet@lwn.net, ashok.raj@intel.com, yi.l.liu@linux.intel.com, jun.j.tian@intel.com, hao.wu@intel.com, dave.jiang@intel.com, jacob.jun.pan@linux.intel.com, kwankhede@nvidia.com, robin.murphy@arm.com, kvm@vger.kernel.org, iommu@lists.linux-foundation.org, dwmw2@infradead.org, linux-kernel@vger.kernel.org, baolu.lu@linux.intel.com, david@gibson.dropbear.id.au, nicolinc@nvidia.com Subject: Re: [RFC 17/20] iommu/iommufd: Report iova range to userspace Message-ID: References: <20210919063848.1476776-1-yi.l.liu@intel.com> <20210919063848.1476776-18-yi.l.liu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210919063848.1476776-18-yi.l.liu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 19, 2021 at 02:38:45PM +0800, Liu Yi L wrote: > [HACK. will fix in v2] > > IOVA range is critical info for userspace to manage DMA for an I/O address > space. This patch reports the valid iova range info of a given device. > > Due to aforementioned hack, this info comes from the hacked vfio type1 > driver. To follow the same format in vfio, we also introduce a cap chain > format in IOMMU_DEVICE_GET_INFO to carry the iova range info. [...] > diff --git a/include/uapi/linux/iommu.h b/include/uapi/linux/iommu.h > index 49731be71213..f408ad3c8ade 100644 > --- a/include/uapi/linux/iommu.h > +++ b/include/uapi/linux/iommu.h > @@ -68,6 +68,7 @@ > * +---------------+------------+ > * ... > * @addr_width: the address width of supported I/O address spaces. > + * @cap_offset: Offset within info struct of first cap > * > * Availability: after device is bound to iommufd > */ > @@ -77,9 +78,11 @@ struct iommu_device_info { > #define IOMMU_DEVICE_INFO_ENFORCE_SNOOP (1 << 0) /* IOMMU enforced snoop */ > #define IOMMU_DEVICE_INFO_PGSIZES (1 << 1) /* supported page sizes */ > #define IOMMU_DEVICE_INFO_ADDR_WIDTH (1 << 2) /* addr_wdith field valid */ > +#define IOMMU_DEVICE_INFO_CAPS (1 << 3) /* info supports cap chain */ > __u64 dev_cookie; > __u64 pgsize_bitmap; > __u32 addr_width; > + __u32 cap_offset; We can also add vendor-specific page table and PASID table properties as capabilities, otherwise we'll need giant unions in the iommu_device_info struct. That made me wonder whether pgsize and addr_width should also be separate capabilities for consistency, but this way might be good enough. There won't be many more generic capabilities. I have "output address width" and "PASID width", the rest is specific to Arm and SMMU table formats. Thanks, Jean > }; > > #define IOMMU_DEVICE_GET_INFO _IO(IOMMU_TYPE, IOMMU_BASE + 1) > -- > 2.25.1 >