Re: [PATCH V2 07/11] vfio: Update noiommu device detection logic for cdev

Mostafa Saleh
2026-03-22T10:04:41Z

On Thu, Mar 12, 2026 at 08:56:33AM -0700, Jacob Pan wrote:
> Rework vfio_device_is_noiommu() to derive noiommu mode based on device,
> group type, and configurations.
>
> Signed-off-by: Jacob Pan <jacob.pan@linux.microsoft.com>
> ---
> drivers/vfio/vfio.h | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vfio/vfio.h b/drivers/vfio/vfio.h
> index 838c08077ce2..c5541967ef9b 100644
> --- a/drivers/vfio/vfio.h
> +++ b/drivers/vfio/vfio.h
> @@ -127,8 +127,13 @@ static inline bool vfio_null_group_allowed(void)
>
> static inline bool vfio_device_is_noiommu(struct vfio_device *vdev)
> {
> - return IS_ENABLED(CONFIG_VFIO_NOIOMMU) &&
> - vdev->group->type == VFIO_NO_IOMMU;
> + if (!IS_ENABLED(CONFIG_VFIO_NOIOMMU))
> + return false;
> +
> + if (vfio_null_group_allowed())
> + return vdev->noiommu;
> +
> + return vdev->group->type == VFIO_NO_IOMMU;

I see that noiommu is set for both, can this just be simplified to:

return IS_ENABLED(CONFIG_VFIO_NOIOMMU) && vdev->noiommu;

Thanks,
Mostafa

> }
> #else
> struct vfio_group;
> --
> 2.34.1
>