Lines Matching +full:arm +full:- +full:linux +full:- +full:gnueabihf +full:-
1 // SPDX-License-Identifier: BSD-2-Clause
6 * Support for Thread-Local Storage (TLS) ABIs for ARMv7/Aarch32 and Aarch64.
8 * TAs are currently single-threaded, so the only benefit of implementing these
10 * single-threaded. Such as, the g++ compiler from the GCC toolchain targeting a
11 * "Posix thread" Linux runtime, which OP-TEE has been using for quite some time
12 * (arm-linux-gnueabihf-* and aarch64-linux-gnu-*). This allows building C++ TAs
13 * without having to build a specific toolchain with --disable-threads.
17 * - "TLS data structures variant 1" (section 3): the AArch64 compiler uses the
21 * - The "General Dynamic access model" (section 4.1): the ARMv7/Aarch32
31 * [1] "ELF Handling For Thread-Local Storage"
43 /* DTV - Dynamic Thread Vector
50 * tls[2 .. (size-1)] are for shared libraries
67 * plus some zero-initialized space for .tbss.
74 * change if multi-threading is introduced.
98 for (j = 0; j < dlpi->dlpi_phnum; j++) { in __utee_tcb_init()
99 phdr = dlpi->dlpi_phdr + j; in __utee_tcb_init()
100 if (phdr->p_type == PT_TLS) { in __utee_tcb_init()
101 total_size += phdr->p_memsz; in __utee_tcb_init()
113 /* (Re-)allocate the TCB */ in __utee_tcb_init()
120 /* (Re-)allocate the DTV. + 1 since dtv[0] holds the size */ in __utee_tcb_init()
122 _tcb->dtv = malloc_flags(MAF_ZERO_INIT, _tcb->dtv, 1, size); in __utee_tcb_init()
123 if (!_tcb->dtv) { in __utee_tcb_init()
132 for (j = 0; j < dlpi->dlpi_phnum; j++) { in __utee_tcb_init()
133 phdr = dlpi->dlpi_phdr + j; in __utee_tcb_init()
134 if (phdr->p_type != PT_TLS) in __utee_tcb_init()
136 if (size + phdr->p_memsz <= _tls_size) { in __utee_tcb_init()
140 _tcb->dtv[i + 1].tls = _tcb->tls + size; in __utee_tcb_init()
142 memcpy(_tcb->tls + size, in __utee_tcb_init()
143 (void *)(dlpi->dlpi_addr + phdr->p_vaddr), in __utee_tcb_init()
144 phdr->p_filesz); in __utee_tcb_init()
146 memset(_tcb->tls + size + phdr->p_filesz, 0, in __utee_tcb_init()
147 phdr->p_memsz - phdr->p_filesz); in __utee_tcb_init()
148 size += phdr->p_memsz; in __utee_tcb_init()
151 _tcb->dtv[0].size = i; in __utee_tcb_init()
172 return _tcb->dtv[ti->module].tls + ti->offset; in __tls_get_addr()
184 * dlpi_tls_data is thread-specific so if we were to support in dl_iterate_phdr()
185 * multi-threading, we would need one copy of struct dl_phdr_info per in dl_iterate_phdr()
186 * thread. Could be a pre-allocated area, or could be allocated on the in dl_iterate_phdr()
198 dlpi->dlpi_tls_data = NULL; in dl_iterate_phdr()
199 id = dlpi->dlpi_tls_modid; in dl_iterate_phdr()
201 dlpi->dlpi_tls_data = _tcb->dtv[id].tls; in dl_iterate_phdr()