From bc57635a82b91937317d89bde21700431b20f862 Mon Sep 17 00:00:00 2001 From: Julia Vassiliki Date: Fri, 13 Feb 2026 11:00:12 +1100 Subject: [PATCH] use LibSel4UseThreadLocals to disable TLS ipcbuf See the motivation in the commit libsel4: make thread-local ipc buffer optional in seL4 which adds this option. Signed-off-by: Julia Vassiliki --- build_sdk.py | 7 +++++++ libmicrokit/include/microkit.h | 1 - libmicrokit/src/dbg.c | 1 - libmicrokit/src/main.c | 1 - monitor/src/main.c | 21 --------------------- 5 files changed, 7 insertions(+), 24 deletions(-) diff --git a/build_sdk.py b/build_sdk.py index 346932f86..3b560e7dc 100644 --- a/build_sdk.py +++ b/build_sdk.py @@ -45,6 +45,13 @@ DEFAULT_KERNEL_OPTIONS = { "KernelIsMCS": True, "KernelRootCNodeSizeBits": "17", + # Thread local storage is painful and annoying to configure. + # We'd really rather NOT use thread local storage (especially + # consider we never have more than one thread in a Vspace) + # + # Turning off this feature removes the __thread attribute on + # __sel4_ipc_buffer and makes it a true global. + "LibSel4UseThreadLocals": False, } DEFAULT_KERNEL_OPTIONS_AARCH64 = { diff --git a/libmicrokit/include/microkit.h b/libmicrokit/include/microkit.h index db43ff99a..90155d21e 100644 --- a/libmicrokit/include/microkit.h +++ b/libmicrokit/include/microkit.h @@ -9,7 +9,6 @@ #pragma once -#define __thread #include typedef unsigned int microkit_channel; diff --git a/libmicrokit/src/dbg.c b/libmicrokit/src/dbg.c index 298b3c12c..60090e42b 100644 --- a/libmicrokit/src/dbg.c +++ b/libmicrokit/src/dbg.c @@ -5,7 +5,6 @@ */ #include -#define __thread #include void microkit_dbg_putc(int c) diff --git a/libmicrokit/src/main.c b/libmicrokit/src/main.c index c533bb0c5..cff14f642 100644 --- a/libmicrokit/src/main.c +++ b/libmicrokit/src/main.c @@ -7,7 +7,6 @@ #include #include -#define __thread #include #include diff --git a/monitor/src/main.c b/monitor/src/main.c index b2ff8019a..2adb47a5f 100644 --- a/monitor/src/main.c +++ b/monitor/src/main.c @@ -12,27 +12,6 @@ * Acting as the fault handler for protection domains. */ -/* - * Why this you may ask? Well, the seL4 headers depend on - * a global `__sel4_ipc_buffer` which is a pointer to the - * thread's IPC buffer. Which is reasonable enough, passing - * that explicitly to every function would be annoying. - * - * The seL4 headers make this global a thread-local global, - * which is also reasonable, considering it applies to a - * specific thread! But, for our purposes we don't have threads! - * - * Thread local storage is painful and annoying to configure. - * We'd really rather NOT use thread local storage (especially - * consider we never have more than one thread in a Vspace) - * - * So, by defining __thread to be empty it means the variable - * becomes a true global rather than thread local storage - * variable, which means, we don't need to waste a bunch - * of effort and complexity on thread local storage implementation. - */ -#define __thread - #include #include #include