| 567dbd81 | 29-Aug-2023 |
loubaihui <loubaihui1@huawei.com> |
crypto: change TEE_MAIN_ALGO_X448 value to 0x49
Change the value of TEE_MAIN_ALGO_X448 to 0x49 so that TEE_ALG_GET_KEY_TYPE(TEE_ALG_X448, true) == TEE_TYPE_X448_KEYPAIR and TEE_ALG_GET_KEY_TYPE(TEE_
crypto: change TEE_MAIN_ALGO_X448 value to 0x49
Change the value of TEE_MAIN_ALGO_X448 to 0x49 so that TEE_ALG_GET_KEY_TYPE(TEE_ALG_X448, true) == TEE_TYPE_X448_KEYPAIR and TEE_ALG_GET_KEY_TYPE(TEE_ALG_X448, false) == TEE_TYPE_X448_PUBLIC_KEY.
Signed-off-by: loubaihui <loubaihui1@huawei.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 2a8dfb45 | 23-Aug-2023 |
Jerome Forissier <jerome.forissier@linaro.org> |
compiler.h: add __inhibit_loop_to_libcall
Introduce __inhibit_loop_to_libcall which allows to disable a specific compiler optimization that detects and replaces some open coded loops with standard l
compiler.h: add __inhibit_loop_to_libcall
Introduce __inhibit_loop_to_libcall which allows to disable a specific compiler optimization that detects and replaces some open coded loops with standard library calls (typically: memcpy() and memset()).
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 7ed603a0 | 23-Aug-2023 |
Jerome Forissier <jerome.forissier@linaro.org> |
libutils: asan: raw_realloc(): use unchecked memset() and memcpy()
When raw_realloc() invokes memset() and memcpy() the destination buffer is not yet tagged for ASAN. Therefore use the unchecked ver
libutils: asan: raw_realloc(): use unchecked memset() and memcpy()
When raw_realloc() invokes memset() and memcpy() the destination buffer is not yet tagged for ASAN. Therefore use the unchecked versions of these functions.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 4d6266da | 22-Aug-2023 |
Clement Faure <clement.faure@nxp.com> |
lib: libutee: initialize variables in TEE_GetPropertyAsString()
Initialize local variables at declaration as specified by the coding guidelines.
Signed-off-by: Clement Faure <clement.faure@nxp.com>
lib: libutee: initialize variables in TEE_GetPropertyAsString()
Initialize local variables at declaration as specified by the coding guidelines.
Signed-off-by: Clement Faure <clement.faure@nxp.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| a1f2c430 | 24-Jul-2023 |
Clement Faure <clement.faure@nxp.com> |
lib: libutee: initialize TA property type
TA property type `type` is declared without being initialized and might be used in the if statement uninitialized.
Signed-off-by: Clement Faure <clement.fa
lib: libutee: initialize TA property type
TA property type `type` is declared without being initialized and might be used in the if statement uninitialized.
Signed-off-by: Clement Faure <clement.faure@nxp.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 09a77c98 | 24-Jul-2023 |
Clement Faure <clement.faure@nxp.com> |
lib: libutee: fix use after free
Make sure to call addr_is_in_no_share_heap() before the freeing buffer. This is a false positive as only the pointer value is used and not the memory freed.
Signed-
lib: libutee: fix use after free
Make sure to call addr_is_in_no_share_heap() before the freeing buffer. This is a false positive as only the pointer value is used and not the memory freed.
Signed-off-by: Clement Faure <clement.faure@nxp.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 9c4d0955 | 17-Jul-2023 |
loubaihui <loubaihui1@huawei.com> |
crypto: add drvcrypt_register_x25519() and drvcrypt_register_x448()
Add X25519 and X448 drvcrypt.
Signed-off-by: loubaihui <loubaihui1@huawei.com> Acked-by: Jerome Forissier <jerome.forissier@linar
crypto: add drvcrypt_register_x25519() and drvcrypt_register_x448()
Add X25519 and X448 drvcrypt.
Signed-off-by: loubaihui <loubaihui1@huawei.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 34ce35b1 | 14-Jul-2023 |
loubaihui <loubaihui1@huawei.com> |
crypto: add X448 support
Refer to the X25519 algorithm, add the X448 algorithm framework code.
Signed-off-by: loubaihui <loubaihui1@huawei.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.o
crypto: add X448 support
Refer to the X25519 algorithm, add the X448 algorithm framework code.
Signed-off-by: loubaihui <loubaihui1@huawei.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 546e296f | 04-Jul-2023 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: add {high,low}32_from_64() helper
Adds two helper functions high32_from_64() and low32_from_64() used for retrieving the upper and lower halves of a uint64_t.
Signed-off-by: Jens Wiklande
libutils: add {high,low}32_from_64() helper
Adds two helper functions high32_from_64() and low32_from_64() used for retrieving the upper and lower halves of a uint64_t.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| e2ec831c | 03-Jul-2023 |
Jihwan Park <jihwp@amazon.com> |
core: crypto_bignum_free(): add indirection and set pointer to NULL
To prevent human mistake, crypto_bignum_free() sets the location of the bignum pointer to NULL after freeing it.
Signed-off-by: J
core: crypto_bignum_free(): add indirection and set pointer to NULL
To prevent human mistake, crypto_bignum_free() sets the location of the bignum pointer to NULL after freeing it.
Signed-off-by: Jihwan Park <jihwp@amazon.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 5c2c0fb3 | 14-Jun-2023 |
Jerome Forissier <jerome.forissier@linaro.org> |
ftrace: change implementation to use binary circular buffer
The current implementation of function tracing (CFG_FTRACE_SUPPORT) produces human-readable text into the output buffer that is passed to
ftrace: change implementation to use binary circular buffer
The current implementation of function tracing (CFG_FTRACE_SUPPORT) produces human-readable text into the output buffer that is passed to tee-supplicant and ultimately saved to the Linux filesystem. Two main issues with that:
1. The string formatting code is somewhat complex. It introduces significant overhead in the execution time of the instrumented functions. 2. The various policies about how to handle a buffer full condition (CFG_FTRACE_BUF_WHEN_FULL) are not very convenient. In particular, "shift" is typically the most desirable option because it always keeps the most recent entries, but it is very inefficient to the point of not being usable in practice.
This commit addresses the above concerns by making the ftrace buffer circular one, each entry being 64-bit value. The formatting code is offloaded to a new Python script: scripts/ftrace_format.py. The output is unchanged except for an added field showing the current depth in the call stack.
Typical usage (captured on QEMUv8):
build$ mkdir -p ../tmp build$ chmod a+w ../tmp build$ make CFG_FTRACE_SUPPORT=y CFG_FTRACE_BUF_SIZE=15000 \ CFG_TA_MCOUNT=y CFG_ULIBS_MCOUNT=y CFG_SYSCALL_FTRACE=y \ QEMU_VIRTFS_AUTOMOUNT=y run $ xtest regression_1004 ... $ cp /tmp/ftrace-cb3e5ba0-adf1-11e0-998b-0002a5d5c51b.out /mnt/host/tmp build$ cd .. optee$ optee_os/scripts/ftrace_format.py \ tmp/ftrace-cb3e5ba0-adf1-11e0-998b-0002a5d5c51b.out | optee_os/scripts/symbolize.py \ -d optee_os/out/arm/core \ -d out-br/build/optee_test_ext-1.0/ta/*/out | less TEE load address @ 0x5ab04000 Function graph for TA: cb3e5ba0-adf1-11e0-998b-0002a5d5c51b @ 80085000 | 1 | __ta_entry() { | 2 | __utee_entry() { 43.840 us | 3 | ta_header_get_session() 7.216 us | 3 | tahead_get_trace_level() 14.480 us | 3 | trace_set_level() | 3 | malloc_add_pool() { | 4 | raw_malloc_add_pool() { 46.032 us | 5 | bpool() | 5 | raw_realloc() { 166.256 us | 6 | bget() 23.056 us | 6 | raw_malloc_return_hook() 267.952 us | 5 | } 398.720 us | 4 | } 426.992 us | 3 | } | 3 | TEE_GetPropertyAsU32() { 23.600 us | 4 | is_propset_pseudo_handle() | 4 | __utee_check_instring_annotation() { 26.416 us | 5 | strlen() | 5 | check_access() { | 6 | TEE_CheckMemoryAccessRights() { | 7 | _utee_check_access_rights() { | 8 | syscall_check_access_rights() { | 9 | ts_get_current_session() { 4.304 us | 10 | ts_get_current_session_may_fail() 10.976 us | 9 | } | 9 | to_user_ta_ctx() { 2.496 us | 10 | is_user_ta_ctx() 8.096 us | 9 | } | 9 | vm_check_access_rights() { | 10 | vm_buf_is_inside_um_private() { | 11 | core_is_buffer_inside() { ...
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Sumit Garg <sumit.garg@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| b59abd23 | 20-Jun-2023 |
Alvin Chang <alvinga@andestech.com> |
libutils: ftrace: Add definitions for separating architectural headers
Add definitions for separating architectural headers. In kernel mode, risc-v may include riscv.h to have the timer related func
libutils: ftrace: Add definitions for separating architectural headers
Add definitions for separating architectural headers. In kernel mode, risc-v may include riscv.h to have the timer related functions. In TA libraries, risc-v may include riscv_user_sysreg.h to have those functions.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Sumit Garg <sumit.garg@linaro.org> Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>
show more ...
|
| 53877f84 | 20-Jun-2023 |
Alvin Chang <alvinga@andestech.com> |
libutee: Implement RISC-V helper functions for TA libraries
To enable ftrace support in TA libraries, the timer related functions should be implemented. Add riscv_user_sysreg.h which implements thes
libutee: Implement RISC-V helper functions for TA libraries
To enable ftrace support in TA libraries, the timer related functions should be implemented. Add riscv_user_sysreg.h which implements these functions for TA libraries. The code is referenced from core header and the M-mode related code is removed.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Sumit Garg <sumit.garg@linaro.org> Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>
show more ...
|
| bc12b0e9 | 20-Jun-2023 |
Alvin Chang <alvinga@andestech.com> |
libutils: riscv: Update setjmp() and longjmp() for ftrace support
Fix the registers saving/restoring conventions. The length of jump buffer is increased with one more slot to restore ftrace return s
libutils: riscv: Update setjmp() and longjmp() for ftrace support
Fix the registers saving/restoring conventions. The length of jump buffer is increased with one more slot to restore ftrace return stack.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Sumit Garg <sumit.garg@linaro.org> Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>
show more ...
|
| ae9b3ff9 | 20-Jun-2023 |
Alvin Chang <alvinga@andestech.com> |
libutils: riscv: Implement _mount() and __ftrace_return()
When the core and TA are compiled with the -pg option, the compiler inserts a call to _mcount() into every function prologue. It can be used
libutils: riscv: Implement _mount() and __ftrace_return()
When the core and TA are compiled with the -pg option, the compiler inserts a call to _mcount() into every function prologue. It can be used to trace the function calls such as ftrace.
Implement the _mount() to prepare the necessary parameters for ftrace. The __ftrace_return() is also implemented for returning from ftrace.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Sumit Garg <sumit.garg@linaro.org> Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>
show more ...
|
| 97a70d28 | 20-Jun-2023 |
Alvin Chang <alvinga@andestech.com> |
libutils: Add riscv.S to make it available for core and TA libs
Some assembly macros are necessary for both OP-TEE core and TA libraries. Therefore, we add riscv specific assembly file into libutils
libutils: Add riscv.S to make it available for core and TA libs
Some assembly macros are necessary for both OP-TEE core and TA libraries. Therefore, we add riscv specific assembly file into libutils and move some assembly related macros from riscv.h to riscv.S.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Sumit Garg <sumit.garg@linaro.org> Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>
show more ...
|
| 504f1594 | 19-Jun-2023 |
Vitor Sato Eschholz <vsatoes@baylibre.com> |
libutils: malloc: fix raw_malloc_buffer_overlaps_heap()
When checking if there's an overlap between allocated buffer and heap, raw_malloc_buffer_overlaps_heap() considers two cases: when buffer come
libutils: malloc: fix raw_malloc_buffer_overlaps_heap()
When checking if there's an overlap between allocated buffer and heap, raw_malloc_buffer_overlaps_heap() considers two cases: when buffer comes before the pool and the opposite. On the first case, overlap will happen if the buffer end after the loop start. Since buf_end is computed as buf_start + len, it will point to the address of the first byte after the memory region allocated to the buffer.
Fix raw_malloc_buffer_overlaps_heap() by considering overlap only when buffer end is bigger than the pool start.
Fixes: 12d739bd5028 ("libutils: use raw_malloc_*() as more primitive bget wrappers") Signed-off-by: Vitor Sato Eschholz <vsatoes@baylibre.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| e2eade36 | 02-Jun-2023 |
Alvin Chang <alvinga@andestech.com> |
libutee: riscv: Fix the arguments of __utee_panic() for unwinding
To unwind stack from synchronous panic, the ra and s0(fp) registers should be saved onto stack, and the a1 should be assigned as sp.
libutee: riscv: Fix the arguments of __utee_panic() for unwinding
To unwind stack from synchronous panic, the ra and s0(fp) registers should be saved onto stack, and the a1 should be assigned as sp. The save_panic_regs_rv_ta() can handle these registers for abort usage.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Tested-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>
show more ...
|
| 2661af29 | 26-May-2023 |
Alvin Chang <alvinga@andestech.com> |
libunw: Implement RISC-V stack unwinding
This patch implements stack unwinding for RISC-V architecture into libunw. In RISC-V, the caller stores its frame pointer into register s0 before calling the
libunw: Implement RISC-V stack unwinding
This patch implements stack unwinding for RISC-V architecture into libunw. In RISC-V, the caller stores its frame pointer into register s0 before calling the function. In the prologue of callee function, the return address and the caller's frame pointer are saved into the bottom of the callee's stack frame, and the callee's frame pointer is also calculated and stored into s0 within the process of callee function. Therefore, the caller's stack frame can be traced back from the callee's stack frame.
The following steps describe the stack unwinding on RV64 system: 1. When an exception occurs, we get the current frame pointer from trapped register s0/fp. 2. Get the ra from the memory address (fp-0x8). 3. Get the caller's frame pointer from the memory address (fp-0x10). 4. Update the caller's pc as (ra-0x4), this is information we want from stack unwinding. 5. Repeat the step 2 to step 4, until we exceed the stack frame of the thread.
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>
show more ...
|
| f7a5c21e | 29-May-2023 |
Jerome Forissier <jerome.forissier@linaro.org> |
arm64: memtag: strip tag from crash dumps
The MTE tag is not really useful when displaying a crash dump. In fact it makes it more complicated for tools like script/symbolize.py to retrieve the actua
arm64: memtag: strip tag from crash dumps
The MTE tag is not really useful when displaying a crash dump. In fact it makes it more complicated for tools like script/symbolize.py to retrieve the actual (untagged) virtual address, especially as we now support non-Arm architectures and therefore blindly stripping the MTE bits is not possible.
This commit strips the tag in call stacks displayed by print_stack_arm64(). It also removes it from the virtual address shown on abort (__print_abort_info()) since symbolize.py does try to resolve the address as symbol + offset ; but in this case the tagged address is printed as well, because it can be helpful to diagnose tag check faults.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| af9ee0e0 | 24-May-2023 |
Alvin Chang <alvinga@andestech.com> |
libutee: riscv: Fix relocation type of function call into __utee_panic()
In RISC-V, "j" instruction has R_RISCV_JAL relocation that can represent an even signed 21-bit offset (+-1MiB). However, this
libutee: riscv: Fix relocation type of function call into __utee_panic()
In RISC-V, "j" instruction has R_RISCV_JAL relocation that can represent an even signed 21-bit offset (+-1MiB). However, this range is not enough to be position independent code, and the linker generates linking error. Fix it by using "tail" instruction which has R_RISCV_CALL_PLT relocation that the execution can jump to +-2GB location.
Note that we won't return from _utee_panic(), that's why we use "tail" instead of "call" instruction so that we won't generate redundant return instruction.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Acked-by: liushiwei <liushiwei@eswincomputing.com>
show more ...
|
| 750c544c | 17-May-2023 |
Yuegui He <yuegui.he@amlogic.com> |
libutils: Disable stack protector for __aeabi_uidivmod/__aeabi_idivmod
Some toolchain build optee_os with "-fstack-protector-strong", But the generated codes add "check stack" operations after the "
libutils: Disable stack protector for __aeabi_uidivmod/__aeabi_idivmod
Some toolchain build optee_os with "-fstack-protector-strong", But the generated codes add "check stack" operations after the "ret_idivmod_values", which overwrite the r1 value.
So __aeabi_uidivmod/__aeabi_idivmod will got error value,
Link: https://github.com/OP-TEE/optee_os/issues/6007 Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Yuegui He <yuegui.he@amlogic.com>
show more ...
|
| 69e63e33 | 15-May-2023 |
Alvin Chang <alvinga@andestech.com> |
Add missing conditional compilation for RISC-V
RV64 also uses kern_sp. The elf.h is also used by RV32 and RV64.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jerome Forissier <jerome
Add missing conditional compilation for RISC-V
RV64 also uses kern_sp. The elf.h is also used by RV32 and RV64.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 9fee17aa | 23-Jan-2023 |
Etienne Carriere <etienne.carriere@linaro.org> |
libutils: add bit_ffs_from()
Adds bitstring function bit_ffs_from() that mimics bit_ffs() but looks from a start bit position given as argument, and defines bit_ffs() based on bit_ffs_from().
Revie
libutils: add bit_ffs_from()
Adds bitstring function bit_ffs_from() that mimics bit_ffs() but looks from a start bit position given as argument, and defines bit_ffs() based on bit_ffs_from().
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 31b31015 | 29-Mar-2023 |
liushiwei <liushiwei@eswincomputing.com> |
build: ta: add RISC-V linker script
Sort out the common code compiled by TA, abstract RISCV and ARM compile the common part of TA.
Signed-off-by: liushiwei <liushiwei@eswincomputing.com> Reviewed-b
build: ta: add RISC-V linker script
Sort out the common code compiled by TA, abstract RISCV and ARM compile the common part of TA.
Signed-off-by: liushiwei <liushiwei@eswincomputing.com> Reviewed-by: chenchaokai <chenchaokai@eswincomputing.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
show more ...
|