[PATCH] vfio/iommufd: Add comment emphasizing no movement of hiod->realize() call

Zhenzhong Duan posted 1 patch 5 months, 4 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250521110301.3313877-1-zhenzhong.duan@intel.com
Maintainers: Alex Williamson <alex.williamson@redhat.com>, "Cédric Le Goater" <clg@redhat.com>
hw/vfio/iommufd.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] vfio/iommufd: Add comment emphasizing no movement of hiod->realize() call
Posted by Zhenzhong Duan 5 months, 4 weeks ago
The nested IOMMU support needs device and hwpt id which are generated
only after attachment. Hiod encapsulates these information in realize()
and passes to vIOMMU.

Suggested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
 hw/vfio/iommufd.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index af1c7ab10a..6b2696793f 100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -592,6 +592,10 @@ found_container:
         goto err_listener_register;
     }
 
+    /*
+     * Do not move this code before attachment! The nested IOMMU support
+     * needs device and hwpt id which are generated only after attachment.
+     */
     if (!vfio_device_hiod_create_and_realize(vbasedev,
                      TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO, errp)) {
         goto err_listener_register;
-- 
2.34.1


Re: [PATCH] vfio/iommufd: Add comment emphasizing no movement of hiod->realize() call
Posted by Cédric Le Goater 5 months, 4 weeks ago
On 5/21/25 13:03, Zhenzhong Duan wrote:
> The nested IOMMU support needs device and hwpt id which are generated
> only after attachment. Hiod encapsulates these information in realize()
> and passes to vIOMMU.
> 
> Suggested-by: Cédric Le Goater <clg@redhat.com>
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> ---
>   hw/vfio/iommufd.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
> index af1c7ab10a..6b2696793f 100644
> --- a/hw/vfio/iommufd.c
> +++ b/hw/vfio/iommufd.c
> @@ -592,6 +592,10 @@ found_container:
>           goto err_listener_register;
>       }
>   
> +    /*
> +     * Do not move this code before attachment! The nested IOMMU support
> +     * needs device and hwpt id which are generated only after attachment.
> +     */
>       if (!vfio_device_hiod_create_and_realize(vbasedev,
>                        TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO, errp)) {
>           goto err_listener_register;


Applied to vfio-next.

Thanks,

C.



Re: [PATCH] vfio/iommufd: Add comment emphasizing no movement of hiod->realize() call
Posted by Cédric Le Goater 5 months, 4 weeks ago
On 5/21/25 13:03, Zhenzhong Duan wrote:
> The nested IOMMU support needs device and hwpt id which are generated
> only after attachment. Hiod encapsulates these information in realize()
> and passes to vIOMMU.
> 
> Suggested-by: Cédric Le Goater <clg@redhat.com>
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>


Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.


> ---
>   hw/vfio/iommufd.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
> index af1c7ab10a..6b2696793f 100644
> --- a/hw/vfio/iommufd.c
> +++ b/hw/vfio/iommufd.c
> @@ -592,6 +592,10 @@ found_container:
>           goto err_listener_register;
>       }
>   
> +    /*
> +     * Do not move this code before attachment! The nested IOMMU support
> +     * needs device and hwpt id which are generated only after attachment.
> +     */
>       if (!vfio_device_hiod_create_and_realize(vbasedev,
>                        TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO, errp)) {
>           goto err_listener_register;