From: "Graf (AWS), Alexander" <graf@amazon.de>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: "Jason Wang" <jasowangio@gmail.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Alex Williamson" <alex@shazbot.org>,
"David Airlie" <airlied@redhat.com>,
"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Feng Liu" <feliu@nvidia.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Jens Axboe" <axboe@kernel.dk>, "Jiri Pirko" <jiri@resnulli.us>,
"Jonathan Corbet" <corbet@lwn.net>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"nh-open-source@amazon.com" <nh-open-source@amazon.com>,
"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>,
"Pankaj Gupta" <pankaj.gupta.linux@gmail.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Parav Pandit" <parav@nvidia.com>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"virtualization@lists.linux.dev" <virtualization@lists.linux.dev>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Yishai Hadas" <yishaih@nvidia.com>
Subject: Re: [RFC PATCH 00/12] virtio: support devices that own their virtqueue memory
Date: Tue, 11 Aug 2026 19:39:01 +0000 [thread overview]
Message-ID: <235f84ba-0327-4dd4-8f37-e566bf000656@amazon.com> (raw)
In-Reply-To: <20260810203901.GA35278@fedora>
On 10.08.26 22:39, Stefan Hajnoczi wrote:
> On Sun, Aug 09, 2026 at 06:19:58PM +0000, Alexander Graf wrote:
>> Virtio drivers use guest memory to back virtqueues and their buffers.
>> That means a VMM needs to be able to map guest memory. That is ok in the
>> normal virt case. It gets icky with confidential computing (where we use
>> swiotlb as workaround) and it defeats the purpose of isolated vhost-user
>> backing devices, because they end up with full RAM access to the guest.
>>
>> So instead, I'm proposing an extension to virtio which allows it to give
>> each virtio device its own dedicated memory region to communicate with the
>> host, called DMB (Device Memory Buffer). A trusted hypervisor can force
>> DMB to be present, which then enables safer, more isolated and resilient
>> communication between guest and host.
>>
>> With DMB, the device provides a shared memory region that both parties
>> agree is the full memory map both have access to. All memory offsets
>> that previously would have been into guest RAM, are then offsets into
>> this shared memory buffer region. One nice property of this is that it
>> is a generic mechanism in the virtio transport layer, so higher level
>> drivers work unmodified.
> This is similar to VIRTIO's Shared Memory Regions. A problem with this
> kind of approach is that guest software that depends on zero-copy,
> O_DIRECT, the ability to mmap, etc may break when passing an address
> from one device to another device.
>
> For example, a guest userspace application writing to a virtio-blk
> device with O_DIRECT can pass any source memory buffer. One VIRTIO
> device will be unable to address another VIRTIO device's DMB. This
> problem also extends to vhost-user where one back-end cannot access
> another back-end's DMB or Shared Memory Regions.
>
> Maybe your use case will never hit this problem because you can rely on
> the guest software never to assume zero-copy/O_DIRECT/etc works.
> virtiofs hit it with its DAX Shared Memory Regions.
Virtiofs is a bit trickier. It assumes reverse mapping order (host maps
memory into guest address space's SHM region) which is something I'm not
looking to support. The main reason you did run into it is because the
page cache is actually implemented by the SHM region, so Linux
(rightfully) assumes that it has direct access to it.
For normal virtio device operations (like O_DIRECT on virtio-blk), I am
not sure whether we can ever run into a case where anything in the
driver assumes that both devices share the same IOVA space. Thanks a lot
for the heads-up though, I'll take a deeper look to make sure that this
is the case. But even if it is, IMHO we can consider it a guest bug and
fix it in the guest code when DMB is active.
> I'm mentioned it in case this is something you want to think about
> before deploying this approach.
>
>> I was exploring to use swiotlb instead to create individual pools. But
>> that approach has multiple downsides:
>>
>> 1. Swiotlb is an OS primitive which is not available in all Operating
>> Systems. DMB however lives in the virtio transport layer, which means we
>> can add support for it in any OS independent of generic layers. This
>> helps with Windows support.
>>
>> 2. We munge DMA space together. DMB provides a separate DMA space per
>> virtio device. This means we can for example implement a device in
>> vhost-user and give the implementing process only visibility to the DMB
>> region, not all of guest memory. That reduces the exposure the
>> vhost-user provider has, improving security.
> Connor Kite is working on a different approach for vhost-user memory
> isolation here:
> https://lore.kernel.org/qemu-devel/20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com/T/#t
>
> It involves a bounce buffer at the VMM level. Unmodified vhost-user
> back-ends never sees guest RAM. Guest drivers are also unmodified. The
> cost of doing this is that the VMM has to intercept kick and call
> eventfds in order to copy between the bounce buffer and guest RAM.
>
> I don't see DMB or vhost-user memory isolation as conflicting features.
> There can be two ways of solving the same problem with different
> trade-offs. I just wanted to share a link to Connor's ongoing work.
Thanks a bunch :). My design motivation is a bit different, but it's
great to see more people interested in isolation!
Alex
prev parent reply other threads:[~2026-08-11 19:39 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-09 18:19 [RFC PATCH 00/12] virtio: support devices that own their virtqueue memory Alexander Graf
2026-08-09 18:20 ` [RFC PATCH 09/12] Documentation: virtio: describe the device memory buffer Alexander Graf
2026-08-09 22:09 ` Michael S. Tsirkin
2026-08-09 18:20 ` [RFC PATCH 10/12] virtio_ring: report a bounded pool's exhaustion as -ENOSPC Alexander Graf
2026-08-09 18:20 ` [RFC PATCH 11/12] virtio: expose device memory buffer occupancy over debugfs Alexander Graf
2026-08-09 18:20 ` [RFC PATCH 12/12] virtio: guarantee a virtqueue can publish its first descriptor chain Alexander Graf
2026-08-09 22:41 ` Michael S. Tsirkin
2026-08-09 23:15 ` Randy Dunlap
2026-08-10 6:23 ` [RFC PATCH 00/12] virtio: support devices that own their virtqueue memory Michael S. Tsirkin
2026-08-10 7:39 ` Graf (AWS), Alexander
2026-08-10 8:04 ` Michael S. Tsirkin
2026-08-10 8:25 ` Graf (AWS), Alexander
2026-08-10 19:14 ` Graf (AWS), Alexander
2026-08-10 21:42 ` Michael S. Tsirkin
2026-08-11 19:33 ` Graf (AWS), Alexander
2026-08-10 20:39 ` Stefan Hajnoczi
2026-08-11 19:39 ` Graf (AWS), Alexander [this message]
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=235f84ba-0327-4dd4-8f37-e566bf000656@amazon.com \
--to=graf@amazon.de \
--cc=airlied@redhat.com \
--cc=alex@shazbot.org \
--cc=axboe@kernel.dk \
--cc=corbet@lwn.net \
--cc=dmitry.osipenko@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=eperezma@redhat.com \
--cc=feliu@nvidia.com \
--cc=jasowangio@gmail.com \
--cc=jiri@resnulli.us \
--cc=kraxel@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=nh-open-source@amazon.com \
--cc=nvdimm@lists.linux.dev \
--cc=pankaj.gupta.linux@gmail.com \
--cc=parav@nvidia.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=skhan@linuxfoundation.org \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
--cc=yishaih@nvidia.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