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

2023-11-02 Thread Zhenzhong Duan
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 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
t vfio/pci: 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_secti

[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 28/41] vfio/iommufd: Implement the iommufd backend

2023-11-02 Thread Zhenzhong Duan
ed-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

[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
ended. 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

[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/

[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 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 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

[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 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 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

[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 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->space-

[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 29/41] vfio/iommufd: Relax assert check for iommufd backend

2023-11-02 Thread Zhenzhong Duan
x27;t supported, 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/c

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

2023-11-02 Thread Zhenzhong Duan
: 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 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 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 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 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 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 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 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 v4 34/41] vfio/pci: Allow the selection of a given iommu backend

2023-11-02 Thread Zhenzhong Duan
mufd0 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 @@

[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 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
: 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 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 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 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 12/22] vfio/ccw: Use vfio_[attach/detach]_device

2023-08-30 Thread Zhenzhong Duan
tatic 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 inser

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

2023-08-30 Thread Zhenzhong Duan
ed-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-e

[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 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
Note 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: Zhenzhon

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

2023-08-30 Thread Zhenzhong Duan
o-authored-by: Eric Auger 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 +

[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 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
: 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 change

[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 v1 00/22] vfio: Adopt iommufd

2023-08-30 Thread Zhenzhong Duan
ommon: Move legacy 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_[

[PATCH] RAMBlock: use return value of ram_block_discard_require() as errno

2024-07-15 Thread Zhenzhong Duan
"make guest_memfd require uncoordinated discard") Signed-off-by: Zhenzhong Duan --- system/physmem.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index 2154432cb6..9a3b3a7636 100644 --- a/system/physmem.c +++ b/system/physme

[PATCH v1 04/17] intel_iommu: Flush stage-2 cache in PADID-selective PASID-based iotlb invalidation

2024-07-18 Thread Zhenzhong Duan
: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 10 + hw/i386/intel_iommu.c | 78 ++ 2 files changed, 88 insertions(+) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 4e0331caba..f71fc91234 100644 --- a/hw/i386

[PATCH v1 00/17] intel_iommu: Enable stage-1 translation for emulated device

2024-07-18 Thread Zhenzhong Duan
intel_iommu: Implement stage-1 translation intel_iommu: Modify x-scalable-mode to be string option Yu Zhang (1): intel_iommu: Use the latest fault reasons defined by spec Zhenzhong Duan (8): intel_iommu: Make pasid entry type check accurate intel_iommu: Add a placeholder variable for s

[PATCH v1 01/17] intel_iommu: Use the latest fault reasons defined by spec

2024-07-18 Thread Zhenzhong Duan
are supported. Instead cap/ecap bits should be checked. Signed-off-by: Yu Zhang Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 9 - hw/i386/intel_iommu.c | 25 - 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/hw/i386

[PATCH v1 08/17] intel_iommu: Set accessed and dirty bits during first stage translation

2024-07-18 Thread Zhenzhong Duan
From: Clément Mathieu--Drif Signed-off-by: Clément Mathieu--Drif Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 3 +++ hw/i386/intel_iommu.c | 24 2 files changed, 27 insertions(+) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386

[PATCH v1 14/17] intel_iommu: piotlb invalidation should notify unmap

2024-07-18 Thread Zhenzhong Duan
This is used by some emulated devices which caches address translation result. When piotlb invalidation issued in guest, those caches should be refreshed. Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 35 ++- 1 file changed, 34

[PATCH v1 12/17] intel_iommu: Add an internal API to find an address space with PASID

2024-07-18 Thread Zhenzhong Duan
From: Clément Mathieu--Drif This will be used to implement the device IOTLB invalidation Signed-off-by: Clément Mathieu--Drif Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 39 --- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a

[PATCH v1 11/17] intel_iommu: Extract device IOTLB invalidation logic

2024-07-18 Thread Zhenzhong Duan
From: Clément Mathieu--Drif This piece of code can be shared by both IOTLB invalidation and PASID-based IOTLB invalidation No functional changes intended. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Clément Mathieu--Drif Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 57

[PATCH v1 03/17] intel_iommu: Add a placeholder variable for scalable modern mode

2024-07-18 Thread Zhenzhong Duan
ng is supported. Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 2 ++ include/hw/i386/intel_iommu.h | 1 + hw/i386/intel_iommu.c | 34 +++--- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/hw

[PATCH v1 05/17] intel_iommu: Rename slpte to pte

2024-07-18 Thread Zhenzhong Duan
: Clément Mathieu--Drif Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 24 +++--- include/hw/i386/intel_iommu.h | 2 +- hw/i386/intel_iommu.c | 129 + 3 files changed, 78 insertions(+), 77 deletions(-) diff

[PATCH v1 10/17] intel_iommu: Process PASID-based iotlb invalidation

2024-07-18 Thread Zhenzhong Duan
PASID-based iotlb (piotlb) is used during walking Intel VT-d stage-1 page table. This emulates the stage-1 page table iotlb invalidation requested by a PASID-based IOTLB Invalidate Descriptor (P_IOTLB). Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h

[PATCH v1 09/17] intel_iommu: Flush stage-1 cache in iotlb invalidation

2024-07-18 Thread Zhenzhong Duan
what in iotlb cache are only first-stage and second-stage mappings. Add a tag pgtt in VTDIOTLBEntry to mark PGTT type of the mapping and invalidate entries based on PGTT type. Signed-off-by: Zhenzhong Duan --- include/hw/i386/intel_iommu.h | 1 + hw/i386/intel_iommu.c

[PATCH v1 02/17] intel_iommu: Make pasid entry type check accurate

2024-07-18 Thread Zhenzhong Duan
Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index e65f5b29a5..1cff8b00ae 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -759,20 +759,16 @@ sta

[PATCH v1 13/17] intel_iommu: Add support for PASID-based device IOTLB invalidation

2024-07-18 Thread Zhenzhong Duan
From: Clément Mathieu--Drif Signed-off-by: Clément Mathieu--Drif Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 11 hw/i386/intel_iommu.c | 50 ++ 2 files changed, 61 insertions(+) diff --git a/hw/i386

[PATCH v1 15/17] intel_iommu: Set default aw_bits to 48 in scalable modren mode

2024-07-18 Thread Zhenzhong Duan
for compatibility. Add a check to ensure user specified value is 48 in modern mode for now. Signed-off-by: Zhenzhong Duan --- include/hw/i386/intel_iommu.h | 2 +- hw/i386/intel_iommu.c | 16 +++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/hw

[PATCH v1 06/17] intel_iommu: Implement stage-1 translation

2024-07-18 Thread Zhenzhong Duan
From: Yi Liu This adds stage-1 page table walking to support stage-1 only transltion in scalable modern mode. Signed-off-by: Yi Liu Co-developed-by: Clément Mathieu--Drif Signed-off-by: Clément Mathieu--Drif Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386

[PATCH v1 07/17] intel_iommu: Check if the input address is canonical

2024-07-18 Thread Zhenzhong Duan
From: Clément Mathieu--Drif First stage translation must fail if the address to translate is not canonical. Signed-off-by: Clément Mathieu--Drif Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 2 ++ hw/i386/intel_iommu.c | 21 + 2 files

[PATCH v1 17/17] tests/qtest: Add intel-iommu test

2024-07-18 Thread Zhenzhong Duan
Add the framework to test the intel-iommu device. Currently only tested cap/ecap bits correctness in scalable modern mode. Also tested cap/ecap bits consistency before and after system reset. Signed-off-by: Zhenzhong Duan --- MAINTAINERS| 1 + include/hw/i386/intel_iommu.h

[PATCH v1 16/17] intel_iommu: Modify x-scalable-mode to be string option

2024-07-18 Thread Zhenzhong Duan
scalable mode support - if not configured, means no scalable mode support, if not proper configured, will throw error Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- include/hw/i386/intel_iommu.h | 1 + hw/i386/intel_iommu.c | 24 +++

[PATCH 0/2] Don't initialize HOST_IOMMU_DEVICE with mdev

2024-07-22 Thread Zhenzhong Duan
See https://lists.gnu.org/archive/html/qemu-devel/2024-07/msg04612.html Not tested due to no ap/ccw environment. But build test pass. Thanks Zhenzhong Zhenzhong Duan (2): vfio/ap: Don't initialize HOST_IOMMU_DEVICE with mdev vfio/ccw: Don't initialize HOST_IOMMU_DEVICE with mdev

[PATCH 1/2] vfio/ap: Don't initialize HOST_IOMMU_DEVICE with mdev

2024-07-22 Thread Zhenzhong Duan
nt HostIOMMUDeviceClass::realize() handler") Signed-off-by: Zhenzhong Duan --- hw/vfio/ap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index 0c4354e3e7..391bfb72ca 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -230,6 +230,9 @@ static void vfio_

[PATCH 2/2] vfio/ccw: Don't initialize HOST_IOMMU_DEVICE with mdev

2024-07-22 Thread Zhenzhong Duan
nt HostIOMMUDeviceClass::realize() handler") Signed-off-by: Zhenzhong Duan --- hw/vfio/ccw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 1f8e1272c7..70934b01d5 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -675,6 +675,9 @@ static void vfio_c

[PATCH v2 01/17] intel_iommu: Use the latest fault reasons defined by spec

2024-08-04 Thread Zhenzhong Duan
are supported. Instead cap/ecap bits should be checked. Signed-off-by: Yu Zhang Signed-off-by: Zhenzhong Duan Reviewed-by: Clément Mathieu--Drif --- hw/i386/intel_iommu_internal.h | 9 - hw/i386/intel_iommu.c | 25 - 2 files changed, 24 insertions(+), 10

[PATCH v2 02/17] intel_iommu: Make pasid entry type check accurate

2024-08-04 Thread Zhenzhong Duan
Signed-off-by: Zhenzhong Duan Reviewed-by: Clément Mathieu--Drif --- hw/i386/intel_iommu.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index c52912f593..e3465fc27d 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i38

[PATCH v2 05/17] intel_iommu: Rename slpte to pte

2024-08-04 Thread Zhenzhong Duan
: Clément Mathieu--Drif Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 24 +++--- include/hw/i386/intel_iommu.h | 2 +- hw/i386/intel_iommu.c | 129 + 3 files changed, 78 insertions(+), 77 deletions(-) diff

[PATCH v2 11/17] intel_iommu: Add an internal API to find an address space with PASID

2024-08-04 Thread Zhenzhong Duan
From: Clément Mathieu--Drif This will be used to implement the device IOTLB invalidation Signed-off-by: Clément Mathieu--Drif Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 39 --- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a

[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: Fix an assert failure in error path

2021-06-09 Thread Zhenzhong Duan
_setv: 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

[PATCH v3] intel_iommu: Introduce property "x-stale-tm" to control Transient Mapping (TM) field

2024-10-10 Thread Zhenzhong Duan
ansient Mapping. Suggested-by: Yi Liu Suggested-by: Jason Wang Signed-off-by: Zhenzhong Duan --- v3: still need to check x86_iommu->dt_supported v2: introcude "x-stale-tm" to handle migration compatibility (Jason) hw/i386/intel_iommu_internal.h | 12 ++-- include/hw/i386/inte

[PATCH v4 11/17] intel_iommu: Add an internal API to find an address space with PASID

2024-09-30 Thread Zhenzhong Duan
From: Clément Mathieu--Drif This will be used to implement the device IOTLB invalidation Signed-off-by: Clément Mathieu--Drif Signed-off-by: Zhenzhong Duan Acked-by: Jason Wang --- hw/i386/intel_iommu.c | 39 --- 1 file changed, 24 insertions(+), 15

[PATCH v4 02/17] intel_iommu: Make pasid entry type check accurate

2024-09-30 Thread Zhenzhong Duan
Signed-off-by: Zhenzhong Duan Reviewed-by: Clément Mathieu--Drif Reviewed-by: Yi Liu Acked-by: Jason Wang --- hw/i386/intel_iommu.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 378e417b27..be7c8a670b 10064

[PATCH v4 06/17] intel_iommu: Implement stage-1 translation

2024-09-30 Thread Zhenzhong Duan
From: Yi Liu This adds stage-1 page table walking to support stage-1 only translation in scalable modern mode. Signed-off-by: Yi Liu Co-developed-by: Clément Mathieu--Drif Signed-off-by: Clément Mathieu--Drif Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan Acked-by: Jason Wang --- hw

[PATCH v4 14/17] intel_iommu: Set default aw_bits to 48 in scalable modern mode

2024-09-30 Thread Zhenzhong Duan
for backward compatibility. Add a check to ensure user specified value is 48 in modern mode for now. Signed-off-by: Zhenzhong Duan Reviewed-by: Clément Mathieu--Drif --- include/hw/i386/intel_iommu.h | 2 +- hw/i386/intel_iommu.c | 10 +- 2 files changed, 10 insertions(+), 2

[PATCH v4 13/17] intel_iommu: piotlb invalidation should notify unmap

2024-09-30 Thread Zhenzhong Duan
enable it if there is need to cache the translation result. Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan Reviewed-by: Clément Mathieu--Drif --- hw/i386/intel_iommu.c | 35 ++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/hw/i386

[PATCH v4 01/17] intel_iommu: Use the latest fault reasons defined by spec

2024-09-30 Thread Zhenzhong Duan
are supported. Instead cap/ecap bits should be checked. Signed-off-by: Yu Zhang Signed-off-by: Zhenzhong Duan Reviewed-by: Clément Mathieu--Drif Reviewed-by: Yi Liu Acked-by: Jason Wang --- hw/i386/intel_iommu_internal.h | 9 - hw/i386/intel_iommu.c | 25

[PATCH v4 05/17] intel_iommu: Rename slpte to pte

2024-09-30 Thread Zhenzhong Duan
: Clément Mathieu--Drif Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan Acked-by: Jason Wang Reviewed-by: Yi Liu --- hw/i386/intel_iommu_internal.h | 24 +++--- include/hw/i386/intel_iommu.h | 2 +- hw/i386/intel_iommu.c | 129 + 3 files changed

[PATCH v4 03/17] intel_iommu: Add a placeholder variable for scalable modern mode

2024-09-30 Thread Zhenzhong Duan
igned-off-by: Yi Liu Signed-off-by: Zhenzhong Duan Acked-by: Jason Wang --- include/hw/i386/intel_iommu.h | 1 + hw/i386/intel_iommu.c | 23 ++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_io

[PATCH v4 16/17] intel_iommu: Introduce a property to control FS1GP cap bit setting

2024-09-30 Thread Zhenzhong Duan
n scalable modern mode. Signed-off-by: Zhenzhong Duan Reviewed-by: Clément Mathieu--Drif --- include/hw/i386/intel_iommu.h | 1 + hw/i386/intel_iommu.c | 5 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index

[PATCH v4 17/17] tests/qtest: Add intel-iommu test

2024-09-30 Thread Zhenzhong Duan
Add the framework to test the intel-iommu device. Currently only tested cap/ecap bits correctness in scalable modern mode. Also tested cap/ecap bits consistency before and after system reset. Signed-off-by: Zhenzhong Duan Acked-by: Thomas Huth Reviewed-by: Clément Mathieu--Drif Acked-by: Jason

[PATCH v4 00/17] intel_iommu: Enable stage-1 translation for emulated device

2024-09-30 Thread Zhenzhong Duan
canonical intel_iommu: Set accessed and dirty bits during first stage translation intel_iommu: Add an internal API to find an address space with PASID intel_iommu: Add support for PASID-based device IOTLB invalidation Yi Liu (2): intel_iommu: Rename slpte to pte intel_iommu: Implement

<    2   3   4   5   6   7   8   9   10   >