Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1361559ybz; Thu, 16 Apr 2020 07:53:11 -0700 (PDT) X-Google-Smtp-Source: APiQypKMCdnHT2inLnQfCimcpZgcJzTM2WW3ZV59ocKJylMYLdBnrzhDqLHto533XjT/CdNMaFa/ X-Received: by 2002:a17:906:d291:: with SMTP id ay17mr10186373ejb.183.1587048791170; Thu, 16 Apr 2020 07:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587048791; cv=none; d=google.com; s=arc-20160816; b=CyCehfU5HuyDiJX7yeKZKoaB7bUmaUUAy8LvFOh0cF4D25sZn3yq+7zhlvMqiqj+3J 5P/l9Rdba+EpVVqvmJPFcwihP21guiYpiB51AF1TI4aPQV2v/0JJfGDiO/11MHw0TLWF Z5rO/ZoV9pghsy7GyHx+4oo+FoC/fRaOokwKVl8JLyrv81HGAzs9HKOs9Nc7Zzldsp1D wppY/tP7DjeClLyBUXDXn+46bRT+zq0n61iViODaIwzKImm04GtNH6z2Twj7Bbc2pA+H +/tMfjmWYi/tNlxaTkwBHUCkuytc1KfxExJMuc+dQgcVAuthfNM9HVMkNxIc3dEkOqr8 HEnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=mMOcvd8rqB/SDYGbEUATBrqiayoKdChDgtyzI2z56+k=; b=YJgbJoePnX+k9uzjaqKiszE20wWeyXrdP5UE8w5uPR+HK0GthIl34QfXewMQ+Z7lK9 Dd/SKzgwV5yJxSO63Jd2LNDsutQeDS17IxrO/BsFmrdtygnIv2nA3sFyLUZ2oFp5zrxY 2MqoysTRvmQZhyrjgyZbFwTN/JHblGVtZjkkPLaYXQUAVtSNxo5wwqsWa6qNEH/crMP+ JHa+y22oEe3CjGZi1oX7F8zrTxGDwOdQq1/G+LemrohG040Prq4nNZ7o48Y8EM6YMSPj 0UUhXW0Minuu+4kgwjS0a4UL0CWokNmgfI4QnVmRNdJRZdGUAaUxIwcpFUx2RlpXK9Fh sUrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Krne45FA; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f5si2235248edm.270.2020.04.16.07.52.38; Thu, 16 Apr 2020 07:53:11 -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=@redhat.com header.s=mimecast20190719 header.b=Krne45FA; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393899AbgDPOss (ORCPT + 99 others); Thu, 16 Apr 2020 10:48:48 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:52765 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2394733AbgDPOsi (ORCPT ); Thu, 16 Apr 2020 10:48:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587048517; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mMOcvd8rqB/SDYGbEUATBrqiayoKdChDgtyzI2z56+k=; b=Krne45FAuGtE+nCqLRJI2urtG1H855rkgdOygzUb8CAk6ntjUqaWou8CFiRuOxy0wASgJ/ C/Fzc1ng1e8/UbQ1keRubk8PqXJ3lg7BVydY4DnhvDi/fl+jZXxSZ/xn8YcLjIEm7B5FO6 P56j/AN6g8y6ZoIy2E4Kh+ESDb1bKaI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-458-Le46VK3hP4KmFRFu2epPvQ-1; Thu, 16 Apr 2020 10:48:29 -0400 X-MC-Unique: Le46VK3hP4KmFRFu2epPvQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5360E85EE81; Thu, 16 Apr 2020 14:48:12 +0000 (UTC) Received: from w520.home (ovpn-112-162.phx2.redhat.com [10.3.112.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CDFE5C1C5; Thu, 16 Apr 2020 14:48:11 +0000 (UTC) Date: Thu, 16 Apr 2020 08:48:11 -0600 From: Alex Williamson To: "Liu, Yi L" Cc: "jean-philippe@linaro.org" , "Tian, Kevin" , "Raj, Ashok" , "kvm@vger.kernel.org" , "Tian, Jun J" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "Sun, Yi Y" , "Wu, Hao" Subject: Re: [PATCH v1 7/8] vfio/type1: Add VFIO_IOMMU_CACHE_INVALIDATE Message-ID: <20200416084811.5acf4424@w520.home> In-Reply-To: <20200416084031.7266ad40@w520.home> References: <1584880325-10561-1-git-send-email-yi.l.liu@intel.com> <1584880325-10561-8-git-send-email-yi.l.liu@intel.com> <20200402142428.2901432e@w520.home> <20200403093436.094b1928@w520.home> <20200416084031.7266ad40@w520.home> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 16 Apr 2020 08:40:31 -0600 Alex Williamson wrote: > On Thu, 16 Apr 2020 10:40:03 +0000 > "Liu, Yi L" wrote: > > > Hi Alex, > > Still have a direction question with you. Better get agreement with you > > before heading forward. > > > > > From: Alex Williamson > > > Sent: Friday, April 3, 2020 11:35 PM > > [...] > > > > > > + * > > > > > > + * returns: 0 on success, -errno on failure. > > > > > > + */ > > > > > > +struct vfio_iommu_type1_cache_invalidate { > > > > > > + __u32 argsz; > > > > > > + __u32 flags; > > > > > > + struct iommu_cache_invalidate_info cache_info; > > > > > > +}; > > > > > > +#define VFIO_IOMMU_CACHE_INVALIDATE _IO(VFIO_TYPE, > > > VFIO_BASE > > > > > + 24) > > > > > > > > > > The future extension capabilities of this ioctl worry me, I wonder if > > > > > we should do another data[] with flag defining that data as CACHE_INFO. > > > > > > > > Can you elaborate? Does it mean with this way we don't rely on iommu > > > > driver to provide version_to_size conversion and instead we just pass > > > > data[] to iommu driver for further audit? > > > > > > No, my concern is that this ioctl has a single function, strictly tied > > > to the iommu uapi. If we replace cache_info with data[] then we can > > > define a flag to specify that data[] is struct > > > iommu_cache_invalidate_info, and if we need to, a different flag to > > > identify data[] as something else. For example if we get stuck > > > expanding cache_info to meet new demands and develop a new uapi to > > > solve that, how would we expand this ioctl to support it rather than > > > also create a new ioctl? There's also a trade-off in making the ioctl > > > usage more difficult for the user. I'd still expect the vfio layer to > > > check the flag and interpret data[] as indicated by the flag rather > > > than just passing a blob of opaque data to the iommu layer though. > > > Thanks, > > > > Based on your comments about defining a single ioctl and a unified > > vfio structure (with a @data[] field) for pasid_alloc/free, bind/ > > unbind_gpasid, cache_inv. After some offline trying, I think it would > > be good for bind/unbind_gpasid and cache_inv as both of them use the > > iommu uapi definition. While the pasid alloc/free operation doesn't. > > It would be weird to put all of them together. So pasid alloc/free > > may have a separate ioctl. It would look as below. Does this direction > > look good per your opinion? > > > > ioctl #22: VFIO_IOMMU_PASID_REQUEST > > /** > > * @pasid: used to return the pasid alloc result when flags == ALLOC_PASID > > * specify a pasid to be freed when flags == FREE_PASID > > * @range: specify the allocation range when flags == ALLOC_PASID > > */ > > struct vfio_iommu_pasid_request { > > __u32 argsz; > > #define VFIO_IOMMU_ALLOC_PASID (1 << 0) > > #define VFIO_IOMMU_FREE_PASID (1 << 1) > > __u32 flags; > > __u32 pasid; > > struct { > > __u32 min; > > __u32 max; > > } range; > > }; > > Can't the ioctl return the pasid valid on alloc (like GET_DEVICE_FD)? s/valid/value/ > Would it be useful to support freeing a range of pasids? If so then we > could simply use range for both, ie. allocate a pasid from this range > and return it, or free all pasids in this range? vfio already needs to > track pasids to free them on release, so presumably this is something > we could support easily. > > > ioctl #23: VFIO_IOMMU_NESTING_OP > > struct vfio_iommu_type1_nesting_op { > > __u32 argsz; > > __u32 flags; > > __u32 op; > > __u8 data[]; > > }; > > data only has 4-byte alignment, I think we really want it at an 8-byte > alignment. This is why I embedded the "op" into the flag for > DEVICE_FEATURE. Thanks, > > Alex > > > > > /* Nesting Ops */ > > #define VFIO_IOMMU_NESTING_OP_BIND_PGTBL 0 > > #define VFIO_IOMMU_NESTING_OP_UNBIND_PGTBL 1 > > #define VFIO_IOMMU_NESTING_OP_CACHE_INVLD 2 > > > > Thanks, > > Yi Liu > > > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu >