Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1 | .. SPDX-License-Identifier: BSD-3-Clause |
| 2 | .. SPDX-FileCopyrightText: Copyright TF-RMM Contributors. |
| 3 | |
| 4 | ############################# |
| 5 | RMM Cold and Warm boot design |
| 6 | ############################# |
| 7 | |
| 8 | This section covers the boot design of RMM. The below |
| 9 | diagram gives an overview of the boot flow. |
| 10 | |
| 11 | |Boot Design| |
| 12 | |
| 13 | Both warm and cold boot enters RMM at the same entry point |
Javier Almansa Sobrino | 6166c03 | 2022-11-10 14:24:03 +0000 | [diff] [blame] | 14 | ``rmm_entry()``. This scheme simplifies the |
| 15 | `RMM-EL3 communications interface`_. The boot args as specified by boot |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 16 | contract are stashed to high registers. |
| 17 | |
| 18 | The boot is divided into several phases as described below: |
| 19 | |
| 20 | 1. **Sysreg and C runtime initialization phase.** |
| 21 | |
| 22 | The essential system registers are initialized. ``SCTLR_EL2.I`` |
| 23 | is set to 1 which means instruction accesses to Normal memory are |
| 24 | Outer Shareable, Inner Write-Through cacheable, Outer Write-Through |
| 25 | cacheable. ``SCTLR_EL2.C`` is also set 1 and data accesses default |
| 26 | to Device-nGnRnE. The cpu-id, received as part of boot args, is programmed |
| 27 | to ``tpidr_el2`` and this can be retrieved using the helper function |
| 28 | ``my_cpuid()``. The per-CPU stack is also initialized using the cpu-id |
| 29 | received and this completes the C runtime initialization for warm boot. |
| 30 | |
| 31 | Only the primary CPU enters RMM during cold boot and a global |
| 32 | variable is used to keep track whether it is cold or warm boot. If |
| 33 | cold boot, the Global Descriptor Table (GDT) and Relocations are fixed |
| 34 | up so that RMM can run as position independent executable (PIE). The BSS |
| 35 | is zero initialized which completes the C runtime initialization |
| 36 | for cold boot. |
| 37 | |
| 38 | 2. **Platform initialization phase** |
| 39 | |
| 40 | The boot args are restored to their original registers and plat_setup() |
| 41 | and plat_warmboot_setup() are invoked for cold and warm boot respectively. |
| 42 | During cold boot, the platform is expected to consume the boot manifest |
Javier Almansa Sobrino | 6166c03 | 2022-11-10 14:24:03 +0000 | [diff] [blame] | 43 | which is part of the `RMM-EL3 communications interface`_. The platform |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 44 | initializes any platform specific peripherals and also intializes and |
| 45 | configures the translation table contexts for Stage 1. |
| 46 | |
| 47 | 3. **MMU enable phase** |
| 48 | |
| 49 | The EL2&0 translation regime is enabled after suitable TLB and cache |
| 50 | invalidations. |
| 51 | |
Arvind Ram Prakash | bd36a1b | 2022-12-15 12:16:36 -0600 | [diff] [blame^] | 52 | 4. **PAuth enable phase** |
| 53 | |
| 54 | Disable API, APK Trap, to allow PAuth instructions access from Realm without trapping. |
| 55 | Initialize APIA Keys to random 128-bit value, Enable PAuth for R-EL2. |
| 56 | |
| 57 | 5. **RMM Main phase** |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 58 | |
| 59 | Any cold boot or warm initialization of RMM components is done in this |
| 60 | phase. This phase also involves invoking suitable EL3 services, like |
| 61 | acquiring platform attestation token for Realm attestation. |
| 62 | |
| 63 | After all the phases have completed successfully, RMM issues |
| 64 | ``RMM_BOOT_COMPLETE`` SMC. The next entry into RMM from EL3 would be for |
| 65 | handling RMI calls and hence the next intruction following the SMC call |
| 66 | branches to the main SMC handler routine. |
| 67 | |
| 68 | |
| 69 | ################################### |
| 70 | RMM-EL3 communication specification |
| 71 | ################################### |
| 72 | |
| 73 | The communication interface between RMM and EL3 is specified in |
Javier Almansa Sobrino | 6166c03 | 2022-11-10 14:24:03 +0000 | [diff] [blame] | 74 | `RMM-EL3 communications interface`_ specification in the TF-A repository. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 75 | |
| 76 | .. |Boot Design| image:: ./diagrams/boot_design.drawio.png |
Javier Almansa Sobrino | 6166c03 | 2022-11-10 14:24:03 +0000 | [diff] [blame] | 77 | .. _`RMM-EL3 communications interface`: https://trustedfirmware-a.readthedocs.io/en/latest/components/rmm-el3-comms-spec.html |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 78 | |