14efd2193SJayanth Dodderi ChidanandContext Management Library 24efd2193SJayanth Dodderi Chidanand************************** 34efd2193SJayanth Dodderi Chidanand 44efd2193SJayanth Dodderi ChidanandThis document provides an overview of the Context Management library implementation 54efd2193SJayanth Dodderi Chidanandin Trusted Firmware-A (TF-A). It enumerates and describes the APIs implemented 64efd2193SJayanth Dodderi Chidanandand their accessibility from other components at EL3. 74efd2193SJayanth Dodderi Chidanand 84efd2193SJayanth Dodderi ChidanandOverview 94efd2193SJayanth Dodderi Chidanand======== 104efd2193SJayanth Dodderi Chidanand 114efd2193SJayanth Dodderi ChidanandArm TrustZone architecture facilitates hardware-enforced isolation between 124efd2193SJayanth Dodderi Chidanandsoftware running in various security states (Secure/Non-Secure/Realm). 134efd2193SJayanth Dodderi ChidanandThe general-purpose registers, most of the system registers and vector registers 144efd2193SJayanth Dodderi Chidanandare not banked per world. When moving between the security states it is the 154efd2193SJayanth Dodderi Chidanandresponsibility of the secure monitor software (BL31(AArch64) / BL32(Aarch32)) 164efd2193SJayanth Dodderi Chidanandin TF-A, not the hardware, to save and restore register state. 174efd2193SJayanth Dodderi ChidanandRefer to `Trustzone for AArch64`_ for more details. 184efd2193SJayanth Dodderi Chidanand 194efd2193SJayanth Dodderi ChidanandEL3 Runtime Firmware, also termed as secure monitor firmware, is integrated 204efd2193SJayanth Dodderi Chidanandwith a context management library to handle the context of the CPU, managing the 214efd2193SJayanth Dodderi Chidanandsaving and restoring of register states across the worlds. 224efd2193SJayanth Dodderi Chidanand 234efd2193SJayanth Dodderi ChidanandTF-A Context 244efd2193SJayanth Dodderi Chidanand============ 254efd2193SJayanth Dodderi Chidanand 264efd2193SJayanth Dodderi ChidanandIn TF-A, the context is represented as a data structure used by the EL3 firmware 274efd2193SJayanth Dodderi Chidanandto preserve the state of the CPU at the next lower exception level (EL) in a given 284efd2193SJayanth Dodderi Chidanandsecurity state and save enough EL3 metadata to be able to return to that exception 294efd2193SJayanth Dodderi Chidanandlevel and security state. The memory for the context data structures are allocated 304efd2193SJayanth Dodderi Chidanandin BSS section of EL3 firmware. 314efd2193SJayanth Dodderi Chidanand 324efd2193SJayanth Dodderi ChidanandIn a trusted system at any instance, a given CPU could be executing in one of the 334efd2193SJayanth Dodderi Chidanandsecurity states (Non-Secure, Secure, Realm). Each world must have its 344efd2193SJayanth Dodderi Chidanandconfiguration of system registers independent of other security states to access 354efd2193SJayanth Dodderi Chidanandand execute any of the architectural features. 364efd2193SJayanth Dodderi Chidanand 374efd2193SJayanth Dodderi ChidanandIf the CPU switches across security states (for example: from Non-secure to Secure 384efd2193SJayanth Dodderi Chidanandor vice versa), the register contents, especially the ones that are not banked 394efd2193SJayanth Dodderi Chidanand(EL2/EL1, vector, general-purpose registers), will be overwritten, as the software 404efd2193SJayanth Dodderi Chidanandrunning in either state has the privileges to access them. Additionally, some of 414efd2193SJayanth Dodderi Chidanandthe architectural features enabled in the former security state will be unconditionally 424efd2193SJayanth Dodderi Chidanandaccessible in the latter security state as well. This can be a major concern when 434efd2193SJayanth Dodderi Chidananddealing with security-specific bits, as they need to be explicitly enabled or 444efd2193SJayanth Dodderi Chidananddisabled in each state to prevent data leakage across the worlds. 454efd2193SJayanth Dodderi Chidanand 464efd2193SJayanth Dodderi ChidanandIn general, an ideal trusted system should have Secure world-specific configurations 474efd2193SJayanth Dodderi Chidanandthat are not influenced by Normal World operations. Therefore, for each CPU, we 484efd2193SJayanth Dodderi Chidanandneed to maintain world-specific context to ensure that register entries from one 494efd2193SJayanth Dodderi Chidanandworld do not leak or impact the execution of the CPU in other worlds. 504efd2193SJayanth Dodderi ChidanandThis will help ensure the integrity and security of the system, preventing any 514efd2193SJayanth Dodderi Chidanandunauthorized access or data corruption between the different security states. 524efd2193SJayanth Dodderi Chidanand 534efd2193SJayanth Dodderi ChidanandDesign 544efd2193SJayanth Dodderi Chidanand====== 554efd2193SJayanth Dodderi Chidanand 564efd2193SJayanth Dodderi ChidanandThe Context Management library in TF-A is designed to cover all the requirements 574efd2193SJayanth Dodderi Chidanandfor maintaining world-specific context essential for a trusted system. 584efd2193SJayanth Dodderi ChidanandThis includes implementing CPU context initialization and management routines, 594efd2193SJayanth Dodderi Chidanandas well as other helper APIs that are required by dispatcher components in EL3 604efd2193SJayanth Dodderi Chidanandfirmware, which are collectively referred to as CPU Context Management. 614efd2193SJayanth Dodderi ChidanandThe APIs and their usecases are listed in detail under the :ref:`Library APIs` 624efd2193SJayanth Dodderi Chidanandsection. 634efd2193SJayanth Dodderi Chidanand 644efd2193SJayanth Dodderi ChidanandOriginally, the Context Management library in TF-A was designed to cater for a 654efd2193SJayanth Dodderi Chidanandtwo-world system, comprising of Non-Secure and Secure Worlds. In this case, the 664efd2193SJayanth Dodderi ChidanandEL3 Firmware is assumed to be running in Secure World. 674efd2193SJayanth Dodderi ChidanandWith introduction of Realm Management Extension (RME), from Armv9.2 a system 684efd2193SJayanth Dodderi Chidanandcan have four distinct worlds (Non-Secure, Secure, Realm, Root). 694efd2193SJayanth Dodderi ChidanandRME isolates EL3 from all other Security states and moves it into its own security 704efd2193SJayanth Dodderi Chidanandstate called root. EL3 firmware now runs at Root World and thereby is 714efd2193SJayanth Dodderi Chidanandtrusted from software in Non-secure, Secure, and Realm states. 724efd2193SJayanth Dodderi ChidanandRefer to `Security States with RME`_ for more details. 734efd2193SJayanth Dodderi Chidanand 744efd2193SJayanth Dodderi ChidanandKey principles followed in designing the context management library : 754efd2193SJayanth Dodderi Chidanand 764efd2193SJayanth Dodderi Chidanand1. **EL3 should only initialize immediate used lower EL** 774efd2193SJayanth Dodderi Chidanand 784efd2193SJayanth Dodderi ChidanandContext Management library running at EL3 should only initialize and monitor the 794efd2193SJayanth Dodderi Chidanandimmediate used lower EL. This implies that, when S-EL2 is present in the system, 804efd2193SJayanth Dodderi ChidanandEL3 should initialise and monitor S-EL2 registers only. S-EL1 registers should 814efd2193SJayanth Dodderi Chidanandnot be the concern of EL3 while S-EL2 is in place. In systems where S-EL2 is 824efd2193SJayanth Dodderi Chidanandabsent, S-EL1 registers should be initialised from EL3. 834efd2193SJayanth Dodderi Chidanand 844efd2193SJayanth Dodderi Chidanand2. **Decentralized model for context management** 854efd2193SJayanth Dodderi Chidanand 864efd2193SJayanth Dodderi ChidanandEach world (Non-Secure, Secure, and Realm) should have their separate component 874efd2193SJayanth Dodderi Chidanandin EL3 responsible for their respective world context management. 884efd2193SJayanth Dodderi ChidanandBoth the Secure and Realm world have associated dispatcher components in EL3 894efd2193SJayanth Dodderi Chidanandfirmware to allow management of the respective worlds. For the Non-Secure world, 904efd2193SJayanth Dodderi ChidanandPSCI Library (BL31)/context management library provides routines to help 914efd2193SJayanth Dodderi Chidanandinitialize the Non-Secure world context. 924efd2193SJayanth Dodderi Chidanand 934efd2193SJayanth Dodderi Chidanand3. **Flexibility for Dispatchers to select desired feature set to save and restore** 944efd2193SJayanth Dodderi Chidanand 954efd2193SJayanth Dodderi ChidanandEach feature is supported with a helper function ``is_feature_supported(void)``, 964efd2193SJayanth Dodderi Chidanandto detect its presence at runtime. This helps dispatchers to select the desired 974efd2193SJayanth Dodderi Chidanandfeature set, and thereby save and restore the configuration associated with them. 984efd2193SJayanth Dodderi Chidanand 994efd2193SJayanth Dodderi Chidanand4. **Dynamic discovery of Feature enablement by EL3** 1004efd2193SJayanth Dodderi Chidanand 10143d1d951SManish PandeyTF-A supports four states for feature enablement at EL3, to make them available 1024efd2193SJayanth Dodderi Chidanandfor lower exception levels. 1034efd2193SJayanth Dodderi Chidanand 1044efd2193SJayanth Dodderi Chidanand.. code:: c 1054efd2193SJayanth Dodderi Chidanand 1064efd2193SJayanth Dodderi Chidanand #define FEAT_STATE_DISABLED 0 1074efd2193SJayanth Dodderi Chidanand #define FEAT_STATE_ENABLED 1 1084efd2193SJayanth Dodderi Chidanand #define FEAT_STATE_CHECK 2 1094efd2193SJayanth Dodderi Chidanand 1104efd2193SJayanth Dodderi ChidanandA pattern is established for feature enablement behavior. 1114efd2193SJayanth Dodderi ChidanandEach feature must support the 3 possible values with rigid semantics. 1124efd2193SJayanth Dodderi Chidanand 1134efd2193SJayanth Dodderi Chidanand- **FEAT_STATE_DISABLED** - all code relating to this feature is always skipped. 1144efd2193SJayanth Dodderi Chidanand Firmware is unaware of this feature. 1154efd2193SJayanth Dodderi Chidanand 1164efd2193SJayanth Dodderi Chidanand- **FEAT_STATE_ALWAYS** - all code relating to this feature is always executed. 1174efd2193SJayanth Dodderi Chidanand Firmware expects this feature to be present in hardware. 1184efd2193SJayanth Dodderi Chidanand 1194efd2193SJayanth Dodderi Chidanand- **FEAT_STATE_CHECK** - same as ``FEAT_STATE_ALWAYS`` except that the feature's 1204efd2193SJayanth Dodderi Chidanand existence will be checked at runtime. Default on dynamic platforms (example: FVP). 1214efd2193SJayanth Dodderi Chidanand 12243d1d951SManish Pandey .. note:: 123*ef738d19SManish Pandey 124*ef738d19SManish Pandey In general, it is assumed that all cores will support the same set of 125*ef738d19SManish Pandey architectural features (features will be symmetrical). However, there are 126*ef738d19SManish Pandey cases where this is impractical to achieve. Only some features can be 127*ef738d19SManish Pandey mismatched among cores and this is the exception rather than the rule. This 128*ef738d19SManish Pandey is due to the fact that Operating systems are designed for SMP systems. There 129*ef738d19SManish Pandey are no clear guidelines what kind of mismatch is allowed but following 130*ef738d19SManish Pandey pointers can help in making a decision: 13143d1d951SManish Pandey 13243d1d951SManish Pandey - All mandatory features must be symmetric. 13343d1d951SManish Pandey - Any feature that impacts the generation of page tables must be symmetric. 13443d1d951SManish Pandey - Any feature access which does not trap to EL3 should be symmetric. 13543d1d951SManish Pandey - Features related with profiling, debug and trace could be asymmetric 13643d1d951SManish Pandey - Migration of vCPU/tasks between CPUs should not cause an error 13743d1d951SManish Pandey 138*ef738d19SManish Pandey TF-A caters for mismatched features, however, this is not regularly tested 139*ef738d19SManish Pandey for all features and may not work as expected, even without considering OS 140*ef738d19SManish Pandey support. 14143d1d951SManish Pandey 1424efd2193SJayanth Dodderi Chidanand .. note:: 1434efd2193SJayanth Dodderi Chidanand ``FEAT_RAS`` is an exception here, as it impacts the execution of EL3 and 1444efd2193SJayanth Dodderi Chidanand it is essential to know its presence at compile time. Refer to ``ENABLE_FEAT`` 1454efd2193SJayanth Dodderi Chidanand macro under :ref:`Build Options` section for more details. 1464efd2193SJayanth Dodderi Chidanand 1474efd2193SJayanth Dodderi ChidanandCode Structure 1484efd2193SJayanth Dodderi Chidanand============== 1494efd2193SJayanth Dodderi Chidanand 1504efd2193SJayanth Dodderi Chidanand`lib/el3_runtime/(aarch32/aarch64)`_ - Context library code directory. 1514efd2193SJayanth Dodderi Chidanand 1524efd2193SJayanth Dodderi ChidanandSource Files 1534efd2193SJayanth Dodderi Chidanand~~~~~~~~~~~~ 1544efd2193SJayanth Dodderi Chidanand 1554efd2193SJayanth Dodderi Chidanand#. ``context_mgmt.c`` : consists of core functions that setup, save and restore 1564efd2193SJayanth Dodderi Chidanand context for different security states alongside high level feature enablement 1574efd2193SJayanth Dodderi Chidanand APIs for individual worlds. 1584efd2193SJayanth Dodderi Chidanand 1594efd2193SJayanth Dodderi Chidanand#. ``cpu_data_array.c`` : contains per_cpu_data structure instantiation. 1604efd2193SJayanth Dodderi Chidanand 1614efd2193SJayanth Dodderi Chidanand#. ``context.S`` : consists of functions that save and restore some of the context 1624efd2193SJayanth Dodderi Chidanand structure members in assembly code. 1634efd2193SJayanth Dodderi Chidanand 1644efd2193SJayanth Dodderi Chidanand#. ``cpu_data.S`` : consists of helper functions to initialise per_cpu_data pointers. 1654efd2193SJayanth Dodderi Chidanand 1664efd2193SJayanth Dodderi Chidanand#. ``el3_common_macros.S`` : consists of macros to facilitate actions to be performed 1674efd2193SJayanth Dodderi Chidanand during cold and warmboot and el3 registers initialisation in assembly code. 1684efd2193SJayanth Dodderi Chidanand 1694efd2193SJayanth Dodderi ChidanandHeader Files 1704efd2193SJayanth Dodderi Chidanand~~~~~~~~~~~~ 1714efd2193SJayanth Dodderi Chidanand 1724efd2193SJayanth Dodderi Chidanand#. ``context_mgmt.h`` : contains the public interface to Context Management Library. 1734efd2193SJayanth Dodderi Chidanand 1744efd2193SJayanth Dodderi Chidanand#. ``context.h`` : contains the helper macros and definitions for context entries. 1754efd2193SJayanth Dodderi Chidanand 1764efd2193SJayanth Dodderi Chidanand#. ``cpu_data.h`` : contains the public interface to Per CPU data structure. 1774efd2193SJayanth Dodderi Chidanand 1784efd2193SJayanth Dodderi Chidanand#. ``context_debug.h`` : contains public interface to report context memory 1794efd2193SJayanth Dodderi Chidanand utilisation across the security states. 1804efd2193SJayanth Dodderi Chidanand 1814efd2193SJayanth Dodderi Chidanand#. ``context_el2.h`` : internal header consisting of helper macros to access EL2 1824efd2193SJayanth Dodderi Chidanand context entries. Used by ``context.h``. 1834efd2193SJayanth Dodderi Chidanand 1844efd2193SJayanth Dodderi ChidanandApart from these files, we have some context related source files under ``BL1`` 1854efd2193SJayanth Dodderi Chidanandand ``BL31`` directory. ``bl1_context_mgmt.c`` ``bl31_context_mgmt.c`` 1864efd2193SJayanth Dodderi Chidanand 1874efd2193SJayanth Dodderi ChidanandBootloader Images utilizing Context Management Library 1884efd2193SJayanth Dodderi Chidanand====================================================== 1894efd2193SJayanth Dodderi Chidanand 1904efd2193SJayanth Dodderi Chidanand+-------------------------------------------+-----------------------------+ 1914efd2193SJayanth Dodderi Chidanand| Bootloader | Context Management Library | 1924efd2193SJayanth Dodderi Chidanand+-------------------------------------------+-----------------------------+ 1934efd2193SJayanth Dodderi Chidanand| BL1 | Yes | 1944efd2193SJayanth Dodderi Chidanand+-------------------------------------------+-----------------------------+ 1954efd2193SJayanth Dodderi Chidanand| BL2 | No | 1964efd2193SJayanth Dodderi Chidanand+-------------------------------------------+-----------------------------+ 1974efd2193SJayanth Dodderi Chidanand| BL31 (Aarch64- EL3runtime firmware) | Yes | 1984efd2193SJayanth Dodderi Chidanand+-------------------------------------------+-----------------------------+ 1994efd2193SJayanth Dodderi Chidanand| BL32 (Aarch32- EL3runtime firmware) | Yes | 2004efd2193SJayanth Dodderi Chidanand+-------------------------------------------+-----------------------------+ 2014efd2193SJayanth Dodderi Chidanand 2024efd2193SJayanth Dodderi ChidanandCPU Data Structure 2034efd2193SJayanth Dodderi Chidanand================== 2044efd2193SJayanth Dodderi ChidanandFor a given system, depending on the CPU count, the platform statically 2054efd2193SJayanth Dodderi Chidanandallocates memory for the CPU data structure. 2064efd2193SJayanth Dodderi Chidanand 2074efd2193SJayanth Dodderi Chidanand.. code:: c 2084efd2193SJayanth Dodderi Chidanand 2094efd2193SJayanth Dodderi Chidanand /* The per_cpu_ptr_cache_t space allocation */ 2104efd2193SJayanth Dodderi Chidanand cpu_data_t percpu_data[PLATFORM_CORE_COUNT]; 2114efd2193SJayanth Dodderi Chidanand 2124efd2193SJayanth Dodderi ChidanandThis CPU data structure has a member element with an array of pointers to hold 2134efd2193SJayanth Dodderi Chidanandthe Non-Secure, Realm and Secure security state context structures as listed below. 2144efd2193SJayanth Dodderi Chidanand 2154efd2193SJayanth Dodderi Chidanand.. code:: c 2164efd2193SJayanth Dodderi Chidanand 2174efd2193SJayanth Dodderi Chidanand typedef struct cpu_data { 2184efd2193SJayanth Dodderi Chidanand #ifdef __aarch64__ 2194efd2193SJayanth Dodderi Chidanand void *cpu_context[CPU_DATA_CONTEXT_NUM]; 2204efd2193SJayanth Dodderi Chidanand #endif 2214efd2193SJayanth Dodderi Chidanand 2224efd2193SJayanth Dodderi Chidanand .... 2234efd2193SJayanth Dodderi Chidanand .... 2244efd2193SJayanth Dodderi Chidanand 2254efd2193SJayanth Dodderi Chidanand }cpu_data_t; 2264efd2193SJayanth Dodderi Chidanand 2274efd2193SJayanth Dodderi Chidanand|CPU Data Structure| 2284efd2193SJayanth Dodderi Chidanand 2294efd2193SJayanth Dodderi ChidanandAt runtime, ``cpu_context[CPU_DATA_CONTEXT_NUM]`` array will be intitialised with 2304efd2193SJayanth Dodderi Chidanandthe Secure, Non-Secure and Realm context structure addresses to ensure proper 2314efd2193SJayanth Dodderi Chidanandhandling of the register state. 2324efd2193SJayanth Dodderi ChidanandSee :ref:`Library APIs` section for more details. 2334efd2193SJayanth Dodderi Chidanand 2344efd2193SJayanth Dodderi ChidanandCPU Context and Memory allocation 2354efd2193SJayanth Dodderi Chidanand================================= 2364efd2193SJayanth Dodderi Chidanand 2374efd2193SJayanth Dodderi ChidanandCPU Context 2384efd2193SJayanth Dodderi Chidanand~~~~~~~~~~~ 2394efd2193SJayanth Dodderi ChidanandThe members of the context structure used by the EL3 firmware to preserve the 2404efd2193SJayanth Dodderi Chidanandstate of CPU across exception levels for a given security state are listed below. 2414efd2193SJayanth Dodderi Chidanand 2424efd2193SJayanth Dodderi Chidanand.. code:: c 2434efd2193SJayanth Dodderi Chidanand 2444efd2193SJayanth Dodderi Chidanand typedef struct cpu_context { 2454efd2193SJayanth Dodderi Chidanand gp_regs_t gpregs_ctx; 2464efd2193SJayanth Dodderi Chidanand el3_state_t el3state_ctx; 2474efd2193SJayanth Dodderi Chidanand 2484efd2193SJayanth Dodderi Chidanand cve_2018_3639_t cve_2018_3639_ctx; 2490f3cd515SJayanth Dodderi Chidanand 2500f3cd515SJayanth Dodderi Chidanand #if ERRATA_SPECULATIVE_AT 2510f3cd515SJayanth Dodderi Chidanand errata_speculative_at_t errata_speculative_at_ctx; 2520f3cd515SJayanth Dodderi Chidanand #endif 2530f3cd515SJayanth Dodderi Chidanand 2544efd2193SJayanth Dodderi Chidanand #if CTX_INCLUDE_PAUTH_REGS 2554efd2193SJayanth Dodderi Chidanand pauth_t pauth_ctx; 2564efd2193SJayanth Dodderi Chidanand #endif 2574efd2193SJayanth Dodderi Chidanand 2580f3cd515SJayanth Dodderi Chidanand #if (CTX_INCLUDE_EL2_REGS && IMAGE_BL31) 2590f3cd515SJayanth Dodderi Chidanand el2_sysregs_t el2_sysregs_ctx; 2600f3cd515SJayanth Dodderi Chidanand #else 2610f3cd515SJayanth Dodderi Chidanand el1_sysregs_t el1_sysregs_ctx; 2624efd2193SJayanth Dodderi Chidanand #endif 2634efd2193SJayanth Dodderi Chidanand } cpu_context_t; 2644efd2193SJayanth Dodderi Chidanand 2654efd2193SJayanth Dodderi ChidanandContext Memory Allocation 2664efd2193SJayanth Dodderi Chidanand~~~~~~~~~~~~~~~~~~~~~~~~~ 2674efd2193SJayanth Dodderi Chidanand 2684efd2193SJayanth Dodderi ChidanandCPUs maintain their context per world. The individual context memory allocation 2694efd2193SJayanth Dodderi Chidanandfor each CPU per world is allocated by the world-specific dispatcher components 2704efd2193SJayanth Dodderi Chidanandat compile time as shown below. 2714efd2193SJayanth Dodderi Chidanand 2724efd2193SJayanth Dodderi Chidanand|Context memory allocation| 2734efd2193SJayanth Dodderi Chidanand 2744efd2193SJayanth Dodderi ChidanandNS-Context Memory 2754efd2193SJayanth Dodderi Chidanand~~~~~~~~~~~~~~~~~ 2764efd2193SJayanth Dodderi ChidanandIt's important to note that the Normal world doesn't possess the dispatcher 2774efd2193SJayanth Dodderi Chidanandcomponent found in the Secure and Realm worlds. Instead, the PSCI library at EL3 2784efd2193SJayanth Dodderi Chidanandhandles memory allocation for ``Non-Secure`` world context for all CPUs. 2794efd2193SJayanth Dodderi Chidanand 2804efd2193SJayanth Dodderi Chidanand.. code:: c 2814efd2193SJayanth Dodderi Chidanand 2824efd2193SJayanth Dodderi Chidanand static cpu_context_t psci_ns_context[PLATFORM_CORE_COUNT]; 2834efd2193SJayanth Dodderi Chidanand 2844efd2193SJayanth Dodderi ChidanandSecure-Context Memory 2854efd2193SJayanth Dodderi Chidanand~~~~~~~~~~~~~~~~~~~~~ 2864efd2193SJayanth Dodderi ChidanandSecure World dispatcher (such as SPMD) at EL3 allocates the memory for ``Secure`` 2874efd2193SJayanth Dodderi Chidanandworld context of all CPUs. 2884efd2193SJayanth Dodderi Chidanand 2894efd2193SJayanth Dodderi Chidanand.. code:: c 2904efd2193SJayanth Dodderi Chidanand 2914efd2193SJayanth Dodderi Chidanand static spmd_spm_core_context_t spm_core_context[PLATFORM_CORE_COUNT]; 2924efd2193SJayanth Dodderi Chidanand 2934efd2193SJayanth Dodderi ChidanandRealm-Context Memory 2944efd2193SJayanth Dodderi Chidanand~~~~~~~~~~~~~~~~~~~~ 2954efd2193SJayanth Dodderi ChidanandRealm World dispatcher (RMMD) at EL3 allocates the memory for ``Realm`` world 2964efd2193SJayanth Dodderi Chidanandcontext of all CPUs. 2974efd2193SJayanth Dodderi Chidanand 2984efd2193SJayanth Dodderi Chidanand.. code:: c 2994efd2193SJayanth Dodderi Chidanand 3004efd2193SJayanth Dodderi Chidanand rmmd_rmm_context_t rmm_context[PLATFORM_CORE_COUNT]; 3014efd2193SJayanth Dodderi Chidanand 3024efd2193SJayanth Dodderi ChidanandTo summarize, the world-specific context structures are synchronized with 3034efd2193SJayanth Dodderi Chidanandper-CPU data structures, which means that each CPU will have an array of pointers 3044efd2193SJayanth Dodderi Chidanandto individual worlds. The figure below illustrates the same. 3054efd2193SJayanth Dodderi Chidanand 3064efd2193SJayanth Dodderi Chidanand|CPU Context Memory Configuration| 3074efd2193SJayanth Dodderi Chidanand 3084efd2193SJayanth Dodderi ChidanandContext Setup/Initialization 3094efd2193SJayanth Dodderi Chidanand============================ 3104efd2193SJayanth Dodderi Chidanand 3114efd2193SJayanth Dodderi ChidanandThe CPU has been assigned context structures for every security state, which include 3124efd2193SJayanth Dodderi ChidanandNon-Secure, Secure and Realm. It is crucial to initialize each of these structures 3134efd2193SJayanth Dodderi Chidanandduring the bootup of every CPU before they enter any security state for the 3144efd2193SJayanth Dodderi Chidanandfirst time. This section explains the specifics of how the initialization of 3154efd2193SJayanth Dodderi Chidanandevery CPU context takes place during both cold and warm boot paths. 3164efd2193SJayanth Dodderi Chidanand 3174efd2193SJayanth Dodderi ChidanandContext Setup during Cold boot 3184efd2193SJayanth Dodderi Chidanand~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3194efd2193SJayanth Dodderi ChidanandThe cold boot path is mainly executed by the primary CPU, other than essential 3204efd2193SJayanth Dodderi ChidanandCPU initialization executed by all CPUs. After executing BL1 and BL2, the Primary 3214efd2193SJayanth Dodderi ChidanandCPU jumps to the BL31 image for runtime services initialization. 3224efd2193SJayanth Dodderi ChidanandDuring this process, the per_cpu_data structure gets initialized with statically 3234efd2193SJayanth Dodderi Chidanandallocated world-specific context memory. 3244efd2193SJayanth Dodderi Chidanand 3254efd2193SJayanth Dodderi ChidanandLater in the cold boot sequence, the BL31 image at EL3 checks for the presence 3264efd2193SJayanth Dodderi Chidanandof a Secure world image at S-EL2. If detected, it invokes the secure context 3274efd2193SJayanth Dodderi Chidanandinitialization sequence under SPMD. Additionally, based on RME enablement, 3284efd2193SJayanth Dodderi Chidanandthe Realm context gets initialized from the RMMD at EL3. Finally, before exiting 3294efd2193SJayanth Dodderi Chidanandto the normal world, the Non-Secure context gets initialized via the context 3304efd2193SJayanth Dodderi Chidanandmanagement library. At this stage, all Primary CPU contexts are initialized 3314efd2193SJayanth Dodderi Chidanandand the CPU exits EL3 to enter the Normal world. 3324efd2193SJayanth Dodderi Chidanand 3334efd2193SJayanth Dodderi Chidanand|Context Init ColdBoot| 3344efd2193SJayanth Dodderi Chidanand 3354efd2193SJayanth Dodderi Chidanand.. note:: 3364efd2193SJayanth Dodderi Chidanand The figure above illustrates a scenario on FVP for one of the build 3374efd2193SJayanth Dodderi Chidanand configurations with TFTF component at NS-EL2. 3384efd2193SJayanth Dodderi Chidanand 3394efd2193SJayanth Dodderi ChidanandContext Setup during Warmboot 3404efd2193SJayanth Dodderi Chidanand~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414efd2193SJayanth Dodderi Chidanand 3424efd2193SJayanth Dodderi ChidanandDuring a warm boot sequence, the primary CPU is responsible for powering on the 3434efd2193SJayanth Dodderi Chidanandsecondary CPUs. Refer to :ref:`CPU Reset` and :ref:`Firmware Design` sections for 3444efd2193SJayanth Dodderi Chidanandmore details on the warm boot. 3454efd2193SJayanth Dodderi Chidanand 3464efd2193SJayanth Dodderi Chidanand|Context Init WarmBoot| 3474efd2193SJayanth Dodderi Chidanand 348*ef738d19SManish PandeyThe primary CPU writes the entrypoint for the secondary CPU. When the secondary 349*ef738d19SManish Pandeywakes up it initialises its own context via ``cm_init_my_context( ep )`` using 350*ef738d19SManish Pandeythe provided entrypoint. 3514efd2193SJayanth Dodderi Chidanand 3524efd2193SJayanth Dodderi Chidanand``psci_warmboot_entrypoint()`` is the warm boot entrypoint procedure. 3534efd2193SJayanth Dodderi ChidanandDuring the warm bootup process, secondary CPUs have their secure context 3544efd2193SJayanth Dodderi Chidanandinitialized through SPMD at EL3. Upon successful SP initialization, the SPD 3554efd2193SJayanth Dodderi Chidanandpower management operations become shared with the PSCI library. During this 3564efd2193SJayanth Dodderi Chidanandprocess, the SPMD duly registers its handlers with the PSCI library. 3574efd2193SJayanth Dodderi Chidanand 3584efd2193SJayanth Dodderi Chidanand.. code:: c 3594efd2193SJayanth Dodderi Chidanand 3604efd2193SJayanth Dodderi Chidanand file: psci_common.c 3614efd2193SJayanth Dodderi Chidanand const spd_pm_ops_t *psci_spd_pm; 3624efd2193SJayanth Dodderi Chidanand 3634efd2193SJayanth Dodderi Chidanand file: spmd_pm.c 3644efd2193SJayanth Dodderi Chidanand const spd_pm_ops_t spmd_pm = { 3654efd2193SJayanth Dodderi Chidanand .svc_on_finish = spmd_cpu_on_finish_handler, 3664efd2193SJayanth Dodderi Chidanand .svc_off = spmd_cpu_off_handler 3674efd2193SJayanth Dodderi Chidanand } 3684efd2193SJayanth Dodderi Chidanand 3694efd2193SJayanth Dodderi ChidanandSecondary CPUs during their bootup in the ``psci_cpu_on_finish()`` routine get 3704efd2193SJayanth Dodderi Chidanandtheir secure context initialised via the registered SPMD handler 3714efd2193SJayanth Dodderi Chidanand``spmd_cpu_on_finish_handler()`` at EL3. 3724efd2193SJayanth Dodderi ChidanandThe figure above illustrates the same with reference of Primary CPU running at 3734efd2193SJayanth Dodderi ChidanandNS-EL2. 3744efd2193SJayanth Dodderi Chidanand 3754efd2193SJayanth Dodderi Chidanand.. _Library APIs: 3764efd2193SJayanth Dodderi Chidanand 3774efd2193SJayanth Dodderi ChidanandLibrary APIs 3784efd2193SJayanth Dodderi Chidanand============ 3794efd2193SJayanth Dodderi Chidanand 3804efd2193SJayanth Dodderi ChidanandThe public APIs and types can be found in ``include/lib/el3_runtime/context_management.h`` 3814efd2193SJayanth Dodderi Chidanandand this section is intended to provide additional details and clarifications. 3824efd2193SJayanth Dodderi Chidanand 3834efd2193SJayanth Dodderi ChidanandContext Initialization for Individual Worlds 3844efd2193SJayanth Dodderi Chidanand~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3854efd2193SJayanth Dodderi ChidanandThe library implements high level APIs for the CPUs in setting up their individual 3864efd2193SJayanth Dodderi Chidanandcontext for each world (Non-Secure, Secure and Realm). 3874efd2193SJayanth Dodderi Chidanand 3884efd2193SJayanth Dodderi Chidanand.. c:function:: static void setup_context_common(cpu_context_t *ctx, const entry_point_info_t *ep); 3894efd2193SJayanth Dodderi Chidanand 3904efd2193SJayanth Dodderi ChidanandThis function is responsible for the general context initialization that applies 3914efd2193SJayanth Dodderi Chidanandto all worlds. It will be invoked first, before calling the individual 3924efd2193SJayanth Dodderi Chidanandworld-specific context setup APIs. 3934efd2193SJayanth Dodderi Chidanand 3944efd2193SJayanth Dodderi Chidanand.. c:function:: static void setup_ns_context(cpu_context_t *ctx, const struct entry_point_info *ep); 3954efd2193SJayanth Dodderi Chidanand.. c:function:: static void setup_realm_context(cpu_context_t *ctx, const struct entry_point_info *ep); 3964efd2193SJayanth Dodderi Chidanand.. c:function:: static void setup_secure_context(cpu_context_t *ctx, const struct entry_point_info *ep); 3974efd2193SJayanth Dodderi Chidanand 3984efd2193SJayanth Dodderi ChidanandDepending on the security state that the CPU needs to enter, the respective 3994efd2193SJayanth Dodderi Chidanandworld-specific context setup handlers listed above will be invoked once per-CPU 4004efd2193SJayanth Dodderi Chidanandto set up the context for their execution. 4014efd2193SJayanth Dodderi Chidanand 4024efd2193SJayanth Dodderi Chidanand.. c:function:: void cm_manage_extensions_el3(void) 4034efd2193SJayanth Dodderi Chidanand 4044efd2193SJayanth Dodderi ChidanandThis function initializes all EL3 registers whose values do not change during the 4054efd2193SJayanth Dodderi Chidanandlifetime of EL3 runtime firmware. It is invoked from each CPU via the cold boot 4064efd2193SJayanth Dodderi Chidanandpath ``bl31_main()`` and in the WarmBoot entry path ``void psci_warmboot_entrypoint()``. 4074efd2193SJayanth Dodderi Chidanand 4084efd2193SJayanth Dodderi ChidanandRuntime Save and Restore of Registers 4094efd2193SJayanth Dodderi Chidanand~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104efd2193SJayanth Dodderi Chidanand 4114efd2193SJayanth Dodderi ChidanandEL1 Registers 4124efd2193SJayanth Dodderi Chidanand------------- 4134efd2193SJayanth Dodderi Chidanand 4144efd2193SJayanth Dodderi Chidanand.. c:function:: void cm_el1_sysregs_context_save(uint32_t security_state); 4154efd2193SJayanth Dodderi Chidanand.. c:function:: void cm_el1_sysregs_context_restore(uint32_t security_state); 4164efd2193SJayanth Dodderi Chidanand 4174efd2193SJayanth Dodderi ChidanandThese functions are utilized by the world-specific dispatcher components running 4184efd2193SJayanth Dodderi Chidanandat EL3 to facilitate the saving and restoration of the EL1 system registers 4194efd2193SJayanth Dodderi Chidanandduring a world switch. 4204efd2193SJayanth Dodderi Chidanand 4214efd2193SJayanth Dodderi ChidanandEL2 Registers 4224efd2193SJayanth Dodderi Chidanand------------- 4234efd2193SJayanth Dodderi Chidanand 4244efd2193SJayanth Dodderi Chidanand.. c:function:: void cm_el2_sysregs_context_save(uint32_t security_state); 4254efd2193SJayanth Dodderi Chidanand.. c:function:: void cm_el2_sysregs_context_restore(uint32_t security_state); 4264efd2193SJayanth Dodderi Chidanand 4274efd2193SJayanth Dodderi ChidanandThese functions are utilized by the world-specific dispatcher components running 4284efd2193SJayanth Dodderi Chidanandat EL3 to facilitate the saving and restoration of the EL2 system registers 4294efd2193SJayanth Dodderi Chidanandduring a world switch. 4304efd2193SJayanth Dodderi Chidanand 4314efd2193SJayanth Dodderi ChidanandPauth Registers 4324efd2193SJayanth Dodderi Chidanand--------------- 4334efd2193SJayanth Dodderi Chidanand 4344efd2193SJayanth Dodderi ChidanandPointer Authentication feature is enabled by default for Non-Secure world and 4354efd2193SJayanth Dodderi Chidananddisabled for Secure and Realm worlds. In this case, we don't need to explicitly 4364efd2193SJayanth Dodderi Chidanandsave and restore the Pauth registers during world switch. 4374efd2193SJayanth Dodderi ChidanandHowever, ``CTX_INCLUDE_PAUTH_REGS`` flag is explicitly used to enable Pauth for 4384efd2193SJayanth Dodderi Chidanandlower exception levels of Secure and Realm worlds. In this scenario, we save the 4394efd2193SJayanth Dodderi Chidanandgeneral purpose and Pauth registers while we enter EL3 from lower ELs via 4404efd2193SJayanth Dodderi Chidanand``prepare_el3_entry`` and restore them back while we exit EL3 to lower ELs 4414efd2193SJayanth Dodderi Chidanandvia ``el3_exit``. 4424efd2193SJayanth Dodderi Chidanand 4434efd2193SJayanth Dodderi Chidanand.. code:: c 4444efd2193SJayanth Dodderi Chidanand 4454efd2193SJayanth Dodderi Chidanand .macro save_gp_pmcr_pauth_regs 4464efd2193SJayanth Dodderi Chidanand func restore_gp_pmcr_pauth_regs 4474efd2193SJayanth Dodderi Chidanand 4484efd2193SJayanth Dodderi ChidanandFeature Enablement for Individual Worlds 4494efd2193SJayanth Dodderi Chidanand~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504efd2193SJayanth Dodderi Chidanand 4514efd2193SJayanth Dodderi Chidanand.. c:function:: static void manage_extensions_nonsecure(cpu_context_t *ctx); 4524efd2193SJayanth Dodderi Chidanand.. c:function:: static void manage_extensions_secure(cpu_context_t *ctx); 4534efd2193SJayanth Dodderi Chidanand.. c:function:: static void manage_extensions_realm(cpu_context_t *ctx) 4544efd2193SJayanth Dodderi Chidanand 4554efd2193SJayanth Dodderi ChidanandFunctions that allow the enabling and disabling of architectural features for 4564efd2193SJayanth Dodderi Chidanandeach security state. These functions are invoked from the top-level setup APIs 4574efd2193SJayanth Dodderi Chidanandduring context initialization. 4584efd2193SJayanth Dodderi Chidanand 4594efd2193SJayanth Dodderi ChidanandFurther, a pattern is established for feature enablement code (AArch64). 4604efd2193SJayanth Dodderi ChidanandEach feature implements following APIs as applicable: 4614efd2193SJayanth Dodderi ChidanandNote: (``xxx`` is the name of the feature in the APIs) 4624efd2193SJayanth Dodderi Chidanand 4634efd2193SJayanth Dodderi Chidanand- ``is_feat_xxx_supported()`` and ``is_feat_xxx_present()`` - mandatory for all features. 4644efd2193SJayanth Dodderi Chidanand 4654efd2193SJayanth Dodderi Chidanand- ``xxx_enable(cpu_context * )`` and ``xxx_disable(cpu_context * )`` - optional 4664efd2193SJayanth Dodderi Chidanand functions to enable the feature for the passed context only. To be called in 4674efd2193SJayanth Dodderi Chidanand the respective world's setup_context to select behaviour. 4684efd2193SJayanth Dodderi Chidanand 4694efd2193SJayanth Dodderi Chidanand- ``xxx_init_el3()`` - optional function to enable the feature in-place in any EL3 4704efd2193SJayanth Dodderi Chidanand registers that are never context switched. The values they write must never 4714efd2193SJayanth Dodderi Chidanand change, otherwise the functions mentioned in previous point should be used. 4724efd2193SJayanth Dodderi Chidanand Invoked from ``cm_manage_extensions_el3()``. 4734efd2193SJayanth Dodderi Chidanand 4744efd2193SJayanth Dodderi Chidanand- ``xxx_init_el2_unused()`` - optional function to enable the feature in-place 4754efd2193SJayanth Dodderi Chidanand in any EL2 registers that are necessary for execution in EL1 with no EL2 present. 4764efd2193SJayanth Dodderi Chidanand 4774efd2193SJayanth Dodderi ChidanandThe above mentioned rules, followed for ``FEAT_SME`` is shown below: 4784efd2193SJayanth Dodderi Chidanand 4794efd2193SJayanth Dodderi Chidanand.. code:: c 4804efd2193SJayanth Dodderi Chidanand 4814efd2193SJayanth Dodderi Chidanand void sme_enable(cpu_context_t *context); 4824efd2193SJayanth Dodderi Chidanand void sme_init_el3(void); 4834efd2193SJayanth Dodderi Chidanand void sme_init_el2_unused(void); 4844efd2193SJayanth Dodderi Chidanand void sme_disable(cpu_context_t *context); 4854efd2193SJayanth Dodderi Chidanand 4864efd2193SJayanth Dodderi ChidanandPer-world Context 4874efd2193SJayanth Dodderi Chidanand================= 4884efd2193SJayanth Dodderi Chidanand 4894efd2193SJayanth Dodderi ChidanandApart from the CPU context structure, we have another structure to manage some 4904efd2193SJayanth Dodderi Chidanandof the EL3 system registers whose values are identical across all the CPUs 4914efd2193SJayanth Dodderi Chidanandreferred to as ``per_world_context_t``. 4924efd2193SJayanth Dodderi ChidanandThe Per-world context structure is intended for managing EL3 system registers with 4934efd2193SJayanth Dodderi Chidanandidentical values across all CPUs, requiring only a singular context entry for each 4944efd2193SJayanth Dodderi Chidanandindividual world. This structure operates independently of the CPU context 4954efd2193SJayanth Dodderi Chidanandstructure and is intended to manage specific EL3 registers. 4964efd2193SJayanth Dodderi Chidanand 4974efd2193SJayanth Dodderi Chidanand.. code-block:: c 4984efd2193SJayanth Dodderi Chidanand 4994efd2193SJayanth Dodderi Chidanand typedef struct per_world_context { 5004efd2193SJayanth Dodderi Chidanand uint64_t ctx_cptr_el3; 5014efd2193SJayanth Dodderi Chidanand uint64_t ctx_mpam3_el3; 5024efd2193SJayanth Dodderi Chidanand } per_world_context_t; 5034efd2193SJayanth Dodderi Chidanand 5044efd2193SJayanth Dodderi ChidanandThese functions facilitate the activation of architectural extensions that possess 5054efd2193SJayanth Dodderi Chidanandidentical values across all cores for the individual Non-secure, Secure, and 5064efd2193SJayanth Dodderi ChidanandRealm worlds. 5074efd2193SJayanth Dodderi Chidanand 5080f3cd515SJayanth Dodderi ChidanandRoot-Context (EL3-Execution-Context) 5090f3cd515SJayanth Dodderi Chidanand==================================== 5100f3cd515SJayanth Dodderi Chidanand 5110f3cd515SJayanth Dodderi ChidanandEL3/Root Context is the execution environment while the CPU is running at EL3. 5120f3cd515SJayanth Dodderi Chidanand 5130f3cd515SJayanth Dodderi ChidanandPreviously, while the CPU is in execution at EL3, the system registers persist 5140f3cd515SJayanth Dodderi Chidanandwith the values of the incoming world. This implies that if the CPU is entering 5150f3cd515SJayanth Dodderi ChidanandEL3 from NS world, the EL1 and EL2 system registers which might be modified in 5160f3cd515SJayanth Dodderi Chidanandlower exception levels NS(EL2/EL1) will carry forward those values to EL3. 5170f3cd515SJayanth Dodderi ChidanandFurther the EL3 registers also hold on to the values configured for Non-secure 5180f3cd515SJayanth Dodderi Chidanandworld, written during the previous ERET from EL3 to NS(EL2/EL1). 5190f3cd515SJayanth Dodderi ChidanandSame policy is followed with respect to other worlds (Secure/Realm) depending on 5200f3cd515SJayanth Dodderi Chidanandthe system configuration. 5210f3cd515SJayanth Dodderi Chidanand 5220f3cd515SJayanth Dodderi ChidanandThe firmware at EL3 has traditionally operated within the context of the incoming 5230f3cd515SJayanth Dodderi Chidanandworld (Secure/Non-Secure/Realm). This becomes problematic in scenarios where the 5240f3cd515SJayanth Dodderi ChidanandEL3/Root world must explicitly use architectural features that depend on system 5250f3cd515SJayanth Dodderi Chidanandregisters configured for lower exception levels. 5260f3cd515SJayanth Dodderi ChidanandA good example of this is the PAuth regs. The Root world would need to program 5270f3cd515SJayanth Dodderi Chidanandits own PAuth Keys while executing in EL3 and this needs to be restored in entry 5280f3cd515SJayanth Dodderi Chidanandto EL3 from any world. 5290f3cd515SJayanth Dodderi ChidanandTherefore, Root world should maintain its own distinct settings to access 5300f3cd515SJayanth Dodderi Chidanandfeatures for its own execution at EL3. 5310f3cd515SJayanth Dodderi Chidanand 5320f3cd515SJayanth Dodderi ChidanandRegister values which are currently known to be of importance during EL3 execution, 5330f3cd515SJayanth Dodderi Chidanandis referred to as the EL3/Root context. 5340f3cd515SJayanth Dodderi ChidanandThis includes ( MDCR_EL3.SDD, SCR_EL3.{EA, SIF}, PMCR_EL0.DP, PSTATE.DIT) 5350f3cd515SJayanth Dodderi ChidanandEL3 Context ensures, CPU executes under fixed EL3 system register settings 5360f3cd515SJayanth Dodderi Chidanandwhich is not affected by settings of other worlds. 5370f3cd515SJayanth Dodderi Chidanand 5380f3cd515SJayanth Dodderi ChidanandRoot Context needs to be setup as early as possible before we try and access/modify 5390f3cd515SJayanth Dodderi Chidanandarchitectural features at EL3. Its a simple restore operation ``setup_el3_execution_context`` 5400f3cd515SJayanth Dodderi Chidanandthat overwrites the selected bits listed above. EL3 never changes its mind about 5410f3cd515SJayanth Dodderi Chidanandwhat those values should be, sets it as required for EL3. Henceforth, a Root 5420f3cd515SJayanth Dodderi Chidanandcontext save operation is not required. 5430f3cd515SJayanth Dodderi Chidanand 5440f3cd515SJayanth Dodderi ChidanandThe figure below illustrates the same with NS-world as a reference while entering 5450f3cd515SJayanth Dodderi ChidanandEL3. 5460f3cd515SJayanth Dodderi Chidanand 5470f3cd515SJayanth Dodderi Chidanand|Root Context Sequence| 5480f3cd515SJayanth Dodderi Chidanand 5490f3cd515SJayanth Dodderi Chidanand.. code:: c 5500f3cd515SJayanth Dodderi Chidanand 5510f3cd515SJayanth Dodderi Chidanand # EL3/Root_Context routine 5520f3cd515SJayanth Dodderi Chidanand .macro setup_el3_execution_context 5530f3cd515SJayanth Dodderi Chidanand 5540f3cd515SJayanth Dodderi ChidanandEL3 execution context needs to setup at both boot time (cold and warm boot) 5550f3cd515SJayanth Dodderi Chidanandentrypaths and at all the possible exception handlers routing to EL3 at runtime. 5560f3cd515SJayanth Dodderi Chidanand 5570a580b51SBoyan Karatotev*Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved.* 5584efd2193SJayanth Dodderi Chidanand 5594efd2193SJayanth Dodderi Chidanand.. |Context Memory Allocation| image:: ../resources/diagrams/context_memory_allocation.png 5604efd2193SJayanth Dodderi Chidanand.. |CPU Context Memory Configuration| image:: ../resources/diagrams/cpu_data_config_context_memory.png 5614efd2193SJayanth Dodderi Chidanand.. |CPU Data Structure| image:: ../resources/diagrams/percpu-data-struct.png 5624efd2193SJayanth Dodderi Chidanand.. |Context Init ColdBoot| image:: ../resources/diagrams/context_init_coldboot.png 5634efd2193SJayanth Dodderi Chidanand.. |Context Init WarmBoot| image:: ../resources/diagrams/context_init_warmboot.png 5640f3cd515SJayanth Dodderi Chidanand.. |Root Context Sequence| image:: ../resources/diagrams/root_context_sequence.png 5654efd2193SJayanth Dodderi Chidanand.. _Trustzone for AArch64: https://developer.arm.com/documentation/102418/0101/TrustZone-in-the-processor/Switching-between-Security-states 5664efd2193SJayanth Dodderi Chidanand.. _Security States with RME: https://developer.arm.com/documentation/den0126/0100/Security-states 5674efd2193SJayanth Dodderi Chidanand.. _lib/el3_runtime/(aarch32/aarch64): https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/lib/el3_runtime 568