| #
8800b01d |
| 08-Nov-2019 |
Jerome Forissier <jerome@forissier.org> |
gprof: fix TEE core crash by allocating sample buffer dynamically
The gprof sample buffer is in user space memory but is also accessed by the TEE core. Currently, space is reserved by the TA linker
gprof: fix TEE core crash by allocating sample buffer dynamically
The gprof sample buffer is in user space memory but is also accessed by the TEE core. Currently, space is reserved by the TA linker script. The address and size of the buffer is passed to the TEE core via a call to the gprof PTA. After this call, the TEE core accesses the buffer periodically, such as when the TA is interrupted by a timer interrupt.
Commit ef305e54eac8 ("libutee: allocate temp secmem for invoke") modified the way that private TA memory is mapped in TA to TA invocations, so that memory is mapped only for the duration of the call. After this point, the memory is unmapped so the gprof sample buffer becomes inaccessible, resulting in a crash:
E/TC:0 0 Core data-abort at address 0x121356 (translation fault) E/TC:0 0 fsr 0x00000007 ttbr0 0x0e19206a ttbr1 0x0e18806a cidr 0x2 E/TC:0 0 cpu #0 cpsr 0x800001f2 E/TC:0 0 r0 0x00000000 r4 0x00000000 r8 0x00000000 r12 0x0017bb4b E/TC:0 0 r1 0x000021ab r5 0x00000000 r9 0x00000000 sp 0x0e1928f0 E/TC:0 0 r2 0x0011d000 r6 0x00000000 r10 0x00000000 lr 0x0e112763 E/TC:0 0 r3 0x00121356 r7 0x0e1928f0 r11 0x00000000 pc 0x0e12958e E/TC:0 0 Core data-abort at address 0x121356 .debug_info+1184598 (translation fault) E/TC:0 0 Call stack: E/TC:0 0 0x0e12958e tee_ta_gprof_sample_pc at optee_os/core/kernel/tee_ta_manager.c:897
The solution is to allocate and map the sample buffer explicitly in user space when profiling is initialized, and at the same time get rid of the reserved area in the TA linker script. The TEE core also needs to check that the sample buffer is valid before writing to it, otherwise a malicious TA could crash the core by unmapping that memory.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Sumit Garg <sumit.garg@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 ...
|
| #
883c4be3 |
| 13-Oct-2016 |
Jerome Forissier <jerome.forissier@linaro.org> |
Add support for user TA profiling with gprof (-pg)
Adds the infrastructure to collect profiling information from Trusted Applications running in user mode and instrumented with -pg. Enable with: CFG
Add support for user TA profiling with gprof (-pg)
Adds the infrastructure to collect profiling information from Trusted Applications running in user mode and instrumented with -pg. Enable with: CFG_TA_GPROF_SUPPORT=y.
Profiling support in itself adds no significant performance overhead. Instrumented applications however may run 1.3x - 2x slower, and have a larger .bss section (+1.36 times .text size for 32-bit TAs, +1.77 times .text size for 64-bit ones).
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (D02 64-bit) Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (QEMU 32-bit) Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|