Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 1 | ############## |
| 2 | FF-M Isolation |
| 3 | ############## |
| 4 | |
| 5 | :Organization: Arm Limited |
| 6 | :Contact: tf-m@lists.trustedfirmware.org |
| 7 | |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 8 | This document analyzes the isolation rules of implementing Firmware Framework |
| 9 | for M 1.1 (FF-M 1.1) [2]_ isolation and introduces the reference implementation |
| 10 | in TF-M, which complies with the rules by operating the hardware and software |
| 11 | resources. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 12 | |
| 13 | .. note:: |
Anton Komlev | 3356ba3 | 2022-03-31 22:02:11 +0100 | [diff] [blame] | 14 | Reference the document :doc:`Glossary </glossary>` for terms |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 15 | and abbreviations. |
| 16 | |
| 17 | ************ |
| 18 | Introduction |
| 19 | ************ |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 20 | This chapter describes the definitions from Firmware Framework for M (FF-M) [1]_ |
| 21 | and analyzes the possible implementation keypoints. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 22 | |
| 23 | Isolation Levels |
| 24 | ================ |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 25 | There are 3 isolation levels (1-3) defined in FF-M, the greater level number has |
| 26 | more isolation boundaries. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 27 | |
| 28 | The definition for Isolation Level 1: |
| 29 | |
| 30 | - L1.1 NPSE needs protection from nobody. |
| 31 | - L1.2 SPE needs protection from NSPE. |
| 32 | |
| 33 | The definition for Isolation Level 2: |
| 34 | |
| 35 | - L2.1 NPSE needs protection from nobody. |
| 36 | - L2.2 Application Root of Trust (ARoT) needs protection from NSPE. |
| 37 | - L2.3 PSA Root of Trust (PRoT) needs protection from NSPE and ARoT. |
| 38 | |
| 39 | The definition for Isolation Level 3: |
| 40 | |
| 41 | - L3.1 NPSE needs protection from nobody. |
| 42 | - L3.2 Secure Partition needs protection from NSPE and other Secure Partitions. |
| 43 | - L3.3 PSA Root of Trust (RoT) domain needs protection from NSPE and all Secure |
| 44 | Partitions. |
| 45 | |
| 46 | .. important:: |
Ken Liu | e6b477c | 2022-08-22 10:56:24 +0800 | [diff] [blame] | 47 | A Secure Partition RoT Service is a Root of Trust Service implemented within |
| 48 | a Secure Partition. An Application RoT Service must be implemented as |
| 49 | a Secure Partition RoT Service. But it is implementation-defined whether a |
| 50 | PSA RoT Service is a Secure Partition RoT Service. |
| 51 | |
| 52 | Here listed several possible PSA RoT Service implementation mechanisms: |
| 53 | |
Ken Liu | 0ca70e0 | 2023-01-29 17:36:18 +0800 | [diff] [blame] | 54 | 1. Implement PSA RoT Services in Secure Partitions with respective |
| 55 | boundaries. |
| 56 | 2. Implement PSA RoT Services in Secure Partitions, but no boundaries between |
| 57 | these Secure Partitions as they are in the PSA RoT Domain. |
| 58 | 3. Implement PSA RoT Services in a customized way instead of Secure |
| 59 | Partitions, an internal library of PSA RoT domain e.g. |
Ken Liu | e6b477c | 2022-08-22 10:56:24 +0800 | [diff] [blame] | 60 | |
| 61 | TF-M chooses the 2nd option to balance performance and complexity. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 62 | |
| 63 | Isolation Rules |
| 64 | =============== |
| 65 | The essence of isolation is to protect the assets of one protection domain from |
| 66 | being accessed from other domains. The isolation levels define where the |
| 67 | isolation boundaries should be placed, the isolation rules define the strength |
| 68 | of the isolation the boundaries should offer. |
| 69 | |
| 70 | .. note:: |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 71 | Refer to chapter *Memory Assets* in FF-M [1]_ to know asset class items. |
| 72 | Assets are represented by memory addresses in the system memory map, which |
| 73 | makes assets named *Memory Assets*. The often-seen asset items are ROM, RAM, |
| 74 | and memory-mapped peripherals. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 75 | |
| 76 | Memory Asset Class |
| 77 | ------------------ |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 78 | There are 3 memory asset classes defined in FF-M: |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 79 | |
| 80 | - Code |
| 81 | - Constant data |
| 82 | - Private data |
| 83 | |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 84 | There are 7 isolation rules for protecting assets described in chapter ``3.1`` |
| 85 | of FF-M 1.0 [1]_ and chapters ``8.4`` to ``8.5`` of FF-M 1.1 [2]_. The following |
| 86 | is a summary of the rules: |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 87 | |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 88 | - I1. (Changed in FF-M 1.1) Private data is not executable. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 89 | - I2. Only private data is writable. |
| 90 | - I3. If domain A needs protection from domain B, then Private data in domain A |
| 91 | cannot be accessed by domain B. |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 92 | - I4. (Optional, changed in FF-M 1.1) If domain A needs protection from domain |
| 93 | B, then Code and Constant data in domain A, which is not part of a shared |
| 94 | library, is not readable or executable by domain B. |
| 95 | - I5. (Optional, changed in FF-M 1.1) Code in a domain, which is not part of a |
| 96 | shared library, is not executable by any other domain. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 97 | - I6. (Optional) All assets in a domain are private to that domain and cannot be |
| 98 | accessed by any other domain, with the following exception: |
| 99 | The domain containing the SPM can only access Private data and Constant data |
| 100 | assets of other domains when required to implement the PSA Firmware Framework |
| 101 | API. |
Ken Liu | 0ca70e0 | 2023-01-29 17:36:18 +0800 | [diff] [blame] | 102 | - I7. (Optional, added in FF-M 1.1) Constant data is not executable. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 103 | |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 104 | The first 3 rules from ``I1`` to ``I3`` define the mandatory rules to comply |
| 105 | with the PSA security model, while ``I4`` to ``I7`` are optional rules to |
| 106 | enhance the isolation boundaries. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 107 | |
| 108 | .. important:: |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 109 | There is a table in chapter ``3.1.2`` of FF-M 1.0 [1]_ under ``I1`` that |
| 110 | lists the asset types and allowed access method. Preventing executable access |
| 111 | to constant data costs more hardware resources, so there is an optional rule |
| 112 | I7 created in FF-M 1.1 [2]_ to aid implementations with constrained hardware |
| 113 | resources. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 114 | |
| 115 | Hardware Infrastructure |
| 116 | ======================= |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 117 | To implement a secure system, the hardware security framework (e.g. TrustZone or |
| 118 | multiple-core) and their auxiliary components (e.g. SAU) are required to ensure |
| 119 | the isolation between SPE and NSPE, as described in Trusted Base System |
| 120 | Architecture for M (TBSA-M) [3]_. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 121 | |
| 122 | .. important:: |
| 123 | The interface between secure and non-secure states needs to be fully |
| 124 | enumerated and audited to prove the integrity of the secure state |
| 125 | isolation. |
| 126 | |
| 127 | Besides this SPE and NSPE isolation mechanism, the following analyzes the |
| 128 | implementation rules to find out the hardware requirements for isolation inside |
| 129 | SPE domains: |
| 130 | |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 131 | - I1, I2 and I7: The assets can be categorized into 3 `Memory Asset Class`_, |
| 132 | each type has the specific access rules. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 133 | - I3: The private data access from the prevented domain needs to be blocked. |
| 134 | - I4: All the assets access from the prevented domain needs to be blocked. |
| 135 | - I5: Code execution from all other domains (even the domain not prevented |
| 136 | from) needs to be blocked. |
| 137 | - I6: All the assets access from all other domains (includes non-prevented |
| 138 | domain) needs to be blocked, but, SPM is an exception, which can access the |
| 139 | private data and constant data of the current domain. |
| 140 | |
| 141 | The above items list the requirements for memory access, here are two more |
| 142 | points: |
| 143 | |
| 144 | - If the memory device or the peripheral are shared between multiple hosts |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 145 | (such as multiple CPU or DMA, etc.), specific hardware protection units need |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 146 | to be available for validating accesses to that device or peripheral. |
| 147 | - The MMIO range for Secure Partitions is not allowed to be overlapped, which |
| 148 | means each partition should have exclusive memory-mapped region if they |
| 149 | require a peripheral device. The memory-mapped region is regarded as |
| 150 | the private data so access to this area needs to be validated. |
| 151 | |
| 152 | ************************ |
| 153 | Reference Implementation |
| 154 | ************************ |
| 155 | This chapter describes the isolation implementation inside SPE by using the |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 156 | Armv8-M architecture component - Memory Protection Unit (MPU). The MPU can |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 157 | isolate CPU execution and data access. |
| 158 | |
| 159 | .. note:: |
| 160 | Previous version M-profile architecture MPU setting is similar in concept but |
| 161 | the difference in practical register formats, which is not described in this |
| 162 | document. |
| 163 | |
| 164 | The MPU protects memory assets by regions. Each region represents a memory |
| 165 | range with specific access attributes. |
| 166 | |
| 167 | .. note:: |
| 168 | The maximum numbers of MPU regions are platform-specific. |
| 169 | |
| 170 | The SPM is running under the privileged mode for handling access from services. |
| 171 | The MPU region for SPM needs to be available all the time since SPM controls |
| 172 | the MPU setting while scheduling. |
| 173 | |
| 174 | Since partitions are scheduled by SPM, the MPU regions corresponding to the |
| 175 | partitions can be configured dynamically while scheduling. Since there is only |
| 176 | one running at a time and all others are deactivated, the SPM needs to set up |
| 177 | necessary regions for each asset type in one partition only. |
| 178 | |
Antonio de Angelis | 9d496a5 | 2025-01-07 21:18:00 +0000 | [diff] [blame] | 179 | There is reusable code like the C-Runtime and RoT Service API which are same |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 180 | across different partitions. TF-M creates a Secure Partition Runtime Library |
| 181 | (SPRTL) as a specific library shared by the Secure Partition. Please refer to |
Ken Liu | 7f18fe3 | 2023-02-22 12:45:46 +0800 | [diff] [blame] | 182 | :doc:`Secure Partition Runtime Library </design_docs/services/secure_partition_runtime_library>` |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 183 | for more detail. |
| 184 | |
| 185 | .. note:: |
| 186 | Enable SPRTL makes it hard to comply with the rules I4, I5 and I6, |
| 187 | duplicating the library code can be one solution but it is not "shared" |
| 188 | library anymore. |
| 189 | |
| 190 | As mentioned in the last chapter, MMIO needs extra MPU regions as private data. |
| 191 | |
| 192 | MPU Region Access Permission |
| 193 | ============================ |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 194 | The following content describes the memory access permission to represent the |
| 195 | corresponding asset classes. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 196 | |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 197 | These access permissions are available on Armv8-M MPU: |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 198 | |
| 199 | - Privileged Read-Only (RO) |
| 200 | - All RO |
| 201 | - Privileged Read-Write (RW) |
| 202 | - All RW |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 203 | - Execute Never (XN) |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 204 | |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 205 | And one more Armv8.1-M access permission: |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 206 | |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 207 | - Privileged Execute Never (PXN) |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 208 | |
| 209 | The available regions type list: |
| 210 | |
| 211 | ======== =========== =============== ======================================== |
| 212 | Type Attributes Privilege Level Asset |
| 213 | ======== =========== =============== ======================================== |
| 214 | P_RO RO Privileged PRoT Code |
| 215 | P_ROXN RO + XN Privileged PRoT Constant Data |
| 216 | P_RWXN RW + XN Privileged PRoT Private Data/Peripheral |
| 217 | A_RO RO Any privilege Partition/SPRTL Code |
| 218 | A_ROXN RO + XN Any privilege Partition/SPRTL Constant Data |
| 219 | A_RWXN RW + XN Any privilege Partition/SPRTL Private Data/Peripheral |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 220 | A_ROPXN RO + PXN Any privilege Armv8.1-M Partition Code |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 221 | ======== =========== =============== ======================================== |
| 222 | |
| 223 | Example Image Layout |
| 224 | ==================== |
| 225 | The secure firmware image contains components such as partitions, SPM and the |
| 226 | shared code and data. Each component may have different class assets. There |
| 227 | would be advantages if placing the assets from all components with the same |
| 228 | access attributes into one same region: |
| 229 | |
| 230 | - The data relocating or clearing when booting can be done in one step instead |
| 231 | of breaking into fragments. |
| 232 | - Assets with statically assigned access attribute can share the same MPU |
| 233 | region which saves regions. |
| 234 | |
| 235 | Take the TF-M existing implementation image layout as an example:: |
| 236 | |
| 237 | Level 1 Level 2 Level 3 |
| 238 | Boundaries Boundaries Boundaries |
| 239 | +------------+----------+------------------------------------+ |
| 240 | | | | PRoT SPM Code | |
| 241 | | | PRoT +------------------------------------+ |
| 242 | | | Code | PRoT Service Code | |
| 243 | | Code +----------+------------------------------------+ |
| 244 | | (ROM) | | Partition 1 Code | |
| 245 | | | +------------------------------------+ |
| 246 | | | ARoT | Partition N Code | |
| 247 | | | Code +------------------------------------+ |
| 248 | | | | SPRTL Code | |
| 249 | +------------+----------+------------------------------------+ |
| 250 | Check [4] for more details between Code and Constant Data. |
| 251 | +------------+----------+------------------------------------+ |
| 252 | | | PRoT | PRoT SPM Constant Data | |
| 253 | | | Constant +------------------------------------+ |
| 254 | | | Data | PRoT Service Constant Data | |
| 255 | | Constant +----------+------------------------------------+ |
| 256 | | Data | ARoT | Partition 1 Constant Data | |
| 257 | | (ROM) | Constant +------------------------------------+ |
| 258 | | | Data | Partition N Constant Data | |
| 259 | | | +------------------------------------+ |
| 260 | | | | SPRTL Constant Data | |
| 261 | +------------+----------+------------------------------------+ |
| 262 | |
| 263 | +------------+----------+------------------------------------+ |
| 264 | | | PRoT | PRoT SPM Private Data | |
| 265 | | | Private +------------------------------------+ |
| 266 | | | Data | PRoT Service Private Data | |
| 267 | | Private +----------+------------------------------------+ |
| 268 | | Data | | Partition 1 Private Data | |
| 269 | | (RAM) | ARoT +------------------------------------+ |
| 270 | | | Private | Partition N Private Data | |
| 271 | | | Data +------------------------------------+ |
| 272 | | | | SPRTL Private Data | |
| 273 | +------------+----------+------------------------------------+ |
| 274 | |
| 275 | .. note:: |
| 276 | 1. Multiple binaries image implementation could also reference this layout if |
| 277 | its hardware protection unit can cover the exact boundaries mentioned |
| 278 | above. |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 279 | 2. Private data includes both initialized and zero-initialized (ZI) sections. |
| 280 | Check chapter ``3.1.1`` of FF-M [1]_ for the details. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 281 | 3. This diagram shows the boundaries but not orders. The order of regions |
| 282 | inside one upper region can be adjusted freely. |
| 283 | 4. As described in the ``important`` of `Memory Asset Class`_, the setting |
| 284 | between Code and Constant Data can be skipped if the executable access |
| 285 | method is not applied to constant data. In this case, the groups of Code |
| 286 | and Constant Data can be combined or even mixed -- but the boundary |
| 287 | between PRoT and ARoT are still required under level higher than 1. |
| 288 | |
| 289 | Example Region Numbers under Isolation Level 3 |
| 290 | ============================================== |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 291 | The following table lists the required regions to comply with the rules for |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 292 | implementing isolation level 3. The level 1 and level 2 can be exported by |
| 293 | simplifying the items in level 3 table. |
| 294 | |
| 295 | .. important:: |
| 296 | The table described below is trying to be shared between all supported |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 297 | platforms in Trusted Firmware-M. It is obvious that some platforms have |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 298 | special characteristics. In that case, the specific layout table for a |
| 299 | particular platform can be totally redesigned but need to fulfil the |
| 300 | isolation level requirements. |
| 301 | |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 302 | - Only the running partition's assets are covered since the inactive partitions |
| 303 | do not need regions. |
| 304 | - ``X`` indicates the existence of this region can't comply with the rule. |
| 305 | - An ``ATTR + n`` represent extra ``n`` regions are necessary. |
| 306 | - The table assumes each rule is in addition to the rules in previous columns |
| 307 | (but the FF-M permits any combination of optional rules). |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 308 | |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 309 | The following table lists the required regions to comply with the rules: |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 310 | |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 311 | +-------------------+-------------+-------------+-------------+-------------+ |
| 312 | | Region Purpose | I1 I2 I3 I7 | I4 | I5 | I6 | |
| 313 | +===================+=============+=============+=============+=============+ |
| 314 | | PRoT SPM Code | A_RO | P_RO | P_RO | P_RO | |
| 315 | +-------------------+ | | +-------------+ |
| 316 | | PRoT Service Code | | | | A_ROPXN | |
| 317 | +-------------------+ +-------------+-------------+ | |
| 318 | | Active Partition | | A_RO | A_ROPXN | | |
| 319 | | Code | | | | | |
| 320 | +-------------------+ +-------------+-------------+-------------+ |
| 321 | | SPRTL Code | | A_RO | A_RO | ``X`` | |
| 322 | +-------------------+-------------+-------------+-------------+-------------+ |
| 323 | | PRoT SPM RO | A_ROXN | P_ROXN | P_ROXN | P_ROXN | |
| 324 | +-------------------+ | | +-------------+ |
| 325 | | PRoT Service RO | | | | A_ROXN | |
| 326 | +-------------------+ +-------------+-------------+ | |
| 327 | | Active Partition | | A_ROXN | A_ROXN | | |
| 328 | | RO | | | | | |
| 329 | +-------------------+ +-------------+-------------+-------------+ |
| 330 | | SPRTL RO | | A_ROXN | A_ROXN | ``X`` | |
| 331 | +-------------------+-------------+-------------+-------------+-------------+ |
| 332 | | PRoT SPM RW | P_RWXN | P_RWXN | P_RWXN | P_RWXN | |
| 333 | +-------------------+ | | +-------------+ |
| 334 | | PRoT Service RW | | | | A_RWXN | |
| 335 | +-------------------+-------------+-------------+-------------+ | |
| 336 | | Active Partition | A_RWXN | A_RWXN | A_RWXN | | |
| 337 | | RW | | | | | |
| 338 | +-------------------+-------------+-------------+-------------+-------------+ |
| 339 | | SPRTL RW [5] | A_RWXN + 1 | A_RWXN + 1 | A_RWXN + 1 | ``X`` | |
| 340 | +-------------------+-------------+-------------+-------------+-------------+ |
| 341 | | Partition Periph | A_RWXN + n | A_RWXN + n | A_RWXN + n | A_RWXN + n | |
| 342 | +-------------------+-------------+-------------+-------------+-------------+ |
| 343 | | Total Numbers | [1] | [2] | [3] | [4] | |
| 344 | +-------------------+-------------+-------------+-------------+-------------+ |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 345 | |
| 346 | .. note:: |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 347 | 1. Total number = A_RO + A_ROXN + P_RWXN + (2 + n)A_RWXN = ``5 + n``, where |
| 348 | ``n`` is the maximum number of peripherals needed by one partition. |
| 349 | 2. Total number = [1] + P_RO + A_RO + P_ROXN + A_ROXN = ``9 + n`` (or |
| 350 | ``6 + n`` without SPRTL). |
| 351 | 3. Total number = [2] = ``9 + n``, and Armv8.1-M PXN is required. |
| 352 | 4. Total number = P_RO + A_ROPXN + P_ROXN + A_ROXN + P_RWXN + (1 + n)A_RWXN = |
| 353 | ``6 + n``, but SPRTL cannot be used, and Armv8.1-M PXN is required. To |
| 354 | comply with this rule, the PSA RoT Services need to be implemented as |
| 355 | Secure Partitions. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 356 | 5. This data belongs to SPRTL RW but it is set as Read-Only and only SPM |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 357 | can update this region with the active partition's metadata for |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 358 | implementing functions with owner SP's context, such as heap functions. |
| 359 | This region can be skipped if there is no metadata required (such as no |
| 360 | heap functionalities required). |
| 361 | |
| 362 | The memory-mapped regions for peripherals have different memory access |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 363 | attributes in general, they are standalone regions in the MPU even though |
| 364 | their attributes covers 'A_RWXN'. |
| 365 | |
| 366 | TF-M provides the reference linker scripts ``tfm_isolation_s.sct.template``, |
| 367 | ``tfm_isolation_s.ld.template``, and ``tfm_isolation_s.icf.template`` for the |
| 368 | Armclang, GCC, and IAR compilers in the ``platform/ext/common`` directory. These |
| 369 | linker scripts arrange the SPE's memory by attribute to aid the implementation |
| 370 | of the isolation rules. |
| 371 | |
| 372 | The reference isolation HAL for Armv8-M and Armv8.1-M platforms in |
| 373 | ``platform/ext/common/tfm_hal_isolation_v8m.c`` uses the memory position tags |
| 374 | defined by the linker scripts to set up the MPU region base and limit addresses. |
| 375 | It implements isolation rules I1, I2, I3 and I7 for isolation levels 1 to 3. It |
| 376 | partially implements rule I4 by statically partitioning code into privileged and |
| 377 | unprivileged read-only regions but collecting all constant data into a single |
| 378 | unprivileged, read-only, execute-never region, which provides a good level |
| 379 | of protection against ROP attacks by limiting the amount of executable memory. |
| 380 | On Armv8.1-M targets, it statically configures all Application RoT Partition |
| 381 | code as PXN, which is sufficient to satisfy rule I5 in isolation level 2, but |
| 382 | not in isolation level 3, where it would require dynamically mapping only the |
| 383 | active partition's code region. |
| 384 | |
| 385 | TF-M platforms may replace the reference linker scripts and/or isolation HAL |
| 386 | with a customized implementation, but it must meet at least isolation rules I1, |
| 387 | I2 and I3 to comply with the PSA security model. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 388 | |
Ken Liu | 297c2aa | 2023-02-23 11:22:33 +0800 | [diff] [blame] | 389 | Default access rules |
| 390 | ==================== |
| 391 | Hardware protection components MAY have the capability to collect regions |
| 392 | not explicitly configured in static or runtime settings, and then apply |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 393 | default access rules to these regions. Furthermore, one default rule can be |
Ken Liu | 297c2aa | 2023-02-23 11:22:33 +0800 | [diff] [blame] | 394 | applied to multiple non-contiguous regions which makes them share a common |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 395 | boundary. This operation sets up a standalone 'region' the same as other |
Ken Liu | 297c2aa | 2023-02-23 11:22:33 +0800 | [diff] [blame] | 396 | explicitly configured regions. And it doesn't affect the analysis summary |
| 397 | above - just be aware that some regions listed in the table MAY not be |
| 398 | explicitly configured. |
| 399 | |
| 400 | Take the MPU as an example, MPU can assign a default privileged access |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 401 | attribute to the regions (e.g. SPM and PRoT regions) not explicitly configured. |
Ken Liu | 297c2aa | 2023-02-23 11:22:33 +0800 | [diff] [blame] | 402 | This feature can reduce required MPU regions and ease the programming because |
| 403 | regions can be put non-address-contiguous and skip the explicit configuration. |
| 404 | |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 405 | .. important:: |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 406 | When this default access rules mechanism is applied, the implicitly configured |
| 407 | regions must be reviewed to ensure the isolation boundaries are set correctly. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 408 | |
| 409 | Interfaces |
| 410 | ========== |
| 411 | The isolation implementation is based on the HAL framework. The SPM relies on |
| 412 | the HAL API to perform the necessary isolation related operations. |
| 413 | |
| 414 | The requirement the software need to do are these: |
| 415 | |
| 416 | - Create enough isolation protection at the early stage of system booting, just |
| 417 | need to focus on the SPM domain. |
| 418 | - Create an isolation domain between secure and non-secure before the jump to |
| 419 | the non-secure world. |
| 420 | - Create an isolation domain for each Secure Partition after the Secure |
| 421 | Partition is loaded and before jumping to its entry point. The isolation |
| 422 | domain should cover all the assets of the Secure Partition, include all its |
| 423 | memory, interrupts, and peripherals. |
| 424 | - Switch isolation domains when scheduling different Secure Partitions. |
| 425 | - It is also a requirement that the platform needs to help to check if the |
| 426 | caller of the PSA APIs is permitted to access some memory ranges. |
| 427 | |
Minos Galanakis | ba3d41c | 2020-11-20 10:28:47 +0000 | [diff] [blame] | 428 | The design document |
Anton Komlev | b3f6466 | 2023-01-28 11:53:05 +0000 | [diff] [blame] | 429 | :doc:`TF-M Hardware Abstraction Layer </design_docs/software/hardware_abstraction_layer>` |
Minos Galanakis | ba3d41c | 2020-11-20 10:28:47 +0000 | [diff] [blame] | 430 | gives a detail design, include the platform initialization, isolation |
| 431 | interfaces. Please refer to it for more detail. |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 432 | |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 433 | ********** |
| 434 | References |
| 435 | ********** |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 436 | |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 437 | .. [1] `Arm PSA Firmware Framework for M 1.0 (FF-M 1.0) <https://developer.arm.com/documentation/den0063/latest/>`_ |
| 438 | .. [2] `Arm Firmware Framework for M 1.1 Extension (FF-M 1.1) <https://developer.arm.com/documentation/aes0039/latest/>`_ |
| 439 | .. [3] `Arm Trusted Base System Architecture for M (TBSA-M) <https://www.arm.com/en/architecture/security-features/platform-security>`_ |
Ken Liu | 87b4f41 | 2020-06-04 11:13:39 +0800 | [diff] [blame] | 440 | |
| 441 | -------------- |
| 442 | |
Jamie Fox | 6667705 | 2024-09-10 14:51:48 +0100 | [diff] [blame] | 443 | *Copyright (c) 2020-2024, Arm Limited. All rights reserved.* |