blob: 22961b0bdc0a16e9cc3931c838cf121b2f6c1a4f [file] [log] [blame]
Soby Mathewb4c6df42022-11-09 11:13:29 +00001.. SPDX-License-Identifier: BSD-3-Clause
2.. SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
3
4#############################
5RMM Cold and Warm boot design
6#############################
7
8This section covers the boot design of RMM. The below
9diagram gives an overview of the boot flow.
10
11|Boot Design|
12
13Both warm and cold boot enters RMM at the same entry point
Javier Almansa Sobrino6166c032022-11-10 14:24:03 +000014``rmm_entry()``. This scheme simplifies the
15`RMM-EL3 communications interface`_. The boot args as specified by boot
Soby Mathewb4c6df42022-11-09 11:13:29 +000016contract are stashed to high registers.
17
18The boot is divided into several phases as described below:
19
201. **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
382. **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 Sobrino6166c032022-11-10 14:24:03 +000043 which is part of the `RMM-EL3 communications interface`_. The platform
Soby Mathewb4c6df42022-11-09 11:13:29 +000044 initializes any platform specific peripherals and also intializes and
45 configures the translation table contexts for Stage 1.
46
473. **MMU enable phase**
48
49 The EL2&0 translation regime is enabled after suitable TLB and cache
50 invalidations.
51
524. **RMM Main phase**
53
54 Any cold boot or warm initialization of RMM components is done in this
55 phase. This phase also involves invoking suitable EL3 services, like
56 acquiring platform attestation token for Realm attestation.
57
58After all the phases have completed successfully, RMM issues
59``RMM_BOOT_COMPLETE`` SMC. The next entry into RMM from EL3 would be for
60handling RMI calls and hence the next intruction following the SMC call
61branches to the main SMC handler routine.
62
63
64###################################
65RMM-EL3 communication specification
66###################################
67
68The communication interface between RMM and EL3 is specified in
Javier Almansa Sobrino6166c032022-11-10 14:24:03 +000069`RMM-EL3 communications interface`_ specification in the TF-A repository.
Soby Mathewb4c6df42022-11-09 11:13:29 +000070
71.. |Boot Design| image:: ./diagrams/boot_design.drawio.png
Javier Almansa Sobrino6166c032022-11-10 14:24:03 +000072.. _`RMM-EL3 communications interface`: https://trustedfirmware-a.readthedocs.io/en/latest/components/rmm-el3-comms-spec.html
Soby Mathewb4c6df42022-11-09 11:13:29 +000073