Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp101581img; Thu, 21 Mar 2019 15:09:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXCVXuqdySlw8QuSeV2GymvKrXeLGzwhzBAgzs+ibP3yOIzxmI9HTc7q+uKf7DEHfxRh6p X-Received: by 2002:a62:1318:: with SMTP id b24mr3100493pfj.201.1553206145757; Thu, 21 Mar 2019 15:09:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553206145; cv=none; d=google.com; s=arc-20160816; b=CHRXklYTdgcQEudlNAJhTFLvJ/rQTb7d4X3cthLuPhObOGraKGdaaGsx1HsY3tCUDC I8QXKohrX+Q2NfBZfdgajrclrQqczEnrdUWu6MMyM12sMS79EL2H1m+tV+HJRShtkauD gMZB/osY8gdECUQNVnhQTETED9uJjFjT2j8Vlo1O2FxS2cWVJLmpr+5gRbGCCgfBGN6E pf4sfWqVDoxZfEYhDUcp4N3ZqfJj5S7o8ZJZVqIplGgKPlrimDS6YYeUkz7YZZq44H9o /DO8SgE0+3Xkm67F/Dz3FIge6Td0j0oMI4F8pe1yu8PB9WzFJNnqFkz9aT2fYGRQosiQ 6KMQ== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=iDg+benhXjC3juvdLNh5IzmmnfnbBMwLkHsBZYoraI8=; b=Y3EL45OCRM/uzGqiYzBVa23m1N5YNPfKD0w3rejPBHKXOewSN4G0452TuPaUIKNUtT xIpPABHsAwXOhTfg+QwJCChAQrMWwE1NY17fx4fjGEUFMLQcyEDK75a9k62nYe8F4YKX BOo2gWCnB+e9nKRHRYHaNxYdnrtgCeQdkFfX7OvxXcegIG+Ta1p/BNPIfoFhCpO/MBfS jdREBIcXw8su1kWMrmQvDAc7MmwXwhIAEq+3HYNadV5bfQt2NUzsGTRw/NKRVZoaUBVs o20uk/e7qngxOwpDHCi2Z3EWsmovwLY7JYeqm59dNBLhnslUZjST/zEI87sb00t+QkCL rTng== 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 o8si5363838pfh.136.2019.03.21.15.08.48; Thu, 21 Mar 2019 15:09:05 -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 S1727257AbfCUWHm convert rfc822-to-8bit (ORCPT + 99 others); Thu, 21 Mar 2019 18:07:42 -0400 Received: from mga18.intel.com ([134.134.136.126]:38820 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726370AbfCUWHm (ORCPT ); Thu, 21 Mar 2019 18:07:42 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Mar 2019 15:07:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,254,1549958400"; d="scan'208";a="330812590" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by fmsmga005.fm.intel.com with ESMTP; 21 Mar 2019 15:07:40 -0700 Date: Thu, 21 Mar 2019 15:10:05 -0700 From: Jacob Pan To: Auger Eric Cc: Jean-Philippe Brucker , yi.l.liu@linux.intel.com, kevin.tian@intel.com, vincent.stehle@arm.com, ashok.raj@intel.com, kvm@vger.kernel.org, peter.maydell@linaro.org, marc.zyngier@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, christoffer.dall@arm.com, alex.williamson@redhat.com, robin.murphy@arm.com, kvmarm@lists.cs.columbia.edu, eric.auger.pro@gmail.com, jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v6 05/22] iommu: Introduce cache_invalidate API Message-ID: <20190321151005.07374be0@jacob-builder> In-Reply-To: <41173658-dde0-6e58-90ed-65cff2b1dd1c@redhat.com> References: <20190317172232.1068-1-eric.auger@redhat.com> <20190317172232.1068-6-eric.auger@redhat.com> <20190320093727.45a86866@jacob-builder> <7ae1df77-18d0-0993-8dab-6af3a4474b42@arm.com> <109c3520-dd26-3c0b-35d1-48b169fea982@arm.com> <41173658-dde0-6e58-90ed-65cff2b1dd1c@redhat.com> Organization: OTC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 Mar 2019 15:32:45 +0100 Auger Eric wrote: > Hi jean, Jacob, > > On 3/21/19 3:13 PM, Jean-Philippe Brucker wrote: > > On 21/03/2019 13:54, Auger Eric wrote: > >> Hi Jacob, Jean-Philippe, > >> > >> On 3/20/19 5:50 PM, Jean-Philippe Brucker wrote: > >>> On 20/03/2019 16:37, Jacob Pan wrote: > >>> [...] > >>>>> +struct iommu_inv_addr_info { > >>>>> +#define IOMMU_INV_ADDR_FLAGS_PASID (1 << 0) > >>>>> +#define IOMMU_INV_ADDR_FLAGS_ARCHID (1 << 1) > >>>>> +#define IOMMU_INV_ADDR_FLAGS_LEAF (1 << 2) > >>>>> + __u32 flags; > >>>>> + __u32 archid; > >>>>> + __u64 pasid; > >>>>> + __u64 addr; > >>>>> + __u64 granule_size; > >>>>> + __u64 nb_granules; > >>>>> +}; > >>>>> + > >>>>> +/** > >>>>> + * First level/stage invalidation information > >>>>> + * @cache: bitfield that allows to select which caches to > >>>>> invalidate > >>>>> + * @granularity: defines the lowest granularity used for the > >>>>> invalidation: > >>>>> + * domain > pasid > addr > >>>>> + * > >>>>> + * Not all the combinations of cache/granularity make sense: > >>>>> + * > >>>>> + * type | DEV_IOTLB | IOTLB | > >>>>> PASID | > >>>>> + * granularity | | | > >>>>> cache | > >>>>> + * > >>>>> -------------+---------------+---------------+---------------+ > >>>>> + * DOMAIN | N/A | Y | > >>>>> Y | > >>>>> + * PASID | Y | Y | > >>>>> Y | > >>>>> + * ADDR | Y | Y | > >>>>> N/A | > >>>>> + */ > >>>>> +struct iommu_cache_invalidate_info { > >>>>> +#define IOMMU_CACHE_INVALIDATE_INFO_VERSION_1 1 > >>>>> + __u32 version; > >>>>> +/* IOMMU paging structure cache */ > >>>>> +#define IOMMU_CACHE_INV_TYPE_IOTLB (1 << 0) /* IOMMU > >>>>> IOTLB */ +#define IOMMU_CACHE_INV_TYPE_DEV_IOTLB (1 << > >>>>> 1) /* Device IOTLB */ +#define > >>>>> IOMMU_CACHE_INV_TYPE_PASID (1 << 2) /* PASID cache */ > >>>> Just a clarification, this used to be an enum. You do intend to > >>>> issue a single invalidation request on multiple cache types? > >>>> Perhaps for virtio-IOMMU? I only see a single cache type in your > >>>> patch #14. For VT-d we plan to issue one cache type at a time > >>>> for now. So this format works for us. > >>> > >>> Yes for virtio-iommu I'd like as little overhead as possible, > >>> which means a single invalidation message to hit both IOTLB and > >>> ATC at once, and the ability to specify multiple pages with > >>> @nb_granules. > >> The original request/explanation from Jean-Philippe can be found > >> here: https://lkml.org/lkml/2019/1/28/1497 > >> > >>> > >>>> However, if multiple cache types are issued in a single > >>>> invalidation. They must share a single granularity, not all > >>>> combinations are valid. e.g. dev IOTLB does not support domain > >>>> granularity. Just a reminder, not an issue. Driver could filter > >>>> out invalid combinations. > >> Sure I will add a comment about this restriction. > >>> > >>> Agreed. Even the core could filter out invalid combinations based > >>> on the table above: IOTLB and domain granularity are N/A. > >> I don't get this sentence. What about vtd IOTLB domain-selective > >> invalidation: > > > > My mistake: I meant dev-IOTLB and domain granularity are N/A > > Ah OK, no worries. > > How do we proceed further with those user APIs? Besides the comment to > be added above and previous suggestion from Jean ("Invalidations by > @granularity use field ...), have we reached a consensus now on: > > - attach/detach_pasid_table > - cache_invalidate > - fault data and fault report API? > These APIs are sufficient for today's VT-d use and leave enough space for extension. E.g. new fault reasons. I have cherry picked the above APIs from your patchset to enable VT-d nested translation. Going forward, I will reuse these until they get merged. > If not, please let me know. > > Thanks > > Eric > > > > > > Thanks, > > Jean > > > >> " > >> • IOTLB entries caching mappings associated with the specified > >> domain-id are invalidated. > >> • Paging-structure-cache entries caching mappings associated with > >> the specified domain-id are invalidated. > >> " > >> > >> Thanks > >> > >> Eric > >> > >>> > >>> Thanks, > >>> Jean > >>> > >>>> > >>>>> + __u8 cache; > >>>>> + __u8 granularity; > >>>>> + __u8 padding[2]; > >>>>> + union { > >>>>> + __u64 pasid; > >>>>> + struct iommu_inv_addr_info addr_info; > >>>>> + }; > >>>>> +}; > >>>>> + > >>>>> + > >>>>> #endif /* _UAPI_IOMMU_H */ > >>>> > >>>> [Jacob Pan] > >>>> _______________________________________________ > >>>> iommu mailing list > >>>> iommu@lists.linux-foundation.org > >>>> https://lists.linuxfoundation.org/mailman/listinfo/iommu > >>>> > >>> > >> _______________________________________________ > >> iommu mailing list > >> iommu@lists.linux-foundation.org > >> https://lists.linuxfoundation.org/mailman/listinfo/iommu > >> > > [Jacob Pan]