qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: Alex Williamson <alex.williamson@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] vfio/common: Work around kernel overflow bug in DMA unmap
Date: Fri, 19 Sep 2025 11:24:51 +0200	[thread overview]
Message-ID: <8019c941-e67d-4288-bb75-ff18a917464a@redhat.com> (raw)
In-Reply-To: <aMx8T5-u6Uj64Vgx@x1.local>

On 9/18/25 23:40, Peter Xu wrote:
> On Thu, Sep 18, 2025 at 10:55:47PM +0200, Cédric Le Goater wrote:
>> Alex, Peter,
>>
>> On 1/10/19 00:10, Alex Williamson wrote:
>>> A kernel bug was introduced in v4.15 via commit 71a7d3d78e3c which
>>> adds a test for address space wrap-around in the vfio DMA unmap path.
>>> Unfortunately due to overflow, the kernel detects an unmap of the last
>>> page in the 64-bit address space as a wrap-around.  In QEMU, a Q35
>>> guest with VT-d emulation and guest IOMMU enabled will attempt to make
>>> such an unmap request during VM system reset, triggering an error:
>>>
>>>     qemu-kvm: VFIO_UNMAP_DMA: -22
>>>     qemu-kvm: vfio_dma_unmap(0x561f059948f0, 0xfef00000, 0xffffffff01100000) = -22 (Invalid argument)
>>>
>>> Here the IOVA start address (0xfef00000) and the size parameter
>>> (0xffffffff01100000) add to exactly 2^64, triggering the bug.  A
>>> kernel fix is queued for the Linux v5.0 release to address this.
>>>
>>> This patch implements a workaround to retry the unmap, excluding the
>>> final page of the range when we detect an unmap failing which matches
>>> the requirements for this issue.  This is expected to be a safe and
>>> complete workaround as the VT-d address space does not extend to the
>>> full 64-bit space and therefore the last page should never be mapped.
>>>
>>> This workaround can be removed once all kernels with this bug are
>>> sufficiently deprecated.
>>
>> Have we waited long enough ? what does "sufficiently deprecated" mean ?
>> Is it related to the linux stable updates ?
> 
> Alex might be the best to define it.
> 
> To me, it doesn't sound a major issue to have it even forever just in case
> someone was using a broken v4.15..v5.0 kernel.  It's pretty small, limited
> and self contained workaround.

So it seems it is not that useful anymore for upstream kernels
and downstream should have done the required backports.

> Any blockers on this?
No.

If we could remove the workaround in QEMU, we would be able to
refactor some of the code unmapping DMAs to make it common
between the VFIO IOMMU Type1 and IOMMUFD backends.


Thanks,

C.




  reply	other threads:[~2025-09-19  9:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-09 23:10 [Qemu-devel] [PATCH] vfio/common: Work around kernel overflow bug in DMA unmap Alex Williamson
2019-01-10  3:11 ` Peter Xu
2019-01-10  9:04 ` Cornelia Huck
2025-09-18 20:55 ` Cédric Le Goater
2025-09-18 21:40   ` Peter Xu
2025-09-19  9:24     ` Cédric Le Goater [this message]
2025-09-19 16:24   ` Alex Williamson

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=8019c941-e67d-4288-bb75-ff18a917464a@redhat.com \
    --to=clg@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).