Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 07321a6d087d4ec9866cfb0c8b53692a59758976
      
https://github.com/qemu/qemu/commit/07321a6d087d4ec9866cfb0c8b53692a59758976
  Author: Eric Auger <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M hw/vfio/container.c

  Log Message:
  -----------
  hw/vfio/container: Fix SIGSEV on vfio_container_instance_finalize()

In vfio_connect_container's error path, the base container is
removed twice form the VFIOAddressSpace QLIST: first on the
listener_release_exit label and second, on free_container_exit
label, through object_unref(container), which calls
vfio_container_instance_finalize().

Let's remove the first instance.

Fixes: 938026053f4 ("vfio/container: Switch to QOM")
Signed-off-by: Eric Auger <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>


  Commit: 13e522f644e2b15fa857028a33e6a3b75e45158d
      
https://github.com/qemu/qemu/commit/13e522f644e2b15fa857028a33e6a3b75e45158d
  Author: Joao Martins <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M hw/vfio/helpers.c
    M hw/vfio/pci.c
    M include/hw/vfio/vfio-common.h

  Log Message:
  -----------
  vfio/pci: Extract mdev check into an helper

In preparation to skip initialization of the HostIOMMUDevice for mdev,
extract the checks that validate if a device is an mdev into helpers.

A vfio_device_is_mdev() is created, and subsystems consult VFIODevice::mdev
to check if it's mdev or not.

Signed-off-by: Joao Martins <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>


  Commit: 9f17604195c03580b16c3cc5631c86f3894dd442
      
https://github.com/qemu/qemu/commit/9f17604195c03580b16c3cc5631c86f3894dd442
  Author: Joao Martins <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M hw/vfio/common.c
    M hw/vfio/pci.c

  Log Message:
  -----------
  vfio/iommufd: Don't initialize nor set a HOST_IOMMU_DEVICE with mdev

mdevs aren't "physical" devices and when asking for backing IOMMU info, it
fails the entire provisioning of the guest. Fix that by skipping
HostIOMMUDevice initialization in the presence of mdevs, and skip setting
an iommu device when it is known to be an mdev.

Cc: Zhenzhong Duan <[email protected]>
Fixes: 930589520128 ("vfio/iommufd: Implement HostIOMMUDeviceClass::realize() 
handler")
Signed-off-by: Joao Martins <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>


  Commit: 2d1bf2589736b3714f3940d360404732ac13019c
      
https://github.com/qemu/qemu/commit/2d1bf2589736b3714f3940d360404732ac13019c
  Author: Joao Martins <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M backends/iommufd.c
    M hw/vfio/iommufd.c
    M include/sysemu/iommufd.h

  Log Message:
  -----------
  backends/iommufd: Extend iommufd_backend_get_device_info() to fetch HW 
capabilities

The helper will be able to fetch vendor agnostic IOMMU capabilities
supported both by hardware and software. Right now it is only iommu dirty
tracking.

Signed-off-by: Joao Martins <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Eric Auger <[email protected]>


  Commit: b07dcb7d4f116b157de5aaacfa9d58a496a9ed1d
      
https://github.com/qemu/qemu/commit/b07dcb7d4f116b157de5aaacfa9d58a496a9ed1d
  Author: Joao Martins <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M hw/vfio/iommufd.c

  Log Message:
  -----------
  vfio/iommufd: Return errno in iommufd_cdev_attach_ioas_hwpt()

In preparation to implement auto domains have the attach function
return the errno it got during domain attach instead of a bool.

-EINVAL is tracked to track domain incompatibilities, and decide whether
to create a new IOMMU domain.

Signed-off-by: Joao Martins <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>


  Commit: c598d65aef4016b80608c93e2fba2c46d4c5e42e
      
https://github.com/qemu/qemu/commit/c598d65aef4016b80608c93e2fba2c46d4c5e42e
  Author: Zhenzhong Duan <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M hw/vfio/ap.c

  Log Message:
  -----------
  vfio/ap: Don't initialize HOST_IOMMU_DEVICE with mdev

mdevs aren't "physical" devices and when asking for backing IOMMU info,
it fails the entire provisioning of the guest. Fix that by setting
vbasedev->mdev true so skipping HostIOMMUDevice initialization in the
presence of mdevs.

Fixes: 930589520128 ("vfio/iommufd: Implement HostIOMMUDeviceClass::realize() 
handler")
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Joao Martins <[email protected]>
Reviewed-by: Eric Auger <[email protected]>


  Commit: 8b8705e7f20afa545862fcae15c1515b8a832d2d
      
https://github.com/qemu/qemu/commit/8b8705e7f20afa545862fcae15c1515b8a832d2d
  Author: Zhenzhong Duan <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M hw/vfio/ccw.c

  Log Message:
  -----------
  vfio/ccw: Don't initialize HOST_IOMMU_DEVICE with mdev

mdevs aren't "physical" devices and when asking for backing IOMMU info,
it fails the entire provisioning of the guest. Fix that by setting
vbasedev->mdev true so skipping HostIOMMUDevice initialization in the
presence of mdevs.

Fixes: 930589520128 ("vfio/iommufd: Implement HostIOMMUDeviceClass::realize() 
handler")
Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Joao Martins <[email protected]>
Acked-by: Eric Farman <[email protected]>
Reviewed-by: Eric Auger <[email protected]>


  Commit: 5b1e96e654036a65d3edb2671281e1a30c6f5ce7
      
https://github.com/qemu/qemu/commit/5b1e96e654036a65d3edb2671281e1a30c6f5ce7
  Author: Joao Martins <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M backends/iommufd.c
    M backends/trace-events
    M hw/vfio/iommufd.c
    M include/hw/vfio/vfio-common.h
    M include/sysemu/iommufd.h

  Log Message:
  -----------
  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 <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>
[ clg: Added ERRP_GUARD() in iommufd_cdev_autodomains_get() ]
Signed-off-by: Cédric Le Goater <[email protected]>
Reviewed-by: Eric Auger <[email protected]>


  Commit: 6c635326425091e164b563a7ce96408ef74ff2ec
      
https://github.com/qemu/qemu/commit/6c635326425091e164b563a7ce96408ef74ff2ec
  Author: Joao Martins <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M backends/iommufd.c
    M hw/vfio/container.c
    M hw/vfio/iommufd.c
    M include/sysemu/host_iommu_device.h

  Log Message:
  -----------
  vfio/{iommufd,container}: Remove caps::aw_bits

Remove caps::aw_bits which requires the bcontainer::iova_ranges being
initialized after device is actually attached. Instead defer that to
.get_cap() and call vfio_device_get_aw_bits() directly.

This is in preparation for HostIOMMUDevice::realize() being called early
during attach_device().

Suggested-by: Zhenzhong Duan <[email protected]>
Signed-off-by: Joao Martins <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Eric Auger <[email protected]>


  Commit: 21e8d3a3aa1627079088e2430946dea62bf5c703
      
https://github.com/qemu/qemu/commit/21e8d3a3aa1627079088e2430946dea62bf5c703
  Author: Joao Martins <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M hw/vfio/iommufd.c
    M include/sysemu/host_iommu_device.h

  Log Message:
  -----------
  vfio/iommufd: Add hw_caps field to HostIOMMUDeviceCaps

Store the value of @caps returned by iommufd_backend_get_device_info()
in a new field HostIOMMUDeviceCaps::hw_caps. Right now the only value is
whether device IOMMU supports dirty tracking (IOMMU_HW_CAP_DIRTY_TRACKING).

This is in preparation for HostIOMMUDevice::realize() being called early
during attach_device().

Signed-off-by: Joao Martins <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>


  Commit: 83a4d596a93bc22ace521789979f5ccdcd91ab96
      
https://github.com/qemu/qemu/commit/83a4d596a93bc22ace521789979f5ccdcd91ab96
  Author: Joao Martins <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M hw/vfio/common.c
    M hw/vfio/container.c
    M hw/vfio/helpers.c
    M hw/vfio/iommufd.c
    M include/hw/vfio/vfio-common.h

  Log Message:
  -----------
  vfio/{iommufd, container}: Invoke HostIOMMUDevice::realize() during 
attach_device()

Move the HostIOMMUDevice::realize() to be invoked during the attach of the 
device
before we allocate IOMMUFD hardware pagetable objects (HWPT). This allows the 
use
of the hw_caps obtained by IOMMU_GET_HW_INFO that essentially tell if the IOMMU
behind the device supports dirty tracking.

Note: The HostIOMMUDevice data from legacy backend is static and doesn't
need any information from the (type1-iommu) backend to be initialized.
In contrast however, the IOMMUFD HostIOMMUDevice data requires the
iommufd FD to be connected and having a devid to be able to successfully
GET_HW_INFO. This means vfio_device_hiod_realize() is called in
different places within the backend .attach_device() implementation.

Suggested-by: Cédric Le Goater <[email protected]>
Signed-off-by: Joao Martins <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
[ clg: Fixed error handling in iommufd_cdev_attach() ]
Signed-off-by: Cédric Le Goater <[email protected]>
Reviewed-by: Eric Auger <[email protected]>


  Commit: dddfd8d6670d2d63b851b0c976c3ae08592f4339
      
https://github.com/qemu/qemu/commit/dddfd8d6670d2d63b851b0c976c3ae08592f4339
  Author: Joao Martins <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M hw/vfio/iommufd.c
    M include/hw/vfio/vfio-common.h

  Log Message:
  -----------
  vfio/iommufd: Probe and request hwpt dirty tracking capability

In preparation to using the dirty tracking UAPI, probe whether the IOMMU
supports dirty tracking. This is done via the data stored in
hiod::caps::hw_caps initialized from GET_HW_INFO.

Qemu doesn't know if VF dirty tracking is supported when allocating
hardware pagetable in iommufd_cdev_autodomains_get(). This is because
VFIODevice migration state hasn't been initialized *yet* hence it can't pick
between VF dirty tracking vs IOMMU dirty tracking. So, if IOMMU supports
dirty tracking it always creates HWPTs with IOMMU_HWPT_ALLOC_DIRTY_TRACKING
even if later on VFIOMigration decides to use VF dirty tracking instead.

Signed-off-by: Joao Martins <[email protected]>
[ clg: - Fixed vbasedev->iommu_dirty_tracking assignment in
         iommufd_cdev_autodomains_get()
       - Added warning for heterogeneous dirty page tracking support
         in iommufd_cdev_autodomains_get() ]
Signed-off-by: Cédric Le Goater <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>


  Commit: 52ce88229c2d63a223f4c822240e84c3daeb7f6e
      
https://github.com/qemu/qemu/commit/52ce88229c2d63a223f4c822240e84c3daeb7f6e
  Author: Joao Martins <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M backends/iommufd.c
    M backends/trace-events
    M hw/vfio/iommufd.c
    M include/sysemu/iommufd.h

  Log Message:
  -----------
  vfio/iommufd: Implement VFIOIOMMUClass::set_dirty_tracking support

ioctl(iommufd, IOMMU_HWPT_SET_DIRTY_TRACKING, arg) is the UAPI that
enables or disables dirty page tracking. The ioctl is used if the hwpt
has been created with dirty tracking supported domain (stored in
hwpt::flags) and it is called on the whole list of iommu domains.

Signed-off-by: Joao Martins <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>


  Commit: 7c30710bd99510b1ce91a1b287118c759c55a495
      
https://github.com/qemu/qemu/commit/7c30710bd99510b1ce91a1b287118c759c55a495
  Author: Joao Martins <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M backends/iommufd.c
    M backends/trace-events
    M hw/vfio/iommufd.c
    M include/sysemu/iommufd.h

  Log Message:
  -----------
  vfio/iommufd: Implement VFIOIOMMUClass::query_dirty_bitmap support

ioctl(iommufd, IOMMU_HWPT_GET_DIRTY_BITMAP, arg) is the UAPI
that fetches the bitmap that tells what was dirty in an IOVA
range.

A single bitmap is allocated and used across all the hwpts
sharing an IOAS which is then used in log_sync() to set Qemu
global bitmaps.

Signed-off-by: Joao Martins <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>


  Commit: f48b472450efd086dec2e32dc93c882a62a53649
      
https://github.com/qemu/qemu/commit/f48b472450efd086dec2e32dc93c882a62a53649
  Author: Joao Martins <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M hw/vfio/migration.c

  Log Message:
  -----------
  vfio/migration: Don't block migration device dirty tracking is unsupported

By default VFIO migration is set to auto, which will support live
migration if the migration capability is set *and* also dirty page
tracking is supported.

For testing purposes one can force enable without dirty page tracking
via enable-migration=on, but that option is generally left for testing
purposes.

So starting with IOMMU dirty tracking it can use to accommodate the lack of
VF dirty page tracking allowing us to minimize the VF requirements for
migration and thus enabling migration by default for those too.

While at it change the error messages to mention IOMMU dirty tracking as
well.

Signed-off-by: Joao Martins <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
[ clg: - spelling in commit log ]
Signed-off-by: Cédric Le Goater <[email protected]>


  Commit: 30b9167785177ac43d11b881fe321918124aeb88
      
https://github.com/qemu/qemu/commit/30b9167785177ac43d11b881fe321918124aeb88
  Author: Joao Martins <[email protected]>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M hw/vfio/common.c
    M hw/vfio/migration.c
    M hw/vfio/pci.c
    M include/hw/vfio/vfio-common.h

  Log Message:
  -----------
  vfio/common: Allow disabling device dirty page tracking

The property 'x-pre-copy-dirty-page-tracking' allows disabling the whole
tracking of VF pre-copy phase of dirty page tracking, though it means
that it will only be used at the start of the switchover phase.

Add an option that disables the VF dirty page tracking, and fall
back into container-based dirty page tracking. This also allows to
use IOMMU dirty tracking even on VFs with their own dirty
tracker scheme.

Signed-off-by: Joao Martins <[email protected]>
Reviewed-by: Zhenzhong Duan <[email protected]>


  Commit: dd4bc5f1cfe92531d654c71e7703b3895afb05df
      
https://github.com/qemu/qemu/commit/dd4bc5f1cfe92531d654c71e7703b3895afb05df
  Author: Richard Henderson <[email protected]>
  Date:   2024-07-24 (Wed, 24 Jul 2024)

  Changed paths:
    M backends/iommufd.c
    M backends/trace-events
    M hw/vfio/ap.c
    M hw/vfio/ccw.c
    M hw/vfio/common.c
    M hw/vfio/container.c
    M hw/vfio/helpers.c
    M hw/vfio/iommufd.c
    M hw/vfio/migration.c
    M hw/vfio/pci.c
    M include/hw/vfio/vfio-common.h
    M include/sysemu/host_iommu_device.h
    M include/sysemu/iommufd.h

  Log Message:
  -----------
  Merge tag 'pull-vfio-20240723-1' of https://github.com/legoater/qemu into 
staging

vfio queue:

* IOMMUFD Dirty Tracking support
* Fix for a possible SEGV in IOMMU type1 container
* Dropped initialization of host IOMMU device with mdev devices

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmafyVUACgkQUaNDx8/7
# 7KGebRAAzEYxvstDxSPNF+1xx937TKbRpiKYtspTfEgu4Ht50MwO2ZqnVWzTBSwa
# qcjhDf2avMBpBvkp4O9fR7nXR0HRN2KvYrBSThZ3Qpqu4KjxCAGcHI5uYmgfizYh
# BBLrw3eWME5Ry220TinQF5KFl50vGq7Z/mku5N5Tgj2qfTfCXYK1Kc19SyAga49n
# LSokTIjZAGJa4vxrE7THawaEUjFRjfCJey64JUs/TPJaGr4R1snJcWgETww6juUE
# 9OSw/xl0AoQhaN/ZTRC1qCsBLUI2MVPsC+x+vqVK62HlTjCx+uDRVQ8KzfDzjCeH
# gaLkMjxJSuJZMpm4UU7DBzDGEGcEBCGeNyFt37BSqqPPpX55CcFhj++d8vqTiwpF
# YzmTNd/znxcZTw6OJN9sQZohh+NeS86CVZ3x31HD3dXifhRf17jbh7NoIyi+0ZCb
# N+mytOH5BXsD+ddwbk+yMaxXV43Fgz7ThG5tB1tjhhNtLZHDA5ezFvGZ5F/FJrqE
# xAbjOhz5MC+RcOVNSzQJCULNqFpfE6Gqeys6btEDm/ltf4LpAe6W1HYuv8BJc19T
# UsqGK2yKAuQX8GErYxJ1zqZCttVrgpsmXFYTC5iGbxC84mvsF0Iti96IdXz9gfzN
# Vlb2OxoefcOwVqIhbkvTZW0ZwYGGDDPAYhLMfr5lSuRqj123OOo=
# =cViP
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 24 Jul 2024 01:16:37 AM AEST
# gpg:                using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1
# gpg: Good signature from "Cédric Le Goater <[email protected]>" [undefined]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: A0F6 6548 F048 95EB FE6B  0B60 51A3 43C7 CFFB ECA1

* tag 'pull-vfio-20240723-1' of https://github.com/legoater/qemu:
  vfio/common: Allow disabling device dirty page tracking
  vfio/migration: Don't block migration device dirty tracking is unsupported
  vfio/iommufd: Implement VFIOIOMMUClass::query_dirty_bitmap support
  vfio/iommufd: Implement VFIOIOMMUClass::set_dirty_tracking support
  vfio/iommufd: Probe and request hwpt dirty tracking capability
  vfio/{iommufd, container}: Invoke HostIOMMUDevice::realize() during 
attach_device()
  vfio/iommufd: Add hw_caps field to HostIOMMUDeviceCaps
  vfio/{iommufd,container}: Remove caps::aw_bits
  vfio/iommufd: Introduce auto domain creation
  vfio/ccw: Don't initialize HOST_IOMMU_DEVICE with mdev
  vfio/ap: Don't initialize HOST_IOMMU_DEVICE with mdev
  vfio/iommufd: Return errno in iommufd_cdev_attach_ioas_hwpt()
  backends/iommufd: Extend iommufd_backend_get_device_info() to fetch HW 
capabilities
  vfio/iommufd: Don't initialize nor set a HOST_IOMMU_DEVICE with mdev
  vfio/pci: Extract mdev check into an helper
  hw/vfio/container: Fix SIGSEV on vfio_container_instance_finalize()

Signed-off-by: Richard Henderson <[email protected]>


Compare: https://github.com/qemu/qemu/compare/43f59bf76535...dd4bc5f1cfe9

To unsubscribe from these emails, change your notification settings at 
https://github.com/qemu/qemu/settings/notifications

Reply via email to