qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@redhat.com>
To: "Duan, Zhenzhong" <zhenzhong.duan@intel.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "alex.williamson@redhat.com" <alex.williamson@redhat.com>,
	"mst@redhat.com" <mst@redhat.com>,
	"jasowang@redhat.com" <jasowang@redhat.com>,
	"Liu, Yi L" <yi.l.liu@intel.com>,
	"clement.mathieu--drif@eviden.com"
	<clement.mathieu--drif@eviden.com>,
	"eric.auger@redhat.com" <eric.auger@redhat.com>,
	"joao.m.martins@oracle.com" <joao.m.martins@oracle.com>,
	"avihaih@nvidia.com" <avihaih@nvidia.com>,
	"Hao, Xudong" <xudong.hao@intel.com>,
	"Cabiddu, Giovanni" <giovanni.cabiddu@intel.com>,
	"Gross, Mark" <mark.gross@intel.com>,
	"Van De Ven, Arjan" <arjan.van.de.ven@intel.com>
Subject: Re: [PATCH 1/5] vfio/iommufd: Add framework code to support getting dirty bitmap before unmap
Date: Tue, 23 Sep 2025 09:06:57 +0200	[thread overview]
Message-ID: <d1345c59-e9aa-479e-a71e-aa1f427bd059@redhat.com> (raw)
In-Reply-To: <IA3PR11MB9136A7B487A547CB5EAD9FEE921DA@IA3PR11MB9136.namprd11.prod.outlook.com>

On 9/23/25 04:45, Duan, Zhenzhong wrote:
> 
> 
>> -----Original Message-----
>> From: Cédric Le Goater <clg@redhat.com>
>> Subject: Re: [PATCH 1/5] vfio/iommufd: Add framework code to support
>> getting dirty bitmap before unmap
>>
>> On 9/22/25 05:17, Duan, Zhenzhong wrote:
>>> Hi Cedric,
>>>
>>>> -----Original Message-----
>>>> From: Cédric Le Goater <clg@redhat.com>
>>>> Subject: Re: [PATCH 1/5] vfio/iommufd: Add framework code to support
>>>> getting dirty bitmap before unmap
>>>>
>>>> Hello Zhenzhong
>>>>
>>>> On 9/10/25 04:36, Zhenzhong Duan wrote:
>>>>> Currently we support device and iommu dirty tracking, device dirty
>>>>> tracking is preferred.
>>>>>
>>>>> Add the framework code in iommufd_cdev_unmap_one() to choose
>> either
>>>>> device or iommu dirty tracking, just like vfio_legacy_dma_unmap_one().
>>>>
>>>> I wonder if commit 567d7d3e6be5 ("vfio/common: Work around kernel
>>>> overflow bug in DMA unmap") could be removed now to make the code
>>>> common to both VFIO IOMMU Type1 and IOMMUFD backends.
>>>
>>> I am not clear if there is other reason to keep the workaround, but the
>> original
>>> kernel issue had been fixed with below commit:
>>>
>>> commit 58fec830fc19208354895d9832785505046d6c01
>>> Author: Alex Williamson <alex.williamson@redhat.com>
>>> Date:   Mon Jan 7 22:13:22 2019 -0700
>>>
>>>       vfio/type1: Fix unmap overflow off-by-one
>>>
>>>       The below referenced commit adds a test for integer overflow, but in
>>>       doing so prevents the unmap ioctl from ever including the last page
>> of
>>>       the address space.  Subtract one to compare to the last address of
>> the
>>>       unmap to avoid the overflow and wrap-around.
>>>
>>>       Fixes: 71a7d3d78e3c ("vfio/type1: silence integer overflow warning")
>>>       Link: https://bugzilla.redhat.com/show_bug.cgi?id=1662291
>>>       Cc: stable@vger.kernel.org # v4.15+
>>>       Reported-by: Pei Zhang <pezhang@redhat.com>
>>>       Debugged-by: Peter Xu <peterx@redhat.com>
>>>       Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
>>>       Reviewed-by: Peter Xu <peterx@redhat.com>
>>>       Tested-by: Peter Xu <peterx@redhat.com>
>>>       Reviewed-by: Cornelia Huck <cohuck@redhat.com>
>>>       Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
>>>
>>>>
>>>> I asked Alex and Peter in another thread.
>>>
>>> Just curious on the answer, may I ask which thread?
>>
>> According to Alex, the QEMU workaround can be removed :
>>
>> https://lore.kernel.org/qemu-devel/20250919102447.748e17fe.alex.williams
>> on@redhat.com/
>>
>>> btw: I just found unmapping in halves seems unnecessary as both backends
>> of kernel side support unmap_all now.
>>>
>>>       if (unmap_all) {
>>>           /* The unmap ioctl doesn't accept a full 64-bit span. */
>>>           Int128 llsize = int128_rshift(int128_2_64(), 1);
>>>
>>>           ret = vfio_legacy_dma_unmap_one(bcontainer, 0,
>> int128_get64(llsize),
>>>                                           iotlb);
>>>
>>>           if (ret == 0) {
>>>               ret = vfio_legacy_dma_unmap_one(bcontainer,
>> int128_get64(llsize),
>>>                                               int128_get64(llsize),
>> iotlb);
>>>           }
>>>
>>>       } else {
>>>           ret = vfio_legacy_dma_unmap_one(bcontainer, iova, size,
>> iotlb);
>>>       }
>>
>> Good. So we can simply both backends it seems.

*ify

> 
> Will you handle them or not? I mean the workaround removing and unmapping_all optimization.

I can revert 567d7d3e6be5 ("vfio/common: Work around kernel overflow
bug in DMA unmap") but, AFAICT, the "unmap DMAs in halves" method (see
1b296c3def4b) should be kept.

Thanks,

C.



  reply	other threads:[~2025-09-23  7:08 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-10  2:36 [PATCH 0/5] vfio: relax the vIOMMU check Zhenzhong Duan
2025-09-10  2:36 ` [PATCH 1/5] vfio/iommufd: Add framework code to support getting dirty bitmap before unmap Zhenzhong Duan
2025-09-19  9:30   ` Cédric Le Goater
2025-09-22  3:17     ` Duan, Zhenzhong
2025-09-22  8:27       ` Cédric Le Goater
2025-09-23  2:45         ` Duan, Zhenzhong
2025-09-23  7:06           ` Cédric Le Goater [this message]
2025-09-23  9:50             ` Duan, Zhenzhong
2025-09-10  2:36 ` [PATCH 2/5] vfio/iommufd: Query dirty bitmap before DMA unmap Zhenzhong Duan
2025-09-10  2:36 ` [PATCH 3/5] vfio/iommufd: Add IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR flag support Zhenzhong Duan
2025-09-19 10:27   ` Joao Martins
2025-09-22  5:49     ` Duan, Zhenzhong
2025-09-22 16:02       ` Cédric Le Goater
2025-09-22 16:06         ` Joao Martins
2025-09-22 17:01           ` Joao Martins
2025-09-23  2:50             ` Duan, Zhenzhong
2025-09-23  9:17               ` Joao Martins
2025-09-23  9:55                 ` Duan, Zhenzhong
2025-09-23 10:06                   ` Duan, Zhenzhong
2025-09-23  2:47         ` Duan, Zhenzhong
2025-10-09 10:20         ` Duan, Zhenzhong
2025-10-09 12:43           ` Cédric Le Goater
2025-10-10  4:09             ` Duan, Zhenzhong
2025-09-10  2:37 ` [PATCH 4/5] intel_iommu: Optimize unmap_bitmap during migration Zhenzhong Duan
2025-10-12 10:31   ` Yi Liu
2025-10-13  2:50     ` Duan, Zhenzhong
2025-10-13 12:56       ` Yi Liu
2025-10-14  2:31         ` Duan, Zhenzhong
2025-09-10  2:37 ` [PATCH 5/5] vfio/migration: Allow live migration with vIOMMU without VFs using device dirty tracking Zhenzhong Duan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d1345c59-e9aa-479e-a71e-aa1f427bd059@redhat.com \
    --to=clg@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=arjan.van.de.ven@intel.com \
    --cc=avihaih@nvidia.com \
    --cc=clement.mathieu--drif@eviden.com \
    --cc=eric.auger@redhat.com \
    --cc=giovanni.cabiddu@intel.com \
    --cc=jasowang@redhat.com \
    --cc=joao.m.martins@oracle.com \
    --cc=mark.gross@intel.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=xudong.hao@intel.com \
    --cc=yi.l.liu@intel.com \
    --cc=zhenzhong.duan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).