1######################## 2Secure Partition Manager 3######################## 4This document describes the Secure Partition Manager (`SPM`) implementation 5design in Trusted Firmware-M (`TF-M`). 6 7.. note:: 8 - The FF-M in this document refers to the accumulated result of two 9 specifications: 10 `FF-M v1.1 Update <https://developer.arm.com/documentation/aes0039/latest>`_ 11 on 12 `FF-M v1.0 <https://developer.arm.com/documentation/den0063/latest/>`_. 13 - The words marked as `interpreted` are defined terms. Find the terms in 14 referenced documents if it is not described in this document. 15 16************ 17Introduction 18************ 19The service access process of FF-M: 20 21.. figure:: /design_docs/media/tfmdev.* 22 :align: center 23 :name: fig-tfmdev 24 :width: 80% 25 26 FF-M service access process 27 28Secure services (aka `Service`) is the component providing secure 29functionalities in `SPE`, and `Client` is the user of the `Service`. A service 30acts as a client when it is accessing its depending services. 31 32Services are grouped into `Secure Partition` (aka `partition`). A partition: 33 34- Contains services with the same purpose. 35- Provides implementation required isolation boundaries. 36- Is a software development unit. 37 38Each service exposes its `Service ID` (`SID`) and `Handle` for client access 39usage. Clients access services by `SID` or `Handle` through FF-M `Client API`. 40Partitions use FF-M `Secure Partition API` when it needs to operate on client 41data or reply to a client. 42 43`SPM` is the centre of an FF-M compliant implementation, which sets up and 44maintains a firmware framework that: 45 46- Implements `Client API` and `Secure Partition API`. 47- Manages partition runtime to follow FF-M. 48- Involves necessary implementation-defined items to support the 49 implementation. 50 51SPM interfaces consist of these two categories: 52 53- FF-M defined API. 54- Extended API to support the implementation. 55 56Both API categories are compliant with FF-M concepts and guidelines. The core 57concept of TF-M SPM surrounds the FF-M defined service management and access 58process. Besides this, another important implementation part is partition 59runtime management. 60 61Partition runtime model 62======================= 63One partition must work under as `ONE` of the runtime models: 64`Inter-process communication` (`IPC`) model or `Secure Function` (`SFN`) 65model. 66 67A partition that runs under the `IPC` model looks like a classic `process`. 68There is `ONE` thread inside the partition keeps waiting for signals. SPM 69converts the service accessing info from the `Client API` call into messages 70and assert a signal to the partition. The partition calls corresponded service 71function indicated by the signal and its bound message, and reply service 72returned result to the client. The advantages of this model: 73 74- It provides better isolation by limiting the interfaces on data interactive. 75 Data are preferred to be processed in a local buffer. 76- It provides a mechanism for handling multiple service access. There is no 77 memory mapping mechanism in the MCU system, hence it is hard to provide 78 multiple function call contexts when serving multiple-threaded clients if 79 the service access is implemented in a function-call based mechanism. This 80 model converts multiple service accesses into messages, let the partition 81 handles the service access in messages one by one. 82 83The `Secure Function` (`SFN`) model partition is close to a `library`. Each 84service is provided as a function entry inside the partition. SPM launches 85the target service function after the service is found. The whole procedure 86(from client to service function) is a function call. This model: 87 88- Saves the workloads spent on `IPC` scheduling. 89 90Meanwhile, it relaxes the data interactive mechanism, for example, allow 91direct memory access (MMIOVEC). And it is hard to enable multiple-threaded 92clients service access because of multiple call context-maintenance 93difficulties. 94 95An implementation contains only `SFN` partitions fits better in the 96resource-constrained devices, it is called an `SFN model implementation`. And 97it is an `IPC model implementation` when `IPC` partitions exist in the system. 98 99.. note:: 100 `IPC model implementation` can handle access to the services in the `SFN` 101 partition. 102 103Components and isolation levels 104=============================== 105There are `THREE` isolation levels defined in `FF-M`. These levels can 106fulfil different security requirements by defining different isolation 107boundaries. 108 109.. figure:: /design_docs/media/modelisolation.* 110 :align: center 111 :name: fig-modelisolation 112 :width: 80% 113 114 Components and isolation boundaries 115 116.. note:: 117 Concept `ARoT`, `PRoT`, `domain`, and boundaries are in the `FF-M` 118 specification. 119 120Not like an `SPE` client that can call `Client API` to access the secure 121services in one step, an `NSPE` client needs to cross the secure boundaries 122first before calling `Client API`. The component `NS Agent` in 123:numref:`fig-modelisolation` represents `NSPE` clients after they crossed 124the secure boundaries. This could help `SPM` handles the request in a 125unified way instead of care about the special boundaries. 126 127.. note:: 128 `NS Agent` is a necessary implementation-defined component out of FF-M 129 specification. `NS Agent` has a dedicated stack because secure and 130 non-secure can not share the stack. It also has dedicated execution bodies. 131 For example, RPC-based `NS Agent` has a while loop that keeps waiting for 132 messages; and Trustzone-based `NS Agent` has veneer code to take over `NSPE` 133 secure call. This makes `NS Agent` to be a component more like a `process`. 134 Hence in the simplest implementation (`SFN model implementation` mentioned 135 above), `NS Agent` is the only process in the system, the scheduling 136 logic can be extremely simplified since no other process execution needs to 137 be scheduled. But the scheduling interface is still necessary to SPM, this 138 could help SPM treat both `SFN` and `IPC` model implementation in a unified 139 way. 140 141 Check `NS Agent`_ for details. 142 143Implementation principle 144======================== 145The principles for TF-M SPM implementation: 146 147.. important:: 148 - SPM can treat these components as the client: NS Agent, SFN Partition, 149 and IPC partition. 150 - These components can provide services: SFN Partition, IPC partition, and 151 built-in services. A built-in service is built up with SPM together. 152 - All partition services must be accessed by `Client API`. 153 - Partitions interact with client data by `Secure Partition API`. 154 - Built-in services are strongly recommended to be accessed by `Client API`. 155 Customized interfaces are restricted. 156 - Built-in services can call SPM internal interfaces directly. 157 158****************** 159Runtime management 160****************** 161The runtime execution runs among the components, there are **4** runtime 162states: 163 164- `Initializing` state, to set up the SPM runtime environment after system 165 powers up 166- `IDLE` state, when SPM runtime environment is set up and partitions are 167 ready for service access. 168- `Serving` state, when partition is under initializing or service access 169 handling. 170- `Background` state, such as the arrival of secure interrupt or unexpected 171 faults. `Background` state returns to the state it preempts. `Background` 172 state can be nested. 173 174The state transition diagram: 175 176.. figure:: /design_docs/media/spestate.* 177 :align: center 178 :name: fig-spestate 179 :width: 70% 180 181 SPE runtime execution states 182 183Initializing 184============ 185The goal of TF-M initializing is to perform necessary initialization and 186move to the `Serving`_ state. This state starts with platform-specific power 187on sequence, then `SPM` takes over the execution to perform these operations: 188 189#. A preparation initialization process before SPM runtime initialization. 190#. SPM runtime initialization. 191#. A post initialization happens after the SPM runtime initialization and 192 before the first partition gets launched. 193 194.. note:: 195 These procedures and their sub-routines are recommended to be applied with 196 execution measurement mechanism to mitigate the `Hardware Fault Injection` 197 attack. 198 199Preparation initialization 200-------------------------- 201The purpose of this preparation initialization is to provide a chance for 202performing those security required but generic platform power-on skipped 203operations, such as: 204 205- Restrict `SPM` execution, for example, set up memory overflow settings for 206 SPM runtime memory, or set code out of SPM as un-executable, even though 207 SPM is a privileged component in general. 208 209.. note:: 210 The ``logging``-related peripheral can be set up **AT THIS STEP**, if 211 logging is enabled and it needs peripheral support. There is no standalone 212 initializing HAL API proposed for logging, so here is an ideal place for 213 initializing them. 214 215This procedure is abstracted into one `HAL`, and a few example procedures 216are implemented as its sub-routines for reference: 217 218- Architecture extensions initialization, Check chapter 219 `Architecture security settings`_ for detailed information. 220- Isolation and lifecycle initialization. 221 222The load isolation boundaries need to be set up here, such as SPE/NSPE 223boundary, and ARoT/PRoT boundary if isolation level 2 is applied. 224 225The lifecycle is initiated by a secure bootloader usually. And in this stage 226of SPM initializing, SPM double-checks the lifecycle set up status (following 227a specific lifecycle management guidelines). Note that the hardware debugger 228settings can be part of lifecycle settings. 229 230.. important:: 231 Double-check debugger settings when performing a product release. 232 233SPM runtime initialization 234-------------------------- 235This procedure initializes necessary runtime operations such as memory 236allocator, loading partitions and partition-specific initialization 237(binding partitions with platform resources). 238 239The general processes: 240 241#. Initialize runtime functionalities, such as memory allocator. 242#. Load partitions by repeating below steps: 243 244 * Find a partition load information. 245 * Allocate runtime objects for this partition. 246 * Link the runtime objects with load information. 247 * Init partition contexts (Thread and call context). 248 * Init partition isolation boundaries (MMIO e.g.). 249 * Init partition interrupts. 250 251After no more partitions need to be loaded, the SPM runtime is set up but 252partitions' initialization routines have not run yet - the partition runtime 253context is initialized for the routine call. 254 255The partition initialization routine is a special service that serves SPM 256only, because: 257 258- SPM needs to call the initialization routine, just like it calls into 259 the service routine. 260- The partition initialization routine can access its depending services. 261 Putting initialization routine in the same runtime environment as common 262 service routines can avoid special operations. 263 264Hence a `Partition initialization client` needs to be created to initialize 265the SFN partitions, because: 266 267- `SPM runtime initialization` happen inside a special runtime environment 268 compare to the partition runtime execution, then an environment switching 269 is needed. 270- IPC partitions are initialized by the scheduler and dependencies are 271 handled by signals and messages asynchronously, hence IPC partitions can 272 process the dependencies by their own. 273 274The `Partition initialization client` is created differently based on the 275implementation runtime model: 276 277- A SFN client is created under the SFN model implementation. 278- A IPC client is created under the IPC model implementation. This client 279 thread has the highest priority. 280 281As the other partitions, the client is created with context standby, and it 282is executed after the `Post initialization`_ stage. 283 284Post initialization 285------------------- 286Platform code can change specific partition settings in this procedure before 287partitions start. A few SPM API is callable at this stage, such as set a 288signal into a specific partition, or customized peripheral settings. 289 290Serving 291======= 292Two execution categories work under this state: 293 294- `Partition initialization routine execution`_. 295- `Secure service access`_. 296 297This state indicates the serving is ongoing. It is mainly the service routine 298execution, plus a few SPM executions when SPM API gets called. 299 300.. important:: 301 The service access process introduced in this chapter 302 (Such as `Secure service access`_) is abstracted from the FF-M 303 specification. Reference the FF-M specification for the details of each 304 step. 305 306Partition initialization routine execution 307------------------------------------------ 308The partition initialization routines get called. One partition may access its 309depending services during initializing, then this procedure is a 310`Secure service access`_. 311 312The initialization routine gets called initially by 313`Partition initialization client`, also can be called by Client API before 314service access, if the target partition is not initialized but a service 315access request is raised by one client. 316 317Secure service access 318--------------------- 319The process of service access: 320 321#. A `client` calls an FF-M Client API. 322#. `SPM` validates inputs and looks up for the targeted service. 323#. `SPM` constructs the request to be delivered under a proper runtime 324 mechanism. 325#. The target service gets executed. It can perform internal executions or 326 access depending services to prepare the response. It also can wait for 327 specific signals. 328#. The target service calls FF-M Secure Partition API to request a reply to 329 the client. 330#. SPM delivers the response to the client, and the API called by the client 331 returns. 332 333The mechanism of how SPM interact with the target partition depends on the 334partition runtime model. 335 336- Access to a service in an SFN partition is a function call, which does not 337 switch the current process indicator. 338- Access to a service in an IPC partition leads to scheduling, which switches 339 the current process indicator. 340- When the execution roams between components because of a function call or 341 scheduling, the isolation boundaries NEED to be switched if there are 342 boundaries between components. 343 344.. figure:: /design_docs/media/hybridruntime.* 345 :align: center 346 :name: fig-hybridruntime 347 :width: 60% 348 349No matter what kind of partition a client is trying to access, the SPM API is 350called firstly as it is the interface for service access. There are two ABI 351types when calling SPM API: Cross-boundary or No-cross-boundary. 352 353Calling SPM API 354--------------- 355SPM is placed in the PRoT domain. It MAY have isolation boundaries under 356particular isolation levels. For example: 357 358- There are boundaries between ARoT components and SPM under isolation level 2 359 and 3. 360 361The API SPM provided needs to support the function call (no boundary 362switching) and cross-boundary call. A direct call reaches the API entrance 363directly, while a cross-boundary call needs a mechanism (Supervisor call e.g.) 364to cross the boundary first before reaching the API entrance. 365 366.. figure:: /design_docs/media/twocalltypes.* 367 :align: center 368 :name: fig-twocalltypes 369 :width: 60% 370 371 SPM call types 372 373SPM internal execution flow 374--------------------------- 375SPM internal execution flow as shown in diagram: 376 377.. figure:: /design_docs/media/abi_scheduler.* 378 :align: center 379 :name: fig-abi_scheduler 380 :width: 60% 381 382 SPM API runtime 383 384The process: 385 386- PSA API gets called by one of the ABI mentioned in the last chapter as 387 `ABI 1` in the diagram. 388- The unified API Handler calls FF-M and backend subroutines in sequence. 389- The `FF-M` subroutine performs `FF-M` defined operations. 390- The backend operations perform target partition runtime model decided 391 operations. For example, enqueue message into the target partition under 392 the IPC runtime model, or prepare to call context with the message as the 393 parameters under the SFN runtime model. 394- API Handler triggers different ABI based on the result of the backends. 395 396The API handler: 397 398- Can process the `PROGRAMMER_ERROR` in a unified place. 399- Can see the prepared caller and callee context, with exited SPM context. It 400 is an ideal place for subsequent operations such as context switching. 401 402An example code: 403 404.. code-block:: c 405 406 void abi(void *p) 407 { 408 status = spm_api(p); 409 /* 410 * Now both the caller and callee contexts are 411 * managed by spm_api. 412 */ 413 if (status == ACTION1) { 414 /* 415 * Check if extra operations are required 416 * instead of a direct return. 417 */ 418 exit_action1(); 419 } 420 } 421 422The explanation about `Scheduler Lock`: 423 424Some FF-M API runs as a generic thread to prevent long time exclusive 425execution. When a preemption happens, a new partition thread can call SPM API 426again, makes SPM API nested. It needs extra memory in SPM to be allocated to 427store the preempted context. Lock the scheduler while SPM API is executing can 428ensure SPM API complete execution after preemption is handled. There can be 429multiple ways to lock the scheduler: 430 431- Set a scheduler lock. 432- Set SPM API thread priority as the highest. 433 434Backend service messaging 435------------------------- 436A message to service is created after the target service is found and the 437target partition runtime model is known. The preparation before ABI triggers 438the final accessing: 439 440- The message is pushed into partition memory under a specific ABI mechanism 441 if the target partition model is `SFN` and there are boundaries between SPM 442 and the target partition. After this, requests a specific call type to the 443 SPM ABI module. 444- The target service routine is called with the message parameter if 445 there are no boundaries between SPM and the target partition and the 446 partition runtime is `SFN`. 447- The message is queued into the partition message list if the target 448 partition runtime model is `IPC`. 449- IPC partition replies to the client by `psa_reply`, which is another SPM API 450 call procedure. 451- SFN partition return triggers an implied `psa_reply`, which is also another 452 SPM API call procedure. 453 454.. note:: 455 The backends also handle the isolation boundary switching. 456 457Sessions and contexts 458--------------------- 459FF-M API allows multiple sessions for a service if the service is classic 460connection-based. The service can maintain multiple local session data and use 461`rhandle` in the message body to identify which client this session is bound 462with. 463 464But this does not mean when an ongoing service accessing is preempted, 465another service access request can get a chance for new access. This is 466because of the limited context storage - supporting multiple contexts in a 467common service costs much memory, and runtime operations (allocation and 468re-location). Limited the context content in the stack only can mitigate the 469effort, but this requirement requires too much for the service development. 470 471The implementation-decisions are: 472 473- IPC partitions handles messages one by one, the client gets blocked before 474 the service replying to the client. 475- The client is blocked when accessing services are handling a service 476 request in an SFN partition. 477 478ABI type summary 479---------------- 480The interface type is decided by the runtime model of the target component. 481Hence PSA API has two types of ABI: `Cross-boundary ABI` and 482`Function call ABI`. After SPM operations, one more component runtime type 483shows up: The IPC partition, hence `schedule` is the mechanism when accessing 484services inside an IPC partition. 485 486.. figure:: /design_docs/media/spmabitypes.* 487 :align: center 488 :name: fig-spmabi 489 :width: 60% 490 491 ABI types 492 493.. note:: 494 The API that does not switch context returns directly, which is not 495 covered in the above diagram. 496 497IDLE state 498========== 499The `IDLE state` can be represented by the `NS Agent` action: 500 501- Launching NSPE software (Trustzone case, e.g.), or send a signal to NSPE 502 software (RPC case, e.g.). 503 504It is because `NS Agent` is the last component being initialized in the 505system. Its execution indicates other partitions' initialization has 506accomplished. 507 508Background state 509================ 510Background execution can happen at any time when the arrival of interrupts or 511execution faults. An ongoing background execution indicates the state is a 512`Background state`. The characteristics: 513 514- The background state has a higher execution priority than other states - 515 other states stall when the background state is executing. 516- Background execution can be nested. For example, an 517 interrupt handler can preempt an ongoing interrupt execution. 518- Particular partition code can be involved in the background state, for 519 example, the `First Level Interrupt Handler (FLIH)` of one partition. 520- Background state MUST return to the state it preempts. 521 522.. note:: 523 Interrupt handling is a common background state example. Check Interrupt 524 design document for details. 525 526****************************** 527Practical implementation items 528****************************** 529This chapter describes the practical implementation contents. 530 531.. important:: 532 Arm M-profile architecture is the default hardware architecture when 533 describing architecture-specific items. 534 535The general M-profile programming is not involved in this document. The 536following chapters introduce the mandatory settings for security 537requirements. 538 539Architecture security settings 540============================== 541When an `Armv8m Security Extension` (Aka `Trustzone-M`) is available in the 542system, these settings are required to be set: 543 544- The MSPLIM needs to be set correctly to prevent stack overflow. 545- The exception handler priority needs to be decided. 546- Boost the secure handler mode priority to prevent NSPE from preempting SPE 547 handler mode execution(`AIRCR.PRIS`). 548- Disable NSPE hardware faults when a secure fault is happening. Trap in the 549 secure fault with the highest priority can be a valid option. 550- Push seals on the stack top when a stack is allocated (`TFMV-1`). Also 551 check `Stack seal`_ chapter for details. 552 553Besides `Armv8m Security Extension`, these settings need to care when 554`Floatpoint Extension` is enabled for partition usage: 555 556- `FPCCR.TS`, `FPCCR.CLRONRET` and `FPCCR.CLRONRETS` need to be set when 557 booting. 558- `CPACR.CP10` and `CPACR.CP11` need to be set when booting. 559 560.. important:: 561 Floatpoint usage is prohibited in SPM and background execution. 562 563Stack seal 564---------- 565When Trustzone-M is applied, the architecture specification recommends sealing 566the secure stack by: 567 568- Push two `SEAL` values (`0xFEF5EDA5`) at the stack bottom, when a stack is 569 allocated. 570- Push two `SEAL` values on the stack pointer which is going to be switched 571 out. 572 573Check architecture specification and vulnerability `TFMV-1` for details. 574 575Trustzone-M reentrant 576--------------------- 577The Trustzone-M has characteristics that: 578 579- SPE keeps the last assigned stack pointer value when execution leaves SPE. 580- SPE execution can be preempted by NSPE which causes an execution left. 581 582It is possible that NSPE preemption caused a second thread calls into SPE and 583re-uses the secure stack contains the first thread's context, which obviously 584causes information leakage and runtime state inconsistent. 585 586Armv8.1-M provides the hardware setting `CCR_S.TRD` to prevent the reentrant. 587On an Armv8.0-M architecture, extra software logic needs to be added at the 588veneer entry: 589 590- Check if the local stack points to a `SEAL` when veneer code get executed. 591 592.. code-block:: c 593 594 /* This is a theoretical code that is not in a real project. */ 595 veneer() { 596 content = get_sp_value(); 597 if (context != SEAL) /* Error if reentrant detected */ 598 error(); 599 } 600 601SPM Runtime ABI 602=============== 603This chapter describes the runtime implementation of SPM. 604 605Scheduling 606---------- 607The scheduling logic is put inside the PendSV mode. PendSV mode's priority 608is set as one level higher than the default thread mode priority. If 609`Trustzone-M` is present, the priority is set as the lowest just above NS 610exception priority to prevent a preemption in secure exceptions. 611 612PendSV is an ideal place for scheduling logic, because: 613 614- An interrupt triggered scheduling during PendSV execution lead to another 615 PendSV execution before exception return to the thread mode, which can find 616 the latest run-able thread. 617 618Function call ABI 619----------------- 620In the diagram :numref:`fig-abi_scheduler`, the ABI can have two basic 621types: cross-boundary and direct call (No-cross-boundary). 622 623When applying `SVCall` (`SVC`) as the cross-boundary mechanism, the 624implementation can be straight like: 625 626- The SVC handler calls SPM internal routines, and eventually back to the 627 handler before an exit. 628 629Under the IPC model implementation, to reuse `ABI 2` in `No-cross-boundary`, 630a software ABI needs to be provided. 631 632While under the SFN model plus isolation level 1, both `ABI 1` and `ABI 2` can 633be a direct function call. 634 635NS Agent 636======== 637The `NS Agent` (`NSA`) forwards NSPE service access request to SPM. It is a 638special `partition` that: 639 640- It does not provide FF-M aligned secure services. 641- It runs with the second-lowest priority under `IPC model implementation` 642 (The IDLE thread has the lowest priority). 643- It has isolation boundaries and an individual stack. 644- It requires specific services and mechanisms compared to common partitions. 645 646There are two known types for NS Agent: 647 648- Trustzone-M based. 649- Remote Procedure Call (RPC) based. 650 651This process is put inside the ARoT domain, to prevent assign unnecessary 652PRoT permissions to the NSPE request parsing logic. 653 654Trustzone-M specific 655-------------------- 656The functionalities of a Trustzone-M specific NSA is: 657 658- Launch NSPE when booting. 659- Wait in the veneer code, and get executed when NSPE accesses services. 660 661As there may be multiple NSPE threads calling into SPE, and SPM wants to 662identify them, special mechanisms can be proposed to provide the identification. 663Check specific NS ID client ID or context related documents for details. 664 665.. figure:: /design_docs/media/tzcontext.* 666 :align: center 667 :name: fig-tzcontext 668 :width: 40% 669 670 TZ NSA and specific service 671 672RPC specific 673------------ 674Compared to Trustzone-M NSA, RPC NSA looks closer to a generic partition: 675 676- It has a message loop, keep waiting for RPC events. 677- It converts received RPC events into FF-M API call to target services. 678 679And compared to generic partitions, the differences are: 680 681- It parses RPC messages to know which NSPE thread is accessing services. 682 Hence it needs special interfaces to help SPM to identify the NSPE clients. 683- It needs to check NSPE client memory and map to local before calling SPM API. 684- It cannot be blocked during API calls, which affects handling the RPC 685 requests. 686 687Partition 688========= 689A partition is a set of services in the same scope. Services are generally 690implemented as functions, and the partition exposes the services in different 691ways based on the partition model: `IPC` or `SFN`. 692 693A partition build generates these outputs: 694 695- A partition load information, used by SPM. 696- A partition program containing service interface and logic, typically a 697 library. 698- An optional service API set for easier client usage, by encapsulating 699 the low-level `FF-M` Client API. These API needs to be integrated 700 into client space. 701 702Partition loading 703----------------- 704SPM needs to set up runtime objects to manage partitions by parsing the load 705information of partitions. In general, the partition load information is 706stored in a const memory area can be random read directly, hence SPM can direct 707link runtime objects to the load information without a copy operation. This 708is called a `Static Load` mechanism. 709 710Each partition has different numbers of dependencies and services, this makes 711the load information size of each partition different, it would be hard to put 712such variable size elements in an array. The solution here is putting these 713elements in a dedicated section, for SPM enumerating while loading. 714Each partition can define variable size load information type based on the 715common load info type. 716 717The common load information: 718 719.. code-block:: c 720 721 struct partition_load_info_t { 722 uint32_t psa_ff_ver; /* Encode the version with magic */ 723 int32_t pid; /* Partition ID */ 724 uint32_t flags; /* ARoT/PRoT, SFN/IPC, priority */ 725 uintptr_t entry; /* Entry point */ 726 size_t stack_size; /* Stack size */ 727 size_t heap_size; /* Heap size */ 728 uint32_t ndeps; /* Dependency number */ 729 uint32_t nservices; /* Service number */ 730 uint32_t nassets; /* Asset numbers */ 731 uint32_t nirqs; /* Number of IRQ owned by Partition */ 732 }; 733 734 And the example for a specific partition load info: 735 struct partition_example_load_info_t { 736 struct partition_load_info_t ldi; /* Common info info */ 737 uint32_t deps[10]; /* Dependencies */ 738 /* ... other infos ... */ 739 }; 740 741Peripheral binding 742------------------ 743A partition can declare multiple peripherals (Interrupts are part of 744peripherals). The peripherals binding process: 745 746- The tooling references symbols in a fixed pattern in the partition load 747 information. 748- The HAL implementation needs to provide the symbols being referenced. 749- SPM calls HAL API to bind the partition info with devices when the partition 750 gets loaded. 751- The platform HAL acknowledges the binding if validation pass on SPM given 752 load information. 753 754*************************** 755Integration and development 756*************************** 757These modules are expected to be object/library level modularised, each 758module should be generated into object/library at build time: 759 760.. list-table:: Object level modularization 761 :header-rows: 1 762 :widths: 40 60 763 764 * - Name 765 - Description 766 * - SPM 767 - All SPM related modules such as SPM, system, and so on. 768 * - Platform 769 - Platform sources are switchable. 770 * - Services and Secure Partition 771 - These items should be standalone. 772 * - Service Runtime Library 773 - This is a shared runtime library. 774 775HAL 776=== 777The HAL here mainly refers to the SPM HAL. The SPM HAL implementation is 778running with the same privilege level and hardware mode with SPM. The 779implementation is object level modularized with SPM. 780 781Check the `HAL` design document for details. 782 783Configurations 784============== 785The same TF-M code base is flexible to address different implementation 786requirements, from the simplest device with isolation level 1 to the most 787complicated device with isolation level 3 and optional isolation rules. 788 789These configurations are set by switches, during the build time, as runtime 790support costs extra resources. The common configurations are named `profile`. 791There are several profiles defined. 792 793******* 794History 795******* 796 797.. list-table:: Revision 798 :header-rows: 1 799 :widths: 20 80 800 801 * - Date 802 - Description 803 * - 2021 Apr-Sep 804 - Updated to cover the implementation for `FF-M v1.1` features. 805 * - 2018 806 - Created as 'TF-M Inter-Process Communication' which is deprecated as 807 this document covers whole SPM content. 808 809-------------- 810 811*Copyright (c) 2021,2024, Arm Limited. All rights reserved.* 812