Discussion of the implementations of VIRTIO specification
 help / color / mirror / Atom feed
* [virtio-dev] virtio-gpu dedicated heap
@ 2022-03-04  4:05 Gurchetan Singh
       [not found] ` <CAAfnVBmCUHKRUVA=UouoSUH-eTyTTpNReU6i8TSD94iyYWyQzg@mail.gmail.com>
       [not found] ` <eecdc1a2-ea5b-9d4f-9d58-ba87ffa5044d@arm.com>
  0 siblings, 2 replies; 3+ messages in thread
From: Gurchetan Singh @ 2022-03-04  4:05 UTC (permalink / raw)
  To: iommu-request, virtio-dev, peterz, m.szyprowski, hch,
	Michael S. Tsirkin, robin.murphy, will, Claire Chang, Tomasz Figa

[-- Attachment #1: Type: text/plain, Size: 2219 bytes --]

Hi everyone,

With the current virtio setup, all of guest memory is shared with host
devices.  There has been interest in changing this, to improve isolation of
guest memory and increase confidentiality.

The recently introduced restricted DMA mechanism makes excellent progress
in this area:

https://patchwork.kernel.org/project/xen-devel/cover/20210624155526.2775863-1-tientzu@chromium.org/


Devices without an IOMMU (traditional virtio devices for example) would
allocate from a specially designated region.  Swiotlb bouncing is done for
all DMA transfers.  This is controlled by the VIRTIO_F_ACCESS_PLATFORM
feature bit.

https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3064198

This mechanism works great for the devices it was designed for, such as
virtio-net.  However, when trying to adapt to it for other devices, there
are some limitations.

It would be great to have a dedicated heap for virtio-gpu rather than
allocating from guest memory.

We would like to use dma_alloc_noncontiguous on the restricted dma pool,
ideally with page-level granularity somehow.  Continuous buffers are
definitely going out of fashion.

There are two considerations when using it with the restricted DMA approach:

1) No bouncing (aka memcpy)

Expensive with graphics buffers, since guest user space would designate
shareable graphics buffers with the host.  We plan to use
DMA_ATTR_SKIP_CPU_SYNC when doing any DMA transactions with GPU buffers.

Bounce buffering will be utilized with virtio-cmds, like the other virtio
devices that use the restricted DMA mechanism.

2) IO_TLB_SEGSIZE is too small for graphics buffers

This issue was hit before here too:

https://www.spinics.net/lists/kernel/msg4154086.html

The suggestion was to use shared-dma-pool rather than restricted DMA.  But
we're not sure a single device can have restricted DMA (for
VIRTIO_F_ACCESS_PLATFORM) and shared-dma-pool (for larger buffers) at the
same time.  Does anyone know?

If not, it sounds like "splitting the allocation into
dma_max_mapping_size() chunks" for restricted-dma is also possible.  What
is the preferred method?

More generally, we would love more feedback on the proposed design or
consider alternatives!

[-- Attachment #2: Type: text/html, Size: 3633 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-04 18:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-04  4:05 [virtio-dev] virtio-gpu dedicated heap Gurchetan Singh
     [not found] ` <CAAfnVBmCUHKRUVA=UouoSUH-eTyTTpNReU6i8TSD94iyYWyQzg@mail.gmail.com>
2022-03-04  4:56   ` [virtio-dev] " Michael S. Tsirkin
     [not found] ` <eecdc1a2-ea5b-9d4f-9d58-ba87ffa5044d@arm.com>
2022-03-04 18:36   ` Gurchetan Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox