| 3560d990 | 01-Sep-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add generic struct ts_ctx
Adds the generic struct ts_ctx to be used instead of struct tee_ta_ctx where generic context operations are performed.
struct tee_ta_ctx adds a field with struct ts_
core: add generic struct ts_ctx
Adds the generic struct ts_ctx to be used instead of struct tee_ta_ctx where generic context operations are performed.
struct tee_ta_ctx adds a field with struct ts_ctx for conversion to struct ts_ctx where needed.
The struct ts_session is updated to keep a pointer to a struct ts_ctx instead of the previous struct tee_ta_ctx.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 00b3b9a2 | 31-Aug-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add generic struct ts_session
As a step in making room for Secure Partitions (SPs) running at S-EL0 add a Trusted Service (TS) abstraction. Both TAs and SPs is a TS.
Adds the generic struct t
core: add generic struct ts_session
As a step in making room for Secure Partitions (SPs) running at S-EL0 add a Trusted Service (TS) abstraction. Both TAs and SPs is a TS.
Adds the generic struct ts_session. All future sessions structs (currently only struct tee_ta_session exists) should add this struct to allow generic session operations.
With this struct comes new functions replacing previous struct tee_ta_session oriented functions. The following functions are replaced as: tee_ta_get_current_session() -> ts_get_current_session() tee_ta_push_current_session() -> ts_push_current_session() tee_ta_pop_current_session() -> ts_pop_current_session() tee_ta_get_calling_session() -> ts_get_calling_session()
ts_get_current_session() is changed compared to its predecessor to panic() in case of failure to return a valid pointer.
A new function ts_get_current_session_may_fail() is added to handle an eventual case where a return NULL session may be handled.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 6b050394 | 08-Oct-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: refactor locking during PTA init
tee_ta_init_pseudo_ta_session() locks tee_ta_mutex only when needed. This makes this function similar to sec_part_init_session() and tee_ta_init_user_ta_sessio
core: refactor locking during PTA init
tee_ta_init_pseudo_ta_session() locks tee_ta_mutex only when needed. This makes this function similar to sec_part_init_session() and tee_ta_init_user_ta_session() in usage.
Reviewed-by: Jerome Forissier <jerome@forissier.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 6b5921cc | 08-Oct-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: refactor locking during StMM load
sec_part_init_session() locks tee_ta_mutex only when needed. This avoids a window where deadlock can occur in case pgt_alloc() goes to sleep.
Reviewed-by: Je
core: refactor locking during StMM load
sec_part_init_session() locks tee_ta_mutex only when needed. This avoids a window where deadlock can occur in case pgt_alloc() goes to sleep.
Reviewed-by: Jerome Forissier <jerome@forissier.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| f0ab1c64 | 07-Oct-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: refactor locking during user TA load
tee_ta_init_user_ta_session() unlocks tee_ta_mutex while loading ldelf and the user TA. This avoids a window where deadlock can occur in case pgt_alloc() g
core: refactor locking during user TA load
tee_ta_init_user_ta_session() unlocks tee_ta_mutex while loading ldelf and the user TA. This avoids a window where deadlock can occur in case pgt_alloc() goes to sleep.
A new condition variable, tee_ta_init_cv, is added to signal that a TA has changed state while initializing.
tee_ta_init_session_with_context waits for a TA context be fully initialized before assigning it to another session.
This also simplifies tee_ta_try_set_busy() since it now doesn't have to handle the case where it has to wait for a TA context to be fully initialized.
Reviewed-by: Jerome Forissier <jerome@forissier.org> Suggested-by: Opensource <opensource@sequiturlabs.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 1527e616 | 29-Aug-2020 |
Marek Vasut <marek.vasut+renesas@gmail.com> |
core: dt: Repair type in _fdt_reg_size()
The function returns ssize_t , while DT_INFO_INVALID_REG is paddr_t, fix the type.
Fixes: c0cfb36c ("core: dt: introduce _fdt_fill_device_info()") Signed-of
core: dt: Repair type in _fdt_reg_size()
The function returns ssize_t , while DT_INFO_INVALID_REG is paddr_t, fix the type.
Fixes: c0cfb36c ("core: dt: introduce _fdt_fill_device_info()") Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jerome Forissier <jerome@forissier.org>
show more ...
|
| 7e4100f3 | 22-Jun-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add copy_{to,from}_private()
Adds the copy_{to,from}_private() functions which checks that the user mode buffer resides in TA private memory and not non-secure shared memory for instance.
Rev
core: add copy_{to,from}_private()
Adds the copy_{to,from}_private() functions which checks that the user mode buffer resides in TA private memory and not non-secure shared memory for instance.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jerome Forissier <jerome@forissier.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| c40a6505 | 21-Jun-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: separate copy_from_user() and friends
Removes the tee_svc_ prefix and moves tee_svc_copy_from_user() and friends into <kernel/user_access.h> and core/kernel/user/access.c
Reviewed-by: Jerome
core: separate copy_from_user() and friends
Removes the tee_svc_ prefix and moves tee_svc_copy_from_user() and friends into <kernel/user_access.h> and core/kernel/user/access.c
Reviewed-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 42471ecf | 11-Sep-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: load stmm via secure partition
Secure variable storage for EFI variables is critical for enabling and protecting UEFI Secure Boot. Unfortunately due to the fact that SPD and SPM are mutually e
core: load stmm via secure partition
Secure variable storage for EFI variables is critical for enabling and protecting UEFI Secure Boot. Unfortunately due to the fact that SPD and SPM are mutually exclusive, we can't run StMM from EDK2 and OP-TEE. An advantage of doing so is that different firmware implementations can leverage EDK2's StandAloneMM and in cooperation with OP-TEE RPMB APIs can store UEFI variables in a secure storage. This makes the variable storage quite generic in any device with an RPMB partition.
Using a well debugged application is preferable over rewriting the whole application as a TA. Another advantage is that this inherits the Fault Tolerant Writes (FTW) functionality built-in on StMM to protect variables against corruptions during writing. Considering the FFA changes of the future Arm architectures using an SP that includes everything seems like a better choice at the moment. The 'SPM emulation' currently added into OP-TEE only supports a single SP to be launched. This means that the StMM embedded application has the RPMB driver built in at the moment. In the future we can add code (evolving FFA) to launch multiple SPs. So the StMM variable handling can be decoupled from the RPMB driver, which will reside in a different SP.
So let's add a user mode secure partition context and support loading "Standalone MM" of EDK2 into it. A separate syscall handling is added to serve as different kind of ABI and syscall IDs. The secure partition has a TA like interface towards normal world, but requests are routed into the StMM partition instead.
CFG_STMM_PATH is assigned the path of BL32_AP_MM.fd, for instance: CFG_STMM_PATH=...Build/QemuVirtMmStandalone/DEBUG_GCC5/FV/BL32_AP_MM.fd
Since this is quite tricky to compile and test you can use this [1]. Just clone the repo and run ./build.sh. The script will pick up edk2, edk2-platforms, op-tee, atf and U-boot and compile all the necessary binaries for QEMU. A patch (awful hack) has been added to U-boot to allow RPMB emulation through it's supplicant, since QEMU RPMB emulation is not yet available. After compiling and launching QEMU the usual U-boot commands for EFI variable management will store the variables on an RPMB device.
[1] https://git.linaro.org/people/ilias.apalodimas/efi_optee_variables.git/
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Co-developed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Co-developed-by: Pipat Methavanitpong <pipat1010@gmail.com> Signed-off-by: Pipat Methavanitpong <pipat1010@gmail.com> Co-developed-by: Miklos Balint <Miklos.Balint@arm.com> Signed-off-by: Miklos Balint <Miklos.Balint@arm.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| e6f01334 | 03-Sep-2020 |
Jerome Forissier <jerome@forissier.org> |
core: remove stack dump macros and multiple log levels
Of the various xPRINT_STACK() macros (x in {E,I,D,F}), only EPRINT_STACK() is used. Let's simplify the code by removing the macros altogether a
core: remove stack dump macros and multiple log levels
Of the various xPRINT_STACK() macros (x in {E,I,D,F}), only EPRINT_STACK() is used. Let's simplify the code by removing the macros altogether and calling print_kernel_stack() instead. Since only the TRACE_ERROR is used, the 'level' argument to print_kernel_stack(), print_stack_arm32() and print_stack_arm64() is removed too.
In addition to simplifying the code, these changes will allow the consolidation of the stack unwinding code between core and ldelf.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 1554a779 | 19-Aug-2020 |
Javier Almansa Sobrino <javier.almansasobrino@arm.com> |
core: Fix the entry on the match table for TPM support.
TF-A Measured Boot driver expects a tpm_event_log node on the DTB with the compatible field set to "arm,tpm_event_log", so fix the match table
core: Fix the entry on the match table for TPM support.
TF-A Measured Boot driver expects a tpm_event_log node on the DTB with the compatible field set to "arm,tpm_event_log", so fix the match table entry for the TPM support to match the one used by TF-A.
Signed-off-by: Javier Almansa Sobrino <javier.almansasobrino@arm.com> Acked-by: Jerome Forissier <jerome@forissier.org>
show more ...
|
| e2f03e07 | 04-Jun-2020 |
Jerome Forissier <jerome@forissier.org> |
core: add stack overflow detection
This commit introduces CFG_CORE_DEBUG_CHECK_STACKS to check the stack limits using compiler instrumentation (-finstrument-functions). When enabled, the C compiler
core: add stack overflow detection
This commit introduces CFG_CORE_DEBUG_CHECK_STACKS to check the stack limits using compiler instrumentation (-finstrument-functions). When enabled, the C compiler will insert entry and exit hooks in all functions in the TEE core. On entry, the stack pointer is checked and if an overflow is detected, panic() is called.
How is this helpful since we have stack canaries already? 1. When a dead canary is found, the call stack will give no indication of the root cause of the corruption which may have happened quite some time before. Running the test case again with a debugger attached and a watchpoint on the canary is not always an option. 2. The system may corrupt the stack and hang in an exception handler before the first canary check, for instance, during boot when the temporary stack is used. This code will likely catch such issues, too.
The downside is increased stack usage and a significant runtime overhead which is why this feature should be enabled only for troubleshooting.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Tested-by: Jerome Forissier <jerome@forissier.org> (QEMU, QEMUv8) Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 1b302ac0 | 02-Jun-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: enable FF-A with SPM Core at S-EL1
Adds support for using FF-A as transport instead of using the proprietary SMCs defined in optee_smc.h.
The configuration support the case where SPM Core is
core: enable FF-A with SPM Core at S-EL1
Adds support for using FF-A as transport instead of using the proprietary SMCs defined in optee_smc.h.
The configuration support the case where SPM Core is implementation at S-EL1, that is, inside OP-TEE. This configuration is also know as "S-EL1 SPMC" in the FF-A 1.0 specification [1].
Compile with CFG_CORE_SEL1_SPMC=y
Note that this is an experimental feature, ABIs etc may have incompatible changes
Link: [1] https://static.docs.arm.com/den0077/a/DEN0077A_PSA_Firmware_Framework_Arm_v8-A_1.0_EAC.pdf
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| f86aa9e1 | 09-Jul-2020 |
Jerome Forissier <jerome@forissier.org> |
core: make thread ID a short int
Changes thread_get_id() and thread_get_id_may_fail() to return 'short int' instead of 'int'. That is, 16 bits instead of 32 on all supported architectures which is m
core: make thread ID a short int
Changes thread_get_id() and thread_get_id_may_fail() to return 'short int' instead of 'int'. That is, 16 bits instead of 32 on all supported architectures which is more than enough since the largest thread ID value is (CFG_NUM_THREADS - 1). Note, struct wait_queue_elem::handle is already a short int.
trace_ext_get_thread_id() is not changed (still returns an int) because it is part of the TA API and modifying it would needlessly introduce incompatibilities.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 0d8358d2 | 10-Jun-2020 |
Jerome Forissier <jerome@forissier.org> |
core: print CPU initialization messages with IMSG()
Start and end of initialization for each CPU is important information that deserves to be shown with I (information) severity rather than D (debug
core: print CPU initialization messages with IMSG()
Start and end of initialization for each CPU is important information that deserves to be shown with I (information) severity rather than D (debug). This is not done consistently, fix that.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| e3172f9d | 05-Jun-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add call_finalcalls()
Adds call_finalcalls() called at the end of paged_init_primary() just before switching to normal world boot. This allows separation of initcalls and finalcalls needed by
core: add call_finalcalls()
Adds call_finalcalls() called at the end of paged_init_primary() just before switching to normal world boot. This allows separation of initcalls and finalcalls needed by virtualization.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| c5c56024 | 05-Jun-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: call call_initcalls() directly
Now that init_teecore() is only a wrapper around call_initcalls(), drop that function and call call_initcalls() directly from init_tee_runtime().
Also move the
core: call call_initcalls() directly
Now that init_teecore() is only a wrapper around call_initcalls(), drop that function and call call_initcalls() directly from init_tee_runtime().
Also move the file to core/kernel/initcall.c since that's what it does.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jerome Forissier <jerome@forissier.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 65401337 | 07-Jun-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: remove generic_ from generic_boot
Now that the CFG_GENERIC_BOOT configuration flag has been removed also remove "generic_" prefix from and in the related files.
Acked-by: Etienne Carriere <et
core: remove generic_ from generic_boot
Now that the CFG_GENERIC_BOOT configuration flag has been removed also remove "generic_" prefix from and in the related files.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Acked-by: Jerome Forissier <jerome@forissier.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| c3682b1c | 15-May-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: make core_is_buffer_*() paddr_t compatible
The core_is_buffer_*() helpers are sometimes used with physical addresses (type paddr_t). This can cause problem on platforms where sizeof(paddr_t) >
core: make core_is_buffer_*() paddr_t compatible
The core_is_buffer_*() helpers are sometimes used with physical addresses (type paddr_t). This can cause problem on platforms where sizeof(paddr_t) > sizeof(vaddr_t), that is on ARM32 systems with CFG_CORE_LARGE_PHYS_ADDR=y. The FVP platform compiled for AArch32 is one such system which as a consequence fails with: E/TC:0 0 check_phys_mem_is_outside:335 Non-sec mem (0x880000000:0x180000000) ove rlaps map (type 12 0xff000000:0x1000000) E/TC:0 0 Panic at core/arch/arm/mm/core_mmu.c:336 <check_phys_mem_is_outside>
This patch fixes this problem by taking input addresses as paddr_t and sizes as paddr_ssize_t instead. The wrapper macros which did some automatic casting removed. The requires updates at some of the places where these functions are called.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 0c1be93b | 05-Apr-2020 |
Volodymyr Babchuk <volodymyr_babchuk@epam.com> |
core: move static IRQC data to nexus memory
itr_chip and handlers list should reside in nexus memory to ensure that irq controller is working.
Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@ep
core: move static IRQC data to nexus memory
itr_chip and handlers list should reside in nexus memory to ensure that irq controller is working.
Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com> Acked-by: Jerome Forissier <jerome@forissier.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| a2fc83d1 | 11-May-2020 |
Jerome Forissier <jerome@forissier.org> |
core: always build libfdt
libfdt is built only when CFG_DT=y. As a result, the libfdt header files are only available when CFG_DT=y and any source file that makes optional use of the library has to
core: always build libfdt
libfdt is built only when CFG_DT=y. As a result, the libfdt header files are only available when CFG_DT=y and any source file that makes optional use of the library has to guard the #include <libfdt.h> with a #ifdef CFG_DT ... #endif block. This contrasts with other features which don't require such guards.
This patch builds libfdt unconditionally and removes the include guards. No change is expected in the binaries.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 75dc8729 | 05-May-2020 |
Etienne Carriere <etienne.carriere@linaro.org> |
core: console: console initialization from embedded DTB
In case CFG_EMBED_DTB is enabled, get the chosen console from the embedded DTB instead of the external DTB.
Signed-off-by: Sahil Malhotra <sa
core: console: console initialization from embedded DTB
In case CFG_EMBED_DTB is enabled, get the chosen console from the embedded DTB instead of the external DTB.
Signed-off-by: Sahil Malhotra <sahil.malhotra@nxp.com> [ec: simplify by calling get_dt(), slightly rephrase commit log] Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Tested-by: Sahil Malhotra <sahil.malhotra@nxp.com> (ls-lx2160ardb)
show more ...
|
| 3639b55f | 04-May-2020 |
Jerome Forissier <jerome@forissier.org> |
core: rename KEEP_INIT() and KEEP_PAGER()
The KEEP_INIT() and KEEP_PAGER() macros are quite often used in C files immediately after the definition of a function or a structure without a blank line i
core: rename KEEP_INIT() and KEEP_PAGER()
The KEEP_INIT() and KEEP_PAGER() macros are quite often used in C files immediately after the definition of a function or a structure without a blank line in between. This style mimics what the Linux kernel does for a similar use cases: EXPORT_SYMBOL().
Unfortunately, the checkpatch.pl tool expects a blank line after structure and function definitions, except for a few special cases such as EXPORT_SYMBOL(). As a result we often get unwanted warnings when we use KEEP_INIT() and KEEP_PAGER(). Among the exceptions are all words starting with DECLARE_ or DEFINE_, so by renaming our macros we could avoid the checkpatch warnings.
This commit renames KEEP_INIT() and KEEP_PAGER() to DECLARE_KEEP_INIT() and DECLARE_KEEP_PAGER(), respectively. The assembler macros are also renamed for consistency. No functional change is expected.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 2288b071 | 06-Apr-2020 |
Jerome Forissier <jerome@forissier.org> |
core: lockdep: introduce CFG_LOCKDEP_RECORD_STACK
The lockdep algorithm uses quite a bit of heap memory to record the call stacks. This commit adds a configuration flag so that this may be turned of
core: lockdep: introduce CFG_LOCKDEP_RECORD_STACK
The lockdep algorithm uses quite a bit of heap memory to record the call stacks. This commit adds a configuration flag so that this may be turned off. When CFG_LOCKDEP_RECORD_STACK=n the deadlock detection still works but the diagnostics message will show no call stack obviously.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| dd333f03 | 20-Jan-2020 |
Javier Almansa Sobrino <javier.almansasobrino@arm.com> |
core: Add support to access a TPM event log in secure memory.
Support for OPTEE to be able to receive a TPM event log through a DTB so it can forward it to a TA (such as a TPM service) in order to e
core: Add support to access a TPM event log in secure memory.
Support for OPTEE to be able to receive a TPM event log through a DTB so it can forward it to a TA (such as a TPM service) in order to extend the measurements.
CFG_CORE_TPM_EVENT_LOG enables this feature. CFG_TPM_LOG_BASE_ADDR hardcodes the phys address of the event log in case CFG_DT is not set. CFG_TPM_MAX_LOG_SIZE harcodes the size of the event log in case CFG_DT is not set.
When this feature is enabled, the PTA_SYSTEM_GET_TPM_EVENT_LOG command is available to any TA.
Signed-off-by: Javier Almansa Sobrino <javier.almansasobrino@arm.com> Reviewed-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|