| 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 ...
|
| bac79749 | 19-Jan-2023 |
Andrew Mustea <andrew.mustea@microsoft.com> |
scripts: checkpatch: rework and add examples to help message
- See https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection for more info about Git Revision Selections.
Signed-off-by: Andrew M
scripts: checkpatch: rework and add examples to help message
- See https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection for more info about Git Revision Selections.
Signed-off-by: Andrew Mustea <andrew.mustea@microsoft.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 7512a644 | 26-Oct-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
sign_encrypt.py: rename to hash_size and sig_size
Renames digest_len to hash_size and sig_len to sig_size in order to match the names used in the corresponding C code.
Reviewed-by: Jerome Forissier
sign_encrypt.py: rename to hash_size and sig_size
Renames digest_len to hash_size and sig_len to sig_size in order to match the names used in the corresponding C code.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| f04ff66a | 26-Oct-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
sign_encrypt.py: add subkey support
Adds support to sign TAs using a subkey. Two new commands are added to help with this: - sign-subkey: signs a new subkey using either the root key or the keys fro
sign_encrypt.py: add subkey support
Adds support to sign TAs using a subkey. Two new commands are added to help with this: - sign-subkey: signs a new subkey using either the root key or the keys from another subkey - subkey-uuid: calculate the UUID of next TA or subkey
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| f454988e | 06-Oct-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
sign_encrypt.py: add display command
Adds a display command to sign_encrypt.py doing what dump_ta_header.py used to do. Removes the now redundant script dump_ta_header.py.
Reviewed-by: Jerome Foris
sign_encrypt.py: add display command
Adds a display command to sign_encrypt.py doing what dump_ta_header.py used to do. Removes the now redundant script dump_ta_header.py.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 3cf28238 | 06-Oct-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
sign_encrypt.py: add command func in argument parsing
While parsing the argument assign the function to handle the command for easier dispatching of the command.
Reviewed-by: Jerome Forissier <jero
sign_encrypt.py: add command func in argument parsing
While parsing the argument assign the function to handle the command for easier dispatching of the command.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 49e93635 | 04-Oct-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
sign_encrypt.py: refactor with BinaryImage class
Moves manipulations of the TA binary into a BinaryImage class for some abstraction and better structure of the code for the different sub-commands.
sign_encrypt.py: refactor with BinaryImage class
Moves manipulations of the TA binary into a BinaryImage class for some abstraction and better structure of the code for the different sub-commands.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| f182afc4 | 04-Oct-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
sign_encrypt.py: refactor argument parsing
Uses the add_subparsers() method from argparse.ArgumentParser to add the command instead of adding command and options at the same level. With this we have
sign_encrypt.py: refactor argument parsing
Uses the add_subparsers() method from argparse.ArgumentParser to add the command instead of adding command and options at the same level. With this we have one parser for each command to allow the argparse module to handle checks for optional and mandatory options. This makes the argument parsing a bit more modular and easier to extend.
Behavior of the script is supposed to be unchanged with the exception of printed help and errors since that now relies more on the argparse module.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 99e82b1f | 05-May-2022 |
Jerome Forissier <jerome.forissier@linaro.org> |
symbolize.py: translate TA panic codes
When a TA panics, the TEE core shows the panic code as follows:
E/TC:? 0 TA panicked with code 0xffff000f
The value is whatever was passed to TEE_Panic() by
symbolize.py: translate TA panic codes
When a TA panics, the TEE core shows the panic code as follows:
E/TC:? 0 TA panicked with code 0xffff000f
The value is whatever was passed to TEE_Panic() by the TA or the library that caused the panic; typically, the TEE Intenal Core API functions implemented in libutee. It quite often happens that this value is a TEE_Result code. Therefore it is convenient to translate the hexadecimal value to a symbolic name (TEE_ERROR_*). With this commit, if a match is found, the name is shown in parentheses like so:
E/TC:? 0 TA panicked with code 0xffff000f (TEE_ERROR_SECURITY)
If the code doesn't correspond to a known TEE_Result value however nothing is appended to the output.
Suggested-by: Peter Griffin <peter.griffin@linaro.org> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Peter Griffin <peter.griffin@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|