| 3dd0e94e | 18-Jun-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: add trace_vprintf()
Adds the trace_vprintf() helper function.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> |
| 34db7172 | 12-Jun-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: pta_system: support memory remap
Adds PTA_SYSTEM_REMAP to support changing virtual address of an already established mapping in a TA.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.or
core: pta_system: support memory remap
Adds PTA_SYSTEM_REMAP to support changing virtual address of an already established mapping in a TA.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 7509ff7c | 23-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
Add user mode ELF loader
Adds ldelf which loads user mode TAs while in user mode. The TA ELF file is loaded and relocated by ldelf before the TA can be executed.
Reviewed-by: Jerome Forissier <jero
Add user mode ELF loader
Adds ldelf which loads user mode TAs while in user mode. The TA ELF file is loaded and relocated by ldelf before the TA can be executed.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| fd652ade | 23-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutee: support compiling for ldelf
Adds support for compiling for ldelf by excluding files not needed in or conflicting with the ldelf environment.
Reviewed-by: Jerome Forissier <jerome.forissier
libutee: support compiling for ldelf
Adds support for compiling for ldelf by excluding files not needed in or conflicting with the ldelf environment.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 0a563c6f | 23-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: pta_system: add PTA_SYSTEM_SET_PROT
Adds PTA_SYSTEM_SET_PROT to support changing protection of already established memory mappings.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
core: pta_system: add PTA_SYSTEM_SET_PROT
Adds PTA_SYSTEM_SET_PROT to support changing protection of already established memory mappings.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 0b414d3f | 23-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: pta_system: ta binary handling
Adds support to open, close and map a TA binary from a user TA.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wik
core: pta_system: ta binary handling
Adds support to open, close and map a TA binary from a user TA.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| ef305e54 | 23-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutee: allocate temp secmem for invoke
Allocates temporary secure memory for buffers in TA private memory passed to invoke_command/open_session. This offloads the logic in TEE core which until now
libutee: allocate temp secmem for invoke
Allocates temporary secure memory for buffers in TA private memory passed to invoke_command/open_session. This offloads the logic in TEE core which until now has allocated temporary secure memory as needed during TA to TA calls.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 87065172 | 23-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutee: support dynamic memory mapping
Adds tee_map_zi() and tee_unmap() as wrappers for PTA_SYSTEM_MAP_ZI and PTA_SYSTEM_UNMAP respectively.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro
libutee: support dynamic memory mapping
Adds tee_map_zi() and tee_unmap() as wrappers for PTA_SYSTEM_MAP_ZI and PTA_SYSTEM_UNMAP respectively.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| d00e014a | 23-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutee: user_ta_entry.c: {to,from}_utee_params()
Use local implementation of to_utee_params() and from_utee_params().
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jen
libutee: user_ta_entry.c: {to,from}_utee_params()
Use local implementation of to_utee_params() and from_utee_params().
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b5b6225f | 23-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: pta_system: support dynamic memory mapping
Adds PTA_SYSTEM_MAP_ZI and PTA_SYSTEM_UNMAP to dynamically map and unmap user space memory from user space. The memory is automatically freed when th
core: pta_system: support dynamic memory mapping
Adds PTA_SYSTEM_MAP_ZI and PTA_SYSTEM_UNMAP to dynamically map and unmap user space memory from user space. The memory is automatically freed when the context of the TA is freed.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 7cc6dea7 | 03-Jun-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: sys/queue.h: add STAILQ_REMOVE_AFTER()
Import macro STAILQ_REMOVE_AFTER from FreeBSD.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklande
libutils: sys/queue.h: add STAILQ_REMOVE_AFTER()
Import macro STAILQ_REMOVE_AFTER from FreeBSD.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| e0e762fe | 14-Jun-2019 |
Jerome Forissier <jerome.forissier@linaro.org> |
arm32: prevent unwinding of __ta_entry()
Since commit eeb866c431db ("Add TA entry point function: __ta_entry()"), __ta_entry() is the first function in the user space call stack, not __utee_entry().
arm32: prevent unwinding of __ta_entry()
Since commit eeb866c431db ("Add TA entry point function: __ta_entry()"), __ta_entry() is the first function in the user space call stack, not __utee_entry(). Therefore, the asm(".cantunwind") declaration should be moved from __utee_entry() to __ta_entry().
When utee_return() was moved from __utee_entry() to __ta_entry() by commit fde3a7f212f8 ("Remove redundant __noreturn from __utee_entry()"), it caused a regression in xtest 1010.3. The stack unwinding would enter an infinite loop as follows:
E/TC:? 0 User TA prefetch-abort at address 0x0 (translation fault) E/TC:? 0 fsr 0x00000005 ttbr0 0x3f07906a ttbr1 0x3f06c06a cidr 0x2 E/TC:? 0 cpu #7 cpsr 0x80000110 E/TC:? 0 r0 0x00000001 r4 0x00161448 r8 0x00161438 r12 0x00152f80 E/TC:? 0 r1 0x00000002 r5 0x00152f40 r9 0x00152f30 sp 0x00152f10 E/TC:? 0 r2 0x00000000 r6 0x00152f80 r10 0x0000000a lr 0x0015498d E/TC:? 0 r3 0x00152f14 r7 0x00161458 r11 0x00245420 pc 0x00000000 E/TC:? 0 Status of TA 5b9e0e40-2636-11e1-ad9e-0002a5d5c51b (0x3f069c30) (active) E/TC:? 0 arch: arm load address: 0x00153000 ctx-idr: 2 E/TC:? 0 stack: 0x00150000 12288 E/TC:? 0 region 0: va 0x00100000 pa 0x3f000000 size 0x002000 flags ---R-X E/TC:? 0 region 1: va 0x00150000 pa 0x3f110000 size 0x003000 flags rw-RW- E/TC:? 0 region 2: va 0x00153000 pa 0x3f113000 size 0x00e000 flags r-xR-- [0] .ta_head .text .plt .rodata .ARM.extab .ARM.extab.text.unlikely .ARM.extab.text.__aeabi_ldivmod .ARM.extab.text.__aeabi_uldivmod .ARM.extab.text.utee_panic .ARM.exidx .dynsym .dynstr .hash E/TC:? 0 region 3: va 0x00161000 pa 0x3f121000 size 0x0e5000 flags rw-RW- [0] .got .rel.got .rel.plt .dynamic .data .bss .rel.dyn E/TC:? 0 region 4: va 0x00246000 pa 0x3f101000 size 0x001000 flags r-xR-- [1] .hash .dynsym .dynstr .rel.plt .plt .text .ARM.exidx E/TC:? 0 region 5: va 0x00247000 pa 0x3f102000 size 0x001000 flags rw-RW- [1] .dynamic .got E/TC:? 0 region 6: va 0x00248000 pa 0x3f100000 size 0x001000 flags r----- E/TC:? 0 [0] 5b9e0e40-2636-11e1-ad9e-0002a5d5c51b @ 0x00153000 (optee_test/out/ta/os_test/5b9e0e40-2636-11e1-ad9e-0002a5d5c51b.elf) E/TC:? 0 [1] ffd2bded-ab7d-4988-95ee-e4962fff7154 @ 0x00246000 (optee_test/out/ta/os_test_lib/libos_test.so) E/TC:? 0 Call stack: E/TC:? 0 0x00000000 ??? E/TC:? 0 0x0015c629 __ta_entry at optee_os/out/arm/export-ta_arm32/src/user_ta_header.c:41 E/TC:? 0 0x0015c62d tahead_get_trace_level at optee_os/out/arm/export-ta_arm32/src/user_ta_header.c:117 E/TC:? 0 0x0015c62d tahead_get_trace_level at optee_os/out/arm/export-ta_arm32/src/user_ta_header.c:117 ...
Moving the .cantunwind directive fixes the issue.
Fixes: fde3a7f212f8 ("Remove redundant __noreturn from __utee_entry()") Fixes: eeb866c431db ("Add TA entry point function: __ta_entry()") Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Sumit Garg <sumit.garg@linaro.org>
show more ...
|
| a30ddda9 | 29-May-2019 |
Joakim Bech <joakim.bech@linaro.org> |
PTA: add support for deriving device and TA unique keys
Enable derivation of device and Trusted Application unique keys that can be used by different Trusted Applications directly. An example of use
PTA: add support for deriving device and TA unique keys
Enable derivation of device and Trusted Application unique keys that can be used by different Trusted Applications directly. An example of use case could be when you need to encrypt some data in a Trusted App and then give it back to normal world.
By default device unique properties (HUK and TA UUID) will be used when deriving a key. However, the one calling the PTA derive key function also have the ability to provide some extra data that will be mixed in together with existing device unique properties. That gives the ability to derive keys that are not only device and Trusted Application unique, but also tied to some additional data, it could for example be a password or something similar.
Signed-off-by: Joakim Bech <joakim.bech@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 9d6ac097 | 10-Jun-2019 |
Sumit Garg <sumit.garg@linaro.org> |
ftrace: arm64: handle special setjmp()/longjmp() apis
setjmp()/longjmp() user-space apis are used to perform a nonlocal goto which transfer execution from one function to a predetermined location in
ftrace: arm64: handle special setjmp()/longjmp() apis
setjmp()/longjmp() user-space apis are used to perform a nonlocal goto which transfer execution from one function to a predetermined location in another function. This is a special case as compared to normal "C" function calls. So this patch enables ftrace to generate function graph for these apis.
Signed-off-by: Sumit Garg <sumit.garg@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (HiKey960)
show more ...
|
| b02ae382 | 22-May-2019 |
Sumit Garg <sumit.garg@linaro.org> |
libutee: arm64: Add support for function tracing of user TAs
Function tracing (ftrace) is a useful debugging technique to dump function call graph for in-depth analysis of program execution and also
libutee: arm64: Add support for function tracing of user TAs
Function tracing (ftrace) is a useful debugging technique to dump function call graph for in-depth analysis of program execution and also to get useful information in case of any program abort.
In case of TA, this function graph information is dumped in a buffer kept in .bss section of corresponding instrumented TA. So this buffer can be dumped to normal world in case TA session closes or in case of any abort. Also size of this ftrace buffer is configurable per TA via following config option during TA compilation:
CFG_FTRACE_BUF_SIZE=2048
Function tracing is completely optional debugging feature which could be enabled via command line config option CFG_TA_FTRACE_SUPPORT=y.
Along with this user needs to add cflag: "-pg" to the files for whom function graph is to be generated. Typically for the whole TA, it should be compiled with CFG_TA_MCOUNT=y.
And in case user wants to set "-pg" for particular file, following should go in corresponding sub.mk:
cflags-<file-name>-y+=-pg
Also, to generate function graph for user mode libraries enable CFG_ULIBS_MCOUNT=y which will set "-pg" for all library files.
Currently this patch adds support for function tracing of 64-bit TAs only.
Signed-off-by: Sumit Garg <sumit.garg@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (HiKey960)
show more ...
|
| 735565db | 16-May-2019 |
Sumit Garg <sumit.garg@linaro.org> |
Rename CFG_ULIBS_GPROF to CFG_ULIBS_MCOUNT
CFG_ULIBS_GPROF builds the user mode libraries with -pg, which adds instrumentation to all functions in the form of a call to mcount(). This was historical
Rename CFG_ULIBS_GPROF to CFG_ULIBS_MCOUNT
CFG_ULIBS_GPROF builds the user mode libraries with -pg, which adds instrumentation to all functions in the form of a call to mcount(). This was historically used by gprof, but other tools can benefit from this instrumentation. Therefore, rename the config flag as well as a couple of source files to remove the reference to gprof.
Signed-off-by: Sumit Garg <sumit.garg@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (HiKey960)
show more ...
|
| 78e8a97d | 23-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
Move reg_pair_*() to util.h
Moves the two functions reg_pair_to_64() and reg_pair_from_64() from the core only .h file <kernel/misc.h> to the libutils .h file util.h to make the functions available
Move reg_pair_*() to util.h
Moves the two functions reg_pair_to_64() and reg_pair_from_64() from the core only .h file <kernel/misc.h> to the libutils .h file util.h to make the functions available from TAs.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| ad443200 | 27-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
libmbedtls: mbedtls_mpi_exp_mod(): optimize mempool usage
d5572fade852 ("libmbedtls: mbedtls_mpi_exp_mod(): optimize mempool usage") from branch import/mbedtls-2.16.0
With W allocated in the mempoo
libmbedtls: mbedtls_mpi_exp_mod(): optimize mempool usage
d5572fade852 ("libmbedtls: mbedtls_mpi_exp_mod(): optimize mempool usage") from branch import/mbedtls-2.16.0
With W allocated in the mempool instead of the stack it is more important to utilize the mempool in a stack like way.
With this patch allocation and initialization of W is moved to a point where all following mempool allocations are free before the function returns.
This reduces maximum memory consumption of mempool in regression case 8101 for an AArch64 TA in from 17280 to 7640 bytes. Figures for an AArch32 TA are 12040 to 5288 bytes.
Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 41e5aa8f | 21-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
libmbedtls: mbedtls_mpi_exp_mod(): reduce stack usage
68df6eb0f256 ("libmbedtls: mbedtls_mpi_exp_mod(): reduce stack usage") from branch import/mbedtls-2.16.0
The W variable is 3072 bytes on AArch6
libmbedtls: mbedtls_mpi_exp_mod(): reduce stack usage
68df6eb0f256 ("libmbedtls: mbedtls_mpi_exp_mod(): reduce stack usage") from branch import/mbedtls-2.16.0
The W variable is 3072 bytes on AArch64 with MBEDTLS_MPI_WINDOW_SIZE set to 6 for maximum performance. Instead of allocating such a large variable on the stack use mempool_alloc().
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 628e1eb0 | 22-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutee: increase MPI mempool size
Increases MPI mempool size from 8Kb to 12Kb to be compensate for changes in the (future) commit "libmbedtls: mbedtls_mpi_exp_mod(): reduce stack usage" where mbedt
libutee: increase MPI mempool size
Increases MPI mempool size from 8Kb to 12Kb to be compensate for changes in the (future) commit "libmbedtls: mbedtls_mpi_exp_mod(): reduce stack usage" where mbedtls_mpi_exp_mod() is allocating an additional ~3Kb.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| fde3a7f2 | 21-May-2019 |
Sumit Garg <sumit.garg@linaro.org> |
Remove redundant __noreturn from __utee_entry()
As __ta_entry() acts as function entry point, it makes sense to logically return from this api only via utee_return(). So remove redundant __noreturn
Remove redundant __noreturn from __utee_entry()
As __ta_entry() acts as function entry point, it makes sense to logically return from this api only via utee_return(). So remove redundant __noreturn from __utee_entry().
Fixes: eeb866c431db ("Add TA entry point function: __ta_entry()") Signed-off-by: Sumit Garg <sumit.garg@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 95d0db1e | 15-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add system wide mempool_default
Adds system wide mempool_default for temporary large memory allocations.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere
core: add system wide mempool_default
Adds system wide mempool_default for temporary large memory allocations.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 7c8b181a | 25-Feb-2019 |
Jerome Forissier <jerome.forissier@linaro.org> |
libutils: add memzero_explicit()
Adds a new function: memzero_explicit(s, count) which is equivalent to memset(s, 0, count) except that it cannot be optimized away by the compiler.
memset() being a
libutils: add memzero_explicit()
Adds a new function: memzero_explicit(s, count) which is equivalent to memset(s, 0, count) except that it cannot be optimized away by the compiler.
memset() being a built-in function, the compiler is free to perform optimizations such as simply discarding a call when it considers that the call cannot have any observable effect from the program's point of view. A typical example is clearing local data before returning from a function. memset() is likely to have no effect in this case while memzero_explicit() will work as expected.
Calling memset() directly from memzero_explicit() would work as long as link time optimization (LTO) is not applied. With LTO however, the compiler could inline the call to memzero_explicit() and find out that dead store optimization applies. In order to avoid that, we use a method mentioned in [1] which consists in using a volatile function pointer. This method is considered "effective in practice" with all the commonly used compilers.
Link: [1] https://www.usenix.org/system/files/conference/usenixsecurity17/sec17-yang.pdf Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
show more ...
|
| 4e570655 | 13-Feb-2019 |
Jerome Forissier <jerome.forissier@linaro.org> |
libutils: add free_wipe()
Adds function free_wipe(void *ptr) to clear a buffer before returning it to the heap. The pattern used to overwrite the data is 0x55. Users have to #include <stdlib_ext.h>
libutils: add free_wipe()
Adds function free_wipe(void *ptr) to clear a buffer before returning it to the heap. The pattern used to overwrite the data is 0x55. Users have to #include <stdlib_ext.h> to import the declaration.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| c2ce4186 | 12-Apr-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
Introduce CFG_CORE_DUMP_OOM
Introduces CFG_CORE_DUMP_OOM which if y will print an error and dump the stack on memory allocation failures using malloc() and friends.
Reviewed-by: Jerome Forissier <j
Introduce CFG_CORE_DUMP_OOM
Introduces CFG_CORE_DUMP_OOM which if y will print an error and dump the stack on memory allocation failures using malloc() and friends.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|