All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anlai Lu" <agicy@qq.com>
Cc: virtualization@lists.linux.dev,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH 3/6] iommu/virtio: allocate the UNMAP request with the mapping
Date: Sun, 04 Oct 2026 12:06:25 +0000	[thread overview]
Message-ID: <20261004120626.192CB1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <tencent_9CB84937FB8F833E78AD4675C36B512A5309@qq.com>

> The iommu core states the contract plainly (iommufd pages.c): a driver
> may not fail unmap for reasons beyond bad arguments, and in particular
> may not allocate on the unmap path, because the caller may free the
> memory as soon as unmap returns. viommu_del_mappings() still allocated
> the UNMAP request there, so a forced allocation failure left the device
> mapping a page the driver had already released, while the caller was told
> nothing.
> 
> Allocate that request object with the mapping instead - on the map path,
> which is allowed to fail and reports the failure to the caller that is
> mapping - and free it with the mapping when no UNMAP is sent: the unmap
> path then only fills in and queues a request. Measured with a fault
> injected into that allocation (failslab, on the fault-injection harness
> this work used): the unpatched driver returns success for a re-map of the
> same IOVA while the device still translates it to the freed page, proven
> with a real DMA through the QEMU iommu-testdev; with this patch the same
> scenario reports no such case in any round and the DMA lands on the new
> page. The unmap path allocates nothing afterwards, and the device sees
> the same request stream.
> 
> Fixes: edcd69ab9a32 ("iommu: Add virtio-iommu driver")
> Signed-off-by: Anlai Lu <agicy@qq.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_85AC6E749F6A912B7BB9FF360F8ECB3F5C09@qq.com?part=3


  reply	other threads:[~2026-10-04 12:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-04 11:55 [PATCH 0/6] iommu/virtio: batch the mapping replay Anlai Lu
2026-10-04 11:57 ` [PATCH 1/6] iommu/virtio: publish the endpoint before replaying it Anlai Lu
2026-10-04 12:08   ` sashiko-bot
2026-10-04 13:02     ` Anlai Lu
2026-10-04 11:57 ` [PATCH 2/6] iommu/virtio: queue an UNMAP for every removed mapping Anlai Lu
2026-10-04 12:04   ` sashiko-bot
2026-10-04 11:57 ` [PATCH 3/6] iommu/virtio: allocate the UNMAP request with the mapping Anlai Lu
2026-10-04 12:06   ` sashiko-bot [this message]
2026-10-04 11:57 ` [PATCH 4/6] iommu/virtio: stop queueing and draining once the device is removed Anlai Lu
2026-10-04 12:09   ` sashiko-bot
2026-10-04 13:04     ` Anlai Lu
2026-10-04 11:57 ` [PATCH 5/6] iommu/virtio: read the endpoint count under the lock in the iotlb paths Anlai Lu
2026-10-04 12:04   ` sashiko-bot
2026-10-04 11:57 ` [PATCH 6/6] iommu/virtio: batch the mapping replay on domain attach Anlai Lu
2026-10-04 12:10   ` sashiko-bot
2026-10-04 13:04     ` Anlai Lu

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=20261004120626.192CB1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agicy@qq.com \
    --cc=eperezma@redhat.com \
    --cc=mst@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=virtualization@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.