libsel4: make thread-local ipc buffer optional
At the moment, the seL4 microkit does not setup TLS variable support. The workaround has been to `#define __thread` (blank) before including `<sel4/sel4.h>` in `<microkit.h>`, which causes issues if `<microkit.h>` is included *after* `<sel4/sel4.h>`, often with obscure linker errors to `__emutls_**` symbols. Instead we add a libsel4 config option that allows us to build it with __thread copied out. We introduce an LIBSEL4_THREAD_LOCAL macro in a similar way to the existing LIBSEL4_INLINE macro. Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
This commit is contained in:
parent
b5d53702d4
commit
b5cc70d753
4 changed files with 19 additions and 4 deletions
|
|
@ -44,6 +44,15 @@ config_string(
|
||||||
UNQUOTE
|
UNQUOTE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
config_option(
|
||||||
|
LibSel4UseThreadLocals
|
||||||
|
LIB_SEL4_USE_THREAD_LOCALS
|
||||||
|
"mark the __sel4_ipc_buffer variable as thread local using '__thread'. \
|
||||||
|
This requires thread local storage support and is useful if multiple \
|
||||||
|
threads share the same virtual address space."
|
||||||
|
DEFAULT ON
|
||||||
|
)
|
||||||
|
|
||||||
if(LibSel4StubsUseIPCBufferOnly)
|
if(LibSel4StubsUseIPCBufferOnly)
|
||||||
set(buffer "--buffer")
|
set(buffer "--buffer")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@
|
||||||
#include <sel4/types.h>
|
#include <sel4/types.h>
|
||||||
#include <sel4/syscalls.h>
|
#include <sel4/syscalls.h>
|
||||||
|
|
||||||
extern __thread seL4_IPCBuffer *__sel4_ipc_buffer;
|
extern LIBSEL4_THREAD_LOCAL seL4_IPCBuffer *__sel4_ipc_buffer;
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_INVOCATION_REPORT_ERROR_IPC
|
#ifdef CONFIG_KERNEL_INVOCATION_REPORT_ERROR_IPC
|
||||||
extern __thread char __sel4_print_error;
|
extern LIBSEL4_THREAD_LOCAL char __sel4_print_error;
|
||||||
|
|
||||||
LIBSEL4_INLINE_FUNC char *seL4_GetDebugError(void)
|
LIBSEL4_INLINE_FUNC char *seL4_GetDebugError(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,12 @@
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_LIB_SEL4_USE_THREAD_LOCALS)
|
||||||
|
#define LIBSEL4_THREAD_LOCAL __thread
|
||||||
|
#else
|
||||||
|
#define LIBSEL4_THREAD_LOCAL
|
||||||
|
#endif
|
||||||
|
|
||||||
/* _Static_assert() is a c11 feature. Since the kernel is currently compiled
|
/* _Static_assert() is a c11 feature. Since the kernel is currently compiled
|
||||||
* with c99, we have to emulate it. */
|
* with c99, we have to emulate it. */
|
||||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
#include <sel4/sel4.h>
|
#include <sel4/sel4.h>
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_INVOCATION_REPORT_ERROR_IPC
|
#ifdef CONFIG_KERNEL_INVOCATION_REPORT_ERROR_IPC
|
||||||
__thread char __sel4_print_error = CONFIG_LIB_SEL4_PRINT_INVOCATION_ERRORS;
|
LIBSEL4_THREAD_LOCAL char __sel4_print_error = CONFIG_LIB_SEL4_PRINT_INVOCATION_ERRORS;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Userland per-thread IPC buffer address **/
|
/** Userland per-thread IPC buffer address **/
|
||||||
__thread seL4_IPCBuffer *__sel4_ipc_buffer;
|
LIBSEL4_THREAD_LOCAL seL4_IPCBuffer *__sel4_ipc_buffer;
|
||||||
|
|
||||||
/** Consider moving bootinfo into libsel4_startup */
|
/** Consider moving bootinfo into libsel4_startup */
|
||||||
seL4_BootInfo *bootinfo;
|
seL4_BootInfo *bootinfo;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue