Re: [PATCH 1/2] vfio: Fix unbalanced vfio_df_close call in no-iommu mode
From: Jason Gunthorpe
Date: Mon Jun 02 2025 - 19:49:23 EST
On Mon, Jun 02, 2025 at 04:43:18PM -0700, Jacob Pan wrote:
> For no-iommu enabled devices working under IOMMUFD VFIO compat mode, the
> group open path does not call vfio_df_open() and the open_count is 0. So
> calling vfio_df_close() in the group close path will trigger warning in
> vfio_assert_device_open(device);
>
> E.g. The following warning can be seen by running VFIO test.
> https://github.com/awilliam/tests/blob/master/vfio-noiommu-pci-device-open.c
> CONFIG_VFIO_CONTAINER = n
> [ 29.094781] vfio-pci 0000:02:01.0: vfio-noiommu device opened by user (vfio-noiommu-pc:164)
> Failed to get device info
> [ 29.096540] ------------[ cut here ]------------
> [ 29.096616] WARNING: CPU: 1 PID: 164 at drivers/vfio/vfio_main.c:487 vfio_df_close+0xac/0xb4
>
> This patch adds checks for no-iommu mode and open_count to skip calling vfio_df_close.
>
> Signed-off-by: Jacob Pan <jacob.pan@xxxxxxxxxxxxxxxxxxx>
> ---
> drivers/vfio/group.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
Did you mean to resend the original version?
Jason