Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3875413ybb; Tue, 31 Mar 2020 13:53:36 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsAN+dVYqdB5xNceRQ+xNv3XWmCqr4p2TrGerkeReme7hU2Jg9KqBw5NmgeTSNLOaXEhhuM X-Received: by 2002:a9d:5787:: with SMTP id q7mr13688731oth.137.1585688016395; Tue, 31 Mar 2020 13:53:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585688016; cv=none; d=google.com; s=arc-20160816; b=Nw8pKPn04r+QEemaC1REbNq2aIUet8t8XaW81Mxk1UNdBS1PjG4BDjLrC4Nop6itFL 0PTB9MytPmg5aiViBDUX6g2ClsH/wSn0TnZbj7y3mVBxclwIRBP6oa2z+9aQT4VQROlH BKNgR0gZ54LRhi+6eegyrsJ9uE9JDD1V/+FaU3u/uNl9ngj/26dYFLU6xMRUiJVSUx5w p2uIEFtklXyaPfgCTr/B3H59gwbLT6JNWw57AoiONafm8oJ7TZ1kYerbwMtgaTQrOkKi xcS3/uACPrbzm7tGYtUhBBCFVGthPERLEk35FgCKrZOR5BNu2W1B1O1NRkWpwga/SDpt LItA== 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:ironport-sdr:ironport-sdr; bh=T9qLTG3sn1tRmzNoPk6xHPc57XsRg7j5rOSKHv9z2yY=; b=ExYbYbfMex1KQLQEtt7aJbV59AwwfXQbYsx8XcTlcg7l3ctkWWRRMtpG9UZgjWjSas +eO+vQ+gtofQ0PnYrbOOMllIqZqRrfVo5v7LLJ0eWwuBFelio12UnPKa9wwndZu1UuzJ cGvb5IdpF1nFUU0vj3OYANgQDTlrT4zdM3yegNT4afvynQrYeg6XjDZkpn0U7iL9MVYN ePwRK/vdSRNjoErlWgF1hedE+qWQhMu731k0k7KW6/+wjBNguIzOS46Gb8svqAIuHV04 0zI8R0QMm5YabCSlemymlI5O6Ocew6TddZ1GSBQarj4GNI2cag/bnQBk8A9VlS2Zj9cs 0aaA== 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 t11si34154oig.108.2020.03.31.13.53.22; Tue, 31 Mar 2020 13:53:36 -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 S1728840AbgCaUwV (ORCPT + 99 others); Tue, 31 Mar 2020 16:52:21 -0400 Received: from mga18.intel.com ([134.134.136.126]:27314 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727852AbgCaUwU (ORCPT ); Tue, 31 Mar 2020 16:52:20 -0400 IronPort-SDR: SftVGfW6sdgGVdl9+vqUlrXYhLVba7ROnFlq6oD+usVQ0jxgakRy1ggMYa+ne996HhphF3LrKu Iq/o/JWcju4g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2020 13:52:20 -0700 IronPort-SDR: 9t856pZgKTfWBnjHJFtoepGRlVzP9m2xf7nkagQHk9zegQsKXZAXpn2HoV+pDnKfBkXrh+6lmR UB9OEnTXfnrA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,329,1580803200"; d="scan'208";a="328202815" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga001.jf.intel.com with ESMTP; 31 Mar 2020 13:52:20 -0700 Date: Tue, 31 Mar 2020 13:58:07 -0700 From: Jacob Pan To: "Tian, Kevin" Cc: Auger Eric , Lu Baolu , "iommu@lists.linux-foundation.org" , LKML , Joerg Roedel , "David Woodhouse" , Alex Williamson , Jean-Philippe Brucker , "Liu, Yi L" , "Raj, Ashok" , Christoph Hellwig , Jonathan Cameron , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH V10 08/11] iommu/vt-d: Add svm/sva invalidate function Message-ID: <20200331135807.4e9976ab@jacob-builder> In-Reply-To: References: <1584746861-76386-1-git-send-email-jacob.jun.pan@linux.intel.com> <1584746861-76386-9-git-send-email-jacob.jun.pan@linux.intel.com> <3215b83c-81f7-a30f-fe82-a51f29d7b874@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=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 31 Mar 2020 02:49:21 +0000 "Tian, Kevin" wrote: > > From: Auger Eric > > Sent: Sunday, March 29, 2020 11:34 PM > > > > Hi, > > > > On 3/28/20 11:01 AM, Tian, Kevin wrote: > > >> From: Jacob Pan > > >> Sent: Saturday, March 21, 2020 7:28 AM > > >> > > >> When Shared Virtual Address (SVA) is enabled for a guest OS via > > >> vIOMMU, we need to provide invalidation support at IOMMU API > > >> and > > driver > > >> level. This patch adds Intel VT-d specific function to implement > > >> iommu passdown invalidate API for shared virtual address. > > >> > > >> The use case is for supporting caching structure invalidation > > >> of assigned SVM capable devices. Emulated IOMMU exposes queue > [...] > [...] > > to > > >> + * VT-d granularity. Invalidation is typically included in the > > >> unmap > > operation > > >> + * as a result of DMA or VFIO unmap. However, for assigned > > >> devices > > guest > > >> + * owns the first level page tables. Invalidations of > > >> translation caches in > > the > [...] > [...] > [...] > > inv_type_granu_map[IOMMU_CACHE_INV_TYPE_NR][IOMMU_INV_GRANU_ > > >> NR] = { > > >> + /* > > >> + * PASID based IOTLB invalidation: PASID selective (per > > >> PASID), > > >> + * page selective (address granularity) > > >> + */ > > >> + {0, 1, 1}, > > >> + /* PASID based dev TLBs, only support all PASIDs or > > >> single PASID */ > > >> + {1, 1, 0}, > > > > > > Is this combination correct? when single PASID is being > > > specified, it is essentially a page-selective invalidation since > > > you need provide Address and Size. > > Isn't it the same when G=1? Still the addr/size is used. Doesn't > > it > > I thought addr/size is not used when G=1, but it might be wrong. I'm > checking with our vt-d spec owner. > > > correspond to IOMMU_INV_GRANU_ADDR with > > IOMMU_INV_ADDR_FLAGS_PASID flag > > unset? > > > > so {0, 0, 1}? > I am not sure I got your logic. The three fields correspond to IOMMU_INV_GRANU_DOMAIN, /* domain-selective invalidation */ IOMMU_INV_GRANU_PASID, /* PASID-selective invalidation */ IOMMU_INV_GRANU_ADDR, /* page-selective invalidation * For devTLB, we use domain as global since there is no domain. Then I came up with {1, 1, 0}, which means we could have global and pasid granu invalidation for PASID based devTLB. If the caller also provide addr and S bit, the flush routine will put that into QI descriptor. I know this is a little odd, but from the granu translation p.o.v. VT-d spec has no G bit for page selective invalidation. > I have one more open: > > How does userspace know which invalidation type/gran is supported? > I didn't see such capability reporting in Yi's VFIO vSVA patch set. > Do we want the user/kernel assume the same capability set if they are > architectural? However the kernel could also do some optimization > e.g. hide devtlb invalidation capability given that the kernel > already invalidate devtlb automatically when serving iotlb > invalidation... > In general, we are trending to use VFIO capability chain to expose iommu capabilities. But for architectural features such as type/granu, we have to assume the same capability between host & guest. Granu and types are not enumerated on the host IOMMU either. For devTLB optimization, I agree we need to expose a capability to the guest stating that implicit devtlb invalidation is supported. Otherwise, if Linux guest runs on other OSes may not support implicit devtlb invalidation. Right Yi? > Thanks > Kevin > > > > > Thanks > > > > Eric > > > > > > > >> + /* PASID cache */ > > > > > > PASID cache is fully managed by the host. Guest PASID cache > > > invalidation is interpreted by vIOMMU for bind and unbind > > > operations. I don't think we should accept any PASID cache > > > invalidation from userspace or guest. > [...] > > inv_type_granu_table[IOMMU_CACHE_INV_TYPE_NR][IOMMU_INV_GRANU > [...] > > > > > > btw do we really need both map and table here? Can't we just > > > use one table with unsupported granularity marked as a special > > > value? > > > > [...] > > > > > > -ENOTSUPP? > > > > [...] > > > > > > granularity == IOMMU_INV_GRANU_ADDR? otherwise it's unclear > > > why IOMMU_INV_GRANU_DOMAIN also needs size check. > > > > [...] > > >>> addr_info.addr), > [...] > [...] > > >> + if (info->ats_enabled) { > > >> + qi_flush_dev_iotlb_pasid(iommu, > > >> sid, info- > > >>> pfsid, > [...] > > >>> pfsid, > > >> + > > >> inv_info->addr_info.pasid, info->ats_qdep, > > >> + > > >> inv_info->addr_info.addr, size, > > >> + granu); > [...] > [...] > > >>> pasid_info.pasid); > > >> + > > > > > > as earlier comment, we shouldn't allow userspace or guest to > > > invalidate PASID cache > > > > [...] > > > > [Jacob Pan]