Maulik Patel | 606ba31 | 2023-10-30 18:09:00 +0000 | [diff] [blame] | 1 | #################################### |
Jamie Fox | f0204f1 | 2024-02-19 14:38:01 +0000 | [diff] [blame] | 2 | ADAC implementation for RSE platform |
Maulik Patel | 606ba31 | 2023-10-30 18:09:00 +0000 | [diff] [blame] | 3 | #################################### |
| 4 | |
Jamie Fox | f0204f1 | 2024-02-19 14:38:01 +0000 | [diff] [blame] | 5 | ADAC Requirements for RSE |
Maulik Patel | 606ba31 | 2023-10-30 18:09:00 +0000 | [diff] [blame] | 6 | ========================= |
| 7 | |
Jamie Fox | f0204f1 | 2024-02-19 14:38:01 +0000 | [diff] [blame] | 8 | For RSE, ADAC design and implementation must meet below requirements. |
Maulik Patel | 606ba31 | 2023-10-30 18:09:00 +0000 | [diff] [blame] | 9 | |
Jamie Fox | f0204f1 | 2024-02-19 14:38:01 +0000 | [diff] [blame] | 10 | 1. Since RSE is HES (Hardware Enforced Security) host for CCA (Confidential |
| 11 | Compute Architecture) system, ADAC functionality must be implemented by RSE. |
Maulik Patel | 606ba31 | 2023-10-30 18:09:00 +0000 | [diff] [blame] | 12 | 2. By default, CCA HES and other trusted subsystems debug should be disabled |
| 13 | all the time. |
Jamie Fox | f0204f1 | 2024-02-19 14:38:01 +0000 | [diff] [blame] | 14 | 3. When in a secured (trustworthy) state, no debug should be allowed to RSE, |
Maulik Patel | 606ba31 | 2023-10-30 18:09:00 +0000 | [diff] [blame] | 15 | and other components of CCA System security Domain. |
| 16 | 4. If life cycle is not in a secured state and if a CCA component debug is |
| 17 | requested, a new debug session should be initiated. |
| 18 | 5. Likewise at the end of debug session, all debug interfaces should be closed |
| 19 | and a system reset is required to return to the previous state. |
| 20 | 6. Depending on current policy, the debug start and stop request may require |
| 21 | a system reset for the request to be processed in a distinct debug session. |
Jamie Fox | f0204f1 | 2024-02-19 14:38:01 +0000 | [diff] [blame] | 22 | For RSE, a system reset is required for handling debug requests for any |
Maulik Patel | 606ba31 | 2023-10-30 18:09:00 +0000 | [diff] [blame] | 23 | components of CCA security domain. |
| 24 | 7. Finally, CCA Platform Attestation token should be different if any CCA debug |
| 25 | is enabled. |
| 26 | |
| 27 | Implementation Constraints |
| 28 | ========================== |
| 29 | |
| 30 | PSA ADAC protocol specifies use of asymmetric key cryptography for certificate |
| 31 | parsing and authentication. Ideally, authentication and application of |
| 32 | permissions should be done at the same time in boot so that they cannot be |
| 33 | tampered later on, but |
| 34 | |
| 35 | * BL1 is constrained on memory resources and |
| 36 | * BL1 is immutable, so any flaw in the authentication scheme would result in |
| 37 | a permanent security vulnerability. |
| 38 | |
| 39 | Hence, authentication has to handled as runtime service while appropriate |
| 40 | permissions can be applied in the bootloader. |
| 41 | |
| 42 | Design description |
| 43 | ================== |
| 44 | |
| 45 | As per the ADAC architecture, debug host must implement Secure Debug Manager |
| 46 | (SDM) component while debug target requires Secure Debug Authenticator (SDA) |
| 47 | as mentioned in architecture specification. Logical link is established |
| 48 | among the above two components to establish secure debug connection. |
| 49 | |
| 50 | To meet the above requirements, ADAC protocol is integrated in TF-M as follows: |
| 51 | |
| 52 | 1. A new ADAC runtime service which calls SDA to authenticate any incoming debug |
| 53 | request from other components. |
| 54 | 2. Above service only acknowledges any incoming debug request if the device is |
| 55 | in appropriate life cycle state. Else, it rejects any incoming debug request. |
| 56 | Here the appropriate life cycle state is defined by the platform specific |
| 57 | policy. |
| 58 | 3. Once the service acknowledges the request, it sends the request to the |
| 59 | core protocol API for authentication. It also checks if the host has |
| 60 | appropriate access rights permissions. If it authenticates the host |
| 61 | successfully, it stores the debug state and may initiate the reset (depending |
| 62 | on platform policy). |
| 63 | 4. On immediate reset, the bootloader (BL1_2) retrieves the stored debug state |
| 64 | and applies corresponding debug permissions. |
| 65 | 5. It also locks the related DCU bits so that the applied permissions stays |
| 66 | the same throughout the debug session. |
| 67 | 6. Runtime service now waits for debug end signal to end debug session. To end |
| 68 | current debug session, it stores the state again and initiates the reset |
| 69 | (depending on platform policy). |
| 70 | 7. On reset, BL1_2 resets the permission and locks the DCU to continue |
| 71 | normal execution. |
| 72 | 8. For debug request of any components where platform policy does not require a |
| 73 | reset, ADAC service does not initiate any reset and enables the debug |
| 74 | immediately. |
| 75 | |
Maulik Patel | 52addf5 | 2024-07-16 12:14:31 +0100 | [diff] [blame] | 76 | ************************************ |
| 77 | Code structure & Service Integration |
| 78 | ************************************ |
| 79 | |
| 80 | The ADAC Service source and header files are located in the current directory. |
| 81 | The interface for the ADAC runtime Service is located in ``interface/include``. |
| 82 | The only header to be included by applications that want to use functions from |
| 83 | the PSA API is ``tfm_adac_api.h``. |
| 84 | |
| 85 | Service interface |
| 86 | ================= |
| 87 | The ADAC Service exposes the following interface: |
| 88 | |
| 89 | .. code-block:: c |
| 90 | |
| 91 | /*! |
| 92 | * \brief Authenticates the requested debug service. |
| 93 | * |
| 94 | * \param[in] debug_request Request identifier for the debug zone |
| 95 | * (valid values vary based on the platform |
| 96 | * Each bit of the \p debug_request represents |
| 97 | * debug request for corresponding zone. |
| 98 | * e.g. |
| 99 | * If no bits are set => no debug request |
| 100 | * If bit0 is set => start debug for zone1 |
| 101 | * If bit0 is cleared => end debug for zone1 |
| 102 | * If bit1 is set => start debug for zone2 |
| 103 | * If bit1 is cleared => end debug for zone2 |
| 104 | * ... |
| 105 | * |
| 106 | * Enumeration of zones (zone1, zone2, etc.) is |
| 107 | * done by ``tfm_debug_zones`` (platform specific) |
| 108 | * |
| 109 | * \return Returns PSA_SUCCESS on success, |
| 110 | * otherwise error as specified in \ref psa_status_t |
| 111 | */ |
| 112 | psa_status_t tfm_adac_service(uint32_t debug_request) |
| 113 | |
| 114 | Service source files |
| 115 | ==================== |
| 116 | - ``tfm_adac_api.c``: Implements the secure API layer to allow |
| 117 | other services in the secure domain to request functionalities |
| 118 | from the adac service using the PSA API interface. |
| 119 | |
| 120 | - ``adac_req_mngr.c``: Includes the initialization entry of |
| 121 | adac service and handles adac service requests in IPC model. |
| 122 | |
| 123 | - ``adac.c``: Implements core functionalities such as implementation |
| 124 | of APIs, handling and processing of debug request. |
| 125 | |
Maulik Patel | 606ba31 | 2023-10-30 18:09:00 +0000 | [diff] [blame] | 126 | Hardware abstraction layer Interface |
| 127 | ==================================== |
| 128 | |
| 129 | Classification of various debug zones is platform/system specific. |
Jamie Fox | f0204f1 | 2024-02-19 14:38:01 +0000 | [diff] [blame] | 130 | For system with RSE subsystem, these are mainly classified into CCA security |
Maulik Patel | 606ba31 | 2023-10-30 18:09:00 +0000 | [diff] [blame] | 131 | domain debug and Non-CCA debug zones. |
| 132 | |
| 133 | - ``tfm_debug_zones``: enumerates 2 CCA and 4 Non-CCA debug zones. |
| 134 | |
| 135 | - ``tfm_platform_system_reset()``: Request system reset to initiate or terminate |
| 136 | a debug session. |
| 137 | |
| 138 | - ``tfm_plat_otp_read()``: Reads the life cycle state as well as secure debug |
| 139 | key required for authentication. |
| 140 | |
| 141 | Bootloader Interface |
| 142 | ==================== |
| 143 | |
| 144 | The ADAC runtime service requires to convey debug state information between |
| 145 | runtime service and bootloader. This needs be in platform specific |
| 146 | predefined persistent area as this information needs to be retained after reset. |
| 147 | |
Jamie Fox | f0204f1 | 2024-02-19 14:38:01 +0000 | [diff] [blame] | 148 | For RSE platform, this functionality is provided by RESET_SYNDROME register. |
Maulik Patel | 606ba31 | 2023-10-30 18:09:00 +0000 | [diff] [blame] | 149 | 8 bits field, SWSYN, of above register is allocated to convey debug state |
| 150 | information between bootloader and runtime service |
| 151 | |
| 152 | - ``lcm_dcu_set_enabled()``: Apply appropriate debug zone permissions by setting |
| 153 | the DCU register values. |
| 154 | |
| 155 | - ``lcm_dcu_set_locked()``: Locks the DCU so permission cannot be modified |
| 156 | during that power cycle. |
| 157 | |
| 158 | ADAC Protocol (SDA) integration |
| 159 | =============================== |
| 160 | |
Jamie Fox | f0204f1 | 2024-02-19 14:38:01 +0000 | [diff] [blame] | 161 | - ``tfm_to_psa_adac_rse_secure_debug()``: Initiates the connection with the |
Maulik Patel | 606ba31 | 2023-10-30 18:09:00 +0000 | [diff] [blame] | 162 | host debugger and performs secure debug authentication process. |
| 163 | |
| 164 | Enable Secure Debug |
| 165 | =================== |
| 166 | |
Jamie Fox | f0204f1 | 2024-02-19 14:38:01 +0000 | [diff] [blame] | 167 | To enable ADAC on RSE, below options must be configured: |
Maulik Patel | 606ba31 | 2023-10-30 18:09:00 +0000 | [diff] [blame] | 168 | |
| 169 | - ``-DPLATFORM_PSA_ADAC_SECURE_DEBUG=ON`` |
| 170 | |
| 171 | - ``-DTFM_PARTITION_ADAC=ON`` |
| 172 | |
| 173 | -------------- |
| 174 | |
Maulik Patel | 52addf5 | 2024-07-16 12:14:31 +0100 | [diff] [blame] | 175 | *Copyright (c) 2023-2024, Arm Limited. All rights reserved.* |