All of lore.kernel.org
 help / color / mirror / Atom feed
* [XEN RFC PATCH v5 0/5] IOMMU subsystem redesign and PV-IOMMU interface
@ 2025-01-21 16:13 Teddy Astie
  2025-01-21 16:13 ` [XEN RFC PATCH v5 1/5] docs/designs: Add a design document for IOMMU subsystem redesign Teddy Astie
                   ` (5 more replies)
  0 siblings, 6 replies; 20+ messages in thread
From: Teddy Astie @ 2025-01-21 16:13 UTC (permalink / raw)
  To: xen-devel
  Cc: Teddy Astie, Andrew Cooper, Jan Beulich, Julien Grall,
	Stefano Stabellini, Roger Pau Monné, Lukasz Hawrylko,
	Daniel P. Smith, Mateusz Mówka,
	Marek Marczykowski-Górecki

This work has been presented at Xen Summit 2024 during the
  IOMMU paravirtualization and Xen IOMMU subsystem rework
design session.

Operating systems may want to have access to a IOMMU in order to do DMA
protection or implement certain features (e.g VFIO on Linux).

VFIO support is mandatory for framework such as SPDK, which can be useful to
implement an alternative storage backend for virtual machines [1].

In this patch series, we introduce in Xen the ability to manage several
contexts per domain and provide a new hypercall interface to allow guests
to manage IOMMU contexts.

The VT-d driver is updated to support these new features.

[1] Using SPDK with the Xen hypervisor - FOSDEM 2023
---
Cc: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>

PCI Passthrough now work on my side, but things are still feels quite brittle.

Changed in v2 :
* fixed Xen crash when dumping IOMMU contexts (using X debug key)
with DomUs without IOMMU
* s/dettach/detach/
* removed some unused includes
* fix dangling devices in contexts with detach

Changed in v3 :
* lock entirely map/unmap in hypercall
* prevent IOMMU operations on dying contexts (fix race condition)
* iommu_check_context+iommu_get_context -> iommu_get_context and check for NULL

Changed in v4 :
* Part of initialization logic is moved to domain or toolstack (IOMMU_init)
  + domain/toolstack now decides on "context count" and "pagetable pool size"
  + for now, all domains are able to initialize PV-IOMMU
* introduce "dom0-iommu=no-dma" to make default context block all DMA
  (disables HAP and sync-pt), enforcing usage of PV-IOMMU for DMA
  Can be used to expose properly "Pre-boot DMA protection"
* redesigned locking logic for contexts
  + contexts are accessed using iommu_get_context and released with iommu_put_context

Changed in v5 :
* various PCI Passthrough related fixes
  + rewrote parts of PCI Passthrough logic
  + various other related bug fixes
* simplified VT-d DID (for hardware) management by only having one map instead of two
  (pseudo_domid map was previously used for old quarantine code then recycled for PV-IOMMU
   in addition to another map also tracing Domain<->VT-d DID, now there is only one
   map tracking both making things simpler)
* reworked parts of Xen quarantine logic (needed for PCI Passthrough)
* added cf_check annotations
* some changes to PV-IOMMU headers (Alejandro)

TODO:
* add stub implementations for bissecting needs and non-ported IOMMU implementations
* fix some issues with no-dma+PV and grants
* complete "no-dma" mode (expose to toolstack, add documentation, ...)
* properly define nested mode and PASID support

* make new quarantine code more unity region aware (isolate devices with
  different reserved regions regions using separate 'contexts')
* find a way to make PV-IOMMU work in DomUs (they don't see machine bdf)
* there are corner cases with PV-IOMMU and to-domain Xen PCI Passthrough
  (e.g pci-assignable-remove will reassign to context 0, while the driver
   expects the device to to be in context X)

Teddy Astie (5):
  docs/designs: Add a design document for IOMMU subsystem redesign
  docs/designs: Add a design document for PV-IOMMU
  xen/public: Introduce PV-IOMMU hypercall interface
  IOMMU: Introduce redesigned IOMMU subsystem
  VT-d: Port IOMMU driver to new subsystem

 docs/designs/iommu-contexts.md       |  403 ++++++
 docs/designs/pv-iommu.md             |  116 ++
 xen/arch/x86/domain.c                |    2 +-
 xen/arch/x86/include/asm/arena.h     |   54 +
 xen/arch/x86/include/asm/iommu.h     |   58 +-
 xen/arch/x86/include/asm/pci.h       |   17 -
 xen/arch/x86/mm/p2m-ept.c            |    2 +-
 xen/arch/x86/pv/dom0_build.c         |    6 +-
 xen/arch/x86/tboot.c                 |    4 +-
 xen/common/Makefile                  |    1 +
 xen/common/memory.c                  |    4 +-
 xen/common/pv-iommu.c                |  539 ++++++++
 xen/drivers/passthrough/Makefile     |    3 +
 xen/drivers/passthrough/context.c    |  740 +++++++++++
 xen/drivers/passthrough/iommu.c      |  431 +++----
 xen/drivers/passthrough/pci.c        |  379 ++----
 xen/drivers/passthrough/quarantine.c |   49 +
 xen/drivers/passthrough/vtd/Makefile |    2 +-
 xen/drivers/passthrough/vtd/extern.h |   16 +-
 xen/drivers/passthrough/vtd/iommu.c  | 1692 ++++++++------------------
 xen/drivers/passthrough/vtd/iommu.h  |    4 +-
 xen/drivers/passthrough/vtd/qinval.c |    2 +-
 xen/drivers/passthrough/vtd/quirks.c |   20 +-
 xen/drivers/passthrough/x86/Makefile |    1 +
 xen/drivers/passthrough/x86/arena.c  |  157 +++
 xen/drivers/passthrough/x86/iommu.c  |  299 +++--
 xen/include/hypercall-defs.c         |    6 +
 xen/include/public/pv-iommu.h        |  343 ++++++
 xen/include/public/xen.h             |    1 +
 xen/include/xen/iommu.h              |  119 +-
 xen/include/xen/pci.h                |    3 +
 31 files changed, 3606 insertions(+), 1867 deletions(-)
 create mode 100644 docs/designs/iommu-contexts.md
 create mode 100644 docs/designs/pv-iommu.md
 create mode 100644 xen/arch/x86/include/asm/arena.h
 create mode 100644 xen/common/pv-iommu.c
 create mode 100644 xen/drivers/passthrough/context.c
 create mode 100644 xen/drivers/passthrough/quarantine.c
 create mode 100644 xen/drivers/passthrough/x86/arena.c
 create mode 100644 xen/include/public/pv-iommu.h

--
2.45.3



 | Vates

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



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

end of thread, other threads:[~2025-02-04 23:41 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-21 16:13 [XEN RFC PATCH v5 0/5] IOMMU subsystem redesign and PV-IOMMU interface Teddy Astie
2025-01-21 16:13 ` [XEN RFC PATCH v5 1/5] docs/designs: Add a design document for IOMMU subsystem redesign Teddy Astie
2025-01-21 16:13 ` [XEN RFC PATCH v5 2/5] docs/designs: Add a design document for PV-IOMMU Teddy Astie
2025-01-21 16:13 ` [XEN RFC PATCH v5 3/5] xen/public: Introduce PV-IOMMU hypercall interface Teddy Astie
2025-01-30 20:17   ` Jason Andryuk
2025-01-31  6:45     ` Jan Beulich
2025-02-03 11:18     ` Teddy Astie
2025-02-03 17:47       ` Stefano Stabellini
2025-02-04 14:46         ` Teddy Astie
2025-02-04 15:52           ` Julien Grall
2025-02-04 20:57             ` Stefano Stabellini
2025-02-04 22:54               ` Julien Grall
2025-02-04 23:41           ` Stefano Stabellini
2025-01-21 16:13 ` [XEN RFC PATCH v5 4/5] IOMMU: Introduce redesigned IOMMU subsystem Teddy Astie
2025-01-21 16:13 ` [XEN RFC PATCH v5 5/5] VT-d: Port IOMMU driver to new subsystem Teddy Astie
2025-01-23 12:45 ` [XEN RFC PATCH v5 0/5] IOMMU subsystem redesign and PV-IOMMU interface Marek Marczykowski-Górecki
2025-01-23 12:48   ` Jan Beulich
2025-01-23 13:23     ` Marek Marczykowski-Górecki
2025-01-23 13:58   ` Marek Marczykowski-Górecki
2025-01-23 15:46   ` Teddy Astie

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.