All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v13 0/8] Nested Shared Virtual Address (SVA) VT-d support
@ 2020-05-13 23:01 ` Jacob Pan
  0 siblings, 0 replies; 37+ messages in thread
From: Jacob Pan @ 2020-05-13 23:01 UTC (permalink / raw)
  To: Lu Baolu, iommu, LKML, Joerg Roedel, David Woodhouse,
	Jean-Philippe Brucker, Eric Auger
  Cc: Yi Liu, Tian, Kevin, Raj Ashok, Alex Williamson,
	Christoph Hellwig, Jonathan Cameron, Jacob Pan

Shared virtual address (SVA), a.k.a, Shared virtual memory (SVM) on Intel
platforms allow address space sharing between device DMA and applications.
SVA can reduce programming complexity and enhance security.
This series is intended to enable SVA virtualization, i.e. enable use of SVA
within a guest user application.

This is the remaining portion of the original patchset that is based on
Joerg's x86/vt-d branch. The preparatory and cleanup patches are merged here.
(git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git)

Only IOMMU portion of the changes are included in this series. Additional
support is needed in VFIO and QEMU (will be submitted separately) to complete
this functionality.

To make incremental changes and reduce the size of each patchset. This series
does not inlcude support for page request services.

In VT-d implementation, PASID table is per device and maintained in the host.
Guest PASID table is shadowed in VMM where virtual IOMMU is emulated.

    .-------------.  .---------------------------.
    |   vIOMMU    |  | Guest process CR3, FL only|
    |             |  '---------------------------'
    .----------------/
    | PASID Entry |--- PASID cache flush -
    '-------------'                       |
    |             |                       V
    |             |                CR3 in GPA
    '-------------'
Guest
------| Shadow |--------------------------|--------
      v        v                          v
Host
    .-------------.  .----------------------.
    |   pIOMMU    |  | Bind FL for GVA-GPA  |
    |             |  '----------------------'
    .----------------/  |
    | PASID Entry |     V (Nested xlate)
    '----------------\.------------------------------.
    |             |   |SL for GPA-HPA, default domain|
    |             |   '------------------------------'
    '-------------'
Where:
 - FL = First level/stage one page tables
 - SL = Second level/stage two page tables

This is the remaining VT-d only portion of V5 since the uAPIs and IOASID common
code have been applied to Joerg's IOMMU core branch.
(https://lkml.org/lkml/2019/10/2/833)

The complete set with VFIO patches are here:
https://github.com/jacobpan/linux.git:siov_sva

The complete nested SVA upstream patches are divided into three phases:
    1. Common APIs and PCI device direct assignment
    2. Page Request Services (PRS) support
    3. Mediated device assignment

With this set and the accompanied VFIO code, we will achieve phase #1.

Thanks,

Jacob

ChangeLog:
	- v13
	  - Dropped memory type support (MTS) in guest PASID bind
	  - Do not support multiple bind gpasid if device has no aux domain
	  - Removed extra error msgs in pasid_setup_bind_data()
	  - Replaced SVM device list free function with combined out label

	- v12
	  - Fixed IA64 cross compile error
	  - Squashed two patches that add macros with its users
	  - Use ratelimited prints for all user called APIs
	  - Check domain nesting attr for vSVA APIs.
	  - Misc style improvements

	- v11 Misc fixes and improvements based on review by Kevin & Eric
	  - Fixed devTLB granularity conversion
	  - Simplified VT-d granulairy lookup by replacing 2D map array
	    with invalid entries.
	  - Fixed locking in bind guest PASID
	  - Added nesting domain attr check
	  - Squashed agaw checking patch with user
	  - Use rate limitted error message for all user originated calls
 
	- v10
	  - Addressed Eric's review in v7 and v9. Most fixes are in 3/10 and
	    6/10. Extra condition checks and consolidation of duplicated codes.

	- v9
	  - Addressed Baolu's comments for v8 for IOTLB flush consolidation,
	    bug fixes
	  - Removed IOASID notifier code which will be submitted separately
	    to address PASID life cycle management with multiple users.

	- v8
	  - Extracted cleanup patches from V7 and accepted into maintainer's
	    tree (https://lkml.org/lkml/2019/12/2/514).
	  - Added IOASID notifier and VT-d handler for termination of PASID
	    IOMMU context upon free. This will ensure success of VFIO IOASID
	    free API regardless PASID is in use.
	    (https://lore.kernel.org/linux-iommu/1571919983-3231-1-git-send-email-yi.l.liu@intel.com/)

	- V7
	  - Respect vIOMMU PASID range in virtual command PASID/IOASID allocator
	  - Caching virtual command capabilities to avoid runtime checks that
	    could cause vmexits.

	- V6
	  - Rebased on top of Joerg's core branch
	  (git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git core)
	  - Adapt to new uAPIs and IOASID allocators

	- V5
	  Rebased on v5.3-rc4 which has some of the IOMMU fault APIs merged.
 	  Addressed v4 review comments from Eric Auger, Baolu Lu, and
	    Jonathan Cameron. Specific changes are as follows:
	  - Refined custom IOASID allocator to support multiple vIOMMU, hotplug
	    cases.
	  - Extracted vendor data from IOMMU guest PASID bind data, for VT-d
	    will support all necessary guest PASID entry fields for PASID
	    bind.
	  - Support non-identity host-guest PASID mapping
	  - Exception handling in various cases

	- V4
	  - Redesigned IOASID allocator such that it can support custom
	  allocators with shared helper functions. Use separate XArray
	  to store IOASIDs per allocator. Took advice from Eric Auger to
	  have default allocator use the generic allocator structure.
	  Combined into one patch in that the default allocator is just
	  "another" allocator now. Can be built as a module in case of
	  driver use without IOMMU.
	  - Extended bind guest PASID data to support SMMU and non-identity
	  guest to host PASID mapping https://lkml.org/lkml/2019/5/21/802
	  - Rebased on Jean's sva/api common tree, new patches starts with
	   [PATCH v4 10/22]

	- V3
	  - Addressed thorough review comments from Eric Auger (Thank you!)
	  - Moved IOASID allocator from driver core to IOMMU code per
	    suggestion by Christoph Hellwig
	    (https://lkml.org/lkml/2019/4/26/462)
	  - Rebased on top of Jean's SVA API branch and Eric's v7[1]
	    (git://linux-arm.org/linux-jpb.git sva/api)
	  - All IOMMU APIs are unmodified (except the new bind guest PASID
	    call in patch 9/16)

	- V2
	  - Rebased on Joerg's IOMMU x86/vt-d branch v5.1-rc4
	  - Integrated with Eric Auger's new v7 series for common APIs
	  (https://github.com/eauger/linux/tree/v5.1-rc3-2stage-v7)
	  - Addressed review comments from Andy Shevchenko and Alex Williamson on
	    IOASID custom allocator.
	  - Support multiple custom IOASID allocators (vIOMMUs) and dynamic
	    registration.


Jacob Pan (7):
  iommu/vt-d: Move domain helper to header
  iommu/vt-d: Use a helper function to skip agaw for SL
  iommu/vt-d: Add nested translation helper function
  iommu/vt-d: Add bind guest PASID support
  iommu/vt-d: Support flushing more translation cache types
  iommu/vt-d: Add svm/sva invalidate function
  iommu/vt-d: Add custom allocator for IOASID

Lu Baolu (1):
  iommu/vt-d: Enlightened PASID allocation

 drivers/iommu/dmar.c        |  40 ++++++
 drivers/iommu/intel-iommu.c | 291 +++++++++++++++++++++++++++++++++++++++-----
 drivers/iommu/intel-pasid.c | 266 +++++++++++++++++++++++++++++++++++++---
 drivers/iommu/intel-pasid.h |  23 +++-
 drivers/iommu/intel-svm.c   | 203 ++++++++++++++++++++++++++++++
 include/linux/intel-iommu.h |  69 ++++++++++-
 include/linux/intel-svm.h   |  12 ++
 include/uapi/linux/iommu.h  |   5 +
 8 files changed, 858 insertions(+), 51 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 37+ messages in thread
* Re: [PATCH v13 3/8] iommu/vt-d: Add nested translation helper function
@ 2020-05-15 21:11 kbuild test robot
  0 siblings, 0 replies; 37+ messages in thread
From: kbuild test robot @ 2020-05-15 21:11 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 7837 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <1589410909-38925-4-git-send-email-jacob.jun.pan@linux.intel.com>
References: <1589410909-38925-4-git-send-email-jacob.jun.pan@linux.intel.com>
TO: Jacob Pan <jacob.jun.pan@linux.intel.com>

Hi Jacob,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.7-rc5 next-20200515]
[cannot apply to iommu/next linux/master]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Jacob-Pan/Nested-Shared-Virtual-Address-SVA-VT-d-support/20200514-070150
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 24085f70a6e1b0cb647ec92623284641d8270637
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-193-gb8fad4bc-dirty
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)

>> drivers/iommu/intel-pasid.c:743:33: sparse: sparse: non size-preserving pointer to integer cast
   drivers/iommu/intel-pasid.c:744:17: sparse: sparse: non size-preserving pointer to integer cast
   drivers/iommu/intel-pasid.c:749:35: sparse: sparse: non size-preserving pointer to integer cast

# https://github.com/0day-ci/linux/commit/f7bb13d830a2527772eceb1fcb7d76a82e20ae72
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout f7bb13d830a2527772eceb1fcb7d76a82e20ae72
vim +743 drivers/iommu/intel-pasid.c

f7bb13d830a252 Jacob Pan 2020-05-13  664  
f7bb13d830a252 Jacob Pan 2020-05-13  665  /**
f7bb13d830a252 Jacob Pan 2020-05-13  666   * intel_pasid_setup_nested() - Set up PASID entry for nested translation.
f7bb13d830a252 Jacob Pan 2020-05-13  667   * This could be used for guest shared virtual address. In this case, the
f7bb13d830a252 Jacob Pan 2020-05-13  668   * first level page tables are used for GVA-GPA translation in the guest,
f7bb13d830a252 Jacob Pan 2020-05-13  669   * second level page tables are used for GPA-HPA translation.
f7bb13d830a252 Jacob Pan 2020-05-13  670   *
f7bb13d830a252 Jacob Pan 2020-05-13  671   * @iommu:      IOMMU which the device belong to
f7bb13d830a252 Jacob Pan 2020-05-13  672   * @dev:        Device to be set up for translation
f7bb13d830a252 Jacob Pan 2020-05-13  673   * @gpgd:       FLPTPTR: First Level Page translation pointer in GPA
f7bb13d830a252 Jacob Pan 2020-05-13  674   * @pasid:      PASID to be programmed in the device PASID table
f7bb13d830a252 Jacob Pan 2020-05-13  675   * @pasid_data: Additional PASID info from the guest bind request
f7bb13d830a252 Jacob Pan 2020-05-13  676   * @domain:     Domain info for setting up second level page tables
f7bb13d830a252 Jacob Pan 2020-05-13  677   * @addr_width: Address width of the first level (guest)
f7bb13d830a252 Jacob Pan 2020-05-13  678   */
f7bb13d830a252 Jacob Pan 2020-05-13  679  int intel_pasid_setup_nested(struct intel_iommu *iommu, struct device *dev,
f7bb13d830a252 Jacob Pan 2020-05-13  680  			     pgd_t *gpgd, int pasid,
f7bb13d830a252 Jacob Pan 2020-05-13  681  			     struct iommu_gpasid_bind_data_vtd *pasid_data,
f7bb13d830a252 Jacob Pan 2020-05-13  682  			     struct dmar_domain *domain, int addr_width)
f7bb13d830a252 Jacob Pan 2020-05-13  683  {
f7bb13d830a252 Jacob Pan 2020-05-13  684  	struct pasid_entry *pte;
f7bb13d830a252 Jacob Pan 2020-05-13  685  	struct dma_pte *pgd;
f7bb13d830a252 Jacob Pan 2020-05-13  686  	int ret = 0;
f7bb13d830a252 Jacob Pan 2020-05-13  687  	u64 pgd_val;
f7bb13d830a252 Jacob Pan 2020-05-13  688  	int agaw;
f7bb13d830a252 Jacob Pan 2020-05-13  689  	u16 did;
f7bb13d830a252 Jacob Pan 2020-05-13  690  
f7bb13d830a252 Jacob Pan 2020-05-13  691  	if (!ecap_nest(iommu->ecap)) {
f7bb13d830a252 Jacob Pan 2020-05-13  692  		pr_err_ratelimited("IOMMU: %s: No nested translation support\n",
f7bb13d830a252 Jacob Pan 2020-05-13  693  				   iommu->name);
f7bb13d830a252 Jacob Pan 2020-05-13  694  		return -EINVAL;
f7bb13d830a252 Jacob Pan 2020-05-13  695  	}
f7bb13d830a252 Jacob Pan 2020-05-13  696  
f7bb13d830a252 Jacob Pan 2020-05-13  697  	if (!(domain->flags & DOMAIN_FLAG_NESTING_MODE)) {
f7bb13d830a252 Jacob Pan 2020-05-13  698  		pr_err_ratelimited("Domain is not in nesting mode, %x\n",
f7bb13d830a252 Jacob Pan 2020-05-13  699  				   domain->flags);
f7bb13d830a252 Jacob Pan 2020-05-13  700  		return -EINVAL;
f7bb13d830a252 Jacob Pan 2020-05-13  701  	}
f7bb13d830a252 Jacob Pan 2020-05-13  702  
f7bb13d830a252 Jacob Pan 2020-05-13  703  	pte = intel_pasid_get_entry(dev, pasid);
f7bb13d830a252 Jacob Pan 2020-05-13  704  	if (WARN_ON(!pte))
f7bb13d830a252 Jacob Pan 2020-05-13  705  		return -EINVAL;
f7bb13d830a252 Jacob Pan 2020-05-13  706  
f7bb13d830a252 Jacob Pan 2020-05-13  707  	/*
f7bb13d830a252 Jacob Pan 2020-05-13  708  	 * Caller must ensure PASID entry is not in use, i.e. not bind the
f7bb13d830a252 Jacob Pan 2020-05-13  709  	 * same PASID to the same device twice.
f7bb13d830a252 Jacob Pan 2020-05-13  710  	 */
f7bb13d830a252 Jacob Pan 2020-05-13  711  	if (pasid_pte_is_present(pte))
f7bb13d830a252 Jacob Pan 2020-05-13  712  		return -EBUSY;
f7bb13d830a252 Jacob Pan 2020-05-13  713  
f7bb13d830a252 Jacob Pan 2020-05-13  714  	pasid_clear_entry(pte);
f7bb13d830a252 Jacob Pan 2020-05-13  715  
f7bb13d830a252 Jacob Pan 2020-05-13  716  	/* Sanity checking performed by caller to make sure address
f7bb13d830a252 Jacob Pan 2020-05-13  717  	 * width matching in two dimensions:
f7bb13d830a252 Jacob Pan 2020-05-13  718  	 * 1. CPU vs. IOMMU
f7bb13d830a252 Jacob Pan 2020-05-13  719  	 * 2. Guest vs. Host.
f7bb13d830a252 Jacob Pan 2020-05-13  720  	 */
f7bb13d830a252 Jacob Pan 2020-05-13  721  	switch (addr_width) {
f7bb13d830a252 Jacob Pan 2020-05-13  722  #ifdef CONFIG_X86
f7bb13d830a252 Jacob Pan 2020-05-13  723  	case ADDR_WIDTH_5LEVEL:
f7bb13d830a252 Jacob Pan 2020-05-13  724  		if (cpu_feature_enabled(X86_FEATURE_LA57) &&
f7bb13d830a252 Jacob Pan 2020-05-13  725  		    cap_5lp_support(iommu->cap)) {
f7bb13d830a252 Jacob Pan 2020-05-13  726  			pasid_set_flpm(pte, 1);
f7bb13d830a252 Jacob Pan 2020-05-13  727  		} else {
f7bb13d830a252 Jacob Pan 2020-05-13  728  			dev_err_ratelimited(dev, "5-level paging not supported\n");
f7bb13d830a252 Jacob Pan 2020-05-13  729  			return -EINVAL;
f7bb13d830a252 Jacob Pan 2020-05-13  730  		}
f7bb13d830a252 Jacob Pan 2020-05-13  731  		break;
f7bb13d830a252 Jacob Pan 2020-05-13  732  #endif
f7bb13d830a252 Jacob Pan 2020-05-13  733  	case ADDR_WIDTH_4LEVEL:
f7bb13d830a252 Jacob Pan 2020-05-13  734  		pasid_set_flpm(pte, 0);
f7bb13d830a252 Jacob Pan 2020-05-13  735  		break;
f7bb13d830a252 Jacob Pan 2020-05-13  736  	default:
f7bb13d830a252 Jacob Pan 2020-05-13  737  		dev_err_ratelimited(dev, "Invalid guest address width %d\n",
f7bb13d830a252 Jacob Pan 2020-05-13  738  				    addr_width);
f7bb13d830a252 Jacob Pan 2020-05-13  739  		return -EINVAL;
f7bb13d830a252 Jacob Pan 2020-05-13  740  	}
f7bb13d830a252 Jacob Pan 2020-05-13  741  
f7bb13d830a252 Jacob Pan 2020-05-13  742  	/* First level PGD is in GPA, must be supported by the second level */
f7bb13d830a252 Jacob Pan 2020-05-13 @743  	if ((unsigned long long)gpgd > domain->max_addr) {

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2020-05-16  6:31 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-13 23:01 [PATCH v13 0/8] Nested Shared Virtual Address (SVA) VT-d support Jacob Pan
2020-05-13 23:01 ` Jacob Pan
2020-05-13 23:01 ` [PATCH v13 1/8] iommu/vt-d: Move domain helper to header Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-13 23:01 ` [PATCH v13 2/8] iommu/vt-d: Use a helper function to skip agaw for SL Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-14  5:51   ` Christoph Hellwig
2020-05-14  5:51     ` Christoph Hellwig
2020-05-14 15:20     ` Jacob Pan
2020-05-14 15:20       ` Jacob Pan
2020-05-13 23:01 ` [PATCH v13 3/8] iommu/vt-d: Add nested translation helper function Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-14  5:54   ` Christoph Hellwig
2020-05-14  5:54     ` Christoph Hellwig
2020-05-14 15:31     ` Jacob Pan
2020-05-14 15:31       ` Jacob Pan
2020-05-13 23:01 ` [PATCH v13 4/8] iommu/vt-d: Add bind guest PASID support Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-14  5:59   ` Christoph Hellwig
2020-05-14  5:59     ` Christoph Hellwig
2020-05-14 15:57     ` Jacob Pan
2020-05-14 15:57       ` Jacob Pan
2020-05-15  1:01       ` Lu Baolu
2020-05-15  1:01         ` Lu Baolu
2020-05-16  6:02       ` Lu Baolu
2020-05-16  6:02         ` Lu Baolu
2020-05-13 23:01 ` [PATCH v13 5/8] iommu/vt-d: Support flushing more translation cache types Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-13 23:01 ` [PATCH v13 6/8] iommu/vt-d: Add svm/sva invalidate function Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-13 23:01 ` [PATCH v13 7/8] iommu/vt-d: Enlightened PASID allocation Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-13 23:01 ` [PATCH v13 8/8] iommu/vt-d: Add custom allocator for IOASID Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-16  6:31 ` [PATCH v13 0/8] Nested Shared Virtual Address (SVA) VT-d support Lu Baolu
2020-05-16  6:31   ` Lu Baolu
2020-05-15 21:11 [PATCH v13 3/8] iommu/vt-d: Add nested translation helper function kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.