summaryrefslogtreecommitdiff
path: root/hw/xwayland/xwayland-shm.c
AgeCommit message (Collapse)AuthorFilesLines
2024-03-09os: move os_move_fd() out of public APIEnrico Weigelt, metux IT consult1-0/+2
This function isn't used by any driver and doesn't seem to be useful for them, thus move it out of the public module API, in order to tidy it up a bit. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1366>
2024-01-22xwayland: Enable Present extension support also without glamorMichel Dänzer1-2/+25
This allows e.g. xfwm4 --vblank=xpresent to hit the page flip path instead of copies. In the future, Mesa might also use the Present extension with software rendering.
2024-01-22xwayland: Handle NULL xwl_pixmap in xwl_shm_pixmap_get_wl_bufferMichel Dänzer1-1/+6
2021-10-05xwayland/shm: Avoid integer overflow on large pixmapsOlivier Fourdan1-2/+9
Xwayland's xwl_shm_create_pixmap() computes the size of the shared memory pool to create using a size_t, yet the Wayland protocol uses an integer for that size. If the pool size becomes larger than INT32_MAX, we end up asking Wayland to create a shared memory pool of negative size which in turn will raise a protocol error which terminates the Wayland connection, and therefore Xwayland. Avoid that issue early by return a NULL pixmap in that case, which will trigger a BadAlloc error, but leave Xwayland alive. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2020-07-20xwayland: Remove harmless duplicated #includeEmmanuel Gil Peyrot1-1/+0
2020-07-20xwayland: Use memfd_create() when availableEmmanuel Gil Peyrot1-14/+35
This (so-far) Linux-only API lets users create file descriptors purely in memory, without any backing file on the filesystem and the race condition which could ensue when unlink()ing it. It also allows seals to be placed on the file, ensuring to every other process that we won’t be allowed to shrink the contents, potentially causing a SIGBUS when they try reading it. This patch is best viewed with the -w option of git log -p. This is a port of this commit from Weston: https://gitlab.freedesktop.org/wayland/weston/-/commit/deae98ef45e060b8412a5edd195fb0c7c14f0321 Fixes #848. Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2020-07-05Fix spelling/wording issuesAlan Coopersmith1-1/+1
Most (but not all) of these were found by using codespell --builtin clear,rare,usage,informal,code,names but not everything reported by that was fixed. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-12-20xwayland: Cleanup and remove `xwayland.h`Olivier Fourdan1-1/+0
Now that each source and header should be in order, we can safely cleaup the last remaining bits from the main `xwayland.h` which is not needed anymore and can be removed. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20xwayland: Separate Xwayland screen codeOlivier Fourdan1-0/+1
Move Xwayland screen related code to a separate source file and header. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20xwayland: Separate Xwayland pixmap codeOlivier Fourdan1-0/+3
Move Xwayland generic pixmap code to a separate source file and header. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20xwayland: Move SHM declarations to their own headerOlivier Fourdan1-7/+8
Currently, `xwayland.h` contains all the declarations, which is a bit awkward and hard to follow. Move the SHM relevant declarations to their own header file. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-11-28xwayland: Add buffer release callbackOlivier Fourdan1-0/+8
The API `wl_buffer_add_listener` is misleading in the sense that there can be only one `wl_buffer` release callback, and trying to add a new listener when once is already in place will lead to a protocol error. The Xwayland EGL backends may need to set up their own `wl_buffer` release listener, meaning that there is no way to our own `wl_buffer` release callback. To avoid the problem, add our own callback API to be notified when the `wl_buffer` associated with an `xwl_pixmap` is released, triggered from the different `xwl_pixmap` implementations. Also update the Present code to use the new buffer release callback API. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-11-08xwayland/shm: Use `calloc()`Olivier Fourdan1-1/+1
Currently, Xwayland pixmap SHM code uses `malloc()` to allocate the xwl_pixmap. Use `calloc()` instead, as the EGLstream backend does, as it is safer (initializing the allocated data to 0). Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-09-23xwayland: Don't create wl_buffer backing pixmapOlivier Fourdan1-0/+1
In non-rootless mode, not all pixmaps need a wl_buffer backing. Suggested-by: Twaik Yont (@twaik) in #834 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2017-03-23xserver: Check the right HAVE_*_CONFIG_H.Eric Anholt1-1/+1
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniels@collabora.com> Signed-off-by: Eric Anholt <eric@anholt.net>
2016-11-01xwayland-shm: block signals during fallocateIan Ray1-0/+10
posix_fallocate() does an explicit rollback if it gets EINTR, and this is a problem on slow systems because when the allocation size is sufficiently large posix_fallocate() will always be interrupted by the smart scheduler's SIGALRM. Changes since v1 - big comment in the code to explain what is going on Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Ian Ray <ian.ray@ge.com> Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Acked-by: Daniel Stone <daniels@collabora.com>
2016-09-28xwayland: Close the shm fd as early as possibleRui Matos1-27/+19
Keeping the shm fd open beyond pixmap creation means we can easily reach the open file descriptor limit if an X client asks us to create that many pixmaps. Instead, let's get the wl_buffer immediatly so that we can destroy the shm pool and close the fd before being asked to create more. Tested-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2016-04-25xwayland-shm: fortify fallocate against EINTRMarek Chalupa1-2/+8
If posix_fallocate or ftruncate is interrupted by signal while working, we return -1 as fd and the allocation process returns BadAlloc error. That causes xwayland clients to abort with 'BadAlloc (insufficient resources for operation)' even when there's a lot of resources available. Fix it by trying again when we get EINTR. Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-03-08xwayland: Correctly detect whether posix_fallocate existsJonas Ådahl1-0/+4
We had HAVE_POSIX_FALLOCATE checks, but no such macros were ever defined anywhere. This commit makes it so that this macro is defined if the posix_fallocate is detected during configure. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Julien Cristau <jcristau@debian.org>
2016-02-22xwayland: Prefix shm tmp file names with xwaylandJonas Ådahl1-1/+1
Prefix the temporary file names used for allocating pixmaps with "xwayland-" instead of "weston-". This makes it less confusing while looking at the file names of the currently open fds of the Xwayland process. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2016-02-22dix: Add hybrid full-size/empty-clip mode to SetRootClipDaniel Stone1-3/+3
216bdbc735 removed the SetRootClip call in the XWayland output-hotplug handler when running rootless (e.g. as a part of Weston/Mutter), since the root window has no storage, so generating exposures will result in writes to invalid memory. Unfortunately, preventing the segfault also breaks sprite confinement. SetRootClip updates winSize and borderSize for the root window, which when combined with RRScreenSizeChanged calling ScreenRestructured, generates a new sprite-confinment area to update it to the whole screen. Removing this call results in the window geometry being reported correctly, but winSize/borderSize never changing from their values at startup, i.e. out of sync with the root window geometry / screen information in the connection info / XRandR. This patch introduces a hybrid mode, where we update winSize and borderSize for the root window, enabling sprite confinement to work correctly, but keep the clip emptied so exposures are never generated. Signed-off-by: Daniel Stone <daniels@collabora.com> Tested-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2015-11-30xwayland: Do not set root clip when rootlessOlivier Fourdan1-1/+3
Otherwise the server may try to draw onto the root window when closing down, but when running rootless the root window has no storage thus causing a memory corruption. Thanks to Adam Jackson <ajax@redhat.com> for helping tracking this down! Reviewed-by: Adam Jackson <ajax@redhat.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93045 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Tested-by: Marek Chalupa <mchqwerty@gmail.com>
2015-06-25xwayland: keep temp files out of the client maskChris Wilson1-1/+1
Xwayland opens anonymous files for its sharing buffers, move these file descriptors out of the range of the client select mask to avoid reaching the maximum number of clients prematurely. https://bugs.freedesktop.org/show_bug.cgi?id=91072 Tested-by: Olivier Fourdan <fourdan@gmail.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-04-03Xwayland DDXKristian Høgsberg1-0/+292
Started out as an Xorg module to be used from Xorg drivers to let Xorg run under a wayland server. The idea was to be able to reuse the 2D acceleration from the Xorg driver. Now with glamor being credible, a better plan is to just make Xwayland its own DDX, similar to Xwin and Xquartz. This is a much better fit, as much of the code in the original approach had to hack around Xorg doing Xorg things like take over the VT, probe input devices and read config files. Another big win is that Xwayland dosn't need to be setuid root. The Xwayland support for DRI3, Glamor and render nodes was done by Axel Davy <axel.davy@ens.fr>, who also did a lot of work on the rebase to the Xwayland DDX. Contributions from: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> Corentin Chary <corentin.chary@gmail.com> Daniel Stone <daniel@fooishbar.org> Kristian Høgsberg <krh@bitplanet.net> Robert Bragg <robert@linux.intel.com> Scott Moreau <oreaus@gmail.com> Tiago Vignatti <tiago.vignatti@intel.com> Giovanni Campagna <gcampagn@redhat.com> Jonas Ådahl <jadahl@gmail.com> Ray Strode <rstrode@redhat.com> Trevor McCort <tjmccort@gmail.com> Rui Matos <tiagomatos@gmail.com> Axel Davy <axel.davy@ens.fr> Jasper St. Pierre <jstpierre@mecheye.net> Signed-off-by: Kristian Høgsberg <krh@bitplanet.net> Reviewed-by: Axel Davy <axel.davy@ens.fr>