[PATCH] vl: Fix an assert failure in error path

2021-06-09 Thread Zhenzhong Duan
: Assertion `*errp == NULL' failed. After fix: qemu-system-x86_64: cannot create PID file: Cannot open pid file: Permission denied Signed-off-by: Zhenzhong Duan --- softmmu/vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 326c1e9080

[PATCH] cutils: Fix memleak in get_relocated_path()

2021-04-26 Thread Zhenzhong Duan
Valgrind complains definitely loss in get_relocated_path(), because GString is leaked in get_relocated_path() when returning with gchar *. Use g_string_free(, false) to free GString while preserving gchar *. Signed-off-by: Zhenzhong Duan --- util/cutils.c | 2 +- 1 file changed, 1 insertion

[PATCH] vl: transform QemuOpts device to JSON syntax device

2022-02-23 Thread Zhenzhong Duan
id=scsi1,bus=pci.0 Succeed! Because both kind of options are inserted into their own list and break the order in QEMU command line during BDF auto assign. Fix it by transform QemuOpts into JSON syntax and insert in JSON device list, so the order in QEMU command line kept. Signed-off-by: Zhenzhong Dua

[PATCH] pci: show id info when pci BDF conflict

2022-02-23 Thread Zhenzhong Duan
t, showing the id info in the warning. Signed-off-by: Zhenzhong Duan --- hw/pci/pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 5d30f9ca60e5..0103a2c36ca2 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1078,9 +1078,9 @@ static

[PATCH] qdev: move legacy cli device creation after JSON syntax ones

2022-02-23 Thread Zhenzhong Duan
by the passthroughed "-device" in legacy syntax. But legacy syntax described devices are assigned BDF first, this leads to conflict with the pci devices in JSON syntax with fixed BDF. Move legacy syntax described device creation after JSON syntax described ones so we can start that

[PATCH] softmmu/vl: Remove redundant local variable

2022-02-27 Thread Zhenzhong Duan
While there is already a local variable opts in main function scope, no need to define another one with same name in smaller scope. No functional changes. Signed-off-by: Zhenzhong Duan --- softmmu/vl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/softmmu/vl.c b

[PATCH v1 17/22] util/char_dev: Add open_cdev()

2023-08-30 Thread Zhenzhong Duan
From: Yi Liu /dev/vfio/devices/vfioX may not exist. In that case it is still possible to open /dev/char/$major:$minor instead. Add helper function to abstract the cdev open. Suggested-by: Jason Gunthorpe Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- MAINTAINERS | 6

[PATCH v1 21/22] vfio/pci: Allow the selection of a given iommu backend

2023-08-30 Thread Zhenzhong Duan
the /dev/iommu device may have been pre-opened by a management tool such as libvirt. This mode is no more considered for the legacy backend. So let's remove the "TODO" comment. Suggested-by: Alex Williamson Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --

[PATCH v1 13/22] vfio: Add base container

2023-08-30 Thread Zhenzhong Duan
Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/vfio/common.c | 72 +--- hw/vfio/container-base.c | 160 + hw/vfio/container.c | 247 -- hw

[PATCH v1 12/22] vfio/ccw: Use vfio_[attach/detach]_device

2023-08-30 Thread Zhenzhong Duan
functions, local to container.c. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/vfio/ccw.c | 120 -- hw/vfio/container.c | 10 +-- include/hw/vfio/vfio-common.h | 5 -- 3 files changed, 33 insertions

[PATCH v1 18/22] vfio/iommufd: Implement the iommufd backend

2023-08-30 Thread Zhenzhong Duan
-by: Eric Auger Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/vfio/common.c | 12 +- hw/vfio/iommufd.c | 521 ++ hw/vfio/meson.build | 3 + hw/vfio/trace-events

[PATCH v1 20/22] vfio/pci: Adapt vfio pci hot reset support with iommufd BE

2023-08-30 Thread Zhenzhong Duan
share the common bus reset and system reset path for different BEs. Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c| 224 +++ hw/vfio/trace-events | 1 + 2 files changed, 208 insertions(+), 17 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio

[PATCH v1 14/22] vfio/common: Simplify vfio_viommu_preset()

2023-08-30 Thread Zhenzhong Duan
Commit "vfio/container-base: Introduce [attach/detach]_device container callbacks" add support to link to address space, we can utilize it to simplify vfio_viommu_preset(). Signed-off-by: Zhenzhong Duan --- hw/vfio/common.c | 17 + 1 file changed, 1 insertion(+), 16

[PATCH v1 06/22] vfio/common: Add a vfio device iterator

2023-08-30 Thread Zhenzhong Duan
, saying first vfio address space created instead of the first group. Signed-off-by: Zhenzhong Duan --- hw/vfio/common.c | 224 ++- 1 file changed, 122 insertions(+), 102 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 949ad6714a

[PATCH v1 05/22] vfio/common: Extract out vfio_kvm_device_[add/del]_fd

2023-08-30 Thread Zhenzhong Duan
...which will be used by both legacy and iommufd backend. Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/vfio/common.c | 44 +++ include/hw/vfio/vfio-common.h | 3 +++ 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/hw

[PATCH v1 01/22] scripts/update-linux-headers: Add iommufd.h

2023-08-30 Thread Zhenzhong Duan
From: Eric Auger Update the script to import iommufd.h Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- scripts/update-linux-headers.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/update-linux-headers.sh b/scripts/update

[PATCH v1 11/22] vfio/ap: Use vfio_[attach/detach]_device

2023-08-30 Thread Zhenzhong Duan
From: Eric Auger Let the vfio-ap device use vfio_attach_device() and vfio_detach_device(), hence hiding the details of the used IOMMU backend. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/vfio/ap.c | 68

[PATCH v1 08/22] vfio/common: Move legacy VFIO backend code into separate container.c

2023-08-30 Thread Zhenzhong Duan
-common.h also for containter.c usage. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- --- hw/vfio/common.c | 1085 + hw/vfio/container.c | 1085 + hw/vfio/meson.build

[PATCH v1 03/22] vfio/common: Move IOMMU agnostic helpers to a separate file

2023-08-30 Thread Zhenzhong Duan
From: Yi Liu Move low-level iommu agnostic helpers to a separate helpers.c file. They relate to regions, interrupts and device/region capabilities. Signed-off-by: Eric Auger Signed-off-by: Yi Sun Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/vfio/common.c | 569

[PATCH v1 02/22] Update linux-header to support iommufd cdev and hwpt alloc

2023-08-30 Thread Zhenzhong Duan
>From https://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git branch: for_next commit id: eb501c2d96cfce6b42528e8321ea085ec605e790 Signed-off-by: Zhenzhong Duan --- Note this is a placeholder patch. include/standard-headers/linux/fuse.h | 3 + linux-headers/linux/iommuf

[PATCH v1 09/22] vfio/container: Introduce vfio_[attach/detach]_device

2023-08-30 Thread Zhenzhong Duan
-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/vfio/container.c | 66 +++ hw/vfio/pci.c | 50 -- hw/vfio/trace-events | 2 +- include/hw/vfio/vfio-common.h | 3 ++ 4 files changed, 76

[PATCH v1 07/22] vfio/common: Refactor vfio_viommu_preset() to be group agnostic

2023-08-30 Thread Zhenzhong Duan
So that it doesn't need to be moved into container.c as done in following patch. Signed-off-by: Zhenzhong Duan --- hw/vfio/common.c | 17 - 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 51c6e7598e..fda5fc87b9 100644

[PATCH v1 16/22] backends/iommufd: Introduce the iommufd object

2023-08-30 Thread Zhenzhong Duan
-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- MAINTAINERS | 7 + backends/Kconfig | 4 + backends/iommufd.c | 291 +++ backends/meson.build | 3 + backends/trace-events| 13 ++ include/sysemu

[PATCH v1 00/22] vfio: Adopt iommufd

2023-08-30 Thread Zhenzhong Duan
acy VFIO backend code into separate container.c vfio: Add base container util/char_dev: Add open_cdev() vfio/iommufd: Implement the iommufd backend Zhenzhong Duan (9): Update linux-header to support iommufd cdev and hwpt alloc vfio/common: Extract out vfio_kvm_device_[add/del]_fd v

[PATCH v1 22/22] vfio/pci: Make vfio cdev pre-openable by passing a file handle

2023-08-30 Thread Zhenzhong Duan
vfio devices. There is no easy way to check if a device is mdev with FD passing, so fail the x-balloon-allowed check unconditionally in this case. There is also no easy way to get BDF as name with FD passing, so we fake a name by VFIO_FD[fd]. Signed-off-by: Zhenzhong Duan --- hw/vfio/helpers.c

[PATCH v1 04/22] vfio/common: Introduce vfio_container_add|del_section_window()

2023-08-30 Thread Zhenzhong Duan
-by: Zhenzhong Duan --- hw/vfio/common.c | 156 +++ 1 file changed, 89 insertions(+), 67 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 9ca695837f..67150e4575 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -796,6 +796,92

[PATCH v1 19/22] vfio/iommufd: Add vfio device iterator callback for iommufd

2023-08-30 Thread Zhenzhong Duan
The way to get vfio device pointer is different between legacy container and iommufd container, with iommufd backend support added, it's time to add the iterator support for iommufd. Signed-off-by: Zhenzhong Duan --- hw/vfio/iommufd.c | 29 + 1 file changed, 29

[PATCH v1 15/22] Add iommufd configure option

2023-08-30 Thread Zhenzhong Duan
This adds "--enable-iommufd/--disable-iommufd" to enable or disable iommufd support, enabled by default. Signed-off-by: Zhenzhong Duan --- meson.build | 6 ++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 3 files changed, 11

[PATCH v1 10/22] vfio/platform: Use vfio_[attach/detach]_device

2023-08-30 Thread Zhenzhong Duan
From: Eric Auger Let the vfio-platform device use vfio_attach_device() and vfio_detach_device(), hence hiding the details of the used IOMMU backend. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/vfio/platform.c | 43

[PATCH v4 07/41] vfio/container: Introduce a empty VFIOIOMMUOps

2023-11-02 Thread Zhenzhong Duan
This empty VFIOIOMMUOps named vfio_legacy_ops will hold all general IOMMU ops of legacy container. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 2 +- hw/vfio/container.c | 5 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/hw/vfio/vfio

[PATCH v4 03/41] vfio/container: Move spapr specific init/deinit into spapr.c

2023-11-02 Thread Zhenzhong Duan
. No functional changes intended. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio-common.h | 4 +- hw/vfio/container.c | 82 +-- hw/vfio/spapr.c | 81

[PATCH v4 13/41] vfio/container: Move per container device list in base container

2023-11-02 Thread Zhenzhong Duan
VFIO Device is also changed to point to base container instead of legacy container. No fucntional change intended. Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio-common.h | 3 +-- include/hw/vfio/vfio-container-base.h | 1 + hw/vfio/common.c

[PATCH v4 17/41] vfio/container: Move listener to base container

2023-11-02 Thread Zhenzhong Duan
From: Eric Auger Move listener to base container. Also error and initialized fields are moved at the same time. No functional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h

[PATCH v4 02/41] vfio/container: Move vfio_container_add/del_section_window into spapr.c

2023-11-02 Thread Zhenzhong Duan
vfio_container_add/del_section_window are spapr specific functions, so move them into spapr.c to make container.c cleaner. No functional changes intended. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater --- hw/vfio/container.c | 90

[PATCH v4 01/41] vfio/container: Move IBM EEH related functions into spapr_pci_vfio.c

2023-11-02 Thread Zhenzhong Duan
With vfio_eeh_as_ok/vfio_eeh_as_op moved and made static, vfio.h becomes empty and is deleted. No functional changes intended. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan Acked-by: Eric Farman Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio.h | 7 --- hw/ppc

[PATCH v4 16/41] vfio/container: Move vrdl_list to base container

2023-11-02 Thread Zhenzhong Duan
No functional change intended. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 11 include/hw/vfio/vfio-container-base.h | 11 hw/vfio/common.c | 38 +-- hw/vfio/container-base.c | 1 + hw

[PATCH v4 36/41] vfio: Allow the selection of a given iommu backend for platform ap and ccw

2023-11-02 Thread Zhenzhong Duan
Previously we added support to select iommu backend for vfio pci device. Now we added others, E.g: platform, ap and ccw. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-platform.h | 1 + hw/vfio/ap.c| 5 + hw/vfio/ccw.c | 5 + hw/vfio

[PATCH v4 28/41] vfio/iommufd: Implement the iommufd backend

2023-11-02 Thread Zhenzhong Duan
-by: Eric Auger Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- v4: use SPDX identifier, use iommufd_cdev_* prefix, merge with manual alloc patch include/hw/vfio/vfio-common.h | 23 ++ hw/vfio/common.c | 19 +- hw/vfio/iommufd.c | 504

[PATCH v4 14/41] vfio/container: Convert functions to base container

2023-11-02 Thread Zhenzhong Duan
vfio_get_dirty_bitmap Signed-off-by: Eric Auger Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio-common.h | 9 hw/vfio/common.c | 42 +++ hw/vfio/container.c | 6 ++--- hw/vfio/trace-events

[PATCH v4 06/41] vfio: Introduce base object for VFIOContainer and targeted interface

2023-11-02 Thread Zhenzhong Duan
. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- v4: use SPDX identifier, use const char *name parameter, HW_VFIO_VFIO_CONTAINER_BASE_H include/hw/vfio/vfio-common.h | 8 ++--- include/hw/vfio/vfio-container-base.h | 50

[PATCH v4 24/41] vfio/spapr: Move hostwin_list into spapr container

2023-11-02 Thread Zhenzhong Duan
No functional changes intended. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 1 - hw/vfio/spapr.c | 36 +++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio

[PATCH v4 00/41] vfio: Adopt iommufd

2023-11-02 Thread Zhenzhong Duan
ci: Allow the selection of a given iommu backend Yi Liu (2): util/char_dev: Add open_cdev() vfio/iommufd: Implement the iommufd backend Zhenzhong Duan (28): vfio/container: Move IBM EEH related functions into spapr_pci_vfio.c vfio/container: Move vfio_container_add/del_section_window

[PATCH v4 27/41] util/char_dev: Add open_cdev()

2023-11-02 Thread Zhenzhong Duan
From: Yi Liu /dev/vfio/devices/vfioX may not exist. In that case it is still possible to open /dev/char/$major:$minor instead. Add helper function to abstract the cdev open. Suggested-by: Jason Gunthorpe Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- MAINTAINERS

[PATCH v4 05/41] vfio/common: Move vfio_host_win_add/del into spapr.c

2023-11-02 Thread Zhenzhong Duan
ved into spapr, we changed to check container->pgsizes. Suggested-by: Alex Williamson Signed-off-by: Zhenzhong Duan --- v4: add vfio_find_hostwin back for VFIO_SPAPR_TCE_IOMMU include/hw/vfio/vfio-common.h | 5 --- hw/vfio/common.c | 70 + hw/vfio/conta

[PATCH v4 10/41] vfio/common: Move giommu_list in base container

2023-11-02 Thread Zhenzhong Duan
From: Eric Auger Move the giommu_list field in the base container and store the base container in the VFIOGuestIOMMU. No functional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h

[PATCH v4 18/41] vfio/container: Move dirty_pgsizes and max_dirty_bitmap_size to base container

2023-11-02 Thread Zhenzhong Duan
From: Eric Auger No functional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio-common.h | 2 -- include/hw/vfio/vfio-container-base.h | 2 ++ hw/vfio

[PATCH v4 11/41] vfio/container: Move space field to base container

2023-11-02 Thread Zhenzhong Duan
From: Eric Auger Move the space field to the base object. Also the VFIOAddressSpace now contains a list of base containers. No fucntional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- v4: use bcontainer->sp

[PATCH v4 25/41] Add iommufd configure option

2023-11-02 Thread Zhenzhong Duan
This adds "--enable-iommufd/--disable-iommufd" to enable or disable iommufd support, enabled by default. Signed-off-by: Zhenzhong Duan --- meson.build | 6 ++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 3 files changed, 11

[PATCH v4 08/41] vfio/container: Switch to dma_map|unmap API

2023-11-02 Thread Zhenzhong Duan
From: Eric Auger No fucntional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- v4: use SPDX identifier, use assert include/hw/vfio/vfio-common.h | 4 --- include/hw/vfio/vfio-container-base.h | 7 + hw

[PATCH v4 29/41] vfio/iommufd: Relax assert check for iommufd backend

2023-11-02 Thread Zhenzhong Duan
, query_dirty_bitmap will never be called. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- hw/vfio/container-base.c | 4 hw/vfio/container.c | 4 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c

[PATCH v4 30/41] vfio/iommufd: Add support for iova_ranges

2023-11-02 Thread Zhenzhong Duan
-by: Zhenzhong Duan --- v4: fix build error in 32bit fedora hw/vfio/iommufd.c | 47 +++ 1 file changed, 47 insertions(+) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 1bb55ca2c4..22f02f92a9 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c

[PATCH v4 15/41] vfio/container: Move pgsizes and dma_max_mappings to base container

2023-11-02 Thread Zhenzhong Duan
From: Eric Auger No functional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- v4: Split vrdl_list change out in a seperate patch include/hw/vfio/vfio-common.h | 2 -- include/hw/vfio/vfio-container-base.h

[PATCH v4 22/41] vfio/spapr: switch to spapr IOMMU BE add/del_section_window

2023-11-02 Thread Zhenzhong Duan
No fucntional change intended. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 5 - include/hw/vfio/vfio-container-base.h | 5 + hw/vfio/common.c | 8 ++-- hw/vfio/container-base.c | 21 + hw/vfio

[PATCH v4 35/41] vfio/pci: Make vfio cdev pre-openable by passing a file handle

2023-11-02 Thread Zhenzhong Duan
y to check if a device is mdev with FD passing, so fail the x-balloon-allowed check unconditionally in this case. There is also no easy way to get BDF as name with FD passing, so we fake a name by VFIO_FD[fd]. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 1 + hw/vfio

[PATCH v4 37/41] vfio/platform: Make vfio cdev pre-openable by passing a file handle

2023-11-02 Thread Zhenzhong Duan
This gives management tools like libvirt a chance to open the vfio cdev with privilege and pass FD to qemu. This way qemu never needs to have privilege to open a VFIO or iommu cdev node. Signed-off-by: Zhenzhong Duan --- hw/vfio/platform.c | 41 + 1 file

[PATCH v4 23/41] vfio/spapr: Move prereg_listener into spapr container

2023-11-02 Thread Zhenzhong Duan
No functional changes intended. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 1 - hw/vfio/spapr.c | 24 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h

[PATCH v4 12/41] vfio/container: Switch to IOMMU BE set_dirty_page_tracking/query_dirty_bitmap API

2023-11-02 Thread Zhenzhong Duan
From: Eric Auger dirty_pages_supported field is also moved to the base container No fucntional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- v4: use assert include/hw/vfio/vfio-common.h | 6

[PATCH v4 21/41] vfio/spapr: Introduce spapr backend and target interface

2023-11-02 Thread Zhenzhong Duan
ned-off-by: Zhenzhong Duan --- v4: remove VFIOIOMMUSpaprOps include/hw/vfio/vfio-container-base.h | 6 ++ hw/vfio/spapr.c | 14 ++ 2 files changed, 20 insertions(+) diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h in

[PATCH v4 41/41] vfio: Compile out iommufd for PPC target

2023-11-02 Thread Zhenzhong Duan
Since PPC doesn't support IOMMUFD, make iommufd related code compiled out. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- hw/vfio/common.c | 2 +- hw/vfio/pci.c| 2 +- hw/vfio/platform.c | 2 +- backends/meson.build | 4 ++-- hw/vfio/meson.build | 2 +- 5 files

[PATCH v4 40/41] vfio: Make VFIOContainerBase poiner parameter const in VFIOIOMMUOps callbacks

2023-11-02 Thread Zhenzhong Duan
same changes to avoid build error. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 12 ++ include/hw/vfio/vfio-container-base.h | 12 ++ hw/vfio/common.c | 9 +++ hw/vfio/container-base.c

[PATCH v4 09/41] vfio/common: Introduce vfio_container_init/destroy helper

2023-11-02 Thread Zhenzhong Duan
This adds two helper functions vfio_container_init/destroy which will be used by both legacy and iommufd containers to do base container specific initialization and release. No fucntional change intended. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio

[PATCH v4 04/41] vfio/spapr: Make vfio_spapr_create/remove_window static

2023-11-02 Thread Zhenzhong Duan
vfio_spapr_create_window calls vfio_spapr_remove_window, With reoder of definition of the two, we can make vfio_spapr_create/remove_window static. No functional changes intended. Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio-common.h | 6 - hw/vfio

[PATCH v4 32/41] vfio/pci: Introduce a vfio pci hot reset interface

2023-11-02 Thread Zhenzhong Duan
Legacy vfio pci and iommufd cdev have different process to hot reset vfio device, expand current code to abstract out pci_hot_reset callback for legacy vfio, this same interface will also be used by iommufd cdev vfio device. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- hw

[PATCH v4 34/41] vfio/pci: Allow the selection of a given iommu backend

2023-11-02 Thread Zhenzhong Duan
Suggested-by: Alex Williamson Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c | 5 + 1 file changed, 5 insertions(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index eb662fd086..7a6696ca55 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -42,6

[PATCH v4 26/41] backends/iommufd: Introduce the iommufd object

2023-11-02 Thread Zhenzhong Duan
-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- v4: add CONFIG_IOMMUFD check, document default case MAINTAINERS | 7 ++ qapi/qom.json| 22 include/sysemu/iommufd.h | 46 +++ backends/iommufd-stub.c | 59 + backends/iommufd.c

[PATCH v4 38/41] vfio/ap: Make vfio cdev pre-openable by passing a file handle

2023-11-02 Thread Zhenzhong Duan
This gives management tools like libvirt a chance to open the vfio cdev with privilege and pass FD to qemu. This way qemu never needs to have privilege to open a VFIO or iommu cdev node. Opportunisticly, remove some unnecessory double-cast. Signed-off-by: Zhenzhong Duan --- hw/vfio/ap.c | 32

[PATCH v4 31/41] vfio/pci: Extract out a helper vfio_pci_get_pci_hot_reset_info

2023-11-02 Thread Zhenzhong Duan
This helper will be used by both legacy and iommufd backends. No functional changes intended. Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.h | 3 +++ hw/vfio/pci.c | 54 +++ 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/hw

[PATCH v4 33/41] vfio/iommufd: Enable pci hot reset through iommufd cdev interface

2023-11-02 Thread Zhenzhong Duan
Add a new callback iommufd_pci_hot_reset to do iommufd specific check and reset operation. Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.h| 2 + hw/vfio/iommufd.c| 142 +++ hw/vfio/pci.c| 4 +- hw/vfio/trace-events | 1 + 4 files

[PATCH v4 20/41] vfio/container: Implement attach/detach_device

2023-11-02 Thread Zhenzhong Duan
From: Eric Auger No fucntional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/vfio/common.c| 16 hw/vfio/container.c | 12 +--- 2 files changed, 21 insertions(+), 7 deletions(-) diff

[PATCH v4 19/41] vfio/container: Move iova_ranges to base container

2023-11-02 Thread Zhenzhong Duan
Meanwhile remove the helper function vfio_free_container as it only calls g_free now. No functional change intended. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 1 - include/hw/vfio/vfio-container-base.h | 1 + hw/vfio/common.c | 5

[PATCH v4 39/41] vfio/ccw: Make vfio cdev pre-openable by passing a file handle

2023-11-02 Thread Zhenzhong Duan
This gives management tools like libvirt a chance to open the vfio cdev with privilege and pass FD to qemu. This way qemu never needs to have privilege to open a VFIO or iommu cdev node. Opportunisticly, remove a redundant definition of TYPE_VFIO_CCW. Signed-off-by: Zhenzhong Duan --- hw/vfio

[PATCH v3 07/37] vfio/container: Introduce a empty VFIOIOMMUOps

2023-10-26 Thread Zhenzhong Duan
This empty VFIOIOMMUOps named vfio_legacy_ops will hold all general IOMMU ops of legacy container. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 2 +- hw/vfio/container.c | 5 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/hw/vfio/vfio

[PATCH v3 00/37] vfio: Adopt iommufd

2023-10-26 Thread Zhenzhong Duan
n_cdev() vfio/iommufd: Implement the iommufd backend Zhenzhong Duan (24): vfio/container: Move IBM EEH related functions into spapr_pci_vfio.c vfio/container: Move vfio_container_add/del_section_window into spapr.c vfio/container: Move spapr specific init/deinit into spa

[PATCH v3 04/37] vfio/spapr: Make vfio_spapr_create/remove_window static

2023-10-26 Thread Zhenzhong Duan
vfio_spapr_create_window calls vfio_spapr_remove_window, With reoder of definition of the two, we can make vfio_spapr_create/remove_window static. No functional changes intended. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 6 - hw/vfio/spapr.c | 48

[PATCH v3 11/37] vfio/container: Switch to IOMMU BE set_dirty_page_tracking/query_dirty_bitmap API

2023-10-26 Thread Zhenzhong Duan
From: Eric Auger dirty_pages_supported field is also moved to the base container No fucntional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan Signed-off-by: Cédric Le Goater --- include/hw/vfio/vfio-common.h

[PATCH v3 02/37] vfio/container: Move vfio_container_add/del_section_window into spapr.c

2023-10-26 Thread Zhenzhong Duan
vfio_container_add/del_section_window are spapr specific functions, so move them into spapr.c to make container.c cleaner. No functional changes intended. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- hw/vfio/container.c | 90

[PATCH v3 01/37] vfio/container: Move IBM EEH related functions into spapr_pci_vfio.c

2023-10-26 Thread Zhenzhong Duan
With vfio_eeh_as_ok/vfio_eeh_as_op moved and made static, vfio.h becomes empty and is deleted. No functional changes intended. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio.h | 7 --- hw/ppc/spapr_pci_vfio.c | 100

[PATCH v3 09/37] vfio/common: Move giommu_list in base container

2023-10-26 Thread Zhenzhong Duan
Signed-off-by: Zhenzhong Duan [ clg: context changes ] Signed-off-by: Cédric Le Goater --- include/hw/vfio/vfio-common.h | 9 - include/hw/vfio/vfio-container-base.h | 13 + hw/vfio/common.c | 17 +++-- hw/vfio/container-base.c

[PATCH v3 05/37] vfio/common: Move vfio_host_win_add/del into spapr.c

2023-10-26 Thread Zhenzhong Duan
Only spapr supports a customed host window list, other vfio driver assume 64bit host window. So remove the check in listener callback and move vfio_host_win_add/del into spapr.c and make static. Suggested-by: Alex Williamson Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 5

[PATCH v3 12/37] vfio/container: Move per container device list in base container

2023-10-26 Thread Zhenzhong Duan
VFIO Device is also changed to point to base container instead of legacy container. No fucntional change intended. Signed-off-by: Zhenzhong Duan [ clg: context changes ] Signed-off-by: Cédric Le Goater --- include/hw/vfio/vfio-common.h | 3 +-- include/hw/vfio/vfio-container-base.h

[PATCH v3 10/37] vfio/container: Move space field to base container

2023-10-26 Thread Zhenzhong Duan
From: Eric Auger Move the space field to the base object. Also the VFIOAddressSpace now contains a list of base containers. No fucntional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan [ clg: context changes ] Signed-off

[PATCH v3 22/37] vfio/spapr: Move hostwin_list into spapr container

2023-10-26 Thread Zhenzhong Duan
No functional changes intended. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 1 - hw/vfio/spapr.c | 30 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio

[PATCH v3 24/37] backends/iommufd: Introduce the iommufd object

2023-10-26 Thread Zhenzhong Duan
-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan Signed-off-by: Cédric Le Goater --- MAINTAINERS | 7 + qapi/qom.json| 20 +++ include/sysemu/iommufd.h | 46 +++ backends/iommufd-stub.c | 59 + backends/iommufd.c | 268

[PATCH v3 16/37] vfio/container: Move dirty_pgsizes and max_dirty_bitmap_size to base container

2023-10-26 Thread Zhenzhong Duan
From: Eric Auger No functional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan Signed-off-by: Cédric Le Goater --- include/hw/vfio/vfio-common.h | 2 -- include/hw/vfio/vfio-container-base.h | 2 ++ hw/vfio

[PATCH v3 37/37] vfio/ccw: Make vfio cdev pre-openable by passing a file handle

2023-10-26 Thread Zhenzhong Duan
This gives management tools like libvirt a chance to open the vfio cdev with privilege and pass FD to qemu. This way qemu never needs to have privilege to open a VFIO or iommu cdev node. Opportunisticly, remove a redundant definition of TYPE_VFIO_CCW. Signed-off-by: Zhenzhong Duan Signed-off

[PATCH v3 25/37] util/char_dev: Add open_cdev()

2023-10-26 Thread Zhenzhong Duan
From: Yi Liu /dev/vfio/devices/vfioX may not exist. In that case it is still possible to open /dev/char/$major:$minor instead. Add helper function to abstract the cdev open. Suggested-by: Jason Gunthorpe Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan Signed-off-by: Cédric Le Goater

[PATCH v3 15/37] vfio/container: Move listener to base container

2023-10-26 Thread Zhenzhong Duan
From: Eric Auger Move listener to base container. Also error and initialized fields are moved at the same time. No functional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan [ clg: context changes ] Signed-off-by: Cédric

[PATCH v3 06/37] vfio: Introduce base object for VFIOContainer and targetted interface

2023-10-26 Thread Zhenzhong Duan
. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 8 +--- include/hw/vfio/vfio-container-base.h | 64 +++ 2 files changed, 66 insertions(+), 6 deletions(-) create mode 100644

[PATCH v3 30/37] vfio/pci: Extract out a helper vfio_pci_get_pci_hot_reset_info

2023-10-26 Thread Zhenzhong Duan
This helper will be used by both legacy and iommufd backends. No functional changes intended. Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c | 54 +++ 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c

[PATCH v3 35/37] vfio/platform: Make vfio cdev pre-openable by passing a file handle

2023-10-26 Thread Zhenzhong Duan
This gives management tools like libvirt a chance to open the vfio cdev with privilege and pass FD to qemu. This way qemu never needs to have privilege to open a VFIO or iommu cdev node. Signed-off-by: Zhenzhong Duan Signed-off-by: Cédric Le Goater --- hw/vfio/platform.c | 41

[PATCH v3 23/37] Add iommufd configure option

2023-10-26 Thread Zhenzhong Duan
This adds "--enable-iommufd/--disable-iommufd" to enable or disable iommufd support, enabled by default. Signed-off-by: Zhenzhong Duan Signed-off-by: Cédric Le Goater --- meson.build | 6 ++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh

[PATCH v3 34/37] vfio: Allow the selection of a given iommu backend for platform ap and ccw

2023-10-26 Thread Zhenzhong Duan
Previously we added support to select iommu backend for vfio pci device. Now we added others, E.g: platform, ap and ccw. Signed-off-by: Zhenzhong Duan Signed-off-by: Cédric Le Goater --- include/hw/vfio/vfio-platform.h | 1 + hw/vfio/ap.c| 5 + hw/vfio/ccw.c

[PATCH v3 31/37] vfio/pci: Adapt vfio pci hot reset support with iommufd BE

2023-10-26 Thread Zhenzhong Duan
share the common bus reset and system reset path for both BEs. Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c| 156 ++- hw/vfio/trace-events | 1 + 2 files changed, 156 insertions(+), 1 deletion(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c

[PATCH v3 20/37] vfio/spapr: switch to spapr IOMMU BE add/del_section_window

2023-10-26 Thread Zhenzhong Duan
No fucntional change intended. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 5 - include/hw/vfio/vfio-container-base.h | 5 + hw/vfio/common.c | 8 ++-- hw/vfio/container-base.c | 23 ++- hw/vfio

[PATCH v3 27/37] vfio/iommufd: Switch to manual hwpt allocation

2023-10-26 Thread Zhenzhong Duan
this change. Signed-off-by: Zhenzhong Duan --- hw/vfio/iommufd.c | 89 +-- 1 file changed, 70 insertions(+), 19 deletions(-) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index aee64d63f3..c1daaf1c39 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c

[PATCH v3 33/37] vfio/pci: Make vfio cdev pre-openable by passing a file handle

2023-10-26 Thread Zhenzhong Duan
y to check if a device is mdev with FD passing, so fail the x-balloon-allowed check unconditionally in this case. There is also no easy way to get BDF as name with FD passing, so we fake a name by VFIO_FD[fd]. Signed-off-by: Zhenzhong Duan Signed-off-by: Cédric Le Goater --- include/hw/vfio/vfio-com

[PATCH v3 28/37] vfio/iommufd: Add support for iova_ranges

2023-10-26 Thread Zhenzhong Duan
-by: Zhenzhong Duan --- hw/vfio/iommufd.c | 47 +++ 1 file changed, 47 insertions(+) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index c1daaf1c39..18a09d7f5a 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -348,6 +348,52 @@ static int

[PATCH v3 36/37] vfio/ap: Make vfio cdev pre-openable by passing a file handle

2023-10-26 Thread Zhenzhong Duan
This gives management tools like libvirt a chance to open the vfio cdev with privilege and pass FD to qemu. This way qemu never needs to have privilege to open a VFIO or iommu cdev node. Opportunisticly, remove some unnecessory double-cast. Signed-off-by: Zhenzhong Duan Signed-off-by: Cédric Le

[PATCH v3 08/37] vfio/container: Switch to dma_map|unmap API

2023-10-26 Thread Zhenzhong Duan
From: Eric Auger No fucntional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 4 --- include/hw/vfio/vfio-container-base.h | 7 hw/vfio/common.c

[PATCH v3 14/37] vfio/container: Move vrdl_list, pgsizes and dma_max_mappings to base container

2023-10-26 Thread Zhenzhong Duan
From: Eric Auger Move vrdl_list, pgsizes and dma_max_mappings to the base container object No functional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan [ clg: context changes ] Signed-off-by: Cédric Le Goater

  1   2   3   4   5   6   7   >