| 1 | // SPDX-FileCopyrightText: 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-2.0-only |
| 4 | |
| 5 | #ifndef _LTTNG_UST_SIGBUS_H |
| 6 | #define _LTTNG_UST_SIGBUS_H |
| 7 | |
| 8 | #include <urcu/list.h> |
| 9 | #include <setjmp.h> |
| 10 | |
| 11 | struct lttng_ust_sigbus_range { |
| 12 | void *start; /* inclusive */ |
| 13 | void *end; /* exclusive */ |
| 14 | struct cds_list_head node; |
| 15 | }; |
| 16 | |
| 17 | struct lttng_ust_sigbus_state { |
| 18 | int jmp_ready; |
| 19 | struct cds_list_head head; /* struct lttng_ust_sigbus_range */ |
| 20 | sigjmp_buf sj_env; |
| 21 | }; |
| 22 | |
| 23 | /* |
| 24 | * Define the lttng_ust_sigbus_state TLS variable as initial-exec model |
| 25 | * to allow using it from the SIGBUS signal handler. This variable must |
| 26 | * be defined by the executable using DEFINE_LTTNG_UST_SIGBUS_STATE() |
| 27 | * rather than internally within liblttng-ust-ctl.so to ensure we don't |
| 28 | * contribute to reach glibc limits of pre-allocated TLS IE model space |
| 29 | * for shared objects. |
| 30 | */ |
| 31 | #define DEFINE_LTTNG_UST_SIGBUS_STATE() \ |
| 32 | __thread __attribute__((tls_model("initial-exec"))) struct lttng_ust_sigbus_state lttng_ust_sigbus_state |
| 33 | |
| 34 | extern __thread __attribute__((tls_model("initial-exec"))) struct lttng_ust_sigbus_state lttng_ust_sigbus_state; |
| 35 | |
| 36 | #endif /* _LTTNG_UST_SIGBUS_H */ |