[PATCH] migration/dirtyrate: Show sample pages only in page-sampling mode

2022-11-28 Thread Zhenzhong Duan
dirty_rate Status: measured Start Time: 11646834 (ms) Sample Pages: 0 (per GB) Period: 10 (sec) Mode: dirty-bitmap Dirty rate: 2 (MB/s) While it's totally useless in dirty-ring and dirty-bitmap mode, fix to show it only in page-sampling mode. Signed-off-by: Zhenzhong Duan --- migration/d

[PATCH v2] softmmu/physmem: Fix input parameters for flatview_access_allowed()

2022-07-22 Thread Zhenzhong Duan
The comment of flatview_access_allowed() suggests to pass address within that memory region, this isn't true in some call sites. This makes qemu log in flatview_access_allowed() confusing and potential risk if the input parameter will be checked in the future. Signed-off-by: Zhenzhong

[PATCH v1 02/11] backends/iommufd: Introduce IOMMUFDDevice

2024-02-27 Thread Zhenzhong Duan
. IOMMUFDDevice is willingly not a QOM object because we don't want it to be visible from the user interface. Introduce a helper iommufd_device_init to initialize IOMMUFDDevice. Originally-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- include/sysemu/iommufd.h

[PATCH v1 01/11] Introduce a common abstract struct HostIOMMUDevice

2024-02-27 Thread Zhenzhong Duan
HostIOMMUDevice will be inherited by two sub classes, legacy and iommufd currently. Introduce a helper function host_iommu_base_device_init to initialize it. Suggested-by: Eric Auger Signed-off-by: Zhenzhong Duan --- include/sysemu/host_iommu_device.h | 22 ++ 1 file

[PATCH v1 06/11] vfio/container: Implement host_iommu_device_create callback in legacy mode

2024-02-27 Thread Zhenzhong Duan
This callback will be used to initialize base and public elements in IOMMULegacyDevice. Signed-off-by: Zhenzhong Duan --- hw/vfio/container.c | 9 + 1 file changed, 9 insertions(+) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index bd25b9fbad..2e8ff32284 100644 --- a/hw/vfio

[PATCH v1 00/11] Add a host IOMMU device abstraction

2024-02-27 Thread Zhenzhong Duan
& 0x3fULL' a MACRO and add missed '+1' (Cédric) - block migration if vIOMMU cap/ecap updated based on host IOMMU cap/ecap - add R-B Yi Liu (1): hw/pci: Introduce pci_device_set/unset_iommu_device() Zhenzhong Duan (10): Introduce a common abstract struct HostIOMMUDevi

[PATCH v1 08/11] vfio/pci: Allocate and initialize HostIOMMUDevice after attachment

2024-02-27 Thread Zhenzhong Duan
Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c | 4 1 file changed, 4 insertions(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 4fa387f043..6cc7de5d10 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3006,6 +3006,9 @@ static void vfio_realize(PCIDevice *pdev, Error **errp

[PATCH v1 03/11] vfio: Introduce IOMMULegacyDevice

2024-02-27 Thread Zhenzhong Duan
. IOMMULegacyDevice is willingly not a QOM object because we don't want it to be visible from the user interface. Suggested-by: Eric Auger Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/hw/vfio/vfio-common.h b/in

[PATCH v1 10/11] vfio: Pass HostIOMMUDevice to vIOMMU

2024-02-27 Thread Zhenzhong Duan
Support both iommufd and legacy backend. Originally-by: Yi Liu Signed-off-by: Nicolin Chen Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c | 20 +++- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index

[PATCH v1 09/11] hw/pci: Introduce pci_device_set/unset_iommu_device()

2024-02-27 Thread Zhenzhong Duan
Liu Signed-off-by: Yi Sun Signed-off-by: Nicolin Chen Signed-off-by: Zhenzhong Duan --- include/hw/pci/pci.h | 38 ++- hw/pci/pci.c | 62 +--- 2 files changed, 96 insertions(+), 4 deletions(-) diff --git a/include/hw/pci

[PATCH v1 11/11] backends/iommufd: Introduce helper function iommufd_device_get_info()

2024-02-27 Thread Zhenzhong Duan
Introduce a helper function iommufd_device_get_info() to get host IOMMU related information through iommufd uAPI. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- include/sysemu/iommufd.h | 4 backends/iommufd.c | 23 ++- 2 files

[PATCH v1 04/11] vfio: Add HostIOMMUDevice handle into VFIODevice

2024-02-27 Thread Zhenzhong Duan
This handle points to either IOMMULegacyDevice or IOMMUFDDevice variant, neither both. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 8bfb9cbe94..b6676c9f79

[PATCH v1 05/11] vfio: Introduce host_iommu_device_create callback

2024-02-27 Thread Zhenzhong Duan
Introduce host_iommu_device_create callback and a wrapper for it. This callback is used to allocate a host iommu device instance and initialize it based on type. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 1 + include/hw/vfio/vfio-container-base.h | 1 + hw/vfio

[PATCH v1 07/11] vfio/iommufd: Implement host_iommu_device_create callback in iommufd mode

2024-02-27 Thread Zhenzhong Duan
This callback will be used to initialize base and public elements in IOMMUFDDevice. Signed-off-by: Zhenzhong Duan --- hw/vfio/iommufd.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 9bfddc1360..1c2f5da0d0 100644 --- a/hw/vfio

[PATCH v1 5/6] intel_iommu: Use mgaw instead of s->aw_bits

2024-02-28 Thread Zhenzhong Duan
alue sanity check and s->cap initialization. ACPI DMAR table is also updated with right mgaw value. Signed-off-by: Zhenzhong Duan --- hw/i386/acpi-build.c | 3 ++- hw/i386/intel_iommu.c | 44 ++- 2 files changed, 25 insertions(+), 22 deletions(-)

[PATCH v1 6/6] intel_iommu: Block migration if cap is updated

2024-02-28 Thread Zhenzhong Duan
When there is VFIO device and vIOMMU cap/ecap is updated based on host IOMMU cap/ecap, migration should be blocked. Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 16 ++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386

[PATCH v1 0/6] Check and sync host IOMMU cap/ecap with vIOMMU

2024-02-28 Thread Zhenzhong Duan
sed on host IOMMU cap/ecap - add R-B Yi Liu (2): intel_iommu: Add set/unset_iommu_device callback intel_iommu: Add a framework to check and sync host IOMMU cap/ecap Zhenzhong Duan (4): intel_iommu: Extract out vtd_cap_init to initialize cap/ecap intel_iommu: Implement check and sync mechanism in

[PATCH v1 1/6] intel_iommu: Add set/unset_iommu_device callback

2024-02-28 Thread Zhenzhong Duan
From: Yi Liu This adds set/unset_iommu_device() implementation in Intel vIOMMU. In set call, a pointer to host IOMMU device info is stored in hash table indexed by PCI BDF. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 8

[PATCH v1 3/6] intel_iommu: Add a framework to check and sync host IOMMU cap/ecap

2024-02-28 Thread Zhenzhong Duan
>cap/ecap become readonly. Implementation details for different backends will be in following patches. 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 | 50 ++- 2 f

[PATCH v1 2/6] intel_iommu: Extract out vtd_cap_init to initialize cap/ecap

2024-02-28 Thread Zhenzhong Duan
This is a prerequisite for host cap/ecap sync. No functional change intended. Reviewed-by: Eric Auger Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 93 --- 1 file changed, 51 insertions(+), 42 deletions(-) diff --git a/hw/i386/intel_iommu.c

[PATCH v1 4/6] intel_iommu: Implement check and sync mechanism in iommufd mode

2024-02-28 Thread Zhenzhong Duan
tage-1 translation is supported in future, a.k.a. scalable modern mode, this mechanism will be further extended to check more bits. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 1 + include/hw/i386/intel_iommu.h | 1 + hw/

[PATCH 0/2] Optimize user_creatable_add_type error path

2024-02-28 Thread Zhenzhong Duan
Hi, This is a simple optimization to user_creatable_add_type error path. Removed local_err and its check in err path, use *errp instead. Thanks Zhenzhong Zhenzhong Duan (2): qom/object_interfaces: Remove unnecessary local error check qom/object_interfaces: Remove local_err in

[PATCH 2/2] qom/object_interfaces: Remove local_err in user_creatable_add_type

2024-02-28 Thread Zhenzhong Duan
In user_creatable_add_type, there is mixed usage of ERRP_GUARD and local_err. This makes error_abort not taking effect in those callee functions with local_err passed. Now that we already has ERRP_GUARD, remove local_err and use *errp instead. Signed-off-by: Zhenzhong Duan --- qom

[PATCH 1/2] qom/object_interfaces: Remove unnecessary local_err check

2024-02-28 Thread Zhenzhong Duan
In the error return path, local_err is always set, no need to check it. Signed-off-by: Zhenzhong Duan --- qom/object_interfaces.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index e0833c8bfe..255a7bf659 100644

[PATCH rfcv2 04/18] vfio: Add host iommu device instance into VFIODevice

2024-01-31 Thread Zhenzhong Duan
Either IOMMULegacyDevice or IOMMUFDDevice into VFIODevice, neither both. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 8bfb9cbe94..1bbad003ee

[PATCH rfcv2 02/18] backends/iommufd: Introduce IOMMUFDDevice

2024-01-31 Thread Zhenzhong Duan
. IOMMUFDDevice is willingly not a QOM object because we don't want it to be visible from the user interface. Introduce a helper iommufd_device_init to initialize IOMMUFDDevice. Originally-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- include/sysemu/iommufd.h

[PATCH rfcv2 06/18] vfio: Introduce host_iommu_device_init callback

2024-01-31 Thread Zhenzhong Duan
Introduce host_iommu_device_init callback and a wrapper for it. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 1 + include/hw/vfio/vfio-container-base.h | 1 + hw/vfio/common.c | 8 3 files changed, 10 insertions(+) diff --git a/include

[PATCH rfcv2 08/18] vfio/iommufd: Implement host_iommu_device_init callback in iommufd mode

2024-01-31 Thread Zhenzhong Duan
This callback will be used to initialize base and public elements in IOMMUFDDevice, with the exception of iommufd and devid which are initialized early in attachment. Signed-off-by: Zhenzhong Duan --- hw/vfio/iommufd.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/hw/vfio/iommufd.c

[PATCH rfcv2 09/18] vfio/pci: Initialize host iommu device instance after attachment

2024-01-31 Thread Zhenzhong Duan
Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index d1e1b8cb89..dedb64fc08 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3006,6 +3006,9 @@ static void vfio_realize(PCIDevice *pdev, Error **errp

[PATCH rfcv2 12/18] vfio: Initialize host IOMMU device and pass to vIOMMU

2024-01-31 Thread Zhenzhong Duan
Initialize host IOMMU device in vfio and pass to vIOMMU, so that vIOMMU could get hw IOMMU information. Support both iommufd and legacy backend. Originally-by: Yi Liu Signed-off-by: Nicolin Chen Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c | 20

[PATCH rfcv2 00/18] Check and sync host IOMMU cap/ecap with vIOMMU

2024-01-31 Thread Zhenzhong Duan
1' (Cédric) - block migration if vIOMMU cap/ecap updated based on host IOMMU cap/ecap - add R-B Yi Liu (3): hw/pci: Introduce pci_device_set/unset_iommu_device() intel_iommu: Add set/unset_iommu_device callback intel_iommu: Add a framework to check and sync host IOMMU cap/ecap Zhen

[PATCH rfcv2 15/18] backends/iommufd: Introduce helper function iommufd_device_get_info()

2024-01-31 Thread Zhenzhong Duan
Introduce a helper function iommufd_device_get_info() to get host IOMMU related information through iommufd uAPI. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- include/sysemu/iommufd.h | 4 backends/iommufd.c | 25 - 2 files

[PATCH rfcv2 07/18] vfio/container: Implement host_iommu_device_init callback in legacy mode

2024-01-31 Thread Zhenzhong Duan
This callback will be used to initialize base and public elements in IOMMULegacyDevice. Signed-off-by: Zhenzhong Duan --- hw/vfio/container.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index bd25b9fbad..8fafd4b4e5 100644 --- a/hw/vfio

[PATCH rfcv2 17/18] intel_iommu: Use mgaw instead of s->aw_bits

2024-01-31 Thread Zhenzhong Duan
alue sanity check and s->cap initialization. ACPI DMAR table is also updated with right mgaw value. Signed-off-by: Zhenzhong Duan --- hw/i386/acpi-build.c | 3 ++- hw/i386/intel_iommu.c | 44 ++- 2 files changed, 25 insertions(+), 22 deletions(-)

[PATCH rfcv2 03/18] vfio: Introduce IOMMULegacyDevice

2024-01-31 Thread Zhenzhong Duan
. IOMMULegacyDevice is willingly not a QOM object because we don't want it to be visible from the user interface. Suggested-by: Eric Auger Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/hw/vfio/vfio-common.h b/in

[PATCH rfcv2 14/18] intel_iommu: Add a framework to check and sync host IOMMU cap/ecap

2024-01-31 Thread Zhenzhong Duan
>cap/ecap become readonly. Implementation details for different backends will be in following patches. 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 | 41 ++- 2 f

[PATCH rfcv2 10/18] hw/pci: Introduce pci_device_set/unset_iommu_device()

2024-01-31 Thread Zhenzhong Duan
Liu Signed-off-by: Yi Sun Signed-off-by: Nicolin Chen Signed-off-by: Zhenzhong Duan --- include/hw/pci/pci.h | 38 ++- hw/pci/pci.c | 62 +--- 2 files changed, 96 insertions(+), 4 deletions(-) diff --git a/include/hw/pci

[PATCH rfcv2 05/18] vfio: Remove redundant iommufd and devid elements in VFIODevice

2024-01-31 Thread Zhenzhong Duan
iommufd and devid in VFIODevice are redundant with the ones in IOMMUFDDevice, so remove them. Suggested-by: Eric Auger Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 2 -- hw/vfio/ap.c | 2 +- hw/vfio/ccw.c | 2 +- hw/vfio/common.c

[PATCH rfcv2 01/18] Introduce a common abstract struct HostIOMMUDevice

2024-01-31 Thread Zhenzhong Duan
HostIOMMUDevice will be inherited by two sub classes, legacy and iommufd currently. Introduce a helper function host_iommu_base_device_init to initialize it. Suggested-by: Eric Auger Signed-off-by: Zhenzhong Duan --- include/sysemu/host_iommu_device.h | 22 ++ 1 file

[PATCH rfcv2 18/18] intel_iommu: Block migration if cap is updated

2024-01-31 Thread Zhenzhong Duan
When there is VFIO device and vIOMMU cap/ecap is updated based on host IOMMU cap/ecap, migration should be blocked. Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 16 ++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386

[PATCH rfcv2 16/18] intel_iommu: Implement check and sync mechanism in iommufd mode

2024-01-31 Thread Zhenzhong Duan
tage-1 translation is supported in future, a.k.a. scalable modern mode, this mechanism will be further extended to check more bits. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 1 + include/hw/i386/intel_iommu.h | 1 + hw/

[PATCH rfcv2 11/18] intel_iommu: Add set/unset_iommu_device callback

2024-01-31 Thread Zhenzhong Duan
From: Yi Liu This adds set/unset_iommu_device() implementation in Intel vIOMMU. In set call, a pointer to host IOMMU device info is stored in hash table indexed by PCI BDF. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 14

[PATCH rfcv2 13/18] intel_iommu: Extract out vtd_cap_init to initialize cap/ecap

2024-01-31 Thread Zhenzhong Duan
This is a prerequisite for host cap/ecap sync. No functional change intended. Reviewed-by: Eric Auger Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 93 --- 1 file changed, 51 insertions(+), 42 deletions(-) diff --git a/hw/i386/intel_iommu.c

[PATCH v2 00/10] Add a host IOMMU device abstraction

2024-04-08 Thread Zhenzhong Duan
evice declaration to intel_iommu_internal.h (Cédric) - make '(vtd->cap_reg >> 16) & 0x3fULL' a MACRO and add missed '+1' (Cédric) - block migration if vIOMMU cap/ecap updated based on host IOMMU cap/ecap - add R-B Yi Liu (1): hw/pci: Introduce pci_device_set/unset_iommu_de

[PATCH v2 03/10] backends/iommufd: Introduce abstract HIODIOMMUFD device

2024-04-08 Thread Zhenzhong Duan
HIODIOMMUFD device. Suggested-by: Cédric Le Goater Originally-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- include/sysemu/iommufd.h | 22 +++ backends/iommufd.c | 47 ++-- 2 files changed, 53 insertions(+), 16 deletions

[PATCH v2 04/10] vfio/iommufd: Introduce HIODIOMMUFDVFIO device

2024-04-08 Thread Zhenzhong Duan
HIODIOMMUFDVFIO represents a host IOMMU device under VFIO iommufd backend. It will be created during VFIO device attaching and passed to vIOMMU. It includes a link to VFIODevice so that we can do VFIO device specific hwpt attaching/detaching. Signed-off-by: Zhenzhong Duan --- include/hw/vfio

[PATCH v2 06/10] backends/iommufd: Introduce helper function iommufd_backend_get_device_info()

2024-04-08 Thread Zhenzhong Duan
Introduce a helper function iommufd_backend_get_device_info() to get host IOMMU related information through iommufd uAPI. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- include/sysemu/iommufd.h | 4 backends/iommufd.c | 23 ++- 2

[PATCH v2 02/10] vfio: Introduce HIODLegacyVFIO device

2024-04-08 Thread Zhenzhong Duan
HIODLegacyVFIO represents a host IOMMU device under VFIO legacy container backend. It includes a link to VFIODevice. Suggested-by: Eric Auger Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 11 +++ hw/vfio/container.c | 11

[PATCH v2 10/10] vfio: Pass HostIOMMUDevice to vIOMMU

2024-04-08 Thread Zhenzhong Duan
With HostIOMMUDevice passed, vIOMMU can check compatibility with host IOMMU, call into IOMMUFD specific methods, etc. Originally-by: Yi Liu Signed-off-by: Nicolin Chen Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c | 20 +++- 1 file changed, 15

[PATCH v2 07/10] backends/iommufd: Implement get_host_iommu_info() callback

2024-04-08 Thread Zhenzhong Duan
It calls iommufd_backend_get_device_info() to get host IOMMU related information. Define a common structure HIOD_IOMMUFD_INFO to describe the info returned from kernel. Currently only vtd, but easy to add arm smmu when kernel supports. Signed-off-by: Zhenzhong Duan --- include/sysemu/iommufd.h

[PATCH v2 01/10] backends: Introduce abstract HostIOMMUDevice

2024-04-08 Thread Zhenzhong Duan
. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- MAINTAINERS| 2 ++ include/sysemu/host_iommu_device.h | 19 +++ backends/host_iommu_device.c | 19 +++ backends/Kconfig | 5 + backends/meson.build

[PATCH v2 05/10] vfio: Implement get_host_iommu_info() callback

2024-04-08 Thread Zhenzhong Duan
Utilize iova_ranges to calculate host IOMMU address width and package it in HIOD_LEGACY_INFO for vIOMMU usage. HIOD_LEGACY_INFO will be used by both VFIO and VDPA so declare it in host_iommu_device.h. Signed-off-by: Zhenzhong Duan --- include/sysemu/host_iommu_device.h | 10 ++ hw/vfio

[PATCH v2 08/10] vfio: Create host IOMMU device instance

2024-04-08 Thread Zhenzhong Duan
Create host IOMMU device instance and initialize it based on backend. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 1 + hw/vfio/container.c | 5 + hw/vfio/iommufd.c | 8 3 files changed, 14 insertions(+) diff --git a/include/hw/vfio/vfio

[PATCH v2 09/10] hw/pci: Introduce pci_device_set/unset_iommu_device()

2024-04-08 Thread Zhenzhong Duan
Liu Signed-off-by: Yi Sun Signed-off-by: Nicolin Chen Signed-off-by: Zhenzhong Duan --- include/hw/pci/pci.h | 40 ++- hw/pci/pci.c | 75 ++-- 2 files changed, 111 insertions(+), 4 deletions(-) diff --git a/include/hw/pci

[PATCH v2 4/5] intel_iommu: Check for compatibility with legacy device

2024-04-08 Thread Zhenzhong Duan
aw-bits <= host IOMMU aw-bits, which is missed before. Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index a49b587c73..d2cd186df0 100644 --- a/hw/

[PATCH v2 0/5] Check host IOMMU compatilibity with vIOMMU

2024-04-08 Thread Zhenzhong Duan
mu: Implement set/unset_iommu_device() callback intel_iommu: Add a framework to do compatibility check with host IOMMU cap/ecap Zhenzhong Duan (3): intel_iommu: Extract out vtd_cap_init() to initialize cap/ecap intel_iommu: Check for compatibility with legacy device intel

[PATCH v2 1/5] intel_iommu: Extract out vtd_cap_init() to initialize cap/ecap

2024-04-08 Thread Zhenzhong Duan
Extract cap/ecap initialization in vtd_cap_init() to make code cleaner. No functional change intended. Reviewed-by: Eric Auger Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 93 --- 1 file changed, 51 insertions(+), 42 deletions(-) diff

[PATCH v2 2/5] intel_iommu: Implement set/unset_iommu_device() callback

2024-04-08 Thread Zhenzhong Duan
From: Yi Liu Implement set/unset_iommu_device() callback in Intel vIOMMU. In set call, a new structure VTDHostIOMMUDevice which holds a reference to HostIOMMUDevice is stored in hash table indexed by PCI BDF. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw

[PATCH v2 3/5] intel_iommu: Add a framework to do compatibility check with host IOMMU cap/ecap

2024-04-08 Thread Zhenzhong Duan
From: Yi Liu If check fails, the host side device(either vfio or vdpa device) should not be passed to guest. Implementation details for different backends will be in following patches. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 35

[PATCH v2 5/5] intel_iommu: Check for compatibility with iommufd backed device

2024-04-08 Thread Zhenzhong Duan
aw-bits <= host IOMMU aw-bits, which is missed before. When stage-1 translation is supported in future, a.k.a. scalable modern mode, this mechanism will be further extended to check more bits. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- include/hw/i386/

[PATCH v2 3/3] qom/object_interfaces: Remove local_err in user_creatable_add_type

2024-03-17 Thread Zhenzhong Duan
In user_creatable_add_type, there is mixed usage of ERRP_GUARD and local_err. This makes error_abort not taking effect in those callee functions with &local_err passed. Now that we already use ERRP_GUARD, remove local_err and pass errp. Signed-off-by: Zhenzhong Duan --- qom/object_interfac

[PATCH v2 1/3] qom/object_interfaces: Remove unnecessary local error check

2024-03-17 Thread Zhenzhong Duan
The original error handling code indicates "local_err is always set", and error_propagate() can handle the case that local_err is NULL. Use err label instead of out label for error path. Reviewed-by: Zhao Liu Signed-off-by: Zhenzhong Duan --- qom/object_interfaces.c | 16 +++--

[PATCH v2 2/3] qom/object_interfaces: Make object_set_properties_from_qdict return bool

2024-03-17 Thread Zhenzhong Duan
Signed-off-by: Zhenzhong Duan --- qom/object_interfaces.c | 21 ++--- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 70179877f1..e17e2de46d 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c

[PATCH v2 0/3] Simplify user_creatable_add_type error path

2024-03-17 Thread Zhenzhong Duan
(Zhao Liu) - Make object_set_properties_from_qdict return bool (Zhao Liu) - Check return value of object_property_try_add_child (Zhao Liu) - Add R-B Zhenzhong Duan (3): qom/object_interfaces: Remove unnecessary local error check qom/object_interfaces: Make object_set_properties_from_qdict return

[PATCH v3 0/1] Introduce Icelake-Server-v7 to enable TSX

2024-03-20 Thread Zhenzhong Duan
omments welcome! Thanks Zhenzhong Zhenzhong Duan (1): target/i386: Introduce Icelake-Server-v7 to enable TSX target/i386/cpu.c | 10 ++ 1 file changed, 10 insertions(+) -- 2.34.1

[PATCH v3 1/1] target/i386: Introduce Icelake-Server-v7 to enable TSX

2024-03-20 Thread Zhenzhong Duan
Fixes: d965dc35592d ("target/i386: Add ARCH_CAPABILITIES related bits into Icelake-Server CPU model") Tested-by: Xiangfei Ma Signed-off-by: Zhenzhong Duan --- target/i386/cpu.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 9a210d8d9

[PATCH v3 01/19] backends: Introduce HostIOMMUDevice abstract

2024-04-28 Thread Zhenzhong Duan
: Zhenzhong Duan --- MAINTAINERS| 2 ++ include/sysemu/host_iommu_device.h | 51 ++ backends/host_iommu_device.c | 30 ++ backends/Kconfig | 5 +++ backends/meson.build | 1 + 5 files changed, 89

[PATCH v3 02/19] vfio/container: Introduce HostIOMMUDeviceLegacyVFIO device

2024-04-28 Thread Zhenzhong Duan
HostIOMMUDeviceLegacyVFIO represents a host IOMMU device under VFIO legacy container backend. It includes a link to VFIODevice. Suggested-by: Eric Auger Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 12 hw/vfio/container.c

[PATCH v3 00/19] Add a host IOMMU device abstraction to check with vIOMMU

2024-04-28 Thread Zhenzhong Duan
and add missed '+1' (Cédric) - block migration if vIOMMU cap/ecap updated based on host IOMMU cap/ecap - add R-B Yi Liu (2): hw/pci: Introduce pci_device_[set|unset]_iommu_device() intel_iommu: Implement [set|unset]_iommu_device() callbacks Zhenzhong Duan (17): backends: Int

[PATCH v3 04/19] vfio/iommufd: Introduce HostIOMMUDeviceIOMMUFDVFIO device

2024-04-28 Thread Zhenzhong Duan
HostIOMMUDeviceIOMMUFDVFIO represents a host IOMMU device under VFIO iommufd backend. It will be created during VFIO device attaching and passed to vIOMMU. It includes a link to VFIODevice so that we can do VFIO device specific operations, i.e., [at/de]taching hwpt, etc. Signed-off-by: Zhenzhong

[PATCH v3 11/19] backends/iommufd: Implement HostIOMMUDeviceClass::check_cap() handler

2024-04-28 Thread Zhenzhong Duan
Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- backends/iommufd.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/backends/iommufd.c b/backends/iommufd.c index d61209788a..28faec528e 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -233,6

[PATCH v3 10/19] vfio/container: Implement HostIOMMUDeviceClass::check_cap() handler

2024-04-28 Thread Zhenzhong Duan
Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- hw/vfio/container.c | 12 1 file changed, 12 insertions(+) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 863eec3943..3683487605 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -1164,11

[PATCH v3 09/19] vfio/iommufd: Implement HostIOMMUDeviceClass::realize() handler

2024-04-28 Thread Zhenzhong Duan
It calls iommufd_backend_get_device_info() to get host IOMMU related information and translate it into HostIOMMUDeviceCaps for query with .check_cap(). Introduce macro VTD_MGAW_FROM_CAP to get MGAW which equals to (aw_bits - 1). Signed-off-by: Zhenzhong Duan --- include/hw/i386/intel_iommu.h

[PATCH v3 16/19] vfio/pci: Pass HostIOMMUDevice to vIOMMU

2024-04-28 Thread Zhenzhong Duan
With HostIOMMUDevice passed, vIOMMU can check compatibility with host IOMMU, call into IOMMUFD specific methods, etc. Originally-by: Yi Liu Signed-off-by: Nicolin Chen Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c | 20 +++- 1 file changed, 15

[PATCH v3 15/19] hw/pci: Introduce pci_device_[set|unset]_iommu_device()

2024-04-28 Thread Zhenzhong Duan
ned-off-by: Zhenzhong Duan --- include/hw/pci/pci.h | 38 +- hw/pci/pci.c | 27 +++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index eaa3fc99d8..849e391813 100644 --

[PATCH v3 07/19] vfio/container: Implement HostIOMMUDeviceClass::realize() handler

2024-04-28 Thread Zhenzhong Duan
Utilize range_get_last_bit() to get host IOMMU address width and package it in HostIOMMUDeviceCaps for query with .check_cap(). Signed-off-by: Zhenzhong Duan --- hw/vfio/container.c | 29 + 1 file changed, 29 insertions(+) diff --git a/hw/vfio/container.c b/hw/vfio

[PATCH v3 18/19] intel_iommu: Implement [set|unset]_iommu_device() callbacks

2024-04-28 Thread Zhenzhong Duan
From: Yi Liu Implement [set|unset]_iommu_device() callbacks in Intel vIOMMU. In set call, a new structure VTDHostIOMMUDevice which holds a reference to HostIOMMUDevice is stored in hash table indexed by PCI BDF. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan

[PATCH v3 13/19] vfio: Create host IOMMU device instance

2024-04-28 Thread Zhenzhong Duan
Create host IOMMU device instance in vfio_attach_device() and call .realize() to initialize it further. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 1 + hw/vfio/common.c | 18 +- 2 files changed, 18 insertions

[PATCH v3 19/19] intel_iommu: Check compatibility with host IOMMU capabilities

2024-04-28 Thread Zhenzhong Duan
If check fails, host device (either VFIO or VDPA device) is not compatible with current vIOMMU config and should not be passed to guest. Only aw_bits is checked for now, we don't care other capabilities before scalable modern mode is introduced. Signed-off-by: Yi Liu Signed-off-by: Zhen

[PATCH v3 05/19] backends/host_iommu_device: Introduce HostIOMMUDeviceCaps

2024-04-28 Thread Zhenzhong Duan
t platform IOMMUs. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/sysemu/host_iommu_device.h | 44 ++ backends/host_iommu_device.c | 29 2 files changed, 73 insertions(+) diff --git a/include/sysemu/host_iommu_d

[PATCH v3 14/19] hw/pci: Introduce helper function pci_device_get_iommu_bus_devfn()

2024-04-28 Thread Zhenzhong Duan
: Zhenzhong Duan --- hw/pci/pci.c | 48 +--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 324c1302d2..02a4bb2af6 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2648,11 +2648,27 @@ static void

[PATCH v3 08/19] backends/iommufd: Introduce helper function iommufd_backend_get_device_info()

2024-04-28 Thread Zhenzhong Duan
Introduce a helper function iommufd_backend_get_device_info() to get host IOMMU related information through iommufd uAPI. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- include/sysemu/iommufd.h | 4 backends/iommufd.c | 24 +++- 2

[PATCH v3 12/19] vfio: Introduce VFIOIOMMUClass::hiod_typename attribute

2024-04-28 Thread Zhenzhong Duan
Initialize attribute VFIOIOMMUClass::hiod_typename based on VFIO backend type. This attribute will facilitate HostIOMMUDevice creation in vfio_attach_device(). Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-container-base.h | 3 +++ hw/vfio/container.c

[PATCH v3 17/19] intel_iommu: Extract out vtd_cap_init() to initialize cap/ecap

2024-04-28 Thread Zhenzhong Duan
Extract cap/ecap initialization in vtd_cap_init() to make code cleaner. No functional change intended. Reviewed-by: Eric Auger Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 93 --- 1 file changed, 51 insertions(+), 42 deletions(-) diff

[PATCH v3 03/19] backends/iommufd: Introduce abstract HostIOMMUDeviceIOMMUFD device

2024-04-28 Thread Zhenzhong Duan
: Cédric Le Goater Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- include/sysemu/iommufd.h | 30 ++ backends/iommufd.c | 37 - 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/include/sysemu/iommufd.h b

[PATCH v3 06/19] range: Introduce range_get_last_bit()

2024-04-28 Thread Zhenzhong Duan
This helper get the highest 1 bit position of the upper bound. If the range is empty or upper bound is zero, -1 is returned. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/qemu/range.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/include/qemu

[PATCH 0/3] Cleanup VFIOIOMMUClass callback return with bool

2024-05-06 Thread Zhenzhong Duan
very first series. Test done on x86 platform: vfio device hotplug/unplug with different backend reboot Thanks Zhenzhong Zhenzhong Duan (3): vfio: Make VFIOIOMMUClass::attach_device() and its wrapper return bool vfio: Make VFIOIOMMUClass::setup() return bool vfio: Make VFIOIOMMUClass

[PATCH 2/3] vfio: Make VFIOIOMMUClass::setup() return bool

2024-05-06 Thread Zhenzhong Duan
This is to follow the coding standand to return bool if 'Error **' is used to pass error. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-container-base.h | 2 +- hw/vfio/container.c | 10 +- hw/vf

[PATCH 3/3] vfio: Make VFIOIOMMUClass::add_window() and its wrapper return bool

2024-05-06 Thread Zhenzhong Duan
Make VFIOIOMMUClass::add_window() and its wrapper function vfio_container_add_section_window() return bool. This is to follow the coding standand to return bool if 'Error **' is used to pass error. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio

[PATCH 1/3] vfio: Make VFIOIOMMUClass::attach_device() and its wrapper return bool

2024-05-06 Thread Zhenzhong Duan
Make VFIOIOMMUClass::attach_device() and its wrapper function vfio_attach_device() return bool. This is to follow the coding standand to return bool if 'Error **' is used to pass error. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h

[PATCH v2 00/11] VFIO: misc cleanups

2024-05-06 Thread Zhenzhong Duan
patch (Cédric) - add processing for more files Zhenzhong Duan (11): vfio/pci: Use g_autofree in vfio_realize vfio/pci: Use g_autofree in iommufd_cdev_get_info_iova_range() vfio: Make VFIOIOMMUClass::attach_device() and its wrapper return bool vfio: Make VFIOIOMMUClass::setup() return bool

[PATCH v2 03/11] vfio: Make VFIOIOMMUClass::attach_device() and its wrapper return bool

2024-05-06 Thread Zhenzhong Duan
Make VFIOIOMMUClass::attach_device() and its wrapper function vfio_attach_device() return bool. This is to follow the coding standand to return bool if 'Error **' is used to pass error. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h

[PATCH v2 04/11] vfio: Make VFIOIOMMUClass::setup() return bool

2024-05-06 Thread Zhenzhong Duan
This is to follow the coding standand to return bool if 'Error **' is used to pass error. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio-container-base.h | 2 +- hw/vfio/container.c | 10

[PATCH v2 02/11] vfio/pci: Use g_autofree in iommufd_cdev_get_info_iova_range()

2024-05-06 Thread Zhenzhong Duan
Local pointer info is freed before return from iommufd_cdev_get_info_iova_range(). Use 'g_autofree' to avoid the g_free() calls. Signed-off-by: Zhenzhong Duan --- hw/vfio/iommufd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/vfio/iommufd.c b/hw/vfio

[PATCH v2 01/11] vfio/pci: Use g_autofree in vfio_realize

2024-05-06 Thread Zhenzhong Duan
Local pointer name is allocated before vfio_attach_device() call and freed after the call. Same for tmp when calling realpath(). Use 'g_autofree' to avoid the g_free() calls. Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletion

[PATCH v2 10/11] vfio/cpr: Make vfio_cpr_register_container() return bool

2024-05-06 Thread Zhenzhong Duan
This is to follow the coding standand to return bool if 'Error **' is used to pass error. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 2 +- hw/vfio/container.c | 3 +-- hw/vfio/cpr.c | 4 ++-- hw/vfio

[PATCH v2 06/11] vfio/container: Make vfio_connect_container() return bool

2024-05-06 Thread Zhenzhong Duan
This is to follow the coding standand to return bool if 'Error **' is used to pass error. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- hw/vfio/container.c | 18 +++--- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/hw/vfio/container.c

[PATCH v2 07/11] vfio/container: Make vfio_set_iommu() return bool

2024-05-06 Thread Zhenzhong Duan
This is to follow the coding standand to return bool if 'Error **' is used to pass error. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- hw/vfio/container.c | 22 ++ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/hw/vfio/contai

[PATCH v2 09/11] vfio/iommufd: Make iommufd_cdev_*() return bool

2024-05-06 Thread Zhenzhong Duan
_container iommufd_cdev_get_info_iova_range After the change, all functions in hw/vfio/iommufd.c follows the standand. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan --- hw/vfio/iommufd.c | 88 +-- 1 file changed, 39 insertions(+), 49 deletions(-) diff --git

[PATCH v2 05/11] vfio: Make VFIOIOMMUClass::add_window() and its wrapper return bool

2024-05-06 Thread Zhenzhong Duan
Make VFIOIOMMUClass::add_window() and its wrapper function vfio_container_add_section_window() return bool. This is to follow the coding standand to return bool if 'Error **' is used to pass error. Suggested-by: Cédric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric

  1   2   3   4   5   6   7   8   >