| 8fd4cad1 | 17-Dec-2024 |
Etienne Carriere <etienne.carriere@foss.st.com> |
libutils: util.h: fix DIV_ROUND_UP() inline description
Remove trailing space char in inline description comment of DIV_ROUND_UP() macro.
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.c
libutils: util.h: fix DIV_ROUND_UP() inline description
Remove trailing space char in inline description comment of DIV_ROUND_UP() macro.
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| fa418fcd | 18-Dec-2024 |
Etienne Carriere <etienne.carriere@foss.st.com> |
libutils: util.h: Relax ROUNDDOWN() and add ROUNDDOWN2()
Remove constraint on ROUNDDOWN() to have its size argument being a power of 2 and add new ROUNDDOWN2() macro with that constraint.
The previ
libutils: util.h: Relax ROUNDDOWN() and add ROUNDDOWN2()
Remove constraint on ROUNDDOWN() to have its size argument being a power of 2 and add new ROUNDDOWN2() macro with that constraint.
The previous implementation of ROUNDDOWN(), optimized for when size argument is a power of 2, is now used for ROUNDDOWN2() but this latter also asserts (in debug build mode) that the size argument conforms to this condition.
The new implementation of ROUNDDOWN() is less optimal but modern compilers produce the same optimized assembly code with this macro when the size argument is a constant value known from the compiler so all use of ROUNDDOWN() with a known constant value do not need move to ROUNDDOWN2().
Performance sensitive routines should now on use ROUNDDOWN2() to leverage the power-of-2 rounding optimization.
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 8132f3be | 18-Dec-2024 |
Etienne Carriere <etienne.carriere@foss.st.com> |
libutils: util.h: Relax ROUNDUP() and add ROUNDUP2()
Remove constraint on ROUNDUP() to have its size argument being a power of 2 and add new ROUNDUP2() macro with that constraint.
The previous impl
libutils: util.h: Relax ROUNDUP() and add ROUNDUP2()
Remove constraint on ROUNDUP() to have its size argument being a power of 2 and add new ROUNDUP2() macro with that constraint.
The previous implementation of ROUNDUP(), optimized for when size argument is a power of 2, is now used for ROUNDUP2() but this latter also asserts (in debug build mode) that the size argument conforms to this condition.
The new implementation of ROUNDUP() is less optimal but modern compilers produce the same optimized assembly code with this macro when the size argument is a constant value known from the compiler so all use of ROUNDUP() with a known constant value do not need move to ROUNDUP2().
Performance sensitive routines should now on use ROUNDUP2() to leverage the power-of-2 rounding optimization.
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| c98faf4d | 18-Dec-2024 |
Etienne Carriere <etienne.carriere@foss.st.com> |
libutils: util.h: Relax ROUNDUP_OVERFLOW() and add ROUNDUP2_OVERFLOW()
Remove constraint on ROUNDUP_OVERFLOW() to have its size argument being a power of 2 and add new ROUNDUP2_OVERFLOW() macro with
libutils: util.h: Relax ROUNDUP_OVERFLOW() and add ROUNDUP2_OVERFLOW()
Remove constraint on ROUNDUP_OVERFLOW() to have its size argument being a power of 2 and add new ROUNDUP2_OVERFLOW() macro with that constraint.
The previous implementation of ROUNDUP_OVERFLOW(), optimized for when size argument is a power of 2, is now used for ROUNDUP2_OVERFLOW() but this latter also asserts (in debug build mode) that the size argument conforms to this condition.
Performance sensitive routines should now on use ROUNDUP2_OVERFLOW() to leverage the power-of-2 rounding optimization.
The new implementation of ROUNDUP_OVERFLOW() is less optimal but modern compilers produce the same optimized assembly code with this macro when the size argument is a constant value known from the compiler so all use of ROUNDUP_OVERFLOW() with a known constant value do not need move to ROUNDUP2_OVERFLOW().
By the way, fix the indentation in the macro implementation for consistency of the header file implementation and extend the inline description comment.
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 4879d4c0 | 16-Dec-2024 |
Etienne Carriere <etienne.carriere@foss.st.com> |
libutils: util.h: Relax ROUNDUP_DIV() and add ROUNDUP2_DIV()
Remove constraint on ROUNDUP_DIV() to have its size argument being a power of 2 and add new ROUNDUP2_DIV() macro with that constraint.
T
libutils: util.h: Relax ROUNDUP_DIV() and add ROUNDUP2_DIV()
Remove constraint on ROUNDUP_DIV() to have its size argument being a power of 2 and add new ROUNDUP2_DIV() macro with that constraint.
The previous implementation of ROUNDUP_DIV(), optimized for when size argument is a power of 2, is now used for ROUNDUP2_DIV() but this latter also asserts (in debug build mode) that the size argument conforms to this condition.
Performance sensitive routines should now on use ROUNDUP2_DIV() to leverage the power-of-2 rounding optimization.
The new implementation of ROUNDUP_DIV() is less optimal but modern compilers produce the same optimized assembly code with this macro when the size argument is a constant value known from the compiler so all use of ROUNDUP_DIV() with a known constant value do not need move to ROUNDUP2_DIV().
By the way, fix the indentation in the macro implementation for consistency of the header file implementation.
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| fd0b115a | 16-Dec-2024 |
Etienne Carriere <etienne.carriere@foss.st.com> |
libutils: util.h: fix ROUND*() macros description argument constraint
Correct inline description comment for ROUNDUP(), ROUNDUP_OVERFLOW(), ROUNDDOWN() where the second argument is expected to be a
libutils: util.h: fix ROUND*() macros description argument constraint
Correct inline description comment for ROUNDUP(), ROUNDUP_OVERFLOW(), ROUNDDOWN() where the second argument is expected to be a power of 2, not a multiple of 2.
Add an inline description comment to ROUNDUP_OVERFLOW() to state this requirement.
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 99627206 | 09-Nov-2024 |
Vincent Mailhol <mailhol.vincent@wanadoo.fr> |
compiler.h: only use __no_stack_protector if supported by the compiler
The __attribute__((no_stack_protector)) was introduced in GCC 11. Building a TA with a version of GCC older than that would tri
compiler.h: only use __no_stack_protector if supported by the compiler
The __attribute__((no_stack_protector)) was introduced in GCC 11. Building a TA with a version of GCC older than that would trigger a -Wattributes warning on the ta/user_ta_header.c file.
Use __has_attribute() to check support of the no_stack_protector attribute before using it. If not supported, define the __no_stack_protector alias as a NOP.
Fixes: e3fb2bd005f0 ("compiler.h: add __no_stack_protector") Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| e3fb2bd0 | 20-Sep-2024 |
Jerome Forissier <jerome.forissier@linaro.org> |
compiler.h: add __no_stack_protector
Add the __no_stack_protector macro as an alias for __attribute__((no_stack_protector)), which prevents the generation by the compiler of the stack protection cod
compiler.h: add __no_stack_protector
Add the __no_stack_protector macro as an alias for __attribute__((no_stack_protector)), which prevents the generation by the compiler of the stack protection code.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Khoa Hoang <admin@khoahoang.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 ...
|
| 88824fa4 | 20-Aug-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: add PADDR_MAX and PADDR_SIZE_MAX
Add defines for the maximum values of paddr_t and paddr_size_t.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <j
libutils: add PADDR_MAX and PADDR_SIZE_MAX
Add defines for the maximum values of paddr_t and paddr_size_t.
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 ...
|
| 81d5a9d5 | 26-Aug-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
Move base64.{c,h} from libutee to libutils
Make the base64 routines publicly available by moving them from libutee to libutils. The _ prefix is removed from the public functions since they aren't in
Move base64.{c,h} from libutee to libutils
Make the base64 routines publicly available by moving them from libutee to libutils. The _ prefix is removed from the public functions since they aren't internal to libutee any longer.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
show more ...
|
| 136db985 | 05-May-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: add array helpers
Add helper function() to insert and remove an element from an array. The helper functions shifts the elements in the array as needed to make room or fill a room of an ele
libutils: add array helpers
Add helper function() to insert and remove an element from an array. The helper functions shifts the elements in the array as needed to make room or fill a room of an element at a certain position.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
show more ...
|
| fa4b4621 | 12-Jul-2024 |
Etienne Carriere <etienne.carriere@foss.st.com> |
libutils: qsort helper for standard types
Add qsort_int(), qsort_uint(), qsort_u32() and friends as qsort() helper functions to sort standard typed arrays.
Signed-off-by: Etienne Carriere <etienne.
libutils: qsort helper for standard types
Add qsort_int(), qsort_uint(), qsort_u32() and friends as qsort() helper functions to sort standard typed arrays.
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| dcf343a2 | 05-Jul-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
arm32: ftrace: skip profiling of __aeabi functions
When compiling the __aeabi functions, skip profiling unconditionally to avoid recursive calls.
Reported-by: Jerome Forissier <jerome.forissier@lin
arm32: ftrace: skip profiling of __aeabi functions
When compiling the __aeabi functions, skip profiling unconditionally to avoid recursive calls.
Reported-by: Jerome Forissier <jerome.forissier@linaro.org> Closes: https://github.com/OP-TEE/optee_os/issues/6870 Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (vexpress-qemu_virt)
show more ...
|
| 47d5e6cb | 14-Jun-2024 |
Jerome Forissier <jerome.forissier@linaro.org> |
libutils, zlib: fix Clang warnings
Clang 18.1.6 reports the following warnings:
CC out/arm/ldelf-lib/libutils/isoc/bget_malloc.o In file included from lib/libutils/isoc/bget_malloc.c:127:
libutils, zlib: fix Clang warnings
Clang 18.1.6 reports the following warnings:
CC out/arm/ldelf-lib/libutils/isoc/bget_malloc.o In file included from lib/libutils/isoc/bget_malloc.c:127: lib/libutils/isoc/bget.c:607:7: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype] 607 | void *bget(requested_align, hdr_size, requested_size, poolset) | ^
And same with lib/zlib/{adler32.c,inffast.c,inflate.c,zutil.c}.
In addition, zutil.c causes:
CC out/arm/core/lib/zlib/zutil.o core/lib/zlib/zutil.c:28:33: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes] 28 | const char * ZEXPORT zlibVersion() | ^ | void
Add -Wno-deprecated-non-prototype to libutils' bget_malloc.c to silence the first series, and simply remove -Wstrict-prototypes (added by default by mk/compile.mk) when building zlib.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Joakim Bech <joakim.bech@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 5b6f4be8 | 28-May-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: compiler friendly 32-bit FTMN_FUNC_HASH() version
Add a more compiler friendly 32-bit implementation of FTMN_FUNC_HASH(). This gives the same output as the previous 64-bit based implementation
core: compiler friendly 32-bit FTMN_FUNC_HASH() version
Add a more compiler friendly 32-bit implementation of FTMN_FUNC_HASH(). This gives the same output as the previous 64-bit based implementation, but base the computation on 32-bit values.
This patch reduces stack usage when compiling with arm-linux-gnueabihf-gcc version 11.3.1 using -O0 optimization. For example, sw_crypto_acipher_rsassa_verify() is reduced from 3616 bytes to 284 bytes.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (vexpress-qemu_virt)
show more ...
|
| e716d498 | 10-Apr-2024 |
Tony Han <tony.han@microchip.com> |
libutils: util.h: fix the GENMASK_32(h, l) macro
The macro has a problem when it is used in an assembly file: .e.g ".word GENMASK_32(15, 8)" will be compiled to ".word 0xffffff00"
The issue is caus
libutils: util.h: fix the GENMASK_32(h, l) macro
The macro has a problem when it is used in an assembly file: .e.g ".word GENMASK_32(15, 8)" will be compiled to ".word 0xffffff00"
The issue is caused by the compiler always treating ~0 as a 64-bit value. Fix it by replacing '~UINT32_C(0)' with 'UINT32_C(0xffffffff)'.
Signed-off-by: Tony Han <tony.han@microchip.com> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| f459d3c7 | 21-Feb-2024 |
Alvin Chang <alvinga@andestech.com> |
libutils: Import part of sys/fcntl.h
Import part of sys/fcntl.h for necessary file flags, from newlib: - newlib/newlib/libc/include/sys/fcntl.h
Signed-off-by: Alvin Chang <alvinga@andestech.com> Ac
libutils: Import part of sys/fcntl.h
Import part of sys/fcntl.h for necessary file flags, from newlib: - newlib/newlib/libc/include/sys/fcntl.h
Signed-off-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| cf2c8f09 | 17-Jan-2024 |
Alvin Chang <alvinga@andestech.com> |
libutils: Implement speculation barrier for RISC-V
Implement load_no_speculate() with implementation consists of RISC-V fence instructions which are used to preserve the memory order.
- Data barrie
libutils: Implement speculation barrier for RISC-V
Implement load_no_speculate() with implementation consists of RISC-V fence instructions which are used to preserve the memory order.
- Data barrier: fence rw, rw - Instruction barrier: fence.i; fence r, r
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.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 ...
|
| bce2f88a | 19-Nov-2023 |
Vincent Mailhol <mailhol.vincent@wanadoo.fr> |
tree-wide: remove useless newline character in *MSG() messages
The *MSG() macros take care of printing a newline. Adding a newline character ('\n') is useless. Remove it.
Signed-off-by: Vincent Mai
tree-wide: remove useless newline character in *MSG() messages
The *MSG() macros take care of printing a newline. Adding a newline character ('\n') is useless. Remove it.
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 17a66904 | 10-Nov-2023 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: print current guest ID in logs
If CFG_NS_VIRTUALIZATION is enabled include the current guest ID on each log line. A number is added before the core number identifying the currently set guest I
core: print current guest ID in logs
If CFG_NS_VIRTUALIZATION is enabled include the current guest ID on each log line. A number is added before the core number identifying the currently set guest ID, for example: D/TC:2 0 0 call_initcalls:40 level 1 teecore_init_pub_ram()
Where the "2" indicates that this is done with guest ID 2 active.
Update the symbolize.py script accordingly to recognize and ignore an eventual guest ID in a log entry.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
show more ...
|
| 0a75d408 | 13-Oct-2023 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: fix data abort during ftrace
With commit c10e3fa93d24 ("core: fix race in handling TA panic") the resources of a panicked TAs are released as early as possible, including the user space mapped
core: fix data abort during ftrace
With commit c10e3fa93d24 ("core: fix race in handling TA panic") the resources of a panicked TAs are released as early as possible, including the user space mapped ftrace buffer. However, the pointer to the ftrace buffer is stored in the ts_session for quick and easy access. The ftrace buffer is always retrieved with get_fbuf() that already have a few other checks to see if the buffer is currently available. So add a check to see that the TA hasn't panicked also.
Fixes: c10e3fa93d24 ("core: fix race in handling TA panic") Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com> Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (vexpress-qemu_armv8a)
show more ...
|
| 78af2f12 | 09-Oct-2023 |
Alvin Chang <alvinga@andestech.com> |
libutils: fault_mitigation.h: Fix indentation
Indentation with tab instead of space.
Fixes: ce56605a0ede ("core: support fault mitigations in non-threaded code") Signed-off-by: Alvin Chang <alvinga
libutils: fault_mitigation.h: Fix indentation
Indentation with tab instead of space.
Fixes: ce56605a0ede ("core: support fault mitigations in non-threaded code") Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|