linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Enable PASID for DMA API users
@ 2021-12-07 13:47 Jacob Pan
  2021-12-07 13:47 ` [PATCH 1/4] ioasid: Reserve a global PASID for in-kernel DMA Jacob Pan
                   ` (4 more replies)
  0 siblings, 5 replies; 46+ messages in thread
From: Jacob Pan @ 2021-12-07 13:47 UTC (permalink / raw)
  To: iommu, LKML, Joerg Roedel, Jason Gunthorpe, Christoph Hellwig,
	Greg Kroah-Hartman, Jean-Philippe Brucker
  Cc: Jacob Pan, Lu Baolu, Raj Ashok, Kumar, Sanjay K, Dave Jiang,
	Tony Luck, Yi Liu, Tian, Kevin, Barry Song, Zanussi, Tom,
	Dan Williams

Modern accelerators such as Intel's Data Streaming Accelerator (DSA) can
perform DMA requests with PASID, which is a finer granularity than the
device's requester ID(RID). In fact, work submissions on DSA shared work
queues require PASID.

DMA mapping API is the de facto standard for in-kernel DMA. However, it
operates on a per device/RID basis which is not PASID-aware.

This patch introduces the following driver facing API that enables DMA API
PASID usage: ioasid_t iommu_enable_pasid_dma(struct device *dev);

A PASID field is added to struct device for the purposes of storing kernel
DMA PASID and flushing device IOTLBs. A separate use case in interrupt
message store (IMS) also hinted adding a PASID field to struct device.
https://lore.kernel.org/all/87pmx73tfw.ffs@nanos.tec.linutronix.de/
IMS virtualization and DMA API does not overlap.

Once enabled, device drivers can continue to use DMA APIs as-is. There is
no difference in terms of mapping in dma_handle between without PASID and
with PASID.  The DMA mapping performed by IOMMU will be identical for both
requests with and without PASID (legacy), let it be IOVA or PA in case of
pass-through.

In addition, this set converts the current support for in-kernel PASID DMA
from SVA lib to DMA API. There have been security and functional issues
with the kernel SVA approach:
(https://lore.kernel.org/linux-iommu/20210511194726.GP1002214@nvidia.com/)
The highlights are as the following:
 - The lack of IOTLB synchronization upon kernel page table updates.
   (vmalloc, module/BPF loading, CONFIG_DEBUG_PAGEALLOC etc.)
 - Other than slight more protection, using kernel virtual address (KVA)
 has little advantage over physical address.
There are also no use cases yet where DMA engines need kernel virtual
addresses for in-kernel DMA.

Once this set is accepted, more cleanup patches will follow. The plan is to
remove the usage of sva_bind_device() for in-kernel usages. Removing page
requests and other special cases around kernel SVA in VT-d driver.



Jacob Pan (4):
  ioasid: Reserve a global PASID for in-kernel DMA
  iommu: Add PASID support for DMA mapping API users
  iommu/vt-d: Support PASID DMA for in-kernel usage
  dmaengine: idxd: Use DMA API for in-kernel DMA with PASID

 .../admin-guide/kernel-parameters.txt         |   6 -
 drivers/dma/Kconfig                           |  10 --
 drivers/dma/idxd/idxd.h                       |   1 -
 drivers/dma/idxd/init.c                       |  59 +++-------
 drivers/dma/idxd/sysfs.c                      |   7 --
 .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c   |   2 +-
 drivers/iommu/dma-iommu.c                     |  71 ++++++++++++
 drivers/iommu/intel/iommu.c                   | 109 +++++++++++++++++-
 drivers/iommu/intel/pasid.c                   |   7 ++
 drivers/iommu/intel/pasid.h                   |   3 +-
 drivers/iommu/intel/svm.c                     |   2 +-
 drivers/iommu/ioasid.c                        |   2 +
 include/linux/device.h                        |   1 +
 include/linux/dma-iommu.h                     |   7 ++
 include/linux/intel-iommu.h                   |   3 +-
 include/linux/ioasid.h                        |   4 +
 include/linux/iommu.h                         |   4 +
 17 files changed, 226 insertions(+), 72 deletions(-)

-- 
2.25.1


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

end of thread, other threads:[~2021-12-12 23:35 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 13:47 [PATCH 0/4] Enable PASID for DMA API users Jacob Pan
2021-12-07 13:47 ` [PATCH 1/4] ioasid: Reserve a global PASID for in-kernel DMA Jacob Pan
2021-12-09 11:03   ` Jean-Philippe Brucker
2021-12-09 18:14     ` Jacob Pan
2021-12-10  9:06       ` Jean-Philippe Brucker
2021-12-10 12:31         ` Jason Gunthorpe
2021-12-10 18:05           ` Jacob Pan
2021-12-11  8:39             ` Tian, Kevin
2021-12-12 23:34               ` Jason Gunthorpe
2021-12-07 13:47 ` [PATCH 2/4] iommu: Add PASID support for DMA mapping API users Jacob Pan
2021-12-08  2:31   ` Lu Baolu
2021-12-08 18:49     ` Jacob Pan
2021-12-09  1:56       ` Tian, Kevin
2021-12-09  2:21         ` Lu Baolu
2021-12-09 16:32           ` Jacob Pan
2021-12-09 16:57             ` Raj, Ashok
2021-12-09 17:34               ` Jacob Pan
2021-12-07 13:47 ` [PATCH 3/4] iommu/vt-d: Support PASID DMA for in-kernel usage Jacob Pan
2021-12-08 13:22   ` Jason Gunthorpe
2021-12-08 19:16     ` Jacob Pan
2021-12-09  2:32       ` Lu Baolu
2021-12-09 23:21         ` Jacob Pan
2021-12-09 23:41           ` Jason Gunthorpe
2021-12-10  6:46           ` Lu Baolu
2021-12-10 17:50             ` Jacob Pan
2021-12-10 17:48               ` Jason Gunthorpe
2021-12-10 18:18                 ` Jacob Pan
2021-12-10 18:53                   ` Jason Gunthorpe
2021-12-07 13:47 ` [PATCH 4/4] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID Jacob Pan
2021-12-07 23:27   ` Dave Jiang
2021-12-08  4:56     ` Vinod Koul
2021-12-08 17:36       ` Jacob Pan
2021-12-08 13:13   ` Jason Gunthorpe
2021-12-08 15:35     ` Dave Jiang
2021-12-08 17:51       ` Jason Gunthorpe
2021-12-09  1:48         ` Tian, Kevin
2021-12-09 19:18           ` Jacob Pan
2021-12-08 19:55     ` Jacob Pan
2021-12-08 20:30       ` Jason Gunthorpe
2021-12-08 21:59         ` Jacob Pan
2021-12-08 23:39           ` Jason Gunthorpe
2021-12-09  0:12             ` Dave Jiang
2021-12-09  2:06               ` Tian, Kevin
2021-12-08 18:37   ` kernel test robot
2021-12-08 13:10 ` [PATCH 0/4] Enable PASID for DMA API users Jason Gunthorpe
2021-12-08 18:15   ` Jacob Pan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).