| 30e743f6 | 13-Dec-2021 |
Ruchika Gupta <ruchika.gupta@linaro.org> |
lib: libutils: Use ret for longjmp with Clang and BTI
longjmp uses br instead of ret to jump to the target. Thus the target location should have the right BTI launchpad to handle this. clang has a b
lib: libutils: Use ret for longjmp with Clang and BTI
longjmp uses br instead of ret to jump to the target. Thus the target location should have the right BTI launchpad to handle this. clang has a bug [1] and doesn't add the BTI after setjmp causing exception when BTI is enabled. This works well with gcc [2] and can be tested when compiling xtests with WITH_CXX_TESTS=n. To avoid the exception, use ret instead of br with clang and BTI.
[1] - https://bugs.llvm.org/show_bug.cgi?id=49544 [2] - https://gcc.gnu.org/legacy-ml/gcc-patches/2018-11/msg02472.html
Signed-off-by: Ruchika Gupta <ruchika.gupta@linaro.org> Reviewed-by: Jerome Forissier <jerome@forissier.org>
show more ...
|
| 181f8492 | 06-Dec-2021 |
Ruchika Gupta <ruchika.gupta@linaro.org> |
Generate ELF Note for BTI in all arm64 asm files
Add program property note section in the assembly files to ensure that when linking them, program property note section is generated in the final ELF
Generate ELF Note for BTI in all arm64 asm files
Add program property note section in the assembly files to ensure that when linking them, program property note section is generated in the final ELF.
Signed-off-by: Ruchika Gupta <ruchika.gupta@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 7ad2713d | 19-Nov-2021 |
Ruchika Gupta <ruchika.gupta@linaro.org> |
Add BTI launch pads in aarch64 assembly files
Compiler adds BTI launchpads only in C source files. For assembly files, BTI launchpad is also required at locations where "br" is used and at the start
Add BTI launch pads in aarch64 assembly files
Compiler adds BTI launchpads only in C source files. For assembly files, BTI launchpad is also required at locations where "br" is used and at the start of the functions. This needs to be added manually.
Signed-off-by: Ruchika Gupta <ruchika.gupta@linaro.org> Reviewed-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 03bada66 | 19-Nov-2021 |
Ruchika Gupta <ruchika.gupta@linaro.org> |
libutils: asm.S : Introduce parameter _bti in FUNC's
There are few places where the original macros FUNC and LOCAL_FUNC are used to define vector tables or exception vector tables. To take care of s
libutils: asm.S : Introduce parameter _bti in FUNC's
There are few places where the original macros FUNC and LOCAL_FUNC are used to define vector tables or exception vector tables. To take care of such assembly code where BTI is not needed, introduce new parameter _bti. If the _bti passed to the function is not default, don't add BTI launchpad to the function.
Signed-off-by: Ruchika Gupta <ruchika.gupta@linaro.org> Reviewed-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| af432c48 | 02-Nov-2021 |
Ruchika Gupta <ruchika.gupta@linaro.org> |
libutils: asm.S : Introduce BTI in macros for functions
When the TEE core, TA's or user space libraries are built for BTI, add a BTI landing pad to the start of all functions, ensuring that they are
libutils: asm.S : Introduce BTI in macros for functions
When the TEE core, TA's or user space libraries are built for BTI, add a BTI landing pad to the start of all functions, ensuring that they are BTI safe.
Signed-off-by: Ruchika Gupta <ruchika.gupta@linaro.org> Reviewed-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| d31aa877 | 14-Dec-2021 |
Marouene Boubakri <marouene.boubakri@nxp.com> |
lib: libutils: trace.c: make print_core_id() architecture-independent
The function print_core_id() in is calling architecture-specific routines to retrieve the core id. It is more relevant to create
lib: libutils: trace.c: make print_core_id() architecture-independent
The function print_core_id() in is calling architecture-specific routines to retrieve the core id. It is more relevant to create a new abstract function trace_ext_get_core_id() in lib/libutee/trace_ext.c that needs to be implemented in the architecture-specific code. This is similar to print_thread_id() which calls trace_ext_get_thread_id() implemented in core/arch/arm/kernel/trace_ext.c
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 52c0b45c | 14-Dec-2021 |
Marouene Boubakri <marouene.boubakri@nxp.com> |
lib: libutils: ext: mempool.c: remove unused thread.h
This commit removes thread.h from lib/libutils/ext/mempool.c since it is not used, but also to eliminate the dependency between generic librarie
lib: libutils: ext: mempool.c: remove unused thread.h
This commit removes thread.h from lib/libutils/ext/mempool.c since it is not used, but also to eliminate the dependency between generic libraries code and architecture-specific core functions.
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 72b4db64 | 08-Dec-2021 |
Jerome Forissier <jerome@forissier.org> |
libutils: trace: support more than 100 threads and cores
Add code to support printing thread and core number on 3 digits when needed.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed
libutils: trace: support more than 100 threads and cores
Add code to support printing thread and core number on 3 digits when needed.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 6327913c | 08-Dec-2021 |
Jerome Forissier <jerome@forissier.org> |
libutils: trace: fix off-by-one when switching to 2 digits for thread id
Threads are numbered starting from zero so when CFG_NUM_THREADS == 10 the number still fits on one digit. Fix the conditional
libutils: trace: fix off-by-one when switching to 2 digits for thread id
Threads are numbered starting from zero so when CFG_NUM_THREADS == 10 the number still fits on one digit. Fix the conditional in print_thread_id().
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| a4909c0d | 10-Dec-2021 |
Jerome Forissier <jerome@forissier.org> |
libutils: qsort.c: fix undefined pointer subtraction
Clang 13.0.0 produces the following warning:
lib/libutils/isoc/qsort.c:81:8: warning: performing pointer subtraction with a null pointer has un
libutils: qsort.c: fix undefined pointer subtraction
Clang 13.0.0 produces the following warning:
lib/libutils/isoc/qsort.c:81:8: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction] loop: SWAPINIT(a, es); ^~~~~~~~~~~~~~~ lib/libutils/isoc/qsort.c:50:47: note: expanded from macro 'SWAPINIT' #define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) ^ ~~~~~~~~~
Replace the subtraction with a simple cast to uintptr_t.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 1b4b9334 | 15-Jun-2021 |
Clément Léger <clement.leger@bootlin.com> |
ext: include: add DIV_ROUND_UP function
Export DIV_ROUND_UP from mbedtls files to be used by clock drivers.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Clément Léger
ext: include: add DIV_ROUND_UP function
Export DIV_ROUND_UP from mbedtls files to be used by clock drivers.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
show more ...
|
| be501eb1 | 05-Oct-2021 |
Jorge Ramirez-Ortiz <jorge@foundries.io> |
util: rename ALIGNMENT_IS_OK to IS_ALIGNED_WITH_TYPE
Implement the renamed macro using the IS_ALIGNED definition.
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io> Reviewed-by: Etienne Carrie
util: rename ALIGNMENT_IS_OK to IS_ALIGNED_WITH_TYPE
Implement the renamed macro using the IS_ALIGNED definition.
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 6d777f26 | 05-Oct-2021 |
Jorge Ramirez-Ortiz <jorge@foundries.io> |
util: define IS_ALIGNED macro
Keep a single version of the macro definition.
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Revi
util: define IS_ALIGNED macro
Keep a single version of the macro definition.
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| eacabbbc | 23-Sep-2021 |
Jerome Forissier <jerome@forissier.org> |
libutils: ta: provide malloc(), calloc() and realloc() when debug is on
When enabling malloc debug for TAs (CFG_TEE_TA_MALLOC_DEBUG=y), the standard malloc entry points malloc(), calloc() and reallo
libutils: ta: provide malloc(), calloc() and realloc() when debug is on
When enabling malloc debug for TAs (CFG_TEE_TA_MALLOC_DEBUG=y), the standard malloc entry points malloc(), calloc() and realloc() are redirected by C macros to instrumented variants: mdbg_malloc(), mdbg_calloc() and mdbg_realloc(). In addition, the 'normal' symbols are not exported by libutils. That is a problem because a TA might still reference them. For example the C++ code in optee_test requires libstdc++ which relies on malloc() etc.:
build (master)$ make -j10 CFG_TEE_TA_MALLOC_DEBUG=y CFG_TEE_TA_LOG_LEVEL=2 ... /home/jerome/work/optee_repo_qemu/build/../toolchains/aarch32/bin/arm-linux-gnueabihf-ld.bfd: /home/jerome/work/toolchains-gcc10.2/aarch32/bin/../lib/gcc/arm-none-linux-gnueabihf/10.2.1/../../../../arm-none-linux-gnueabihf/lib/libstdc++.a(eh_alloc.o): in function `__cxa_allocate_exception': /tmp/dgboter/bbs/build03--cen7x86_64/buildbot/cen7x86_64--arm-none-linux-gnueabihf/build/src/gcc/libstdc++-v3/libsupc++/eh_alloc.cc:284: undefined reference to `malloc' ...
Fix the issue by defining the standard malloc() functions in libutils, calling the debug variants.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| c46bd3e1 | 14-Sep-2021 |
Etienne Carriere <etienne.carriere@linaro.org> |
libutils: bget_malloc: fix test in pool min size
Requires at least 1 kB for the initial malloc memory pool. The rational is that the initial pool min size is not straightforward to compute as it dep
libutils: bget_malloc: fix test in pool min size
Requires at least 1 kB for the initial malloc memory pool. The rational is that the initial pool min size is not straightforward to compute as it depends on the internals of the BGET implementation. However, with a requirement of at least 1 kB in initial memory pool we'll have good margin while still being reasonable.
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| e2c577ca | 12-May-2021 |
Jens Wiklander <jens.wiklander@linaro.org> |
compiler.h: add __rodata_dummy macro
Adds the macro __rodata_dummy which places a symbol in the section ".rodata.dummy". This macro is intended to be used in the core/arch/arm/kernel/link_dummies_*.
compiler.h: add __rodata_dummy macro
Adds the macro __rodata_dummy which places a symbol in the section ".rodata.dummy". This macro is intended to be used in the core/arch/arm/kernel/link_dummies_*.c files.
Reviewed-by: Jerome Forissier <jerome@forissier.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 27c64925 | 12-May-2021 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: use separate sections for each __rodata_unpaged variable
Adds a mandatory argument to the macro __rodata_unpaged() to take the name of the variable to put in the unpaged rodata section. This w
core: use separate sections for each __rodata_unpaged variable
Adds a mandatory argument to the macro __rodata_unpaged() to take the name of the variable to put in the unpaged rodata section. This will result in separate sections for each such variable and make it easier to debug the pruning of the dependency tree for unpaged sections.
Reviewed-by: Jerome Forissier <jerome@forissier.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 53154de7 | 03-Jun-2021 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: fix range check in gen_malloc_add_pool()
Prior to this patch was the length of supplied buffer not checked accurately for very small buffer. This could result in an unexpected assert(): E/
libutils: fix range check in gen_malloc_add_pool()
Prior to this patch was the length of supplied buffer not checked accurately for very small buffer. This could result in an unexpected assert(): E/TC:0 0 assertion 'start < end' failed at lib/libutils/isoc/bget_malloc.c:775 <gen_malloc_add_pool> E/TC:0 0 Panic at core/kernel/assert.c:28 <_assert_break>
So fix this with a proper test.
Reviewed-by: Jerome Forissier <jerome@forissier.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b5fed9f7 | 03-May-2021 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: sys/queue.h: add SLIST_FOREACH_SAFE()
Import macro SLIST_FOREACH_SAFE from FreeBSD.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Acked-by: Jerome Forissier <jerome@forissie
libutils: sys/queue.h: add SLIST_FOREACH_SAFE()
Import macro SLIST_FOREACH_SAFE from FreeBSD.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Acked-by: Jerome Forissier <jerome@forissier.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| c6e827c0 | 25-Feb-2021 |
Jens Wiklander <jens.wiklander@linaro.org> |
Rename to barrier_read_counter_timer()
Renames barrier_read_cntpct() to barrier_read_counter_timer() to use a neutral name for the counter.
With SPMC at S-EL2 OP-TEE will be virtualized and must us
Rename to barrier_read_counter_timer()
Renames barrier_read_cntpct() to barrier_read_counter_timer() to use a neutral name for the counter.
With SPMC at S-EL2 OP-TEE will be virtualized and must use CNTVCT instead of CNTPCT while the old physical OP-TEE must continue to use CNTPCT.
Reviewed-by: Jerome Forissier <jerome@forissier.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 44a8a0cf | 22-Apr-2021 |
Jerome Forissier <jerome@forissier.org> |
libutils: asm.S: introduce WEAK_FUNC
Adds a WEAK_FUNC macro which does the same as FUNC but defines a weak symbol rather than a global one.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Re
libutils: asm.S: introduce WEAK_FUNC
Adds a WEAK_FUNC macro which does the same as FUNC but defines a weak symbol rather than a global one.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 914103c1 | 22-Apr-2021 |
Jerome Forissier <jerome@forissier.org> |
libutils: asm.S: reorder macro definitions
Define function macros first, then data macros. No functional change.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Etienne Carriere
libutils: asm.S: reorder macro definitions
Define function macros first, then data macros. No functional change.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 82dfa933 | 22-Jan-2021 |
Ruchika Gupta <ruchika.gupta@linaro.org> |
libutils: sys/queue.h: add LIST_FOREACH_SAFE()
Import macro LIST_FOREACH_SAFE from FreeBSD.
Signed-off-by: Ruchika Gupta <ruchika.gupta@linaro.org> Reviewed-by: Rouven Czerwinski <r.czerwinski@peng
libutils: sys/queue.h: add LIST_FOREACH_SAFE()
Import macro LIST_FOREACH_SAFE from FreeBSD.
Signed-off-by: Ruchika Gupta <ruchika.gupta@linaro.org> Reviewed-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 1d85a26e | 21-Jan-2021 |
Marouene Boubakri <marouene.boubakri@nxp.com> |
lib: libutils: ext/isoc: sub.mk: make sources path platform generic
The path to platform specific code is hard-coded. This commit changes it to use defined variable. This is helpful in case of porti
lib: libutils: ext/isoc: sub.mk: make sources path platform generic
The path to platform specific code is hard-coded. This commit changes it to use defined variable. This is helpful in case of porting OP-TEE OS to a new architecture such we make maximum reuse of existing sources.
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome@forissier.org>
show more ...
|
| 3f286c3b | 28-Dec-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
Reintroduce memalign() and friends
memalign() and friends where removed with the commit 8cd8a6296974 ("Remove memalign()").
At the time memalign() was unused and a bit buggy. This new memalign() is
Reintroduce memalign() and friends
memalign() and friends where removed with the commit 8cd8a6296974 ("Remove memalign()").
At the time memalign() was unused and a bit buggy. This new memalign() is believed to work correctly due to extensive testing. Recently memalign() has been needed by certain drivers so it makes sense to add it again.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|