Skip to content

RFC Host side (KVM/VFIO/IOMMUFD) support for TDISP using TSM

Xu Yilun dri-devel kvm linux-coco linux-iommu linux-media linux-pci lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest30 patches 48 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/30HACK: dma-buf: Introduce dma_buf_get_pfn_unlocked() kAPIdrivers/dma-buf/dma-buf.c include/linux/dma-buf.h+83 -170 replies
2/30vfio: Export vfio device get and put registration helpersdrivers/vfio/vfio_main.c include/linux/vfio.h+4 -00 replies
3/30vfio/pci: Share the core device pointer while invoking feature functionsdrivers/vfio/pci/vfio_pci_core.c+13 -170 replies
4/30vfio/pci: Allow MMIO regions to be exported through dma-bufdrivers/vfio/pci/Makefile drivers/vfio/pci/vfio_pci_config.c drivers/vfio/pci/vfio_pci_core.c +4 more+446 -50 replies
5/30fixup! vfio/pci: fix dma-buf revoke typo on resetdrivers/vfio/pci/vfio_pci_config.c+2 -20 replies
6/30HACK: vfio/pci: Support get_pfn() callback for dma-bufdrivers/vfio/pci/vfio_pci_dmabuf.c+34 -00 replies
7/30KVM: Support vfio_dmabuf backed MMIO regionDocumentation/virt/kvm/api.rst include/linux/kvm_host.h include/uapi/linux/kvm.h +5 more+205 -40 replies
8/30KVM: x86/mmu: Handle page fault for vfio_dmabuf backed MMIOarch/x86/kvm/mmu/mmu.c include/linux/kvm_host.h+21 -00 replies
9/30KVM: x86/mmu: Handle page fault for private MMIOarch/x86/kvm/mmu/mmu.c include/linux/kvm_host.h+8 -30 replies
10/30vfio/pci: Export vfio dma-buf specific info for importersdrivers/vfio/pci/vfio_pci_dmabuf.c include/linux/vfio.h+36 -013 replies
11/30KVM: vfio_dmabuf: Fetch VFIO specific dma-buf data for sanity checkvirt/kvm/vfio_dmabuf.c+26 -00 replies
12/30iommufd/device: Associate a kvm pointer to iommufd_devicedrivers/iommu/iommufd/device.c drivers/iommu/iommufd/iommufd_private.h drivers/vfio/iommufd.c +1 more+10 -30 replies
13/30fixup! iommufd/selftest: Sync iommufd_device_bind() change to selftestdrivers/iommu/iommufd/selftest.c+1 -10 replies
14/30iommu/arm-smmu-v3-iommufd: Pass in kvm pointer to viommu_allocdrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h drivers/iommu/iommufd/viommu.c +1 more+7 -20 replies
15/30fixup: iommu/selftest: Sync .viommu_alloc() change to selftestdrivers/iommu/iommufd/selftest.c+1 -00 replies
16/30iommufd/viommu: track the kvm pointer & its refcount in viommu coredrivers/iommu/iommufd/viommu.c include/linux/iommufd.h+65 -00 replies
17/30iommufd/device: Add TSM Bind/Unbind for TIO supportdrivers/iommu/iommufd/device.c drivers/iommu/iommufd/iommufd_private.h drivers/iommu/iommufd/viommu.c +1 more+137 -06 replies
18/30iommufd/viommu: Add trusted IOMMU configuration handlers for vdevdrivers/iommu/iommufd/iommufd_private.h drivers/iommu/iommufd/viommu.c include/linux/iommufd.h+43 -10 replies
19/30vfio/pci: Add TSM TDI bind/unbind IOCTLs for TEE-IO supportdrivers/vfio/iommufd.c drivers/vfio/pci/vfio_pci_core.c include/linux/vfio.h +2 more+146 -016 replies
20/30vfio/pci: Do TSM Unbind before zapping barsdrivers/vfio/pci/vfio_pci_config.c drivers/vfio/pci/vfio_pci_core.c drivers/vfio/pci/vfio_pci_priv.h+33 -154 replies
21/30iommufd/vdevice: Add TSM Guest request uAPIdrivers/iommu/iommufd/iommufd_private.h drivers/iommu/iommufd/main.c drivers/iommu/iommufd/viommu.c +1 more+71 -00 replies
22/30fixup! PCI/TSM: Change the guest request type definitioninclude/linux/pci-tsm.h include/uapi/linux/iommufd.h+12 -80 replies
23/30coco/tdx_tsm: Introduce a "tdx" subsystem and "tsm" devicearch/x86/Kconfig drivers/virt/coco/host/Kconfig drivers/virt/coco/host/Makefile +2 more+93 -00 replies
24/30coco/tdx_tsm: TEE Security Manager driver for TDXdrivers/virt/coco/host/Kconfig drivers/virt/coco/host/Makefile drivers/virt/coco/host/tdx_tsm.c+197 -00 replies
25/30coco/tdx_tsm: Add connect()/disconnect() handlers prototypedrivers/virt/coco/host/tdx_tsm.c+54 -10 replies
26/30coco/tdx_tsm: Add bind()/unbind()/guest_req() handlers prototypedrivers/virt/coco/host/tdx_tsm.c+80 -30 replies
27/30PCI/TSM: Add PCI driver callbacks to handle TSM requirementsinclude/linux/pci-tsm.h include/linux/pci.h+10 -02 replies
28/30vfio/pci: Implement TSM handlers for MMIOdrivers/vfio/pci/vfio_pci.c drivers/vfio/pci/vfio_pci_core.c include/linux/vfio_pci_core.h+28 -00 replies
29/30iommufd/vdevice: Implement TSM handlers for trusted DMAdrivers/iommu/iommufd/viommu.c+15 -00 replies
30/30coco/tdx_tsm: Manage TDX Module enforced operation sequences for Unbinddrivers/virt/coco/host/tdx_tsm.c+13 -40 replies

Reviews trailers per patch

1 of 30 patches has a Reviewed-by or Acked-by.

PatchJason GunthorpeAlexey Kardashevskiy
1/30
2/30Original-patch-by
3/30
4/30Original-patch-by
5/30
6/30
7/30
8/30
9/30
10/30
11/30
12/30R-b
13/30
14/30
15/30
16/30
17/30Originally-by
18/30
19/30
20/30
21/30
22/30
23/30
24/30
25/30
26/30
27/30
28/30
29/30
30/30

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [RFC PATCH 00/30] Host side (KVM/VFIO/IOMMUFD) support for TDISP using TSM

This series is the generic host side (KVM/VFIO/IOMMUFD) support for the whole life cycle of private device assignment. It follows the previously discussed flow chart [1], aim to better illustrate the overall flow of private device assignment, find out and narrow down the gaps of different vendors, and reach some common directions.

This series is based on Dan's Core TSM infrastructure series [2]. To give a clear overview of what components are needed, it also includes some existing WIP patchsets in community.

This series has 3 sections:

Patch 1 - 11 deal with the private MMIO mapping in KVM MMU via DMABUF. Leverage Jason & Vivek's latest VFIO dmabuf series [3], see Patch 2 - 4. The concern for get_pfn() kAPI [4] is not addressed so are marked as HACK, will investigate later.

Patch 12 - 22 is about TSM Bind/Unbind/Guest request management in VFIO & IOMMUFD. Picks some of Shameer's patch in [5], see Patch 12 & 14.

Patch 23 - 30 is a solution to meet the TDX specific sequence enforcement on various device Unbind cases, including converting device back to shared, hot unplug, TD destroy. Start with a tdx_tsm driver prototype and finally implement the Unbind enforcement inside the driver. To be honest it is still awkward to me, but I need help.

This series don't include the VMEXIT handle for GHCI/GHCB calls for Bind/Unbind/Guest request, cause it involves vendor specific code. The general idea is KVM should just pass these calls to QEMU, QEMU parses out the command and call the newly introduced VFIO/IOMMUFD IOCTLs.

With additional TDX Connect specific patches (not published), passed engineering test for trusted DMA in TD.

[1]: https://lore.kernel.org/all/aCYsNSFQJZzHVOFI@yilunxu-OptiPlex-7050/
[2]: https://lore.kernel.org/all/[email protected]/
[3]: https://lore.kernel.org/kvm/[email protected]/
[4]: https://lore.kernel.org/all/[email protected]/
[5]: https://lore.kernel.org/all/[email protected]/

Alexey Kardashevskiy (1):
iommufd/vdevice: Add TSM Guest request uAPI

Dan Williams (2):
coco/tdx_tsm: Introduce a "tdx" subsystem and "tsm" device coco/tdx_tsm: TEE Security Manager driver for TDX

Shameer Kolothum (2):
iommufd/device: Associate a kvm pointer to iommufd_device iommu/arm-smmu-v3-iommufd: Pass in kvm pointer to viommu_alloc

Vivek Kasireddy (3):
vfio: Export vfio device get and put registration helpers vfio/pci: Share the core device pointer while invoking feature
functions
vfio/pci: Allow MMIO regions to be exported through dma-buf

Wu Hao (1):
coco/tdx_tsm: Add connect()/disconnect() handlers prototype

Xu Yilun (21):
HACK: dma-buf: Introduce dma_buf_get_pfn_unlocked() kAPI fixup! vfio/pci: fix dma-buf revoke typo on reset
HACK: vfio/pci: Support get_pfn() callback for dma-buf
KVM: Support vfio_dmabuf backed MMIO region
KVM: x86/mmu: Handle page fault for vfio_dmabuf backed MMIO
KVM: x86/mmu: Handle page fault for private MMIO
vfio/pci: Export vfio dma-buf specific info for importers
KVM: vfio_dmabuf: Fetch VFIO specific dma-buf data for sanity check fixup! iommufd/selftest: Sync iommufd_device_bind() change to selftest
fixup: iommu/selftest: Sync .viommu_alloc() change to selftest iommufd/viommu: track the kvm pointer & its refcount in viommu core iommufd/device: Add TSM Bind/Unbind for TIO support iommufd/viommu: Add trusted IOMMU configuration handlers for vdev vfio/pci: Add TSM TDI bind/unbind IOCTLs for TEE-IO support vfio/pci: Do TSM Unbind before zapping bars
fixup! PCI/TSM: Change the guest request type definition coco/tdx_tsm: Add bind()/unbind()/guest_req() handlers prototype PCI/TSM: Add PCI driver callbacks to handle TSM requirements vfio/pci: Implement TSM handlers for MMIO
iommufd/vdevice: Implement TSM handlers for trusted DMA coco/tdx_tsm: Manage TDX Module enforced operation sequences for
Unbind

 Documentation/virt/kvm/api.rst                |   7 +
 arch/x86/Kconfig                              |   1 +
 arch/x86/kvm/mmu/mmu.c                        |  25 +-
 drivers/dma-buf/dma-buf.c                     |  87 +++-
 .../arm/arm-smmu-v3/arm-smmu-v3-iommufd.c     |   1 +
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h   |   1 +
 drivers/iommu/iommufd/device.c                |  89 +++-
 drivers/iommu/iommufd/iommufd_private.h       |  10 +
 drivers/iommu/iommufd/main.c                  |   3 +
 drivers/iommu/iommufd/selftest.c              |   3 +-
 drivers/iommu/iommufd/viommu.c                | 202 ++++++++-
 drivers/vfio/iommufd.c                        |  24 +-
 drivers/vfio/pci/Makefile                     |   1 +
 drivers/vfio/pci/vfio_pci.c                   |   1 +
 drivers/vfio/pci/vfio_pci_config.c            |  26 +-
 drivers/vfio/pci/vfio_pci_core.c              | 161 ++++++-
 drivers/vfio/pci/vfio_pci_dmabuf.c            | 411 ++++++++++++++++++
 drivers/vfio/pci/vfio_pci_priv.h              |  26 ++
 drivers/vfio/vfio_main.c                      |   2 +
 drivers/virt/coco/host/Kconfig                |  10 +
 drivers/virt/coco/host/Makefile               |   3 +
 drivers/virt/coco/host/tdx_tsm.c              | 328 ++++++++++++++
 drivers/virt/coco/host/tdx_tsm_bus.c          |  70 +++
 include/linux/dma-buf.h                       |  13 +
 include/linux/iommu.h                         |   4 +-
 include/linux/iommufd.h                       |  12 +-
 include/linux/kvm_host.h                      |  25 +-
 include/linux/pci-tsm.h                       |  19 +-
 include/linux/pci.h                           |   3 +
 include/linux/tdx_tsm_bus.h                   |  17 +
 include/linux/vfio.h                          |  27 ++
 include/linux/vfio_pci_core.h                 |   3 +
 include/uapi/linux/iommufd.h                  |  36 ++
 include/uapi/linux/kvm.h                      |   1 +
 include/uapi/linux/vfio.h                     |  67 +++
 virt/kvm/Kconfig                              |   6 +
 virt/kvm/Makefile.kvm                         |   1 +
 virt/kvm/kvm_main.c                           |  32 +-
 virt/kvm/kvm_mm.h                             |  19 +
 virt/kvm/vfio_dmabuf.c                        | 151 +++++++
 40 files changed, 1868 insertions(+), 60 deletions(-)
 create mode 100644 drivers/vfio/pci/vfio_pci_dmabuf.c
 create mode 100644 drivers/virt/coco/host/tdx_tsm.c
 create mode 100644 drivers/virt/coco/host/tdx_tsm_bus.c
 create mode 100644 include/linux/tdx_tsm_bus.h
 create mode 100644 virt/kvm/vfio_dmabuf.c

base-commit: 88c473f04098a0f5ac6fbaceaad2daa842006b6a

Signature · 1 line
2.25.1