| a51d45b5 | 17-Dec-2021 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: mempool based raw malloc functions
Instead of the old stack like internal memory allocator, use the raw malloc functions instead for more efficient memory usage.
CFG_WITH_STATS is enabled
libutils: mempool based raw malloc functions
Instead of the old stack like internal memory allocator, use the raw malloc functions instead for more efficient memory usage.
CFG_WITH_STATS is enabled automatically if CFG_MEMPOOL_REPORT_LAST_OFFSET is enabled to secure a new dependency in the code.
Acked-by: Sahil Malhotra <sahil.malhotra@nxp.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 680bc37c | 17-Dec-2021 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: export raw malloc functions
Exports raw_{memalign,malloc,free,calloc,realloc}() and also adds raw_malloc_get_ctx_size(), raw_malloc_init_ctx(), raw_malloc_add_pool() and raw_malloc_get_sta
libutils: export raw malloc functions
Exports raw_{memalign,malloc,free,calloc,realloc}() and also adds raw_malloc_get_ctx_size(), raw_malloc_init_ctx(), raw_malloc_add_pool() and raw_malloc_get_stats().
This allows using the malloc functions to allocate with a independent memory pool.
Acked-by: Sahil Malhotra <sahil.malhotra@nxp.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b224894f | 21-Dec-2021 |
Sumit Garg <sumit.garg@linaro.org> |
libutils: provide __sprintf_chk implementation
While building optee_test CXX test-cases natively on aarch64, OP-TEE build relies on toolchain provided by buildroot. The buildroot toolchain is built
libutils: provide __sprintf_chk implementation
While building optee_test CXX test-cases natively on aarch64, OP-TEE build relies on toolchain provided by buildroot. The buildroot toolchain is built with flag: -fstack-protector-strong which requires __sprintf_chk symbol provided by standard glibc. For OP-TEE we use a customized libc which leads to below error:
... CC out/init.o CC out/os_test.o CC out/ta_entry.o CXX out/cxx_tests.o CC out/user_ta_header.o CPP out/ta.lds LD out/5b9e0e40-2636-11e1-ad9e-0002a5d5c51b.elf /home/sumit/optee_br/build/../toolchains/aarch64/bin/aarch64-linux-ld.bfd: /home/sumit/optee_br/toolchains/aarch64/bin/../lib/gcc/aarch64-buildroot-linux-gnu/10.3.0/../../../../aarch64-buildroot-linux-gnu/lib/../lib64/libstdc++.a(cp-demangle.o): in function d_append_num': cp-demangle.c:(.text+0x830): undefined reference to __sprintf_chk' ...
Fix this issue by providing __sprintf_chk implementation.
Signed-off-by: Sumit Garg <sumit.garg@linaro.org> Acked-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 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 ...
|
| 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 ...
|
| 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 ...
|
| 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 ...
|
| 17967299 | 28-Dec-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutil: add hdr_size parameter to bget
Adds a hdr_size parameter to bget(), bgetz() and bgetr(). hdr_size must be a multiple of BGET_HDR_QUANTUM. If hdr_size is larger than 0 the buffer will be all
libutil: add hdr_size parameter to bget
Adds a hdr_size parameter to bget(), bgetz() and bgetr(). hdr_size must be a multiple of BGET_HDR_QUANTUM. If hdr_size is larger than 0 the buffer will be allocated so that the alignment constraints are fulfilled after advancing hdr_size bytes into the returned buffer.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| cc5981b2 | 28-Dec-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutil: add alignment parameter to bget
Adds alignment parameter to bget(), bgetz() and bgetr(). If alignment is larger then 0 the returned buffer is guaranteed to have an address which is a multip
libutil: add alignment parameter to bget
Adds alignment parameter to bget(), bgetz() and bgetr(). If alignment is larger then 0 the returned buffer is guaranteed to have an address which is a multiple of this value.
The algorithm is basically unchanged, in the way that the memory is still allocated from the end of a free memory block. The difference is in the core implementation in bget() where now alignment of the returned memory is taken into account. If only allocating with the minimum alignment the memory blocks are expected to be allocated in the same pattern.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 9b0773cb | 11-Sep-2020 |
Jerome Forissier <jerome@forissier.org> |
libutils: fix memset(), memcpy(), memmove() with -O3
When libutils is built with optimization -O3 (make CFG_CC_OPT_LEVEL=3), memset() may cause infinite recursion. This bug was observed with GCC 8.3
libutils: fix memset(), memcpy(), memmove() with -O3
When libutils is built with optimization -O3 (make CFG_CC_OPT_LEVEL=3), memset() may cause infinite recursion. This bug was observed with GCC 8.3 with QEMUv8. The reason is, at this optimization level the compiler may decide to replace loops with calls to memset(), which is obviously not valid when the loop is in the memset function itself. This behavior can be turned off with -fno-tree-loop-distribute-patterns.
Therefore, add the appropriate build flag to memset.c. Note that a similar fix was introduced in upstream newlib [1] but since it depends on the newlib build script to detect compiler support, the patch is not directly applicable. Instead $(call cc-option,...) is used here.
Although I have not observed any issue with memcpy() and memmove(), upstream did apply the compiler flag to these functions too [1], [2], which seems quite reasonable so do the same here.
Link: [1] https://github.com/bminor/newlib/commit/10e4d79a191f07999bc94b21535fba5d7c04f419 Link: [2] https://github.com/bminor/newlib/commit/82dfae9ab0734b9946321590162dc6021057fec1 Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 405a5072 | 21-Jul-2020 |
Jerome Forissier <jerome@forissier.org> |
libutils: add simplified fputc(), fputs(), fwrite(), write()
Preparing for C++ support in TAs.
Adds a few <stdio.h> functions to libutils:
fputc() fputs() fwrite() write()
The proposed implem
libutils: add simplified fputc(), fputs(), fwrite(), write()
Preparing for C++ support in TAs.
Adds a few <stdio.h> functions to libutils:
fputc() fputs() fwrite() write()
The proposed implementations are limited in the sense that they only accept writing to stdout or stderr. The output goes directly to the secure console and no difference is made between stdout and stderr.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|