Mesa (main): add execmem build option

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 9 21:50:31 UTC 2021


Module: Mesa
Branch: main
Commit: df1a4e749f5205c0a73671f5e3b59062b85fa565
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=df1a4e749f5205c0a73671f5e3b59062b85fa565

Author: John Bates <jbates at chromium.org>
Date:   Tue May 25 13:21:40 2021 -0700

add execmem build option

The execmem option can be set to false to disable the dynamic
dispatch patching that requires mmap(PROT_WRITE | PROT_EXEC),
which is undesirable on some platforms.

Signed-off-by: John Bates <jbates at chromium.org>
Reviewed-by: Chia-I Wu <olvaffe at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10987>

---

 meson.build          | 7 +++++++
 meson_options.txt    | 8 +++++++-
 src/mapi/u_execmem.c | 5 +++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 6b041dac8f8..620ae7adc11 100644
--- a/meson.build
+++ b/meson.build
@@ -1805,10 +1805,17 @@ endif
 
 dep_selinux = null_dep
 if get_option('selinux')
+  if get_option('execmem') != true
+    warning('execmem option is disabled, selinux will not be able to use execmem.')
+  endif
   dep_selinux = dependency('libselinux')
   pre_args += '-DMESA_SELINUX'
 endif
 
+if get_option('execmem')
+  pre_args += '-DMESA_EXECMEM'
+endif
+
 _libunwind = get_option('libunwind')
 if _libunwind == 'true'
   _libunwind = 'enabled'
diff --git a/meson_options.txt b/meson_options.txt
index 11feb3f6763..84150789f3c 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -377,7 +377,13 @@ option(
   'selinux',
   type : 'boolean',
   value : false,
-  description : 'Build an SELinux-aware Mesa'
+  description : 'Build an SELinux-aware Mesa.  This currently disables execmem support at runtime unless SELinux is configured with allow_execmem.'
+)
+option(
+  'execmem',
+  type : 'boolean',
+  value : true,
+  description : 'Enable execmem support.  Without execmem, glapi will fail to generate dynamic glapi stubs when entrypoints unknown to glapi but known to DRI drivers are requested in eglGetProcAddress or glXGetProcAddress.  This should be enabled unless the platform can guarantee glapi and DRI drivers are always built from the same source tree.'
 )
 option(
   'osmesa',
diff --git a/src/mapi/u_execmem.c b/src/mapi/u_execmem.c
index d6e64c08886..2bb63d02b26 100644
--- a/src/mapi/u_execmem.c
+++ b/src/mapi/u_execmem.c
@@ -121,6 +121,10 @@ init_map(void)
 void *
 u_execmem_alloc(unsigned int size)
 {
+#ifndef MESA_EXECMEM
+   (void)size;
+   return NULL;
+#else
    void *addr = NULL;
 
    mtx_lock(&exec_mutex);
@@ -140,6 +144,7 @@ bail:
    mtx_unlock(&exec_mutex);
 
    return addr;
+#endif /* MESA_EXECMEM */
 }
 
 



More information about the mesa-commit mailing list