From 06dd38480fe980bc893ce91133b4fc193712508f Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Mon, 8 Aug 2022 21:07:58 -0400 Subject: [PATCH] Add extended shared memory attach structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This provides an extended version of `X_ShmAttachFd`, called `X_ShmAttachFdExt`, which allows the client to specify two additional parameters: 1. The size of the mapping, in bytes. 2. The offset that should be passed to `mmap`, in bytes. The intended use-case for this extension is when one needs to map a drawable from a character special device, but it can also be used with regular files if one needs to map with a nonzero offset. Qubes OS needs the X server to map the `/dev/xen/gntdev` character device, which represents memory shared from a different virtual machine. This is currently accomplished with an `LD_PRELOAD`’d shared library that overrides `shmat`, `shmctl`, and `shmdt`, and I have written a version that instead overrides `fstat` and `mmap`. With this extension, the preloaded shared library will not be required. Signed-off-by: Demi Marie Obenour --- include/X11/extensions/shmproto.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/X11/extensions/shmproto.h b/include/X11/extensions/shmproto.h index 6e32606..554abeb 100644 --- a/include/X11/extensions/shmproto.h +++ b/include/X11/extensions/shmproto.h @@ -45,6 +45,7 @@ in this Software without prior written authorization from The Open Group. #define X_ShmCreatePixmap 5 #define X_ShmAttachFd 6 #define X_ShmCreateSegment 7 +#define X_ShmAttachFdExt 8 typedef struct _ShmQueryVersion { CARD8 reqType; /* always ShmReqCode */ @@ -220,6 +221,21 @@ typedef struct { /* File descriptor is passed with this reply */ #define sz_xShmCreateSegmentReply 32 +/* Version 1.3 additions */ +typedef struct _ShmAttachFdExt { + CARD8 reqType; /* always ShmReqCode */ + CARD8 shmReqType; /* always X_ShmAttachFdExt */ + CARD16 length; + ShmSeg shmseg; + BOOL readOnly; + BYTE pad0; + CARD16 pad1; + CARD32 size; /* size of the buffer */ + CARD64 offset; /* offset to pass to mmap() */ +} xShmAttachFdExtReq; +/* File descriptor is passed with this request */ +#define sz_xShmAttachFdExtReq 32 + #undef ShmSeg #undef Drawable #undef VisualID