Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3739507imu; Sun, 11 Nov 2018 22:48:36 -0800 (PST) X-Google-Smtp-Source: AJdET5cxOMOnYj2MzvZEDLC+yDB7OqdmCXQbusgmvxsvv63T+MYq+8RCD3kglfzgHBU1QbxtPEeE X-Received: by 2002:a17:902:6bc9:: with SMTP id m9-v6mr19183257plt.106.1542005316499; Sun, 11 Nov 2018 22:48:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542005316; cv=none; d=google.com; s=arc-20160816; b=KclUZFTI/YGfC2ctT1lccAXj2KjKuiY1qOAui3pN0EVBdft2VMI2QKVXKim5kOGU69 zJtsiZMZ7/b7yr1MGg3IYnCKtLg38smJP5+tSXLmSZ7e5tWObPz6HOY9Je6zU0wIPsbD roU+lYmobq0vEE+YRqgUKnz5jXVOtRDnEPGOkabN5rtn/hapUchAcqM1+D6sbfpuVLzu 4lgf4M9cmnHo3uQBzYqomwBZDFWouFwAxI1+KM0abAq9lKpkxOaKw6n0+noeURTsD1b+ mwpJm4Mh/MkgQUe4W5KQirKveEHxOvzEJVaX69eX6NqBIM/z5A7rRIZ02jeFAoGLJvg9 EUtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=mDCp9Kg9Zr89Cw9sjnDBs0znvZ/yr1yGv/VzuHuNRK0=; b=NzRv4NABkvYNGd3JonuNrHHQ0b/Nv/ZS75V1zaXi6DrTQtqSoh1sYtJvtjedR9miqd YFP+wGviqX4xyL9yKzrVXA3n+k2InaCvunG7QzRtrMpyuAYFNaLRiyTxGfgJpBSaFC9r QhNznNr34v6T4JrQBN3vl7XSvT++DLGEWlBAEr74TgJKoixowrBjS2texCY1nyIc8V7D /vYxUN7Okum0VHaQoj0h7TfNRIodS1Zn1C2Yjq1RqULfohJP5ZQTfrEFKo1IJ57zHgkz S3qqai3hVSsFaWcxsnB2mx+GL9b2pAJWmDjTjxEv0UrQ9f2IrqxpO/f2fivFgXh6OiVr oZ+A== 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 c85-v6si17569006pfe.60.2018.11.11.22.48.21; Sun, 11 Nov 2018 22:48:36 -0800 (PST) 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 S1731921AbeKLQjr (ORCPT + 99 others); Mon, 12 Nov 2018 11:39:47 -0500 Received: from mga17.intel.com ([192.55.52.151]:53355 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731284AbeKLQjr (ORCPT ); Mon, 12 Nov 2018 11:39:47 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Nov 2018 22:47:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,494,1534834800"; d="scan'208";a="88579641" Received: from allen-box.sh.intel.com ([10.239.161.122]) by orsmga007.jf.intel.com with ESMTP; 11 Nov 2018 22:47:50 -0800 From: Lu Baolu To: Joerg Roedel , David Woodhouse , Alex Williamson , Kirti Wankhede Cc: ashok.raj@intel.com, sanjay.k.kumar@intel.com, jacob.jun.pan@intel.com, kevin.tian@intel.com, Jean-Philippe Brucker , yi.l.liu@intel.com, yi.y.sun@intel.com, peterx@redhat.com, tiwei.bie@intel.com, Zeng Xin , iommu@lists.linux-foundation.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [RFC PATCH 0/5] iommu: APIs for paravirtual PASID allocation Date: Mon, 12 Nov 2018 14:44:56 +0800 Message-Id: <20181112064501.2290-1-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds an uniformed API set for global PASIDs used by IOMMU and device drivers which depend on IOMMU. It works for drivers running on bare metal, full virtualized environments and para- virtualized environment. When PASID requests come from components running on the bare metal hardware, the requests will be routed to the system wide I/O ASID allocator. ^ ^ iommu_pasid_init() | | iommu_pasid_exit() | | iommu_pasid_alloc() | | iommu_pasid_free() .-------------------------------. | IOMMU PASID APIs | '-------------------------------' | ^ v | .------------. .---------------. | I/O ASID | | | | allocator | | IOMMU drivers | | (drivers/ | | or | | base/ | | virtio IOMMU | | ioasid.c) | | | '------------' '---------------' When PASID requests come from components running in full-virtualized or para-virtualized environments, they will be routed to the vendor- specific or virtio IOMMU driver, where the requests will be intercepted and routed to the Host Linux via VFIO interfaces. ...................................... . Guest Linux . ...................................... . . . .----------------------------. . . | IOMMU PASID APIs | . . '----------------------------' . . | . . v . . .----------. .---------------. ..---------. . | I/O ASID | | IOMMU drivers | .| QEMU | . '----------' | /virtio IOMMU |---->'---------' . '---------------' .| virtio | ......................................'---------' | | ...........................................|.... . Host Linux | . ...........................................|.... . |-------------------' . . v . . .----------------------------. . . | IOMMU PASID APIs | . . '----------------------------' . . | . . v .---------------. . . .----------. | IOMMU drivers | . . | I/O ASID | | /virtio IOMMU | . . '----------' '---------------' . ................................................ Below APIs are introduced: * iommu_pasid_init(pasid) - Initialize a PASID consumer. The vendor specific IOMMU drivers are able to set the PASID range imposed by IOMMU hardware through a callback in iommu_ops. * iommu_pasid_exit(pasid) - The PASID consumer stops consuming any PASID. * iommu_pasid_alloc(pasid, min, max, private, *ioasid) - Allocate a PASID and associate a @private data with this PASID. The PASID value is stored in @ioaisd if returning success. * iommu_pasid_free(pasid, ioasid) - Free a PASID to the pool so that it could be consumed by others. It also adds below helpers to lookup or iterate PASID items. * iommu_pasid_for_each(pasid, func, data) - Iterate PASID items of the consumer identified by @pasid, and call @func() against each item. An error returned from @func() will break the iteration. * iommu_pasid_find(pasid, ioasid) - Retrieve the private data associated with @ioasid. This patch set depends on the I/O APSID allocator posted here [1] for discussion. [1] https://www.spinics.net/lists/iommu/msg30639.html Best regards, Lu Baolu Lu Baolu (5): iommu: Add APIs for IOMMU PASID management iommu/vt-d: Initialize a PASID consumer iommu/vt-d: Enlightened PASID allocation iommu/vt-d: Allocate and free a pasid iommu/vt-d: Use global pasid allocator drivers/iommu/Kconfig | 1 + drivers/iommu/intel-iommu.c | 83 +++++++++++++++++++++++++++++++--- drivers/iommu/intel-pasid.c | 88 +++++++++++++++++++++++++----------- drivers/iommu/intel-pasid.h | 16 +++++-- drivers/iommu/intel-svm.c | 24 +++++----- drivers/iommu/iommu.c | 89 +++++++++++++++++++++++++++++++++++++ include/linux/intel-iommu.h | 5 +++ include/linux/iommu.h | 73 ++++++++++++++++++++++++++++++ 8 files changed, 332 insertions(+), 47 deletions(-) -- 2.17.1