As reported by several people, mesa contains code that violates W^X.
As a result glxgears aborts when using the swrast driver. The diff
below disables the offending code. The code seems to deal the absence
of W|X memory just fine. There is a fallback path that is also used
on SELinux systems.
Note that the existing code would have worked just fine if mmap
returned MAP_FAILED for W^X violations instead of terminating the
program. Not entirely sure what the long-term plans are.
Index: src/gallium/auxiliary/rtasm/rtasm_execmem.c
===================================================================
RCS file: /cvs/xenocara/lib/mesa/src/gallium/auxiliary/rtasm/rtasm_execmem.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 rtasm_execmem.c
--- src/gallium/auxiliary/rtasm/rtasm_execmem.c 22 Nov 2015 02:43:24 -0000
1.1.1.1
+++ src/gallium/auxiliary/rtasm/rtasm_execmem.c 20 Jun 2016 20:08:37 -0000
@@ -69,6 +69,16 @@ static struct mem_block *exec_heap = NUL
static unsigned char *exec_mem = NULL;
+#ifdef __OpenBSD__
+
+static int
+init_heap(void)
+{
+ return 0;
+}
+
+#else
+
static int
init_heap(void)
{
@@ -82,6 +92,8 @@ init_heap(void)
return (exec_mem != MAP_FAILED);
}
+
+#endif
void *
Index: src/mapi/u_execmem.c
===================================================================
RCS file: /cvs/xenocara/lib/mesa/src/mapi/u_execmem.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 u_execmem.c
--- src/mapi/u_execmem.c 22 Nov 2015 02:45:44 -0000 1.1.1.1
+++ src/mapi/u_execmem.c 20 Jun 2016 20:08:39 -0000
@@ -45,8 +45,15 @@ static unsigned int head = 0;
static unsigned char *exec_mem = (unsigned char *)0;
+#if defined(__OpenBSD__)
-#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) ||
defined(__sun) || defined(__HAIKU__)
+static int
+init_map(void)
+{
+ return 0;
+}
+
+#elif defined(__linux__) || defined(_NetBSD__) || defined(__sun) ||
defined(__HAIKU__)
#include <unistd.h>
#include <sys/mman.h>
Index: src/mesa/main/execmem.c
===================================================================
RCS file: /cvs/xenocara/lib/mesa/src/mesa/main/execmem.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 execmem.c
--- src/mesa/main/execmem.c 22 Nov 2015 02:39:37 -0000 1.1.1.1
+++ src/mesa/main/execmem.c 20 Jun 2016 20:08:40 -0000
@@ -36,7 +36,15 @@
-#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) ||
defined(__sun) || defined(__HAIKU__)
+#if defined(__OpenBSD__)
+
+static int
+init_heap(void)
+{
+ return 0;
+}
+
+#elif defined(__linux__) || defined(_NetBSD__) || defined(__sun) ||
defined(__HAIKU__)
/*
* Allocate a large block of memory which can hold code then dole it out