| e72ad0e2 | 07-Mar-2019 |
Etienne Carriere <etienne.carriere@st.com> |
libutil: add UDIV_ROUND_NEAREST() macro
Default integer division rounds down. Here the interest is to round to the nearest unsigned integer.
This is inspired from [1].
Link: [1] https://chromium.g
libutil: add UDIV_ROUND_NEAREST() macro
Default integer division rounds down. Here the interest is to round to the nearest unsigned integer.
This is inspired from [1].
Link: [1] https://chromium.googlesource.com/chromiumos/platform/ec/+/master/include/util.h
Signed-off-by: Etienne Carriere <etienne.carriere@st.com> Signed-off-by: Nicolas Le Bayon <nicolas.le.bayon@st.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
show more ...
|
| fe8db355 | 06-Mar-2019 |
Jerome Forissier <jerome.forissier@linaro.org> |
core: ignore deprecated TA flags EXEC_DDR and USER_MODE
Commit 387b0ee39b1b ("core: deprecate TA property flags EXEC_DDR and USER_MODE") removes the requirement for user TAs to set the flags TA_FLAG
core: ignore deprecated TA flags EXEC_DDR and USER_MODE
Commit 387b0ee39b1b ("core: deprecate TA property flags EXEC_DDR and USER_MODE") removes the requirement for user TAs to set the flags TA_FLAG_EXEC_DDR (bit 0) and TA_FLAG_USER_MODE (bit 1), the rationale being that they are meaningless in the current implementation. The macros are re-defined to be zero to reflect the fact that they have no use. But, instead of ignoring the previous values, the TEE core now requires that bits 0 and 1 must *not* be set. This is a problem because it needlessly breaks backward compatibility. A TA built against OP-TEE 3.0.0 will not work with 3.1.0 or later:
E/TC:? 0 tee_ta_init_user_ta_session:1040 Invalid TA flag(s) 0x3
This commit changes the acceptable flags mask (TA_FLAGS_MASK) to include the previous EXEC_DDR and USER_MODE bits, thus restoring backward compatibility.
Fixes: 387b0ee39b1b ("core: deprecate TA property flags EXEC_DDR and USER_MODE") Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| bb80916b | 25-Feb-2019 |
Etienne Carriere <etienne.carriere@linaro.org> |
core: use PTA as acronym for pseudo TA
Make inline comments and trace messages more consistent by using PTA as acronym for pseudo TA, rather than using pTA, PTA and pta at various places.
Signed-of
core: use PTA as acronym for pseudo TA
Make inline comments and trace messages more consistent by using PTA as acronym for pseudo TA, rather than using pTA, PTA and pta at various places.
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 48e10604 | 14-Feb-2019 |
Jerome Forissier <jerome.forissier@linaro.org> |
libutils: remove buf_compare_ct()
Now that we have consttime_memcmp(), buf_compare_ct() is redundant. Every time buf_compare_ct() is used, consttime_memcmp() may be used instead.
This commit remove
libutils: remove buf_compare_ct()
Now that we have consttime_memcmp(), buf_compare_ct() is redundant. Every time buf_compare_ct() is used, consttime_memcmp() may be used instead.
This commit removes buf_compare_ct(). A compatibility wrapper is kept in <string_ext.h> to avoid knowingly breaking the build of any TA that may use it.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 65551e69 | 06-Feb-2019 |
Jerome Forissier <jerome.forissier@linaro.org> |
libutee: TEE_MemCompare(): use constant time algorithm
TEE_MemCompare() currently calls memcmp() which returns as soon as a difference is found in the compared buffers. The fact that the comparison
libutee: TEE_MemCompare(): use constant time algorithm
TEE_MemCompare() currently calls memcmp() which returns as soon as a difference is found in the compared buffers. The fact that the comparison is not constant time for a given buffer size can reveal information on the buffer content and lead to side-channel attacks. Although the GlobalPlatform TEE Internal Core API specification says nothing about this timing aspect, it is unsafe not to propose a constant time implementation to TAs. A member of the GP specification working group confirmed in an informal discussion.
Therefore, replace memcmp() with consttime_memcmp() for constant time comparison. If a TA needs the fastest possible buffer comparison it can call the C library function memcmp() (from <string.h>), which we provide in libutils.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reported-by: Bastien Simondi <bsimondi@netflix.com> [3.2] Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
show more ...
|
| b7da54b3 | 08-Feb-2019 |
Jerome Forissier <jerome.forissier@linaro.org> |
libutils: Import isc_tsmemcmp() from NTP as consttime_memcmp()
This patch imports a constant-time byte sequence comparison function from the NTP source tree [1]. Contrary to our buf_compare_ct() fun
libutils: Import isc_tsmemcmp() from NTP as consttime_memcmp()
This patch imports a constant-time byte sequence comparison function from the NTP source tree [1]. Contrary to our buf_compare_ct() function, which has only two possible outcomes (zero or non-zero), the new function is a direct replacement for memcmp() because it returns three possible states (< 0, 0, > 0).
Link: [1] http://bk.ntp.org/ntp-stable/lib/isc/tsmemcmp.c Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Suggested-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 9c7ce04d | 14-Feb-2019 |
Yunjong Jeong <yunjong@kaist.ac.kr> |
libutils: isoc: implement more ctypes functions
Implement missing functions from ctypes.h.
Signed-off-by: Yunjong Jeong <yunjong@kaist.ac.kr> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> |
| 69a3d6be | 18-Feb-2019 |
Daniel Glöckner <dg@emlix.com> |
libutee: fix TEE_OpenPersistentObject() error behavior
The TEE spec says about TEE_OpenPersistentObject(): "If this function fails for any reason, the value pointed to by object is set to TEE_HANDLE
libutee: fix TEE_OpenPersistentObject() error behavior
The TEE spec says about TEE_OpenPersistentObject(): "If this function fails for any reason, the value pointed to by object is set to TEE_HANDLE_NULL."
Signed-off-by: Daniel Glöckner <dg@emlix.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
show more ...
|
| b1f3797d | 06-Feb-2019 |
Volodymyr Babchuk <vlad.babchuk@gmail.com> |
bget: fix nex_ pool building with disabled stats
gen_malloc_reset_stats() and gen_malloc_get_stats() are only available when BufStats is defined.
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmai
bget: fix nex_ pool building with disabled stats
gen_malloc_reset_stats() and gen_malloc_get_stats() are only available when BufStats is defined.
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 8cd8a629 | 06-Feb-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
Remove memalign()
Removes the unused memalign() function. Usage of this function will cause severe fragmentation of the heap.
Another problem is with the implementation which is added on top of bge
Remove memalign()
Removes the unused memalign() function. Usage of this function will cause severe fragmentation of the heap.
Another problem is with the implementation which is added on top of bget while still depending heavily on internals of bget. The implementation was somewhat buggy since it can sometimes can cause: E/TC:0 0 assertion 'bn->prevfree == 0' failed at lib/libutils/isoc/bget_malloc.c :423 <create_free_block> E/TC:0 0 Panic at core/kernel/assert.c:28 <_assert_break>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b2dd8747 | 05-Feb-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
Fix alignment of data for mempool_alloc_pool()
Prior to this patch was _TEE_MathAPI_Init() in lib/libutee/tee_api_arith_mpi.c supplying a data buffer which was only 4 byte aligned while mempool_allo
Fix alignment of data for mempool_alloc_pool()
Prior to this patch was _TEE_MathAPI_Init() in lib/libutee/tee_api_arith_mpi.c supplying a data buffer which was only 4 byte aligned while mempool_alloc_pool() requires the alignment of long. This will work in 32-bit mode, but could lead to alignment problem in 64-bit mode. The same problem can happen with lib/libutee/tee_api_arith_mpa.c, but so far it has remained hidden.
Incorrect alignment can result in errors like: E/TA: assertion '!((vaddr_t)data & (POOL_ALIGN - 1))' failed at lib/libutils/ext/mempool.c:134 in mempool_alloc_pool()
This fix introduces MEMPOOL_ALIGN which specifies required alignment of data supplied to mempool_alloc_pool().
Fixes: 062e3d01c039 ("ta: switch to to mbedtls for bignum") Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Tested-by: Joakim Bech <joakim.bech@linaro.org> (QEMU v8) Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 1131d3c5 | 18-Dec-2018 |
Volodymyr Babchuk <vlad.babchuk@gmail.com> |
libutils: add nex_strdup() function
This is the same as strdup() but it uses nex_malloc(), so it can be used in nexus part of OP-TEE.
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Revie
libutils: add nex_strdup() function
This is the same as strdup() but it uses nex_malloc(), so it can be used in nexus part of OP-TEE.
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| c211d0a4 | 06-Feb-2018 |
Volodymyr Babchuk <vlad.babchuk@gmail.com> |
virt: tag variables with __nex_data and __nex_bss
Variables that are needed by OP-TEE nexus will be moved to nexus memory.
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Acked-by: Jens W
virt: tag variables with __nex_data and __nex_bss
Variables that are needed by OP-TEE nexus will be moved to nexus memory.
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 15216d4d | 06-Feb-2018 |
Volodymyr Babchuk <vlad.babchuk@gmail.com> |
virt: add nexus memory area
This patch is the first in series of patches that split OP-TEE RW memory into two regions: nexus memory and TEE memory. Nexus memory will be always mapped and it will be
virt: add nexus memory area
This patch is the first in series of patches that split OP-TEE RW memory into two regions: nexus memory and TEE memory. Nexus memory will be always mapped and it will be used to store all data that is vital for OP-TEE core and is not bound to virtual guests.
TEE memory is a memory that holds data specific for certain guest. There will be TEE memory bank for every guest and it will be mapped into OP-TEE address space only during call from that guest.
This patch adds nexus memory and moves stacks into it. Also it provides __nex_bss and __nex_data macros, so one can easily set right section for a variable.
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 386fc264 | 05-Feb-2018 |
Volodymyr Babchuk <vlad.babchuk@gmail.com> |
bget_malloc: add nex_malloc pool
If virtualization enabled, this pool will be used to allocate memory for OP-TEE nexus needs. Without virtualization, generic malloc pool will be used.
Signed-off-by
bget_malloc: add nex_malloc pool
If virtualization enabled, this pool will be used to allocate memory for OP-TEE nexus needs. Without virtualization, generic malloc pool will be used.
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 741b437f | 05-Feb-2018 |
Volodymyr Babchuk <vlad.babchuk@gmail.com> |
bget_malloc: hold all malloc state in malloc_ctx structure
This patch moves all bget_malloc.c state into malloc_ctx structure. malloc_lock.c is removed because spinlock now is also stored in malloc_
bget_malloc: hold all malloc state in malloc_ctx structure
This patch moves all bget_malloc.c state into malloc_ctx structure. malloc_lock.c is removed because spinlock now is also stored in malloc_ctx.
Multiple malloc pools can be used now.
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 7539e8c3 | 31-Jan-2019 |
PeiKan Tsai <mark1990301@gmail.com> |
bget: Check for size overflow
Check size overflow to avoid size <= 0 which may be caused by calculation "size += sizeof(struct bhead)" and "size = (size + (SizeQuant - 1)) & (~(SizeQuant - 1))".
Si
bget: Check for size overflow
Check size overflow to avoid size <= 0 which may be caused by calculation "size += sizeof(struct bhead)" and "size = (size + (SizeQuant - 1)) & (~(SizeQuant - 1))".
Signed-off-by: Peikan Tsai <mark1990301@gmail.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b6bc49ca | 17-Jan-2019 |
Sumit Garg <sumit.garg@linaro.org> |
trace: fix core id print if in non-atomic context
Make "?" print repetitive equivalent to number of digits needed to display core id rather than extra spaces as it causes symbolize.py script parsing
trace: fix core id print if in non-atomic context
Make "?" print repetitive equivalent to number of digits needed to display core id rather than extra spaces as it causes symbolize.py script parsing failure for call stack addresses in case number of cores is greater than 10.
Also change symbolize.py to detect repetitive "?".
Signed-off-by: Sumit Garg <sumit.garg@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 98efc118 | 17-Jan-2019 |
Jerome Forissier <jerome.forissier@linaro.org> |
mbedtls: TEE_BigIntMul(): use temporary
mbedtls_mpi_mul_mpi() checks the allocated size of the output number before starting to multiply the numbers. It makes a conservative guess by requiring the r
mbedtls: TEE_BigIntMul(): use temporary
mbedtls_mpi_mul_mpi() checks the allocated size of the output number before starting to multiply the numbers. It makes a conservative guess by requiring the result to be at least as large as the sum of the sizes of the input numbers. For instance, if A fits in one "limb" and B fits in two, then the result is expected to have nblimbs = 3 at least. This is sometimes too restrictive. Consider A = 1 (can be represented with nblimbs == 1 32-bit words) and B = 0x0FFFFFFFFFFFFFFF (fits in a bignum with nblimbs == 2 32-bit words). A * B is equal to B and fits in 2 limbs, but the current code requires 3. This patch fixes the problem by allocating a big enough temporary result.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 336e3299 | 17-Jan-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
mbedtls: fix memory leak in mpi_miller_rabin()
8ff963a60211 ("mbedtls: fix memory leak in mpi_miller_rabin()") from branch import/mbedtls-2.6.1
Fixes memory leak in mpi_miller_rabin() that occurs w
mbedtls: fix memory leak in mpi_miller_rabin()
8ff963a60211 ("mbedtls: fix memory leak in mpi_miller_rabin()") from branch import/mbedtls-2.6.1
Fixes memory leak in mpi_miller_rabin() that occurs when the function has failed to obtain a usable random 'A' 300 turns in a row.
Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 60b39904 | 16-Jan-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
mempool: fix race in get_pool()
Fixes a race in get_pool() which could leave the pool with zero refences but still owned by the last thread using the pool.
Some performance number on Hikey with def
mempool: fix race in get_pool()
Fixes a race in get_pool() which could leave the pool with zero refences but still owned by the last thread using the pool.
Some performance number on Hikey with default configuration: github/master (edbb89f, before this commit):
4006 real 1m 41.11s 4007 real 1m 14.51s 4008 real 0m 0.13s 4009 real 1m 5.68s
Revert "mempool: optimize reference counting", before this commit: 4006 real 3m 27.78s 4007 real 0m 50.03s 4008 real 0m 0.13s 4009 real 2m 24.07s
With this commit, two runs: 4006 real 1m 37.51s 4007 real 0m 56.67s 4008 real 0m 0.09s 4009 real 1m 3.18s
4006 real 1m 37.61s 4007 real 0m 35.32s 4008 real 0m 0.13s 4009 real 1m 3.15s
Numbers are gathered with this script: for a in 4006 4007 4008 4009 ; do \ echo -n $a " " >> time.txt ;\ time -o time.txt.tmp xtest -l 15 $a || break ;\ grep real time.txt.tmp >> time.txt done cat time.txt
Reviewed-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 91334787 | 16-Jan-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
atomic.h: add atomic_{load,store}_int()
Adds atomic_load_int() and atomic_store_int().
Reviewed-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.or
atomic.h: add atomic_{load,store}_int()
Adds atomic_load_int() and atomic_store_int().
Reviewed-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 0b611081 | 07-Jan-2019 |
Sumit Garg <sumit.garg@linaro.org> |
core: pta: Add device pseudo TA
This pseudo TA enumerates OP-TEE pseudo TAs which can act as devices/ services for Linux TEE bus driver. For differentiation of such devices, added TA_FLAG_DEVICE_ENU
core: pta: Add device pseudo TA
This pseudo TA enumerates OP-TEE pseudo TAs which can act as devices/ services for Linux TEE bus driver. For differentiation of such devices, added TA_FLAG_DEVICE_ENUM optional flag in pseudo TA header.
Signed-off-by: Sumit Garg <sumit.garg@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 062e3d01 | 13-Nov-2018 |
Jens Wiklander <jens.wiklander@linaro.org> |
ta: switch to to mbedtls for bignum
Adds tee_api_arith_mpi.c wrapper providing the TEE Arithmetical API around the big (mpi) routines from mbedtls.
CFG_TA_MBEDTLS_MPI=y (default y) enables the usag
ta: switch to to mbedtls for bignum
Adds tee_api_arith_mpi.c wrapper providing the TEE Arithmetical API around the big (mpi) routines from mbedtls.
CFG_TA_MBEDTLS_MPI=y (default y) enables the usage of the bignum routines in libutee.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| ec812024 | 12-Nov-2018 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutee: rename to tee_api_arith_mpa.c
Renames tee_api_arith.c to tee_api_arith_mpa.c to make room for using other bignum implementations.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> S
libutee: rename to tee_api_arith_mpa.c
Renames tee_api_arith.c to tee_api_arith_mpa.c to make room for using other bignum implementations.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|