| #
b13e4076 |
| 01-Apr-2025 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: add raw_malloc_flags()
Add raw_malloc_flags() as a counterpart to malloc_flags().
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier
libutils: add raw_malloc_flags()
Add raw_malloc_flags() as a counterpart to malloc_flags().
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| #
edc125c5 |
| 20-Jan-2025 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: add malloc_flags() and free_flags()
Add malloc_flags() and free_flags() for generic and flexible memory allocations based on a passed flags field.
Signed-off-by: Jens Wiklander <jens.wikl
libutils: add malloc_flags() and free_flags()
Add malloc_flags() and free_flags() for generic and flexible memory allocations based on a passed flags field.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| #
695be9d6 |
| 20-Jan-2025 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: refactor the MDBG malloc functions
Replace the MDBG malloc functions and macros with a new function __mdbg_alloc() handling all the memory allocations similar to mem_alloc(). The old MDBG
libutils: refactor the MDBG malloc functions
Replace the MDBG malloc functions and macros with a new function __mdbg_alloc() handling all the memory allocations similar to mem_alloc(). The old MDBG macros are replace by new macros calling __mdbg_alloc().
mem_alloc(), mem_alloc_unlocked(), and mem_free() are updated to handle configuration with and without MDBG, removing the all the ENABLE_MDBG ifdefs in the C file.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| #
f3d9bdee |
| 20-Jan-2025 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: add malloc_flags.h
Add malloc_flags.h defining flags to control how buffers are allocated. The flags will be used in later patches.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.or
libutils: add malloc_flags.h
Add malloc_flags.h defining flags to control how buffers are allocated. The flags will be used in later patches.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| #
8cd20f23 |
| 16-Aug-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: malloc.h: add nex_malloc_buffer_overlaps_heap()
Add the macros nex_malloc_buffer_overlaps_heap() and nex_malloc_buffer_is_within_alloced() as aliases for malloc_buffer_overlaps_heap() and
libutils: malloc.h: add nex_malloc_buffer_overlaps_heap()
Add the macros nex_malloc_buffer_overlaps_heap() and nex_malloc_buffer_is_within_alloced() as aliases for malloc_buffer_overlaps_heap() and malloc_buffer_is_within_alloced() when virtualization isn't enabled.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| #
a05577ea |
| 23-Nov-2023 |
Etienne Carriere <etienne.carriere@foss.st.com> |
tree wide: clarify PTA ABI
Explicitly describe the statistics PTA ABI using dedicated inline comments and moving struct pta_stats_ta and struct pta_stats_alloc from respectively tee_ta_manager.c and
tree wide: clarify PTA ABI
Explicitly describe the statistics PTA ABI using dedicated inline comments and moving struct pta_stats_ta and struct pta_stats_alloc from respectively tee_ta_manager.c and malloc.h to pta_stats.h header file.
For that purpose, define ALLOC_ID_* macros to identify each allocator one can query information from through the statistics PTA API.
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| #
2617f49f |
| 22-Nov-2023 |
Etienne Carriere <etienne.carriere@foss.st.com> |
tree wide: rename struct malloc_stats
Rename struct malloc_stats to struct pta_stats_alloc to prepare the creation of pta_stats.h header file that will define the whole statistics PTA API and ABI, l
tree wide: rename struct malloc_stats
Rename struct malloc_stats to struct pta_stats_alloc to prepare the creation of pta_stats.h header file that will define the whole statistics PTA API and ABI, located in libutee/include/ as already done for all other PTAs.
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| #
b76b2296 |
| 03-Feb-2023 |
Jerome Forissier <jerome.forissier@linaro.org> |
virt: rename CFG_VIRTUALIZATION to CFG_NS_VIRTUALIZATION
With the advent of virtualization support at S-EL2 in the Armv8.4-A architecture, CFG_VIRTUALIZATION has become ambiguous. Let's rename it to
virt: rename CFG_VIRTUALIZATION to CFG_NS_VIRTUALIZATION
With the advent of virtualization support at S-EL2 in the Armv8.4-A architecture, CFG_VIRTUALIZATION has become ambiguous. Let's rename it to CFG_NS_VIRTUALIZATION to indicate more clearly that it is about supporting virtualization on the non-secure side.
This commit is the result of the following command:
$ for f in $(git grep -l -w CFG_VIRTUALIZATION); do \ sed -i -e 's/CFG_VIRTUALIZATION/CFG_NS_VIRTUALIZATION/g' $f; \ done
...plus the compatibility line in mk/config.mk:
CFG_NS_VIRTUALIZATION ?= $(CFG_VIRTUALIZATION)
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Acked-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
show more ...
|
| #
12d739bd |
| 20-Dec-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: use raw_malloc_*() as more primitive bget wrappers
The malloc implementation is layered on top of BGET, where the raw_malloc_*() layer is the most primitive layer on top of BGET. This lay
libutils: use raw_malloc_*() as more primitive bget wrappers
The malloc implementation is layered on top of BGET, where the raw_malloc_*() layer is the most primitive layer on top of BGET. This layer is unlocked so it's up to the caller to handle eventual synchronization.
Until now this rule hasn't been followed completely by letting raw_malloc_get_stats() call gen_malloc_get_stats() and not the other way around. So fix this and also provide raw_malloc_buffer_overlaps_heap() and raw_malloc_buffer_is_within_alloced().
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
7eaed3a3 |
| 23-Nov-2022 |
Etienne Carriere <etienne.carriere@linaro.org> |
libutils: prefix system header guard with 2 underscore chars
Adds prefix "__" to standard header files implemented in libutils. This is applicable as these header guards macro are system macros. Thi
libutils: prefix system header guard with 2 underscore chars
Adds prefix "__" to standard header files implemented in libutils. This is applicable as these header guards macro are system macros. This change prevents conflicts with external component as faced with SCP-firmware [1] that implements wrapper headers with #include_next for assert.h and stdlib.h using ASSERT_H [2] and STDLIB_H [3] as header guards as in libutils.
Prior this change did stdint.h both define STDINT_H and _STDINT_H but guards only upon STDINT_H. This change removes STDINT_H.
Link: [1] https://github.com/ARM-software/SCP-firmware.git Link: [2] https://github.com/ARM-software/SCP-firmware/blob/v2.11.0/framework/include/assert.h#L8-L9 Link: [3] https://github.com/ARM-software/SCP-firmware/blob/v2.11.0/framework/include/stdlib.h#L8-L9 Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| #
bc8fe8c2 |
| 22-Nov-2022 |
Etienne Carriere <etienne.carriere@linaro.org> |
libutils: implement aligned_alloc()
Implements aligned_alloc() in bget_malloc.c based on memalign(). The implementation also covers when ENABLE_MDBG is enabled, that is when CFG_TEE_CORE_MALLOC_DEBU
libutils: implement aligned_alloc()
Implements aligned_alloc() in bget_malloc.c based on memalign(). The implementation also covers when ENABLE_MDBG is enabled, that is when CFG_TEE_CORE_MALLOC_DEBUG is enabled.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| #
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 ...
|
| #
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 ...
|
| #
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 ...
|
| #
8cd8a629 |
| 06-Feb-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
Remove memalign()
Removes the unused memalign() function. Usage of this function will cause severe fragmentation of the heap.
Another problem is with the implementation which is added on top of bge
Remove memalign()
Removes the unused memalign() function. Usage of this function will cause severe fragmentation of the heap.
Another problem is with the implementation which is added on top of bget while still depending heavily on internals of bget. The implementation was somewhat buggy since it can sometimes can cause: E/TC:0 0 assertion 'bn->prevfree == 0' failed at lib/libutils/isoc/bget_malloc.c :423 <create_free_block> E/TC:0 0 Panic at core/kernel/assert.c:28 <_assert_break>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
386fc264 |
| 05-Feb-2018 |
Volodymyr Babchuk <vlad.babchuk@gmail.com> |
bget_malloc: add nex_malloc pool
If virtualization enabled, this pool will be used to allocate memory for OP-TEE nexus needs. Without virtualization, generic malloc pool will be used.
Signed-off-by
bget_malloc: add nex_malloc pool
If virtualization enabled, this pool will be used to allocate memory for OP-TEE nexus needs. Without virtualization, generic malloc pool will be used.
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
741b437f |
| 05-Feb-2018 |
Volodymyr Babchuk <vlad.babchuk@gmail.com> |
bget_malloc: hold all malloc state in malloc_ctx structure
This patch moves all bget_malloc.c state into malloc_ctx structure. malloc_lock.c is removed because spinlock now is also stored in malloc_
bget_malloc: hold all malloc state in malloc_ctx structure
This patch moves all bget_malloc.c state into malloc_ctx structure. malloc_lock.c is removed because spinlock now is also stored in malloc_ctx.
Multiple malloc pools can be used now.
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
dc0f4ec2 |
| 16-May-2018 |
Etienne Carriere <etienne.carriere@st.com> |
Remove license notice from STMicroelectronics files
Since a while the source files license info are defined by SPDX identifiers. We can safely remove the verbose license text from the files that are
Remove license notice from STMicroelectronics files
Since a while the source files license info are defined by SPDX identifiers. We can safely remove the verbose license text from the files that are owned by either only STMicroelectronics or only both Linaro and STMicroelectronics.
Signed-off-by: Etienne Carriere <etienne.carriere@st.com> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
1bb92983 |
| 15-Dec-2017 |
Jerome Forissier <jerome.forissier@linaro.org> |
Add SPDX license identifiers
Adds one SPDX-License-Identifier line [1] to each source files that contains license text.
Generated by [2]: spdxify.py --add-spdx optee_os/
The scancode tool [3] wa
Add SPDX license identifiers
Adds one SPDX-License-Identifier line [1] to each source files that contains license text.
Generated by [2]: spdxify.py --add-spdx optee_os/
The scancode tool [3] was used to double check the license matching code in the Python script. All the licenses detected by scancode are either detected by spdxify.py, or have no SPDX identifier, or are false matches.
Link: [1] https://spdx.org/licenses/ Link: [2] https://github.com/jforissier/misc/blob/f7b56c8/spdxify.py Link: [3] https://github.com/nexB/scancode-toolkit Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Joakim Bech <joakim.bech@linaro.org>
show more ...
|
| #
82c9f597 |
| 11-Nov-2016 |
Volodymyr Babchuk <vlad.babchuk@gmail.com> |
malloc: use spinlock instead of mutex
Allocation functions are atomic (like linux kernel atomic context), so mutexes are overkill for them. This change will allow use to use allocator in atomic cont
malloc: use spinlock instead of mutex
Allocation functions are atomic (like linux kernel atomic context), so mutexes are overkill for them. This change will allow use to use allocator in atomic contexts like fast SMC calls or IRQ handlers.
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
52f8b816 |
| 01-Sep-2016 |
Jerome Forissier <jerome.forissier@linaro.org> |
core: add heap allocation failure statistics
Adds the following statistics to the heap allocator and export then via the static TA `core/arch/arm/sta/stats.c` (all of them can be reset):
- num_all
core: add heap allocation failure statistics
Adds the following statistics to the heap allocator and export then via the static TA `core/arch/arm/sta/stats.c` (all of them can be reset):
- num_alloc_fail: number of calls to malloc()/calloc()/realloc() that returned NULL - biggest_alloc_fail: the size in bytes of the largest allocation request that resulted in a failure - biggest_alloc_fail_used: the number of bytes that were allocated at that time
Depends on CFG_WITH_STATS=y.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
1d171f95 |
| 30-Aug-2016 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add support for kernel address sanitizer
Adds support for kernel address sanitizer. Currently only for plat-vexpress-qemu_virt.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Tes
core: add support for kernel address sanitizer
Adds support for kernel address sanitizer. Currently only for plat-vexpress-qemu_virt.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU v7) Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
945694b9 |
| 02-Dec-2015 |
Pascal Brand <pascal.brand@st.com> |
alloc: fix mutex usage
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Pascal Brand <pascal.brand@st.com>
|