Skip to content

Add extended shared memory attach support

Demi Marie Obenour requested to merge DemiMarie/wayland:shm-mmap-offset into main

This provides an extended version of create_pool, called create_pool2, which allows the client to specify an offset in the file to map at. create_pool2 also allows for larger pools, up to 2³² - 1 bytes in length. wl_shm_pool has been extended to support such pools.

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 Wayland compositor to map the /dev/xen/gntdev character device, which represents memory shared by a different Xen virtual machine. Currently, this can be accomplished by opening a separate instance of /dev/xen/gntdev every time, but that is slightly wasteful and relies on undocumented behavior in the kernel driver.

As Wayland does not support 64-bit integers, the offset is passed as two 32-bit numbers. Client libraries should hide this difference if possible.

Fixes #217

Signed-off-by: Demi Marie Obenour demi@invisiblethingslab.com

Edited by Demi Marie Obenour

Merge request reports