[PATCH] vfio/pci: Recover sub-page BAR size when base address is not aligned

2025-07-15 Thread Zhenzhong Duan
: Zhenzhong Duan --- hw/vfio/pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 1093b28df7..0455e6ce30 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1348,9 +1348,7 @@ static void vfio_sub_page_bar_update_mapping(PCIDevice *pdev, int bar

[PATCH] i386/tdx: Fix the report of gpa in QAPI

2025-07-09 Thread Zhenzhong Duan
ned-off-by: Zhenzhong Duan --- target/i386/kvm/tdx.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index e809e4b2df..370a9b6e65 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -1269,7 +1269

[PATCH v3 09/20] intel_iommu: Introduce two helpers vtd_as_from/to_iommu_pasid_locked

2025-07-08 Thread Zhenzhong Duan
_as->pasid. vtd_as_to_iommu_pasid_locked() translates from BDF+vtd_as->pasid to iommu_pasid. Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 58 +++ 1 file changed, 58 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu

[PATCH v3 17/20] intel_iommu: Replay all pasid bindings when either SRTP or TE bit is changed

2025-07-08 Thread Zhenzhong Duan
vices to update host side bindings. Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index d8b4296fe4..0a86bd47b2 100644 --- a/hw/i386/intel_iommu.c +++ b/h

[PATCH v3 18/20] vfio: Add a new element bypass_ro in VFIOContainerBase

2025-07-08 Thread Zhenzhong Duan
When bypass_ro is true, read only memory section is bypassed from mapping in the container. This is a preparing patch to workaround Intel ERRATA_772415. Signed-off-by: Zhenzhong Duan --- hw/vfio/listener.c| 13 + include/hw/vfio/vfio-container-base.h | 1 + 2

[PATCH v3 08/20] intel_iommu: Fail passthrough device under PCI bridge if x-flts=on

2025-07-08 Thread Zhenzhong Duan
an be hotplugged under same bridge. For simplify, just forbid passthrough device under PCI bridge no matter if there is, or will be emulated devices under same bridge. This is acceptable because PCIE bridge is more popular than PCI bridge now. Suggested-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw

[PATCH v3 00/20] intel_iommu: Enable stage-1 translation for passthrough device

2025-07-08 Thread Zhenzhong Duan
bindings after context cache invalidation intel_iommu: Propagate PASID-based iotlb invalidation to host intel_iommu: Replay all pasid bindings when either SRTP or TE bit is changed Zhenzhong Duan (17): intel_iommu: Rename vtd_ce_get_rid2pasid_entry to vtd_ce_get_pasid_entry hw/pci: I

[PATCH v3 02/20] hw/pci: Introduce pci_device_get_viommu_cap()

2025-07-08 Thread Zhenzhong Duan
pci_device_get_viommu_cap() call pci_device_get_iommu_bus_devfn() to get iommu_bus->iommu_ops and call get_viommu_cap() callback to get a bitmap with each bit represents a vIOMMU exposed capability. Suggested-by: Yi Liu Signed-off-by: Zhenzhong Duan --- MAINTAINERS | 1 + hw/

[PATCH v3 12/20] intel_iommu: Introduce a new pasid cache invalidation type FORCE_RESET

2025-07-08 Thread Zhenzhong Duan
y: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 25 + hw/i386/intel_iommu_internal.h | 9 + hw/i386/trace-events | 1 + 3 files changed, 35 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c

[PATCH v3 03/20] intel_iommu: Implement get_viommu_cap() callback

2025-07-08 Thread Zhenzhong Duan
Implement get_viommu_cap() callback and expose stage-1 capability for now. VFIO uses it to create nested parent domain which is further used to create nested domain in vIOMMU. All these will be implemented in following patches. Suggested-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/i386

[PATCH v3 15/20] intel_iommu: Replay pasid bindings after context cache invalidation

2025-07-08 Thread Zhenzhong Duan
Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 42 ++ hw/i386/intel_iommu_internal.h | 2 ++ hw/i386/trace-events | 1 + 3 files changed, 45 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index c35673eb58

[PATCH v3 06/20] intel_iommu: Introduce a new structure VTDHostIOMMUDevice

2025-07-08 Thread Zhenzhong Duan
Introduce a new structure VTDHostIOMMUDevice which replaces HostIOMMUDevice to be stored in hash table. It includes a reference to HostIOMMUDevice and IntelIOMMUState, also includes BDF information which will be used in future patches. Signed-off-by: Zhenzhong Duan Reviewed-by: Eric Auger

[PATCH v3 11/20] intel_iommu: Handle PASID entry adding

2025-07-08 Thread Zhenzhong Duan
-present pasid entry moved to present This handles c) by going through each passthrough device and each pasid. When a new valid pasid entry is founded, find or create a vtd_as and cache pasid entry in it. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386

[PATCH v3 19/20] Workaround for ERRATA_772415_SPR17

2025-07-08 Thread Zhenzhong Duan
stage mappings." Signed-off-by: Zhenzhong Duan --- hw/vfio/iommufd.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index c172c177fc..a28641b5f5 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -325,6 +325,7 @@ s

[PATCH v3 14/20] intel_iommu: Bind/unbind guest page table to host

2025-07-08 Thread Zhenzhong Duan
OTLB_EVENTS since the MR is switched to IOMMU MR. So it is able to support shadowing the guest IO page table. Co-Authored-by: Yi Liu Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 221 +++

[PATCH v3 20/20] intel_iommu: Enable host device when x-flts=on in scalable mode

2025-07-08 Thread Zhenzhong Duan
Now that all infrastructures of supporting passthrough device running with stage-1 translation are there, enable it now. Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 0a86bd47b2

[PATCH v3 07/20] intel_iommu: Check for compatibility with IOMMUFD backed device when x-flts=on

2025-07-08 Thread Zhenzhong Duan
, vIOMMU supports stage-1 1GB huge page mapping, but host does not, then this IOMMUFD backed device should fail. Even of the checks pass, for now we willingly reject the association because all the bits are not there yet. Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c

[PATCH v3 16/20] intel_iommu: Propagate PASID-based iotlb invalidation to host

2025-07-08 Thread Zhenzhong Duan
U will cache first level page table related mappings during DMA address translation. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 95 +- hw/i386/intel_iommu_internal.h | 6 +++ 2 files chang

[PATCH v3 01/20] intel_iommu: Rename vtd_ce_get_rid2pasid_entry to vtd_ce_get_pasid_entry

2025-07-08 Thread Zhenzhong Duan
In early days vtd_ce_get_rid2pasid_entry() was used to get pasid entry of rid2pasid, then it was extended to get any pasid entry. So a new name vtd_ce_get_pasid_entry is better to match what it actually does. No functional change intended. Signed-off-by: Zhenzhong Duan Reviewed-by: Clément

[PATCH v3 10/20] intel_iommu: Handle PASID entry removing and updating

2025-07-08 Thread Zhenzhong Duan
-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 194 +++-- hw/i386/intel_iommu_internal.h | 27 - hw/i386/trace-events | 3 + include/hw/i386/intel_iommu.h | 6 + 4 files changed, 218 insertions

[PATCH v3 13/20] intel_iommu: Stick to system MR for IOMMUFD backed host device when x-fls=on

2025-07-08 Thread Zhenzhong Duan
-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 34 ++ 1 file changed, 34 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index cf263498db..030862fb2f 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1773,6 +1773,28 @@ sta

[PATCH v3 05/20] hw/pci: Export pci_device_get_iommu_bus_devfn() and return bool

2025-07-08 Thread Zhenzhong Duan
Returns true if PCI device is aliased or false otherwise. This will be used in following patch to determine if a PCI device is under a PCI bridge. Signed-off-by: Zhenzhong Duan --- hw/pci/pci.c | 12 include/hw/pci/pci.h | 2 ++ 2 files changed, 10 insertions(+), 4

[PATCH v3 04/20] vfio/iommufd: Force creating nested parent domain

2025-07-08 Thread Zhenzhong Duan
through device with x-flts=on. Suggested-by: Nicolin Chen Suggested-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/vfio/iommufd.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 48c590b6a9..c172c177fc 100644 --- a/hw/vfio/iommufd.c +

[PATCH v2 1/2] vfio/container: Fix potential SIGSEGV when recover from unmap-all-vaddr failure

2025-06-26 Thread Zhenzhong Duan
re Signed-off-by: Zhenzhong Duan --- hw/vfio/cpr-legacy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/vfio/cpr-legacy.c b/hw/vfio/cpr-legacy.c index a84c3247b7..0a5d1bd480 100644 --- a/hw/vfio/cpr-legacy.c +++ b/hw/vfio/cpr-legacy.c @@ -180,9 +180

[PATCH v2 0/2] Some trivial live update fixes

2025-06-26 Thread Zhenzhong Duan
Steve) - s/DMA_MAP_FUNC/dma_map_fn (Steve) Zhenzhong Duan (2): vfio/container: Fix potential SIGSEGV when recover from unmap-all-vaddr failure vfio/container: Fix vfio_container_post_load() include/hw/vfio/vfio-cpr.h | 7 --- hw/vfio/cpr-legacy.c | 23 +-

[PATCH v2 2/2] vfio/container: Fix vfio_container_post_load()

2025-06-26 Thread Zhenzhong Duan
eless and is removed. Fixes: 7e9f21411302 ("vfio/container: restore DMA vaddr") Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-cpr.h | 7 --- hw/vfio/cpr-legacy.c | 23 +-- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/include/h

[PATCH 2/4] vfio/container: fails mdev hotplug if add migration blocker failed

2025-06-23 Thread Zhenzhong Duan
It's aggressive to abort a running QEMU process when hotplug a mdev and it fails migration blocker adding. Fix by just failing mdev hotplug itself. Signed-off-by: Zhenzhong Duan --- hw/vfio/container.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw

[PATCH 0/4] Some trivial live update fixes

2025-06-23 Thread Zhenzhong Duan
Hi These are trivial VFIO live update fixes in corner cases. 1) open /dev/vfio/vfio fail trigger SIGSEGV 2) mdev hotplug trigger qemu abort 3) potential SIGSEGV when unmap-all-vaddr failed 3) potential vfio_container_post_load failure Thanks Zhenzhong Zhenzhong Duan (4): vfio/container: Fix

[PATCH 3/4] vfio/container: Fix potential SIGSEGV when recover from unmap-all-vaddr failure

2025-06-23 Thread Zhenzhong Duan
cpr.saved_dma_map isn't initialized in source qemu which lead to vioc->dma_map assigned a NULL value, this will trigger SIGSEGV. Fix it by save and restore vioc->dma_map locally. Fixes: eba1f657cbb1 ("vfio/container: recover from unmap-all-vaddr failure") Signed-o

[PATCH 4/4] vfio/container: Fix vfio_container_post_load()

2025-06-23 Thread Zhenzhong Duan
eless and is removed. Fixes: 7e9f21411302 ("vfio/container: restore DMA vaddr") Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-cpr.h | 1 - hw/vfio/cpr-legacy.c | 20 +++- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/include/hw/vfio/vfio

[PATCH 1/4] vfio/container: Fix SIGSEGV when open container file fails

2025-06-23 Thread Zhenzhong Duan
When open /dev/vfio/vfio fails, SIGSEGV triggers because vfio_listener_unregister() doesn't support a NULL bcontainer pointer. Fixes: a1f267a7d4d9 ("vfio/container: reform vfio_container_connect cleanup") Signed-off-by: Zhenzhong Duan --- hw/vfio/container.c | 4 +++- 1

[PATCH v2 11/19] intel_iommu: Handle PASID entry adding

2025-06-20 Thread Zhenzhong Duan
-present pasid entry moved to present This handles c). Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 1 + hw/i386/intel_iommu.c | 169 - 2 files changed, 169 insertions(+), 1 deletion

[PATCH v2 15/19] intel_iommu: Replay pasid binds after context cache invalidation

2025-06-20 Thread Zhenzhong Duan
Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 1 + hw/i386/intel_iommu.c | 51 -- hw/i386/trace-events | 1 + 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386

[PATCH v2 16/19] intel_iommu: Propagate PASID-based iotlb invalidation to host

2025-06-20 Thread Zhenzhong Duan
U will cache first level page table related mappings during DMA address translation. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 6 ++ hw/i386/intel_iommu.c | 113 - 2 files change

[PATCH v2 07/19] intel_iommu: Check for compatibility with IOMMUFD backed device when x-flts=on

2025-06-20 Thread Zhenzhong Duan
, vIOMMU supports stage-1 1GB huge page mapping, but host does not, then this IOMMUFD backed device should be failed. Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 1 + hw/i386/intel_iommu.c | 28 2 files changed, 29

[PATCH v2 14/19] intel_iommu: Bind/unbind guest page table to host

2025-06-20 Thread Zhenzhong Duan
OTLB_EVENTS since the MR is switched to IOMMU MR. So it is able to support shadowing the guest IO page table. Co-Authored-by: Yi Liu Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 11 ++ hw/i386/intel_iommu.c

[PATCH v2 09/19] intel_iommu: Introduce two helpers vtd_as_from/to_iommu_pasid_locked

2025-06-20 Thread Zhenzhong Duan
_as->pasid. vtd_as_to_iommu_pasid_locked() translates from BDF+vtd_as->pasid to iommu_pasid. Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 58 +++ 1 file changed, 58 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu

[PATCH v2 05/19] hw/pci: Export pci_device_get_iommu_bus_devfn() and return bool

2025-06-20 Thread Zhenzhong Duan
Returns true if PCI device is aliased or false otherwise. This will be used in following patch to determine if a PCI device is under a PCI bridge. Signed-off-by: Zhenzhong Duan --- include/hw/pci/pci.h | 2 ++ hw/pci/pci.c | 12 2 files changed, 10 insertions(+), 4

[PATCH v2 19/19] intel_iommu: Enable host device when x-flts=on in scalable mode

2025-06-20 Thread Zhenzhong Duan
Now that all infrastructures of supporting passthrough device running with stage-1 translation are there, enable it now. Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 0b322078cc

[PATCH v2 13/19] intel_iommu: Stick to system MR for IOMMUFD backed host device when x-fls=on

2025-06-20 Thread Zhenzhong Duan
-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 24 1 file changed, 24 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index ed71bb8ec7..be01f8885f 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1779,6 +1779,7 @@ static b

[PATCH v2 17/19] intel_iommu: Refresh pasid bind when either SRTP or TE bit is changed

2025-06-20 Thread Zhenzhong Duan
From: Yi Liu When either 'Set Root Table Pointer' or 'Translation Enable' bit is changed, the pasid bindings on host side become stale and need to be updated. Introduce a helper function vtd_refresh_pasid_bind() for that purpose. Signed-off-by: Yi Liu Signed-off-by: Zhe

[PATCH v2 00/19] intel_iommu: Enable stage-1 translation for passthrough device

2025-06-20 Thread Zhenzhong Duan
devid/hwpt_id to vIOMMU instead of iommufd/devid/ioas_id - add vtd_as_[from|to]_iommu_pasid() helper to translate between vtd_as and iommu pasid, this is important for dropping VTDPASIDAddressSpace Yi Liu (3): intel_iommu: Replay pasid binds after context cache invalidation intel_iommu: Propagat

[PATCH v2 10/19] intel_iommu: Handle PASID entry removing and updating

2025-06-20 Thread Zhenzhong Duan
Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 27 include/hw/i386/intel_iommu.h | 6 + hw/i386/intel_iommu.c | 265 +++-- hw/i386/trace-events | 3 + 4 files changed, 291 insertions(+), 10 deletions

[PATCH v2 18/19] Workaround for ERRATA_772415_SPR17

2025-06-20 Thread Zhenzhong Duan
, Errata Details, SPR17. https://www.intel.com/content/www/us/en/content-details/772415/content-details.html Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-container-base.h | 1 + hw/vfio/iommufd.c | 8 +++- hw/vfio/listener.c| 13

[PATCH v2 06/19] intel_iommu: Introduce a new structure VTDHostIOMMUDevice

2025-06-20 Thread Zhenzhong Duan
Introduce a new structure VTDHostIOMMUDevice which replaces HostIOMMUDevice to be stored in hash table. It includes a reference to HostIOMMUDevice and IntelIOMMUState, also includes BDF information which will be used in future patches. Signed-off-by: Zhenzhong Duan Reviewed-by: Eric Auger

[PATCH v2 12/19] intel_iommu: Introduce a new pasid cache invalidation type FORCE_RESET

2025-06-20 Thread Zhenzhong Duan
y: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 2 ++ hw/i386/intel_iommu.c | 28 hw/i386/trace-events | 1 + 3 files changed, 31 insertions(+) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_inter

[PATCH v2 01/19] intel_iommu: Rename vtd_ce_get_rid2pasid_entry to vtd_ce_get_pasid_entry

2025-06-20 Thread Zhenzhong Duan
In early days vtd_ce_get_rid2pasid_entry() was used to get pasid entry of rid2pasid, then it was extended to get any pasid entry. So a new name vtd_ce_get_pasid_entry is better to match what it actually does. No functional change intended. Signed-off-by: Zhenzhong Duan Reviewed-by: Clément

[PATCH v2 04/19] vfio/iommufd: Force creating nested parent domain

2025-06-20 Thread Zhenzhong Duan
Call pci_device_get_viommu_cap() to get if vIOMMU supports VIOMMU_CAP_STAGE1, if yes, create nested parent domain which could be reused by vIOMMU to create nested domain. Suggested-by: Nicolin Chen Suggested-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/vfio/iommufd.c | 14 ++ 1

[PATCH v2 08/19] intel_iommu: Fail passthrough device under PCI bridge if x-flts=on

2025-06-20 Thread Zhenzhong Duan
e now. Suggested-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 1c79efc1cb..9d4adc9458 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_io

[PATCH v2 02/19] hw/pci: Introduce pci_device_get_viommu_cap()

2025-06-20 Thread Zhenzhong Duan
pci_device_get_viommu_cap() call pci_device_get_iommu_bus_devfn() to get iommu_bus->iommu_ops and call get_viommu_cap() callback to get a bitmap with each bit represents a vIOMMU exposed capability. Suggested-by: Yi Liu Signed-off-by: Zhenzhong Duan --- include/hw/pci/pci.h |

[PATCH v2 03/19] intel_iommu: Implement get_viommu_cap() callback

2025-06-20 Thread Zhenzhong Duan
Implement get_viommu_cap() callback and expose stage-1 capability for now. VFIO uses it to create nested parent domain which is further used to create nested domain in vIOMMU. All these will be implemented in following patches. Suggested-by: Yi Liu Signed-off-by: Zhenzhong Duan

[PATCH] vfio/pci: Fix instance_size of VFIO_PCI_BASE

2025-06-10 Thread Zhenzhong Duan
Fixes: d4e392d0a99b ("vfio: add vfio-pci-base class") Signed-off-by: Zhenzhong Duan --- hw/vfio/pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 92562898e4..03f52a9b8f 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3478,7 +3

[PATCH] vfio/container: Fix vfio_listener_commit()

2025-06-09 Thread Zhenzhong Duan
It's wrong to call into listener_begin callback in vfio_listener_commit(). Currently this impacts vfio-user. Fixes: d9b7d8b6993b ("vfio/container: pass listener_begin/commit callbacks") Signed-off-by: Zhenzhong Duan --- hw/vfio/listener.c | 2 +- 1 file changed, 1 insertion

[PATCH v4 4/5] hw/char/sh_serial: Remove dummy definition of SH_SERIAL class

2025-06-06 Thread Zhenzhong Duan
/msg00586.html Suggested-by: David Hildenbrand Signed-off-by: Zhenzhong Duan --- hw/char/sh_serial.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c index 6abd80386f..8ccc2234ba 100644 --- a/hw/char/sh_serial.c +++ b/hw/char/sh_serial.c

[PATCH v1 04/15] intel_iommu: Introduce a new structure VTDHostIOMMUDevice

2025-06-06 Thread Zhenzhong Duan
Introduce a new structure VTDHostIOMMUDevice which replaces HostIOMMUDevice to be stored in hash table. It includes a reference to HostIOMMUDevice and IntelIOMMUState, also includes BDF information which will be used in future patches. Signed-off-by: Zhenzhong Duan --- hw/i386

[PATCH v1 00/15] intel_iommu: Enable stage-1 translation for passthrough device

2025-06-06 Thread Zhenzhong Duan
nt for dropping VTDPASIDAddressSpace Yi Liu (3): intel_iommu: Replay pasid binds after context cache invalidation intel_iommu: Propagate PASID-based iotlb invalidation to host intel_iommu: Refresh pasid bind when either SRTP or TE bit is changed Zhenzhong Duan (12): intel_iommu: Rename vt

[PATCH v1 09/15] intel_iommu: Bind/unbind guest page table to host

2025-06-06 Thread Zhenzhong Duan
ce | | (iommufd0)| | (iommufd0)| | (non-CC) | | | | | | (iommufd0) | .---. .---. .. Co-Authored-by: Yi Liu Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h

[PATCH v1 06/15] intel_iommu: Handle PASID entry removing and updating

2025-06-06 Thread Zhenzhong Duan
Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 26 include/hw/i386/intel_iommu.h | 6 + hw/i386/intel_iommu.c | 252 +++-- hw/i386/trace-events | 3 + 4 files changed, 277 insertions(+), 10 deletions

[PATCH v1 05/15] intel_iommu: Introduce two helpers vtd_as_from/to_iommu_pasid_locked

2025-06-06 Thread Zhenzhong Duan
lue. vtd_as_from_iommu_pasid_locked() translates from BDF+iommu_pasid to vtd_as which contains PCI's pasid vtd_as->pasid. vtd_as_to_iommu_pasid_locked() translates from BDF+vtd_as->pasid to iommu_pasid. Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 50 +++

[PATCH v1 11/15] intel_iommu: Replay pasid binds after context cache invalidation

2025-06-06 Thread Zhenzhong Duan
Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 1 + hw/i386/intel_iommu.c | 51 -- hw/i386/trace-events | 1 + 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386

[PATCH v1 02/15] intel_iommu: Optimize context entry cache utilization

2025-06-06 Thread Zhenzhong Duan
it. So introduce a helper function vtd_as_to_context_entry() to fetch from cache before trying with vtd_dev_to_context_entry(). Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 36 +++- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/hw/i

[PATCH v1 08/15] intel_iommu: Introduce a new pasid cache invalidation type FORCE_RESET

2025-06-06 Thread Zhenzhong Duan
FORCE_RESET is different from GLOBAL_INV which updates pasid cache if underlying pasid entry is still valid, it drops all the pasid caches. FORCE_RESET isn't a VTD spec defined invalidation type for pasid cache, only used internally in system level reset. Signed-off-by: Zhenzhong Duan --

[PATCH v1 15/15] intel_iommu: Enable host device when x-flts=on in scalable mode

2025-06-06 Thread Zhenzhong Duan
Now that all infrastructures of supporting passthrough device running with stage-1 translation are there, enable it now. Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 165998896c

[PATCH v1 12/15] intel_iommu: Propagate PASID-based iotlb invalidation to host

2025-06-06 Thread Zhenzhong Duan
U will cache first level page table related mappings during DMA address translation. Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 6 ++ hw/i386/intel_iommu.c | 118 - 2 files change

[PATCH v1 07/15] intel_iommu: Handle PASID entry adding

2025-06-06 Thread Zhenzhong Duan
-present pasid entry moved to present This handles c). Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 1 + hw/i386/intel_iommu.c | 167 - 2 files changed, 167 insertions(+), 1 deletion

[PATCH v1 03/15] intel_iommu: Check for compatibility with IOMMUFD backed device when x-flts=on

2025-06-06 Thread Zhenzhong Duan
, vIOMMU supports stage-1 1GB huge page mapping, but host does not, then this IOMMUFD backed device should be failed. Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 1 + hw/i386/intel_iommu.c | 28 2 files changed, 29

[PATCH v1 14/15] intel_iommu: Bypass replay in stage-1 page table mode

2025-06-06 Thread Zhenzhong Duan
VFIO utilizes replay to setup initial shadow iommu mappings. But when stage-1 page table is configured, it is passed to host to construct nested page table, there is no replay needed. Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 8 1 file changed, 8 insertions(+) diff

[PATCH v1 13/15] intel_iommu: Refresh pasid bind when either SRTP or TE bit is changed

2025-06-06 Thread Zhenzhong Duan
From: Yi Liu When either 'Set Root Table Pointer' or 'Translation Enable' bit is changed, the pasid bindings on host side become stale and need to be updated. Introduce a helper function vtd_refresh_pasid_bind() for that purpose. Signed-off-by: Yi Liu Signed-off-by: Zhe

[PATCH v1 01/15] intel_iommu: Rename vtd_ce_get_rid2pasid_entry to vtd_ce_get_pasid_entry

2025-06-06 Thread Zhenzhong Duan
In early days vtd_ce_get_rid2pasid_entry() was used to get pasid entry of rid2pasid, then it was extended to get any pasid entry. So a new name vtd_ce_get_pasid_entry is better to match what it actually does. No functional change intended. Signed-off-by: Zhenzhong Duan Reviewed-by: Clément

[PATCH v1 10/15] intel_iommu: ERRATA_772415 workaround

2025-06-06 Thread Zhenzhong Duan
0) | | (iommufd0) | .---. .---. .. .. Changed to pass VTDHostIOMMUDevice pointer to vtd_check_hdev() so errata could be saved. Suggested-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_internal.h | 1 + include/hw/i386/intel_iommu.h

[PATCH v4 2/5] virtio-pmem: Fix definition of VirtIOPMEMClass

2025-06-06 Thread Zhenzhong Duan
l/2025-06/msg00586.html Reported-by: David Hildenbrand Reviewed-by: David Hildenbrand Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Zhenzhong Duan --- include/hw/virtio/virtio-pmem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio-pmem.h b/include/

[PATCH v4 1/5] virtio-mem: Fix definition of VirtIOMEMClass

2025-06-06 Thread Zhenzhong Duan
Parent of VirtIOMEMClass is VirtioDeviceClass rather than VirtIODevice. This isn't catastrophic only because sizeof(VirtIODevice) > sizeof(VirtioDeviceClass). Fixes: 910b25766b33 ("virtio-mem: Paravirtualized memory hot(un)plug") Signed-off-by: Zhenzhong Duan Reviewed-by:

[PATCH v4 5/5] hw/riscv/riscv-iommu: Remove definition of RISCVIOMMU[Pci|Sys]Class

2025-06-06 Thread Zhenzhong Duan
eally necessary. Signed-off-by: Zhenzhong Duan Reviewed-by: Daniel Henrique Barboza --- include/hw/riscv/iommu.h | 6 ++ hw/riscv/riscv-iommu-pci.c | 6 -- hw/riscv/riscv-iommu-sys.c | 6 -- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/include/hw/riscv/iommu.h b/inclu

[PATCH v4 3/5] hw/gpio/aspeed: Fix definition of AspeedGPIOClass

2025-06-06 Thread Zhenzhong Duan
u.org/archive/html/qemu-devel/2025-06/msg00586.html Suggested-by: David Hildenbrand Reviewed-by: Cédric Le Goater Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Zhenzhong Duan --- include/hw/gpio/aspeed_gpio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/gpio/

[PATCH v4 0/5] Fix definition of classes with wrong parent

2025-06-06 Thread Zhenzhong Duan
x27;t take effect, so no Fixes tag for them. Thanks Zhenzhong Changelog: v4: - add comments 'this isn't catastrophic only because sizeof(VirtIODevice) > sizeof(VirtioDeviceClass).' to patch1/2/3 (Markus) - collect RB for patch5 v3: - s/Suggested-by/Reported-by on patch2 (David) -

[PATCH v3 2/5] virtio-pmem: Fix definition of VirtIOPMEMClass

2025-06-05 Thread Zhenzhong Duan
hilippe Mathieu-Daudé Signed-off-by: Zhenzhong Duan --- include/hw/virtio/virtio-pmem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio-pmem.h b/include/hw/virtio/virtio-pmem.h index fc4fd1f7fe..9cce600d0b 100644 --- a/include/hw/virtio/virtio-pmem.h +

[PATCH v3 5/5] hw/riscv/riscv-iommu: Remove definition of RISCVIOMMU[Pci|Sys]Class

2025-06-05 Thread Zhenzhong Duan
eally necessary. Signed-off-by: Zhenzhong Duan --- include/hw/riscv/iommu.h | 6 ++ hw/riscv/riscv-iommu-pci.c | 6 -- hw/riscv/riscv-iommu-sys.c | 6 -- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/include/hw/riscv/iommu.h b/include/hw/riscv/iommu.h index b0333

[PATCH v3 3/5] hw/gpio/aspeed: Fix definition of AspeedGPIOClass

2025-06-05 Thread Zhenzhong Duan
édric Le Goater Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Zhenzhong Duan --- include/hw/gpio/aspeed_gpio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/gpio/aspeed_gpio.h b/include/hw/gpio/aspeed_gpio.h index e1e6c54333..e6b2fe71b5 100644 --- a/

[PATCH v3 1/5] virtio-mem: Fix definition of VirtIOMEMClass

2025-06-05 Thread Zhenzhong Duan
Parent of VirtIOMEMClass is VirtioDeviceClass rather than VirtIODevice. Fixes: 910b25766b33 ("virtio-mem: Paravirtualized memory hot(un)plug") Signed-off-by: Zhenzhong Duan Reviewed-by: David Hildenbrand Reviewed-by: Philippe Mathieu-Daudé --- include/hw/virtio/virtio-mem.h | 2

[PATCH v3 0/5] Fix definition of classes with wrong parent

2025-06-05 Thread Zhenzhong Duan
;t take effect. Thanks Zhenzhong Changelog: v3: - s/Suggested-by/Reported-by on patch2 (David) - add Closes: tag (David) - collect RB v2: - add more fixes per David Zhenzhong Duan (5): virtio-mem: Fix definition of VirtIOMEMClass virtio-pmem: Fix definition of VirtIOPMEMClass hw/gpio

[PATCH v3 4/5] hw/char/sh_serial: Remove dummy definition of SH_SERIAL class

2025-06-05 Thread Zhenzhong Duan
/msg00586.html Suggested-by: David Hildenbrand Signed-off-by: Zhenzhong Duan --- hw/char/sh_serial.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c index 6abd80386f..8ccc2234ba 100644 --- a/hw/char/sh_serial.c +++ b/hw/char/sh_serial.c

[PATCH v2 3/5] hw/gpio/aspeed: Fix definition of AspeedGPIOClass

2025-06-04 Thread Zhenzhong Duan
AspeedGPIOClass's parent is SysBusDeviceClass rather than SysBusDevice. Fixes: 4b7f956862dc ("hw/gpio: Add basic Aspeed GPIO model for AST2400 and AST2500") Suggested-by: David Hildenbrand Signed-off-by: Zhenzhong Duan --- include/hw/gpio/aspeed_gpio.h | 2 +- 1 file chang

[PATCH v2 5/5] hw/riscv/riscv-iommu: Remove definition of RISCVIOMMU[Pci|Sys]Class

2025-06-04 Thread Zhenzhong Duan
eally necessary. Signed-off-by: Zhenzhong Duan --- include/hw/riscv/iommu.h | 6 ++ hw/riscv/riscv-iommu-pci.c | 6 -- hw/riscv/riscv-iommu-sys.c | 6 -- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/include/hw/riscv/iommu.h b/include/hw/riscv/iommu.h index b0333

[PATCH v2 2/5] virtio-pmem: Fix definition of VirtIOPMEMClass

2025-06-04 Thread Zhenzhong Duan
VirtIOPMEMClass's parent is VirtioDeviceClass rather than VirtIODevice. Fixes: 5f503cd9f388 ("virtio-pmem: add virtio device") Suggested-by: David Hildenbrand Signed-off-by: Zhenzhong Duan --- include/hw/virtio/virtio-pmem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-

[PATCH v2 1/5] virtio-mem: Fix definition of VirtIOMEMClass

2025-06-04 Thread Zhenzhong Duan
Parent of VirtIOMEMClass is VirtioDeviceClass rather than VirtIODevice. Fixes: 910b25766b33 ("virtio-mem: Paravirtualized memory hot(un)plug") Signed-off-by: Zhenzhong Duan Reviewed-by: David Hildenbrand Reviewed-by: Philippe Mathieu-Daudé --- include/hw/virtio/virtio-mem.h | 2

[PATCH v2 4/5] hw/char/sh_serial: Remove dummy definition of SH_SERIAL class

2025-06-04 Thread Zhenzhong Duan
ggested-by: David Hildenbrand Signed-off-by: Zhenzhong Duan --- hw/char/sh_serial.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c index 6abd80386f..8ccc2234ba 100644 --- a/hw/char/sh_serial.c +++ b/hw/char/sh_serial.c @@ -78,9 +78,7

[PATCH v2 0/5] Fix definition of classes with wrong parent

2025-06-04 Thread Zhenzhong Duan
print FILENAME ":" NR-1 ": " second; print FILENAME ":" NR ": " third; } }' "$file" done Thanks Zhenzhong Changelog: v2: - add more fixes per David Zhenzhong Duan (5): virtio-mem: Fix definition of Vir

[PATCH] virtio-mem: Fix definition of VirtIOMEMClass

2025-06-04 Thread Zhenzhong Duan
Parent of VirtIOMEMClass is VirtioDeviceClass rather than VirtIODevice. Fixes: 910b25766b33 ("virtio-mem: Paravirtualized memory hot(un)plug") Signed-off-by: Zhenzhong Duan --- include/hw/virtio/virtio-mem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include

[PATCH v3 2/4] vfio/iommufd: Add properties and handlers to TYPE_HOST_IOMMU_DEVICE_IOMMUFD

2025-06-03 Thread Zhenzhong Duan
sub-class instead of HostIOMMUDeviceIOMMUFD, e.g., in HostIOMMUDeviceIOMMUFDVFIO. Add two wrappers host_iommu_device_iommufd_[at|de]tach_hwpt to wrap the two functions. Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater Reviewed-by: Eric Auger --- include/system/iommufd.h | 50

[PATCH v3 4/4] vfio/iommufd: Save vendor specific device info

2025-06-03 Thread Zhenzhong Duan
those capability related structures with CONFIG_LINUX. Suggested-by: Eric Auger Suggested-by: Nicolin Chen Signed-off-by: Zhenzhong Duan Reviewed-by: Nicolin Chen Reviewed-by: Eric Auger --- include/system/host_iommu_device.h | 15 +++ hw/vfio/iommufd.c | 8

[PATCH v3 1/4] backends/iommufd: Add a helper to invalidate user-managed HWPT

2025-06-03 Thread Zhenzhong Duan
This helper passes cache invalidation request from guest to invalidate stage-1 page table cache in host hardware. Signed-off-by: Nicolin Chen Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater Reviewed-by: Eric Auger --- include/system/iommufd.h | 4 backends/iommufd.c

[PATCH v3 3/4] vfio/iommufd: Implement [at|de]tach_hwpt handlers

2025-06-03 Thread Zhenzhong Duan
Implement [at|de]tach_hwpt handlers in VFIO subsystem. vIOMMU utilizes them to attach to or detach from hwpt on host side. Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater Reviewed-by: Eric Auger --- hw/vfio/iommufd.c | 22 ++ 1 file

[PATCH v3 0/4] VFIO and IOMMU prerequisite stuff for IOMMU nesting support

2025-06-03 Thread Zhenzhong Duan
structure decoding inside the backend and VFIO wouldn't need to care about types nor what's inside the data. Zhenzhong Duan (4): backends/iommufd: Add a helper to invalidate user-managed HWPT vfio/iommufd: Add properties and handlers to TYPE_HOST_IOMMU_DEVICE_IOMMUFD vfio/iommu

[PATCH v2 3/4] vfio/iommufd: Implement [at|de]tach_hwpt handlers

2025-05-30 Thread Zhenzhong Duan
Implement [at|de]tach_hwpt handlers in VFIO subsystem. vIOMMU utilizes them to attach to or detach from hwpt on host side. Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater --- hw/vfio/iommufd.c | 22 ++ 1 file changed, 22 insertions

[PATCH v2 0/4] VFIO and IOMMU prerequisite stuff for IOMMU nesting support

2025-05-30 Thread Zhenzhong Duan
d to care about types nor what's inside the data. Zhenzhong Duan (4): backends/iommufd: Add a helper to invalidate user-managed HWPT vfio/iommufd: Add properties and handlers to TYPE_HOST_IOMMU_DEVICE_IOMMUFD vfio/iommufd: Implement [at|de]tach_hwpt handlers vfio/iommufd: Save ve

[PATCH v2 4/4] vfio/iommufd: Save vendor specific device info

2025-05-30 Thread Zhenzhong Duan
those capability related structures with CONFIG_LINUX. Suggested-by: Eric Auger Suggested-by: Nicolin Chen Signed-off-by: Zhenzhong Duan --- include/system/host_iommu_device.h | 11 +++ hw/vfio/iommufd.c | 8 +++- 2 files changed, 14 insertions(+), 5 deletions

[PATCH v2 1/4] backends/iommufd: Add a helper to invalidate user-managed HWPT

2025-05-30 Thread Zhenzhong Duan
This helper passes cache invalidation request from guest to invalidate stage-1 page table cache in host hardware. Signed-off-by: Nicolin Chen Signed-off-by: Zhenzhong Duan --- include/system/iommufd.h | 4 backends/iommufd.c | 36 backends/trace

[PATCH v2 2/4] vfio/iommufd: Add properties and handlers to TYPE_HOST_IOMMU_DEVICE_IOMMUFD

2025-05-30 Thread Zhenzhong Duan
sub-class instead of HostIOMMUDeviceIOMMUFD, e.g., in HostIOMMUDeviceIOMMUFDVFIO. Add two wrappers host_iommu_device_iommufd_[at|de]tach_hwpt to wrap the two functions. Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater --- include/system/iommufd.h | 50

[PATCH v1 2/6] vfio/iommufd: Add properties and handlers to TYPE_HOST_IOMMU_DEVICE_IOMMUFD

2025-05-27 Thread Zhenzhong Duan
instead of HostIOMMUDeviceIOMMUFD, e.g., in HostIOMMUDeviceIOMMUFDVFIO. Add two wrappers host_iommu_device_iommufd_[at|de]tach_hwpt to wrap the two functions. Signed-off-by: Zhenzhong Duan --- include/system/iommufd.h | 50 backends/iommufd.c | 22

[PATCH v1 0/6] VFIO and IOMMU prerequisite stuff for IOMMU nesting support

2025-05-27 Thread Zhenzhong Duan
n keep all vendor structure decoding inside the backend and VFIO wouldn't need to care about types nor what's inside the data. Test done: - VFIO devices hotplug/unplug - build test on Windows [1] https://lists.gnu.org/archive/html/qemu-devel/2025-05/msg05002.html Thanks Zhenzhon

  1   2   3   4   5   6   7   8   9   10   >