this is it-----Original Message-----Still not clear (to me at least) what that means. Are you talking about the address space used by the device? If so, that is essentially virtual address space translated by the IOMMU and we have general termed this 'bus address space'.
From: Oleksandr Andrushchenko [mailto:andr2000@xxxxxxxxx]
Sent: 18 April 2018 11:21
To: Paul Durrant <Paul.Durrant@xxxxxxxxxx>; Roger Pau Monne
<roger.pau@xxxxxxxxxx>
Cc: jgross@xxxxxxxx; Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>;
Dongwon Kim <dongwon.kim@xxxxxxxxx>; airlied@xxxxxxxx;
Oleksandr_Andrushchenko@xxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; dri-
devel@xxxxxxxxxxxxxxxxxxxxx; Potrola, MateuszX
<mateuszx.potrola@xxxxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx;
daniel.vetter@xxxxxxxxx; boris.ostrovsky@xxxxxxxxxx; Matt Roper
<matthew.d.roper@xxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 0/1] drm/xen-zcopy: Add Xen zero-copy
helper DRM driver
On 04/18/2018 01:18 PM, Paul Durrant wrote:
Behalf-----Original Message-----
From: Xen-devel [mailto:xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx] On
dri-Of Roger Pau MonnÃ
Sent: 18 April 2018 11:11
To: Oleksandr Andrushchenko <andr2000@xxxxxxxxx>
Cc: jgross@xxxxxxxx; Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>;
Dongwon Kim <dongwon.kim@xxxxxxxxx>; airlied@xxxxxxxx;
Oleksandr_Andrushchenko@xxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx;
Kerneldevel@xxxxxxxxxxxxxxxxxxxxx; Potrola, MateuszX
<mateuszx.potrola@xxxxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx;
daniel.vetter@xxxxxxxxx; boris.ostrovsky@xxxxxxxxxx; Matt Roper
<matthew.d.roper@xxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 0/1] drm/xen-zcopy: Add Xen zero-copy
helper DRM driver
On Wed, Apr 18, 2018 at 11:01:12AM +0300, Oleksandr Andrushchenko
wrote:
On 04/18/2018 10:35 AM, Roger Pau Monnà wrote:wrote:
On Wed, Apr 18, 2018 at 09:38:39AM +0300, Oleksandr Andrushchenko
only writeOn 04/17/2018 11:57 PM, Dongwon Kim wrote:
On Tue, Apr 17, 2018 at 09:59:28AM +0200, Daniel Vetter wrote:3.2 Backend exports dma-buf to xen-front
On Mon, Apr 16, 2018 at 12:29:05PM -0700, Dongwon Kim wrote:
In this case Dom0 pages are shared with DomU. As before, DomU can
consideredto these pages, not any other page from Dom0, so it can be still
safe.
But, the following must be considered (highlighted in xen-front's
trustedcannotdocumentation):
Â- If guest domain dies then pages/grants received from the backend
forÂÂ be claimed back - think of it as memory lost to Dom0 (won't be used
exhaustingany
ÂÂ other guest)
Â- Misbehaving guest may send too many requests to the backend
As theÂÂ its grant references and memory (consider this from security POV).
ÂÂ backend runs in the trusted domain we also assume that it is
doingas
above)I mean that we trust the backend that it can prevent Dom0well,I cannot parse the above sentence:
ÂÂ e.g. must take measures to prevent DDoS attacks.
"As the backend runs in the trusted domain we also assume that it is
trusted as well, e.g. must take measures to prevent DDoS attacks."
What's the relation between being trusted and protecting from DoS
attacks?
from crashing in case DomU's frontend misbehaves, e.g.
if the frontend sends too many memory requests etc.
In any case, all? PV protocols are implemented with the frontendThis is the first use-case above. But there are real-world
sharing pages to the backend, and I think there's a reason why this
model is used, and it should continue to be used.
use-cases (embedded in my case) when physically contiguous memory
needs to be shared, one of the possible ways to achieve this is
to share contiguous memory from Dom0 to DomU (the second use-case
Having to add logic in the backend to prevent such attacks meansYou can live without this code at all, but this is then up to
that:
- We need more code in the backend, which increases complexity and
chances of bugs.
- Such code/logic could be wrong, thus allowing DoS.
backend which may make Dom0 down because of DomU's frontend
Whyevil
thingsIMO we should design protocols that do not allow such attacks instead
of having to defend against them.
between4. xen-front/backend/xen-zcopy synchronization
4.1. As I already said in 2) all the inter VM communication happens
issues axen-front and the backend, xen-zcopy is NOT involved in that.
When xen-front wants to destroy a display buffer (dumb/dma-buf) it
XENDISPL_OP_DBUF_CREATE).XENDISPL_OP_DBUF_DESTROY command (opposite to
theThis call is synchronous, so xen-front expects that backend does free
zcopy to makebuffer pages on return.
4.2. Backend, on XENDISPL_OP_DBUF_DESTROY:
 - closes all dumb handles/fd's of the buffer according to [3]
 - issues DRM_IOCTL_XEN_ZCOPY_DUMB_WAIT_FREE IOCTL to xen-
sureSo this zcopy thing keeps some kind of track of the memory usage?
ÂÂÂ the buffer is freed (think of it as it waits for dma-buf->release
callback)
cyclecan't the user-space backend keep track of the buffer usage?Because there is no dma-buf UAPI which allows to track the buffer life
and(e.g. wait until dma-buf's .release callback is called)and DomU
 - replies to xen-front that the buffer can be destroyed.
This way deletion of the buffer happens synchronously on both Dom0
with time-outsides. In case if DRM_IOCTL_XEN_ZCOPY_DUMB_WAIT_FREE returns
caseerror
(BTW, wait time is a parameter of this IOCTL), Xen will defer grant
reference
removal and will retry later until those are free.
Hope this helps understand how buffers are synchronously deleted in
withof xen-zcopy with a single protocol command.
I think the above logic can also be re-used by the hyper-dmabuf driver
some additional work:
1. xen-zcopy can be split into 2 parts and extend:
1.1. Xen gntdev driver [4], [5] to allow creating dma-buf from grefs
buffer,A dma-buf is seen by user-space as a file descriptor and you canvise versa,I don't know much about the dma-buf implementation in Linux, but
gntdev is a user-space device, and AFAICT user-space applications
don't have any notion of dma buffers. How are such buffers useful for
user-space? Why can't this just be called memory?
pass it to different drivers then. For example, you can share a buffer
used by a display driver for scanout with a GPU, to compose a picture
into it:
1. User-space (US) allocates a display buffer from display driver
2. US asks display driver to export the dma-buf which backs up that
dma_buf_fdUS gets buffer's fd: dma_buf_fd
3. US asks GPU driver to import a buffer and provides it with
fact4. GPU renders contents into display buffer (dma_buf_fd)After speaking with Oleksandr on IRC, I think the main usage of the
gntdev extension is to:
1. Create a dma-buf from a set of grant references.
2. Share dma-buf and get a list of grant references.
I think this set of operations could be broken into:
1.1 Map grant references into user-space using the gntdev.
1.2 Create a dma-buf out of a set of user-space virtual addresses.
2.1 Map a dma-buf into user-space.
2.2 Get grefs out of the user-space addresses where the dma-buf is
mapped.
So it seems like what's actually missing is a way to:
- Create a dma-buf from a list of user-space virtual addresses.
- Allow to map a dma-buf into user-space, so it can then be used with
the gntdev.
I think this is generic enough that it could be implemented by a
device not tied to Xen. AFAICT the hyper_dma guys also wanted
something similar to this.
Finally, this is indeed some memory, but a bit more [1]
Also, (with my FreeBSD maintainer hat) how is this going to translate
to other OSes? So far the operations performed by the gntdev device
are mostly OS-agnostic because this just map/unmap memory, and in
gntdev/balloonthey are implemented by Linux and FreeBSD.At the moment I can only see Linux implementation and it seems
to be perfectly ok as we do not change Xen's APIs etc. and only
use the existing ones (remember, we only extend gntdev/balloon
drivers, all the changes in the Linux kernel)
As the second note I can also think that we do not extend
aredrivers and have re-worked xen-zcopy driver be a separate entity,
say drivers/xen/dma-buf
implement "wait" ioctl (wait for dma-buf->release): currently these
means what I've termed 'Bus Address' elsewhere?I assume 'IPA' means 'IOMMU Physical Address'. I wonder whether thisDRM_XEN_ZCOPY_DUMB_TO_REFS andDRM_XEN_ZCOPY_DUMB_FROM_REFS,
allUse-case: Dom0 has a HW driver which only works with contig memoryDRM_XEN_ZCOPY_DUMB_WAIT_FREEI think this needs clarifying. In which memory space do you need those
1.2. Xen balloon driver [6] to allow allocating contiguous buffers (not
needed
by current hyper-dmabuf, but is a must for xen-zcopy use-cases)
regions to be contiguous?
and I want DomU to be able to directly write into that memory, thus
implementing zero copying
Do they need to be contiguous in host physical memory, or guestHost
physical memory?
If it's in guest memory space, isn't there any generic interface that
you can use?
If it's in host physical memory space, why do you need this buffer to
be contiguous in host physical memory space? The IOMMU should hide
What's IPA contig?this.There are drivers/HW which can only work with contig memory and
if it is backed by an IOMMU then still it has to be contig in IPA
space (real device doesn't know that it is actually IPA contig, not PA)
sorry for not being clear here: I mean that the device sees contiguous
range of
Intermediate Phys Addresses
Paul
Paul
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel