qemu/backends
Joao Martins 5b1e96e654 vfio/iommufd: Introduce auto domain creation
There's generally two modes of operation for IOMMUFD:

1) The simple user API which intends to perform relatively simple things
with IOMMUs e.g. DPDK. The process generally creates an IOAS and attaches
to VFIO and mainly performs IOAS_MAP and UNMAP.

2) The native IOMMUFD API where you have fine grained control of the
IOMMU domain and model it accordingly. This is where most new feature
are being steered to.

For dirty tracking 2) is required, as it needs to ensure that
the stage-2/parent IOMMU domain will only attach devices
that support dirty tracking (so far it is all homogeneous in x86, likely
not the case for smmuv3). Such invariant on dirty tracking provides a
useful guarantee to VMMs that will refuse incompatible device
attachments for IOMMU domains.

Dirty tracking insurance is enforced via HWPT_ALLOC, which is
responsible for creating an IOMMU domain. This is contrast to the
'simple API' where the IOMMU domain is created by IOMMUFD automatically
when it attaches to VFIO (usually referred as autodomains) but it has
the needed handling for mdevs.

To support dirty tracking with the advanced IOMMUFD API, it needs
similar logic, where IOMMU domains are created and devices attached to
compatible domains. Essentially mimicking kernel
iommufd_device_auto_get_domain(). With mdevs given there's no IOMMU domain
it falls back to IOAS attach.

The auto domain logic allows different IOMMU domains to be created when
DMA dirty tracking is not desired (and VF can provide it), and others where
it is. Here it is not used in this way given how VFIODevice migration
state is initialized after the device attachment. But such mixed mode of
IOMMU dirty tracking + device dirty tracking is an improvement that can
be added on. Keep the 'all of nothing' of type1 approach that we have
been using so far between container vs device dirty tracking.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
[ clg: Added ERRP_GUARD() in iommufd_cdev_autodomains_get() ]
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
2024-07-23 17:14:52 +02:00
..
tpm backends/tpm: Remove newline character in trace event 2024-06-10 13:05:27 -04:00
confidential-guest-support.c confidential guest support: Introduce new confidential guest support class 2021-02-08 16:57:37 +11:00
cryptodev-builtin.c backends/cryptodev-builtin: Fix local_error leaks 2024-04-29 15:26:39 +03:00
cryptodev-hmp-cmds.c hmp: add cryptodev info command 2023-03-07 12:38:59 -05:00
cryptodev-lkcf.c cryptodev: Use CryptoDevBackendOpInfo for operation 2023-03-07 12:38:59 -05:00
cryptodev-vhost-user.c cryptodev-vhost-user: add asymmetric crypto support 2023-06-23 02:54:44 -04:00
cryptodev-vhost.c cryptodev: Introduce cryptodev.json 2023-03-07 12:38:59 -05:00
cryptodev.c backends/cryptodev: Do not ignore throttle/backends Errors 2024-01-19 12:28:59 +01:00
dbus-vmstate1.xml docs: move D-Bus VMState documentation to source XML 2021-12-21 10:50:21 +04:00
dbus-vmstate.c backends: Constify VMState 2023-12-30 07:38:06 +11:00
host_iommu_device.c backends: Introduce HostIOMMUDevice abstract 2024-06-24 23:15:30 +02:00
hostmem-epc.c backends/hostmem-epc: Get rid of qemu_open_old() 2024-07-17 14:04:15 +03:00
hostmem-file.c backends/hostmem: Report error when memory size is unaligned 2024-06-08 10:33:38 +02:00
hostmem-memfd.c backends/hostmem: Report error when memory size is unaligned 2024-06-08 10:33:38 +02:00
hostmem-ram.c HostMem: Add mechanism to opt in kvm guest memfd via MachineState 2024-04-23 17:35:25 +02:00
hostmem-shm.c hostmem: add a new memory backend based on POSIX shm_open() 2024-07-03 18:14:06 -04:00
hostmem.c hostmem: simplify the code for merge and dump properties 2024-06-08 10:33:38 +02:00
iommufd.c vfio/iommufd: Introduce auto domain creation 2024-07-23 17:14:52 +02:00
Kconfig backends/iommufd: Introduce the iommufd object 2023-12-19 19:03:38 +01:00
meson.build hostmem: add a new memory backend based on POSIX shm_open() 2024-07-03 18:14:06 -04:00
rng-builtin.c replay: rng-builtin support 2021-02-08 15:15:32 +01:00
rng-egd.c backends: Improve error messages when property can no longer be set 2022-10-27 07:56:56 +02:00
rng-random.c backends/rng-random: Get rid of qemu_open_old() 2024-07-17 14:04:15 +03:00
rng.c error: Drop superfluous #include "qapi/qmp/qerror.h" 2023-02-23 13:56:14 +01:00
trace-events vfio/iommufd: Introduce auto domain creation 2024-07-23 17:14:52 +02:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
vhost-user.c backends/vhost-user: remove the ioeventfd check 2023-03-02 03:10:47 -05:00