From df1a4e749f5205c0a73671f5e3b59062b85fa565 Mon Sep 17 00:00:00 2001 From: John Bates Date: Tue, 25 May 2021 13:21:40 -0700 Subject: [PATCH] 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 Reviewed-by: Chia-I Wu Part-of: --- 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 6b041dac8f874..620ae7adc1105 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 11feb3f6763bd..84150789f3ce0 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 d6e64c08886cd..2bb63d02b269b 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 */ }