Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp714613ybb; Fri, 10 Apr 2020 08:38:53 -0700 (PDT) X-Google-Smtp-Source: APiQypJiPqjxnC+RDdZt3cQo7TUnszn5IPcdqExtsrXgzhCq9+JAQUtoI8DDWpLo1eiV1nW1LJlD X-Received: by 2002:a37:4902:: with SMTP id w2mr4080849qka.13.1586533133240; Fri, 10 Apr 2020 08:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586533133; cv=none; d=google.com; s=arc-20160816; b=K0wkRCEV5GO3DIaJx2Nes0GTowzRM78Pq8sH+4PILSDSwvhJfNs2yBuejJRr+tLW5U UD3Z4VH1YBcagfAuwsstjBURYUSuPohi+senienEt6vOnkwjhlT5mhuH3e8ID7X9E355 h2ffo8N7rg2onkqCqpPvaLGYhNNOEEGcRt6QPZ3ZEvt0UVfIKghbo1rYdEzrv+5SjQMX gMCsrnyN9yT03hHNjkgyBBNfUngGO2nFlbX9VfY5VeNPfC7cP8GX5aVoYli9ZECm0WlZ 6uulm99FLjHw2myPNfBqxkXWl7JFEQqUTuzxjxeJF3bsG46BnAT20PPliNXseVVsYEBQ XHFA== 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=M380V3bFgd46H6Tv50f66q/OajrB0WgcvFrdg7XJ77s=; b=r5FC+ynrW3VaY4Fc744kQ9ky3OBYKcPHmEhd7TPQ1lKJceSFojjKy3yiCDyDa2Tvs8 wE0wwF2cOSXwJdhSvid5uQuI7MR03JefF9h/pROV9f0xucACjOWCeoPMUUZ9HZYZw1KY oZjBreZR5TeWWY1fM8IYWcUnc4CG9IaqhCKRlSHJJpnv/4eHp//1AkqkJBZdYEt/VaPv OhxiNF6jIR5HaWyd/s4KXzVMN4h0vu2/M+ZxjtxtD5aDeP/lRqYm6R9HHTBB45jh9zD1 NbiT90+0s3Nz6KlYDHzlR9cEgWcKYOS0wwxBUnubQkowUJWr/2d3quj9B7tBBbu5ERmA JHmQ== 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 m8si1167624qvb.81.2020.04.10.08.38.38; Fri, 10 Apr 2020 08:38:53 -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 S1726626AbgDJPhk (ORCPT + 99 others); Fri, 10 Apr 2020 11:37:40 -0400 Received: from mga12.intel.com ([192.55.52.136]:15988 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726080AbgDJPhk (ORCPT ); Fri, 10 Apr 2020 11:37:40 -0400 IronPort-SDR: KIjv452/LQ9/fgoZSpd++LTAnZtKZ/59Y2AXbKCdIFaMg0OZ+T4lUtdMywpkJwja1hoRYV4X63 mld0Ns9+90Mw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2020 08:37:40 -0700 IronPort-SDR: J6Dax/bXvKp8e/PrJgA2I2XzuLfvfINEOIs3cyvbW3ArQHG7+oGiWVR519yfHikfr0irB+EU8k 0HEG6rozXItQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,367,1580803200"; d="scan'208";a="252229219" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga003.jf.intel.com with ESMTP; 10 Apr 2020 08:37:40 -0700 Date: Fri, 10 Apr 2020 08:43:32 -0700 From: Jacob Pan To: Jean-Philippe Brucker Cc: Joerg Roedel , Alex Williamson , Lu Baolu , iommu@lists.linux-foundation.org, LKML , David Woodhouse , Jean-Philippe Brucker , Yi Liu , "Tian, Kevin" , Raj Ashok , Christoph Hellwig , Jonathan Cameron , Eric Auger , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH 08/10] iommu/ioasid: Introduce notifier APIs Message-ID: <20200410084332.6a35a8ca@jacob-builder> In-Reply-To: <20200401140006.GI882512@myrica> References: <1585158931-1825-1-git-send-email-jacob.jun.pan@linux.intel.com> <1585158931-1825-9-git-send-email-jacob.jun.pan@linux.intel.com> <20200401140006.GI882512@myrica> 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 Wed, 1 Apr 2020 16:00:06 +0200 Jean-Philippe Brucker wrote: > On Wed, Mar 25, 2020 at 10:55:29AM -0700, Jacob Pan wrote: > > IOASID users fit into the publisher-subscriber pattern, a system > > wide blocking notifier chain can be used to inform subscribers of > > state changes. Notifier mechanism also abstracts publisher from > > knowing the private context each subcriber may have. > > > > This patch adds APIs and a global notifier chain, a further > > optimization might be per set notifier for ioasid_set aware users. > > > > Usage example: > > KVM register notifier block such that it can keep its guest-host > > PASID translation table in sync with any IOASID updates. > > When you talk about KVM, is it for > > [PATCH 0/7] x86: tag application address space for devices > > or something else as well? (I don't see mentions of KVM in that > series) > Yes, related to this set. This is set is for native ENQCMD support. VMCS use of IOASID notifier is for the guest SVA + ENQCMD. We need to maintain a G-H PASID translation in VMCS PASID translation table. When guest binds a GPASID to a host PASID, this translation table can be updated such that subsequent ENQCMD in the guest can resolve to a host PASID. CH 7.3.1 of DSA spec. https://software.intel.com/sites/default/files/341204-intel-data-streaming-accelerator-spec.pdf > > > > VFIO publish IOASID change by performing alloc/free, bind/unbind > > operations. > > I was rather seeing IOASID as the end of the VFIO-IOMMU-IOASID chain, > putting it in the middle complicates locking. If you only need to FREE > notifier for this calse, maybe VFIO could talk directly to the IOMMU > driver before freeing an IOASID? gpasid_unbind() should already > clear the PASID contexts, no? > Yes, VFIO can track all the PASIDs and make sure they do unbind before free. But that might be more complicated in VFIO, whereas here, when a guest exits, VFIO can just free the entire IOASID set, IOASID will notify IOMMU and do all the cleanup. For maintaining VMCS pasid translation table, KVM still need to know bind/unbind in addition to free events. In addition, we also have VDCM (virtual device composition module) that needs to perform G-H PASID translation and sanity check. VDCM needs the free event only. This is also in the DSA spec above. The use is that when the guest programs a GPASID into a virtual device, VDCM (similar to SRIOV PDEV driver) needs to intercept (via vfio mdev) and translate GPASID to HPASID. > Thanks, > Jean > > > IOMMU driver gets notified when IOASID is freed by VFIO or core mm > > code such that PASID context can be cleaned up. > > > > Signed-off-by: Liu Yi L > > Signed-off-by: Jacob Pan [Jacob Pan]