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@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10987>
This commit is contained in:
John Bates 2021-05-25 13:21:40 -07:00 committed by Marge Bot
parent 8b7ff78443
commit df1a4e749f
3 changed files with 19 additions and 1 deletions

View File

@ -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'

View File

@ -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',

View File

@ -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 */
}