xserver: Branch 'server-1.20-branch' - 5 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 29 22:08:48 UTC 2019


 Xext/shm.c              |   68 +++++++++++++++++++++++++++++++-----------------
 configure.ac            |   47 +--------------------------------
 dix/events.c            |    2 +
 include/dix-config.h.in |    6 ++--
 include/meson.build     |    6 ----
 5 files changed, 53 insertions(+), 76 deletions(-)

New commits:
commit df1f8f691d7550a18d2076a44c109b1cb6da05ae
Author: Alexander Tsoy <alexander at tsoy.me>
Date:   Mon Sep 23 18:23:40 2019 +0300

    configure: Set libdrm flags correctly if only XORG is enabled
    
    This fixes modesetting driver build failure which can be triggered with
    the following configure options:
    
    $ ./configure --disable-dri --disable-dri2 --disable-dri3
    --disable-config-udev --enable-xorg
    
    Bugzilla: https://bugs.gentoo.org/689768
    Signed-off-by: Alexander Tsoy <alexander at tsoy.me>
    Reviewed-by: Emil Velikov <emil.velikov at collabora.com>
    (cherry picked from commit 334f1107146a2e6ebf6f7743b77aec2ad5c46f75)

diff --git a/configure.ac b/configure.ac
index 97a2aa0fc..cb9765a70 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1238,7 +1238,7 @@ esac
 
 AM_CONDITIONAL(DRI3, test "x$DRI3" = xyes)
 
-if test "x$DRI" = xyes || test "x$DRI2" = xyes || test "x$DRI3" = xyes || test "x$CONFIG_UDEV_KMS" = xyes; then
+if test "x$DRI" = xyes || test "x$DRI2" = xyes || test "x$DRI3" = xyes || test "x$CONFIG_UDEV_KMS" = xyes || test "x$XORG" = xyes; then
 	if test "x$DRM" = xyes; then
 		AC_DEFINE(WITH_LIBDRM, 1, [Building with libdrm support])
 		PKG_CHECK_MODULES([LIBDRM], $LIBDRM)
commit fada61e89dd1f20fe8e2e0fb9e4baefb45b4b848
Author: Matt Turner <mattst88 at gmail.com>
Date:   Fri Aug 9 20:22:29 2019 -0700

    dix: Assert noPanoramiXExtension is false in PanoramiX code
    
    When compiling with link time optimization, GCC thinks it's discovered
    undefined behavior:
    
    events.c: In function 'XineramaConfineCursorToWindow':
    events.c:609:13: warning: iteration 2147483647 invokes undefined behavior [-Waggressive-loop-optimizations]
    events.c:609:11: note: within this loop
    events.c:605:49: warning: array subscript -1 is below array bounds of 'struct _Window *[16]' [-Warray-bounds]
    events.c:606:31: warning: array subscript -1 is below array bounds of 'struct _Screen *[16]' [-Warray-bounds]
    events.c:610:39: warning: array subscript -2 is below array bounds of 'struct _Screen *[16]' [-Warray-bounds]
    events.c:617:38: warning: array subscript -2 is below array bounds of 'struct _Window *[16]' [-Warray-bounds]
    events.c:619:35: warning: array subscript -2 is below array bounds of 'struct _Screen *[16]' [-Warray-bounds]
    
    This results from
    
        i = PanoramiXNumScreens - 1;
    
        RegionCopy(&pSprite->Reg1, &pSprite->windows[i]->borderSize);
        off_x = screenInfo.screens[i]->x;
        off_y = screenInfo.screens[i]->y;
    
    where GCC believes that PanoramiXNumScreens might be 0. Unfortunately
    GCC is just smart enough to be an annoyance because this case is not
    actually possible: XineramaConfineCursorToWindow() is only called when
    noPanoramiXExtension is false, and if noPanoramiXExtension is false then
    PanoramiXNumScreens must be >1 (see PanoramiXExtensionInit()).
    
    So, add an assert(!noPanoramiXExtension), which to my surprise provides
    GCC with information even in release builds and lets GCC understand that
    the code is not doing anything that is undefined behavior.
    
    I chose this solution instead of the proposed assert(i >= 0) because the
    same pattern occurs in CheckVirtualMotion() but is inside an
    'if (!noPanoramiXExtension)' and does not generate any warnings.
    
    Fixes: xorg/xserver#590
    Signed-off-by: Matt Turner <mattst88 at gmail.com>
    (cherry picked from commit 61aa40aeb3d4efefda47f245ed4b83a1a19b1d4c)

diff --git a/dix/events.c b/dix/events.c
index d3a33ea3f..c02a0594a 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -597,6 +597,8 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
 
     int x, y, off_x, off_y, i;
 
+    assert(!noPanoramiXExtension);
+
     if (!XineramaSetWindowPntrs(pDev, pWin))
         return;
 
commit e815db543450c38d1d4ec03184b8e82fa0a37498
Author: Alexander Volkov <a.volkov at rusbitech.ru>
Date:   Mon Feb 11 18:54:10 2019 +0300

    shm: Use memfd_create when possible
    
    It doesn't require shared memory dir and thus allows
    to avoid cases when this dir is detected incorrectly,
    as in https://bugreports.qt.io/browse/QTBUG-71440
    
    Signed-off-by: Alexander Volkov <a.volkov at rusbitech.ru>
    (cherry picked from commit f6753c117ef0f83499d5e2d6dda226fec9ddf803)

diff --git a/Xext/shm.c b/Xext/shm.c
index 2739a59e7..506fd4df1 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -35,6 +35,9 @@ in this Software without prior written authorization from The Open Group.
 #include <sys/types.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
+#ifdef HAVE_MEMFD_CREATE
+#include <sys/mman.h>
+#endif
 #include <unistd.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -1201,6 +1204,15 @@ shm_tmpfile(void)
     };
     int	fd;
 
+#ifdef HAVE_MEMFD_CREATE
+    fd = memfd_create("xorg", MFD_CLOEXEC|MFD_ALLOW_SEALING);
+    if (fd != -1) {
+        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK);
+        DebugF ("Using memfd_create\n");
+        return fd;
+    }
+#endif
+
 #ifdef O_TMPFILE
     for (int i = 0; i < ARRAY_SIZE(shmdirs); i++) {
         fd = open(shmdirs[i], O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666);
diff --git a/configure.ac b/configure.ac
index 93587b500..97a2aa0fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -159,7 +159,7 @@ dnl Checks for library functions.
 AC_CHECK_FUNCS([backtrace geteuid getuid issetugid getresuid \
 	getdtablesize getifaddrs getpeereid getpeerucred getprogname getzoneid \
 	mmap posix_fallocate seteuid shmctl64 strncasecmp vasprintf vsnprintf \
-	walkcontext setitimer poll epoll_create1 mkostemp])
+	walkcontext setitimer poll epoll_create1 mkostemp memfd_create])
 AC_CONFIG_LIBOBJ_DIR([os])
 AC_REPLACE_FUNCS([reallocarray strcasecmp strcasestr strlcat strlcpy strndup\
 	timingsafe_memcmp])
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 197ed21d2..a9c0bf7fb 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -134,6 +134,9 @@
 /* Define to 1 if you have the <linux/fb.h> header file. */
 #undef HAVE_LINUX_FB_H
 
+/* Define to 1 if you have the `memfd_create' function. */
+#undef HAVE_MEMFD_CREATE
+
 /* Define to 1 if you have the `mkostemp' function. */
 #undef HAVE_MKOSTEMP
 
diff --git a/include/meson.build b/include/meson.build
index 1e2c7d9ef..536e01647 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -120,6 +120,7 @@ conf_data.set('HAVE_GETPEEREID', cc.has_function('getpeereid'))
 conf_data.set('HAVE_GETPEERUCRED', cc.has_function('getpeerucred'))
 conf_data.set('HAVE_GETPROGNAME', cc.has_function('getprogname'))
 conf_data.set('HAVE_GETZONEID', cc.has_function('getzoneid'))
+conf_data.set('HAVE_MEMFD_CREATE', cc.has_function('memfd_create'))
 conf_data.set('HAVE_MKOSTEMP', cc.has_function('mkostemp'))
 conf_data.set('HAVE_MMAP', cc.has_function('mmap'))
 conf_data.set('HAVE_POLL', cc.has_function('poll'))
commit 05c5b970136f0a11fffa16692744bdf5a23963e8
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Sep 19 13:28:06 2018 -0700

    shm: Pick the shm dir at run time, not build time.
    
    Prodding the builder's filesystem for tmp dirs doesn't necessarily
    tell you anything about what the actual host's filesystem is going to
    look like, so we should just try the dirs at runtime.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    (cherry picked from commit 19f6cb570becbc4e355807199c6e251fc7935132)

diff --git a/Xext/shm.c b/Xext/shm.c
index ed43b9202..2739a59e7 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -1194,36 +1194,46 @@ ProcShmAttachFd(ClientPtr client)
 static int
 shm_tmpfile(void)
 {
-#ifdef SHMDIR
+    const char *shmdirs[] = {
+        "/run/shm",
+        "/var/tmp",
+        "/tmp",
+    };
     int	fd;
-    char	template[] = SHMDIR "/shmfd-XXXXXX";
+
 #ifdef O_TMPFILE
-    fd = open(SHMDIR, O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666);
-    if (fd >= 0) {
-        DebugF ("Using O_TMPFILE\n");
-        return fd;
+    for (int i = 0; i < ARRAY_SIZE(shmdirs); i++) {
+        fd = open(shmdirs[i], O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666);
+        if (fd >= 0) {
+            DebugF ("Using O_TMPFILE\n");
+            return fd;
+        }
     }
     ErrorF ("Not using O_TMPFILE\n");
 #endif
+
+    for (int i = 0; i < ARRAY_SIZE(shmdirs); i++) {
+        char template[PATH_MAX];
+        snprintf(template, ARRAY_SIZE(template), "%s/shmfd-XXXXXX", shmdirs[i]);
 #ifdef HAVE_MKOSTEMP
-    fd = mkostemp(template, O_CLOEXEC);
+        fd = mkostemp(template, O_CLOEXEC);
 #else
-    fd = mkstemp(template);
+        fd = mkstemp(template);
 #endif
-    if (fd < 0)
-        return -1;
-    unlink(template);
+        if (fd < 0)
+            continue;
+        unlink(template);
 #ifndef HAVE_MKOSTEMP
-    int flags = fcntl(fd, F_GETFD);
-    if (flags != -1) {
-        flags |= FD_CLOEXEC;
-        (void) fcntl(fd, F_SETFD, &flags);
-    }
+        int flags = fcntl(fd, F_GETFD);
+        if (flags != -1) {
+            flags |= FD_CLOEXEC;
+            (void) fcntl(fd, F_SETFD, &flags);
+        }
 #endif
-    return fd;
-#else
+        return fd;
+    }
+
     return -1;
-#endif
 }
 
 static int
diff --git a/configure.ac b/configure.ac
index af16b0afb..93587b500 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1122,49 +1122,6 @@ case "$DRI2,$HAVE_DRI2PROTO" in
 esac
 AM_CONDITIONAL(DRI2, test "x$DRI2" = xyes)
 
-dnl
-dnl Locate a suitable tmp file system for creating shared memeory files
-dnl
-
-AC_ARG_WITH(shared-memory-dir, AS_HELP_STRING([--with-shared-memory-dir=PATH], [Path to directory in a world-writable temporary directory for anonymous shared memory (default: auto)]),
-[],
-[with_shared_memory_dir=yes])
-
-shmdirs="/run/shm /var/tmp /tmp"
-
-case x"$with_shared_memory_dir" in
-xyes)
-	for dir in $shmdirs; do
-		case x"$with_shared_memory_dir" in
-		xyes)
-			echo Checking temp dir "$dir"
-			if test -d "$dir"; then
-				with_shared_memory_dir="$dir"
-			fi
-			;;
-		esac
-	done
-	;;
-x/*)
-	;;
-xno)
-	;;
-*)
-	AC_MSG_ERROR([Invalid directory specified for --with-shared-memory-dir: $with_shared_memory_dir])
-	;;
-esac
-
-case x"$with_shared_memory_dir" in
-xyes)
-	AC_MSG_ERROR([No directory found for shared memory temp files.])
-	;;
-xno)
-	;;
-*)
-	AC_DEFINE_UNQUOTED(SHMDIR, ["$with_shared_memory_dir"], [Directory for shared memory temp files])
-	;;
-esac
-
 AC_ARG_ENABLE(xtrans-send-fds,	AS_HELP_STRING([--disable-xtrans-send-fds], [Use Xtrans support for fd passing (default: auto)]), [XTRANS_SEND_FDS=$enableval], [XTRANS_SEND_FDS=auto])
 
 case "x$XTRANS_SEND_FDS" in
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index c64321ef1..197ed21d2 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -458,9 +458,6 @@
 /* Wrap SIGBUS to catch MIT-SHM faults */
 #undef BUSFAULT
 
-/* Directory for shared memory temp files */
-#undef SHMDIR
-
 /* Don't let Xdefs.h define 'pointer' */
 #define _XTYPEDEF_POINTER       1
 
diff --git a/include/meson.build b/include/meson.build
index dfca3c340..1e2c7d9ef 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -70,11 +70,6 @@ conf_data.set('SYSTEMD_LOGIND', build_systemd_logind)
 conf_data.set('NEED_DBUS', build_systemd_logind or build_hal)
 conf_data.set('CONFIG_WSCONS', host_machine.system() == 'openbsd')
 
-# XXX: SHMDIR is weird in autoconf, probing the build system for
-# various tmp directories.  Could we replace it with C code at runtime
-# that just uses whatever directory works?
-conf_data.set_quoted('SHMDIR', '/tmp')
-
 conf_data.set('HAVE_XSHMFENCE', xshmfence_dep.found())
 conf_data.set('WITH_LIBDRM', libdrm_dep.found())
 conf_data.set('GLAMOR_HAS_EGL_QUERY_DMABUF',
commit 9ee4e35bfe084fa942c2b2ce46405e048eb335a8
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Sep 19 13:20:12 2018 -0700

    shm: reindent shm_tmpfile to follow our standards.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    (cherry picked from commit 804a9b4f57107fa2d0ed1ae0becda5bebaffe6e1)

diff --git a/Xext/shm.c b/Xext/shm.c
index 589ed0b4d..ed43b9202 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -1195,34 +1195,34 @@ static int
 shm_tmpfile(void)
 {
 #ifdef SHMDIR
-	int	fd;
-	char	template[] = SHMDIR "/shmfd-XXXXXX";
+    int	fd;
+    char	template[] = SHMDIR "/shmfd-XXXXXX";
 #ifdef O_TMPFILE
-	fd = open(SHMDIR, O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666);
-	if (fd >= 0) {
-		DebugF ("Using O_TMPFILE\n");
-		return fd;
-	}
-	ErrorF ("Not using O_TMPFILE\n");
+    fd = open(SHMDIR, O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666);
+    if (fd >= 0) {
+        DebugF ("Using O_TMPFILE\n");
+        return fd;
+    }
+    ErrorF ("Not using O_TMPFILE\n");
 #endif
 #ifdef HAVE_MKOSTEMP
-	fd = mkostemp(template, O_CLOEXEC);
+    fd = mkostemp(template, O_CLOEXEC);
 #else
-	fd = mkstemp(template);
+    fd = mkstemp(template);
 #endif
-	if (fd < 0)
-		return -1;
-	unlink(template);
+    if (fd < 0)
+        return -1;
+    unlink(template);
 #ifndef HAVE_MKOSTEMP
-	int flags = fcntl(fd, F_GETFD);
-	if (flags != -1) {
-		flags |= FD_CLOEXEC;
-		(void) fcntl(fd, F_SETFD, &flags);
-	}
+    int flags = fcntl(fd, F_GETFD);
+    if (flags != -1) {
+        flags |= FD_CLOEXEC;
+        (void) fcntl(fd, F_SETFD, &flags);
+    }
 #endif
-	return fd;
+    return fd;
 #else
-        return -1;
+    return -1;
 #endif
 }
 


More information about the xorg-commit mailing list