1*91f16700SchasingluluSecure Partition Manager (MM) 2*91f16700Schasinglulu***************************** 3*91f16700Schasinglulu 4*91f16700SchasingluluForeword 5*91f16700Schasinglulu======== 6*91f16700Schasinglulu 7*91f16700SchasingluluThis document describes the implementation where the Secure Partition Manager 8*91f16700Schasingluluresides at EL3 and management services run from isolated Secure Partitions at 9*91f16700SchasingluluS-EL0. The communication protocol is established through the Management Mode 10*91f16700Schasinglulu(MM) interface. 11*91f16700Schasinglulu 12*91f16700SchasingluluBackground 13*91f16700Schasinglulu========== 14*91f16700Schasinglulu 15*91f16700SchasingluluIn some market segments that primarily deal with client-side devices like mobile 16*91f16700Schasingluluphones, tablets, STBs and embedded devices, a Trusted OS instantiates trusted 17*91f16700Schasingluluapplications to provide security services like DRM, secure payment and 18*91f16700Schasingluluauthentication. The Global Platform TEE Client API specification defines the API 19*91f16700Schasingluluused by Non-secure world applications to access these services. A Trusted OS 20*91f16700Schasinglulufulfils the requirements of a security service as described above. 21*91f16700Schasinglulu 22*91f16700SchasingluluManagement services are typically implemented at the highest level of privilege 23*91f16700Schasingluluin the system, i.e. EL3 in Trusted Firmware-A (TF-A). The service requirements are 24*91f16700Schasinglulufulfilled by the execution environment provided by TF-A. 25*91f16700Schasinglulu 26*91f16700SchasingluluThe following diagram illustrates the corresponding software stack: 27*91f16700Schasinglulu 28*91f16700Schasinglulu|Image 1| 29*91f16700Schasinglulu 30*91f16700SchasingluluIn other market segments that primarily deal with server-side devices (e.g. data 31*91f16700Schasinglulucentres and enterprise servers) the secure software stack typically does not 32*91f16700Schasingluluinclude a Global Platform Trusted OS. Security functions are accessed through 33*91f16700Schasingluluother interfaces (e.g. ACPI TCG TPM interface, UEFI runtime variable service). 34*91f16700Schasinglulu 35*91f16700SchasingluluPlacement of management and security functions with diverse requirements in a 36*91f16700Schasingluluprivileged Exception Level (i.e. EL3 or S-EL1) makes security auditing of 37*91f16700Schasinglulufirmware more difficult and does not allow isolation of unrelated services from 38*91f16700Schasinglulueach other either. 39*91f16700Schasinglulu 40*91f16700SchasingluluIntroduction 41*91f16700Schasinglulu============ 42*91f16700Schasinglulu 43*91f16700SchasingluluA **Secure Partition** is a software execution environment instantiated in 44*91f16700SchasingluluS-EL0 that can be used to implement simple management and security services. 45*91f16700SchasingluluSince S-EL0 is an unprivileged Exception Level, a Secure Partition relies on 46*91f16700Schasingluluprivileged firmware (i.e. TF-A) to be granted access to system and processor 47*91f16700Schasingluluresources. Essentially, it is a software sandbox in the Secure world that runs 48*91f16700Schasingluluunder the control of privileged software, provides one or more services and 49*91f16700Schasingluluaccesses the following system resources: 50*91f16700Schasinglulu 51*91f16700Schasinglulu- Memory and device regions in the system address map. 52*91f16700Schasinglulu 53*91f16700Schasinglulu- PE system registers. 54*91f16700Schasinglulu 55*91f16700Schasinglulu- A range of synchronous exceptions (e.g. SMC function identifiers). 56*91f16700Schasinglulu 57*91f16700SchasingluluNote that currently TF-A only supports handling one Secure Partition. 58*91f16700Schasinglulu 59*91f16700SchasingluluA Secure Partition enables TF-A to implement only the essential secure 60*91f16700Schasingluluservices in EL3 and instantiate the rest in a partition in S-EL0. 61*91f16700SchasingluluFurthermore, multiple Secure Partitions can be used to isolate unrelated 62*91f16700Schasingluluservices from each other. 63*91f16700Schasinglulu 64*91f16700SchasingluluThe following diagram illustrates the place of a Secure Partition in a typical 65*91f16700SchasingluluArmv8-A software stack. A single or multiple Secure Partitions provide secure 66*91f16700Schasingluluservices to software components in the Non-secure world and other Secure 67*91f16700SchasingluluPartitions. 68*91f16700Schasinglulu 69*91f16700Schasinglulu|Image 2| 70*91f16700Schasinglulu 71*91f16700SchasingluluThe TF-A build system is responsible for including the Secure Partition image 72*91f16700Schasingluluin the FIP. During boot, BL2 includes support to authenticate and load the 73*91f16700SchasingluluSecure Partition image. A BL31 component called **Secure Partition Manager 74*91f16700Schasinglulu(SPM)** is responsible for managing the partition. This is semantically 75*91f16700Schasinglulusimilar to a hypervisor managing a virtual machine. 76*91f16700Schasinglulu 77*91f16700SchasingluluThe SPM is responsible for the following actions during boot: 78*91f16700Schasinglulu 79*91f16700Schasinglulu- Allocate resources requested by the Secure Partition. 80*91f16700Schasinglulu 81*91f16700Schasinglulu- Perform architectural and system setup required by the Secure Partition to 82*91f16700Schasinglulu fulfil a service request. 83*91f16700Schasinglulu 84*91f16700Schasinglulu- Implement a standard interface that is used for initialising a Secure 85*91f16700Schasinglulu Partition. 86*91f16700Schasinglulu 87*91f16700SchasingluluThe SPM is responsible for the following actions during runtime: 88*91f16700Schasinglulu 89*91f16700Schasinglulu- Implement a standard interface that is used by a Secure Partition to fulfil 90*91f16700Schasinglulu service requests. 91*91f16700Schasinglulu 92*91f16700Schasinglulu- Implement a standard interface that is used by the Non-secure world for 93*91f16700Schasinglulu accessing the services exported by a Secure Partition. A service can be 94*91f16700Schasinglulu invoked through a SMC. 95*91f16700Schasinglulu 96*91f16700SchasingluluAlternatively, a partition can be viewed as a thread of execution running under 97*91f16700Schasingluluthe control of the SPM. Hence common programming concepts described below are 98*91f16700Schasingluluapplicable to a partition. 99*91f16700Schasinglulu 100*91f16700SchasingluluDescription 101*91f16700Schasinglulu=========== 102*91f16700Schasinglulu 103*91f16700SchasingluluThe previous section introduced some general aspects of the software 104*91f16700Schasingluluarchitecture of a Secure Partition. This section describes the specific choices 105*91f16700Schasinglulumade in the current implementation of this software architecture. Subsequent 106*91f16700Schasinglulurevisions of the implementation will include a richer set of features that 107*91f16700Schasingluluenable a more flexible architecture. 108*91f16700Schasinglulu 109*91f16700SchasingluluBuilding TF-A with Secure Partition support 110*91f16700Schasinglulu------------------------------------------- 111*91f16700Schasinglulu 112*91f16700SchasingluluSPM is supported on the Arm FVP exclusively at the moment. The current 113*91f16700Schasingluluimplementation supports inclusion of only a single Secure Partition in which a 114*91f16700Schasingluluservice always runs to completion (e.g. the requested services cannot be 115*91f16700Schasinglulupreempted to give control back to the Normal world). 116*91f16700Schasinglulu 117*91f16700SchasingluluIt is not currently possible for BL31 to integrate SPM support and a Secure 118*91f16700SchasingluluPayload Dispatcher (SPD) at the same time; they are mutually exclusive. In the 119*91f16700SchasingluluSPM bootflow, a Secure Partition image executing at S-EL0 replaces the Secure 120*91f16700SchasingluluPayload image executing at S-EL1 (e.g. a Trusted OS). Both are referred to as 121*91f16700SchasingluluBL32. 122*91f16700Schasinglulu 123*91f16700SchasingluluA working prototype of a SP has been implemented by re-purposing the EDK2 code 124*91f16700Schasingluluand tools, leveraging the concept of the *Standalone Management Mode (MM)* in 125*91f16700Schasingluluthe UEFI specification (see the PI v1.6 Volume 4: Management Mode Core 126*91f16700SchasingluluInterface). This will be referred to as the *Standalone MM Secure Partition* in 127*91f16700Schasingluluthe rest of this document. 128*91f16700Schasinglulu 129*91f16700SchasingluluTo enable SPM support in TF-A, the source code must be compiled with the build 130*91f16700Schasingluluflag ``SPM_MM=1``, along with ``EL3_EXCEPTION_HANDLING=1`` and ``ENABLE_SVE_FOR_NS=0``. 131*91f16700SchasingluluOn Arm platforms the build option ``ARM_BL31_IN_DRAM`` must be set to 1. Also, the 132*91f16700Schasinglululocation of the binary that contains the BL32 image 133*91f16700Schasinglulu(``BL32=path/to/image.bin``) must be specified. 134*91f16700Schasinglulu 135*91f16700SchasingluluFirst, build the Standalone MM Secure Partition. To build it, refer to the 136*91f16700Schasinglulu`instructions in the EDK2 repository`_. 137*91f16700Schasinglulu 138*91f16700SchasingluluThen build TF-A with SPM support and include the Standalone MM Secure Partition 139*91f16700Schasingluluimage in the FIP: 140*91f16700Schasinglulu 141*91f16700Schasinglulu.. code:: shell 142*91f16700Schasinglulu 143*91f16700Schasinglulu BL32=path/to/standalone/mm/sp BL33=path/to/bl33.bin \ 144*91f16700Schasinglulu make PLAT=fvp SPM_MM=1 EL3_EXCEPTION_HANDLING=1 ENABLE_SVE_FOR_NS=0 ARM_BL31_IN_DRAM=1 all fip 145*91f16700Schasinglulu 146*91f16700SchasingluluDescribing Secure Partition resources 147*91f16700Schasinglulu------------------------------------- 148*91f16700Schasinglulu 149*91f16700SchasingluluTF-A exports a porting interface that enables a platform to specify the system 150*91f16700Schasingluluresources required by the Secure Partition. Some instructions are given below. 151*91f16700SchasingluluHowever, this interface is under development and it may change as new features 152*91f16700Schasingluluare implemented. 153*91f16700Schasinglulu 154*91f16700Schasinglulu- A Secure Partition is considered a BL32 image, so the same defines that apply 155*91f16700Schasinglulu to BL32 images apply to a Secure Partition: ``BL32_BASE`` and ``BL32_LIMIT``. 156*91f16700Schasinglulu 157*91f16700Schasinglulu- The following defines are needed to allocate space for the translation tables 158*91f16700Schasinglulu used by the Secure Partition: ``PLAT_SP_IMAGE_MMAP_REGIONS`` and 159*91f16700Schasinglulu ``PLAT_SP_IMAGE_MAX_XLAT_TABLES``. 160*91f16700Schasinglulu 161*91f16700Schasinglulu- The functions ``plat_get_secure_partition_mmap()`` and 162*91f16700Schasinglulu ``plat_get_secure_partition_boot_info()`` have to be implemented. The file 163*91f16700Schasinglulu ``plat/arm/board/fvp/fvp_common.c`` can be used as an example. It uses the 164*91f16700Schasinglulu defines in ``include/plat/arm/common/arm_spm_def.h``. 165*91f16700Schasinglulu 166*91f16700Schasinglulu - ``plat_get_secure_partition_mmap()`` returns an array of mmap regions that 167*91f16700Schasinglulu describe the memory regions that the SPM needs to allocate for a Secure 168*91f16700Schasinglulu Partition. 169*91f16700Schasinglulu 170*91f16700Schasinglulu - ``plat_get_secure_partition_boot_info()`` returns a 171*91f16700Schasinglulu ``spm_mm_boot_info_t`` struct that is populated by the platform 172*91f16700Schasinglulu with information about the memory map of the Secure Partition. 173*91f16700Schasinglulu 174*91f16700SchasingluluFor an example of all the changes in context, you may refer to commit 175*91f16700Schasinglulu``e29efeb1b4``, in which the port for FVP was introduced. 176*91f16700Schasinglulu 177*91f16700SchasingluluAccessing Secure Partition services 178*91f16700Schasinglulu----------------------------------- 179*91f16700Schasinglulu 180*91f16700SchasingluluThe `SMC Calling Convention`_ (*Arm DEN 0028B*) describes SMCs as a conduit for 181*91f16700Schasingluluaccessing services implemented in the Secure world. The ``MM_COMMUNICATE`` 182*91f16700Schasingluluinterface defined in the `Management Mode Interface Specification`_ (*Arm DEN 183*91f16700Schasinglulu0060A*) is used to invoke a Secure Partition service as a Fast Call. 184*91f16700Schasinglulu 185*91f16700SchasingluluThe mechanism used to identify a service within the partition depends on the 186*91f16700Schasingluluservice implementation. It is assumed that the caller of the service will be 187*91f16700Schasingluluable to discover this mechanism through standard platform discovery mechanisms 188*91f16700Schasinglululike ACPI and Device Trees. For example, *Volume 4: Platform Initialisation 189*91f16700SchasingluluSpecification v1.6. Management Mode Core Interface* specifies that a GUID is 190*91f16700Schasingluluused to identify a management mode service. A client populates the GUID in the 191*91f16700Schasinglulu``EFI_MM_COMMUNICATE_HEADER``. The header is populated in the communication 192*91f16700Schasinglulubuffer shared with the Secure Partition. 193*91f16700Schasinglulu 194*91f16700SchasingluluA Fast Call appears to be atomic from the perspective of the caller and returns 195*91f16700Schasingluluwhen the requested operation has completed. A service invoked through the 196*91f16700Schasinglulu``MM_COMMUNICATE`` SMC will run to completion in the partition on a given CPU. 197*91f16700SchasingluluThe SPM is responsible for guaranteeing this behaviour. This means that there 198*91f16700Schasinglulucan only be a single outstanding Fast Call in a partition on a given CPU. 199*91f16700Schasinglulu 200*91f16700SchasingluluExchanging data with the Secure Partition 201*91f16700Schasinglulu----------------------------------------- 202*91f16700Schasinglulu 203*91f16700SchasingluluThe exchange of data between the Non-secure world and the partition takes place 204*91f16700Schasingluluthrough a shared memory region. The location of data in the shared memory area 205*91f16700Schasingluluis passed as a parameter to the ``MM_COMMUNICATE`` SMC. The shared memory area 206*91f16700Schasingluluis statically allocated by the SPM and is expected to be either implicitly known 207*91f16700Schasingluluto the Non-secure world or discovered through a platform discovery mechanism 208*91f16700Schasinglulue.g. ACPI table or device tree. It is possible for the Non-secure world to 209*91f16700Schasingluluexchange data with a partition only if it has been populated in this shared 210*91f16700Schasinglulumemory area. The shared memory area is implemented as per the guidelines 211*91f16700Schasingluluspecified in Section 3.2.3 of the `Management Mode Interface Specification`_ 212*91f16700Schasinglulu(*Arm DEN 0060A*). 213*91f16700Schasinglulu 214*91f16700SchasingluluThe format of data structures used to encapsulate data in the shared memory is 215*91f16700Schasingluluagreed between the Non-secure world and the Secure Partition. For example, in 216*91f16700Schasingluluthe `Management Mode Interface specification`_ (*Arm DEN 0060A*), Section 4 217*91f16700Schasingluludescribes that the communication buffer shared between the Non-secure world and 218*91f16700Schasingluluthe Management Mode (MM) in the Secure world must be of the type 219*91f16700Schasinglulu``EFI_MM_COMMUNICATE_HEADER``. This data structure is defined in *Volume 4: 220*91f16700SchasingluluPlatform Initialisation Specification v1.6. Management Mode Core Interface*. 221*91f16700SchasingluluAny caller of a MM service will have to use the ``EFI_MM_COMMUNICATE_HEADER`` 222*91f16700Schasingluludata structure. 223*91f16700Schasinglulu 224*91f16700SchasingluluRuntime model of the Secure Partition 225*91f16700Schasinglulu===================================== 226*91f16700Schasinglulu 227*91f16700SchasingluluThis section describes how the Secure Partition interfaces with the SPM. 228*91f16700Schasinglulu 229*91f16700SchasingluluInterface with SPM 230*91f16700Schasinglulu------------------ 231*91f16700Schasinglulu 232*91f16700SchasingluluIn order to instantiate one or more secure services in the Secure Partition in 233*91f16700SchasingluluS-EL0, the SPM should define the following types of interfaces: 234*91f16700Schasinglulu 235*91f16700Schasinglulu- Interfaces that enable access to privileged operations from S-EL0. These 236*91f16700Schasinglulu operations typically require access to system resources that are either shared 237*91f16700Schasinglulu amongst multiple software components in the Secure world or cannot be directly 238*91f16700Schasinglulu accessed from an unprivileged Exception Level. 239*91f16700Schasinglulu 240*91f16700Schasinglulu- Interfaces that establish the control path between the SPM and the Secure 241*91f16700Schasinglulu Partition. 242*91f16700Schasinglulu 243*91f16700SchasingluluThis section describes the APIs currently exported by the SPM that enable a 244*91f16700SchasingluluSecure Partition to initialise itself and export its services in S-EL0. These 245*91f16700Schasingluluinterfaces are not accessible from the Non-secure world. 246*91f16700Schasinglulu 247*91f16700SchasingluluConduit 248*91f16700Schasinglulu^^^^^^^ 249*91f16700Schasinglulu 250*91f16700SchasingluluThe `SMC Calling Convention`_ (*Arm DEN 0028B*) specification describes the SMC 251*91f16700Schasingluluand HVC conduits for accessing firmware services and their availability 252*91f16700Schasingluludepending on the implemented Exception levels. In S-EL0, the Supervisor Call 253*91f16700Schasingluluexception (SVC) is the only architectural mechanism available for unprivileged 254*91f16700Schasinglulusoftware to make a request for an operation implemented in privileged software. 255*91f16700SchasingluluHence, the SVC conduit must be used by the Secure Partition to access interfaces 256*91f16700Schasingluluimplemented by the SPM. 257*91f16700Schasinglulu 258*91f16700SchasingluluA SVC causes an exception to be taken to S-EL1. TF-A assumes ownership of S-EL1 259*91f16700Schasingluluand installs a simple exception vector table in S-EL1 that relays a SVC request 260*91f16700Schasinglulufrom a Secure Partition as a SMC request to the SPM in EL3. Upon servicing the 261*91f16700SchasingluluSMC request, Trusted Firmware-A returns control directly to S-EL0 through an 262*91f16700SchasingluluERET instruction. 263*91f16700Schasinglulu 264*91f16700SchasingluluCalling conventions 265*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^ 266*91f16700Schasinglulu 267*91f16700SchasingluluThe `SMC Calling Convention`_ (*Arm DEN 0028B*) specification describes the 268*91f16700Schasinglulu32-bit and 64-bit calling conventions for the SMC and HVC conduits. The SVC 269*91f16700Schasingluluconduit introduces the concept of SVC32 and SVC64 calling conventions. The SVC32 270*91f16700Schasingluluand SVC64 calling conventions are equivalent to the 32-bit (SMC32) and the 271*91f16700Schasinglulu64-bit (SMC64) calling conventions respectively. 272*91f16700Schasinglulu 273*91f16700SchasingluluCommunication initiated by SPM 274*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 275*91f16700Schasinglulu 276*91f16700SchasingluluA service request is initiated from the SPM through an exception return 277*91f16700Schasingluluinstruction (ERET) to S-EL0. Later, the Secure Partition issues an SVC 278*91f16700Schasingluluinstruction to signal completion of the request. Some example use cases are 279*91f16700Schasinglulugiven below: 280*91f16700Schasinglulu 281*91f16700Schasinglulu- A request to initialise the Secure Partition during system boot. 282*91f16700Schasinglulu 283*91f16700Schasinglulu- A request to handle a runtime service request. 284*91f16700Schasinglulu 285*91f16700SchasingluluCommunication initiated by Secure Partition 286*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 287*91f16700Schasinglulu 288*91f16700SchasingluluA request is initiated from the Secure Partition by executing a SVC instruction. 289*91f16700SchasingluluAn ERET instruction is used by TF-A to return to S-EL0 with the result of the 290*91f16700Schasinglulurequest. 291*91f16700Schasinglulu 292*91f16700SchasingluluFor instance, a request to perform privileged operations on behalf of a 293*91f16700Schasinglulupartition (e.g. management of memory attributes in the translation tables for 294*91f16700Schasingluluthe Secure EL1&0 translation regime). 295*91f16700Schasinglulu 296*91f16700SchasingluluInterfaces 297*91f16700Schasinglulu^^^^^^^^^^ 298*91f16700Schasinglulu 299*91f16700SchasingluluThe current implementation reserves function IDs for Fast Calls in the Standard 300*91f16700SchasingluluSecure Service calls range (see `SMC Calling Convention`_ (*Arm DEN 0028B*) 301*91f16700Schasingluluspecification) for each API exported by the SPM. This section defines the 302*91f16700Schasinglulufunction prototypes for each function ID. The function IDs specify whether one 303*91f16700Schasingluluor both of the SVC32 and SVC64 calling conventions can be used to invoke the 304*91f16700Schasinglulucorresponding interface. 305*91f16700Schasinglulu 306*91f16700SchasingluluSecure Partition Event Management 307*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 308*91f16700Schasinglulu 309*91f16700SchasingluluThe Secure Partition provides an Event Management interface that is used by the 310*91f16700SchasingluluSPM to delegate service requests to the Secure Partition. The interface also 311*91f16700Schasingluluallows the Secure Partition to: 312*91f16700Schasinglulu 313*91f16700Schasinglulu- Register with the SPM a service that it provides. 314*91f16700Schasinglulu- Indicate completion of a service request delegated by the SPM 315*91f16700Schasinglulu 316*91f16700SchasingluluMiscellaneous interfaces 317*91f16700Schasinglulu------------------------ 318*91f16700Schasinglulu 319*91f16700Schasinglulu``SPM_MM_VERSION_AARCH32`` 320*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^^^^^^^ 321*91f16700Schasinglulu 322*91f16700Schasinglulu- Description 323*91f16700Schasinglulu 324*91f16700Schasinglulu Returns the version of the interface exported by SPM. 325*91f16700Schasinglulu 326*91f16700Schasinglulu- Parameters 327*91f16700Schasinglulu 328*91f16700Schasinglulu - **uint32** - Function ID 329*91f16700Schasinglulu 330*91f16700Schasinglulu - SVC32 Version: **0x84000060** 331*91f16700Schasinglulu 332*91f16700Schasinglulu- Return parameters 333*91f16700Schasinglulu 334*91f16700Schasinglulu - **int32** - Status 335*91f16700Schasinglulu 336*91f16700Schasinglulu On success, the format of the value is as follows: 337*91f16700Schasinglulu 338*91f16700Schasinglulu - Bit [31]: Must be 0 339*91f16700Schasinglulu - Bits [30:16]: Major Version. Must be 0 for this revision of the SPM 340*91f16700Schasinglulu interface. 341*91f16700Schasinglulu - Bits [15:0]: Minor Version. Must be 1 for this revision of the SPM 342*91f16700Schasinglulu interface. 343*91f16700Schasinglulu 344*91f16700Schasinglulu On error, the format of the value is as follows: 345*91f16700Schasinglulu 346*91f16700Schasinglulu - ``NOT_SUPPORTED``: SPM interface is not supported or not available for the 347*91f16700Schasinglulu client. 348*91f16700Schasinglulu 349*91f16700Schasinglulu- Usage 350*91f16700Schasinglulu 351*91f16700Schasinglulu This function returns the version of the Secure Partition Manager 352*91f16700Schasinglulu implementation. The major version is 0 and the minor version is 1. The version 353*91f16700Schasinglulu number is a 31-bit unsigned integer, with the upper 15 bits denoting the major 354*91f16700Schasinglulu revision, and the lower 16 bits denoting the minor revision. The following 355*91f16700Schasinglulu rules apply to the version numbering: 356*91f16700Schasinglulu 357*91f16700Schasinglulu - Different major revision values indicate possibly incompatible functions. 358*91f16700Schasinglulu 359*91f16700Schasinglulu - For two revisions, A and B, for which the major revision values are 360*91f16700Schasinglulu identical, if the minor revision value of revision B is greater than the 361*91f16700Schasinglulu minor revision value of revision A, then every function in revision A must 362*91f16700Schasinglulu work in a compatible way with revision B. However, it is possible for 363*91f16700Schasinglulu revision B to have a higher function count than revision A. 364*91f16700Schasinglulu 365*91f16700Schasinglulu- Implementation responsibilities 366*91f16700Schasinglulu 367*91f16700Schasinglulu If this function returns a valid version number, all the functions that are 368*91f16700Schasinglulu described subsequently must be implemented, unless it is explicitly stated 369*91f16700Schasinglulu that a function is optional. 370*91f16700Schasinglulu 371*91f16700SchasingluluSee `Error Codes`_ for integer values that are associated with each return 372*91f16700Schasinglulucode. 373*91f16700Schasinglulu 374*91f16700SchasingluluSecure Partition Initialisation 375*91f16700Schasinglulu------------------------------- 376*91f16700Schasinglulu 377*91f16700SchasingluluThe SPM is responsible for initialising the architectural execution context to 378*91f16700Schasingluluenable initialisation of a service in S-EL0. The responsibilities of the SPM are 379*91f16700Schasinglululisted below. At the end of initialisation, the partition issues a 380*91f16700Schasinglulu``MM_SP_EVENT_COMPLETE_AARCH64`` call (described later) to signal readiness for 381*91f16700Schasingluluhandling requests for services implemented by the Secure Partition. The 382*91f16700Schasingluluinitialisation event is executed as a Fast Call. 383*91f16700Schasinglulu 384*91f16700SchasingluluEntry point invocation 385*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^^^ 386*91f16700Schasinglulu 387*91f16700SchasingluluThe entry point for service requests that should be handled as Fast Calls is 388*91f16700Schasingluluused as the target of the ERET instruction to start initialisation of the Secure 389*91f16700SchasingluluPartition. 390*91f16700Schasinglulu 391*91f16700SchasingluluArchitectural Setup 392*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^ 393*91f16700Schasinglulu 394*91f16700SchasingluluAt cold boot, system registers accessible from S-EL0 will be in their reset 395*91f16700Schasinglulustate unless otherwise specified. The SPM will perform the following 396*91f16700Schasingluluarchitectural setup to enable execution in S-EL0 397*91f16700Schasinglulu 398*91f16700SchasingluluMMU setup 399*91f16700Schasinglulu^^^^^^^^^ 400*91f16700Schasinglulu 401*91f16700SchasingluluThe platform port of a Secure Partition specifies to the SPM a list of regions 402*91f16700Schasingluluthat it needs access to and their attributes. The SPM validates this resource 403*91f16700Schasingluludescription and initialises the Secure EL1&0 translation regime as follows. 404*91f16700Schasinglulu 405*91f16700Schasinglulu1. Device regions are mapped with nGnRE attributes and Execute Never 406*91f16700Schasinglulu instruction access permissions. 407*91f16700Schasinglulu 408*91f16700Schasinglulu2. Code memory regions are mapped with RO data and Executable instruction access 409*91f16700Schasinglulu permissions. 410*91f16700Schasinglulu 411*91f16700Schasinglulu3. Read Only data memory regions are mapped with RO data and Execute Never 412*91f16700Schasinglulu instruction access permissions. 413*91f16700Schasinglulu 414*91f16700Schasinglulu4. Read Write data memory regions are mapped with RW data and Execute Never 415*91f16700Schasinglulu instruction access permissions. 416*91f16700Schasinglulu 417*91f16700Schasinglulu5. If the resource description does not explicitly describe the type of memory 418*91f16700Schasinglulu regions then all memory regions will be marked with Code memory region 419*91f16700Schasinglulu attributes. 420*91f16700Schasinglulu 421*91f16700Schasinglulu6. The ``UXN`` and ``PXN`` bits are set for regions that are not executable by 422*91f16700Schasinglulu S-EL0 or S-EL1. 423*91f16700Schasinglulu 424*91f16700SchasingluluSystem Register Setup 425*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^^ 426*91f16700Schasinglulu 427*91f16700SchasingluluSystem registers that influence software execution in S-EL0 are setup by the SPM 428*91f16700Schasingluluas follows: 429*91f16700Schasinglulu 430*91f16700Schasinglulu1. ``SCTLR_EL1`` 431*91f16700Schasinglulu 432*91f16700Schasinglulu - ``UCI=1`` 433*91f16700Schasinglulu - ``EOE=0`` 434*91f16700Schasinglulu - ``WXN=1`` 435*91f16700Schasinglulu - ``nTWE=1`` 436*91f16700Schasinglulu - ``nTWI=1`` 437*91f16700Schasinglulu - ``UCT=1`` 438*91f16700Schasinglulu - ``DZE=1`` 439*91f16700Schasinglulu - ``I=1`` 440*91f16700Schasinglulu - ``UMA=0`` 441*91f16700Schasinglulu - ``SA0=1`` 442*91f16700Schasinglulu - ``C=1`` 443*91f16700Schasinglulu - ``A=1`` 444*91f16700Schasinglulu - ``M=1`` 445*91f16700Schasinglulu 446*91f16700Schasinglulu2. ``CPACR_EL1`` 447*91f16700Schasinglulu 448*91f16700Schasinglulu - ``FPEN=b'11`` 449*91f16700Schasinglulu 450*91f16700Schasinglulu3. ``PSTATE`` 451*91f16700Schasinglulu 452*91f16700Schasinglulu - ``D,A,I,F=1`` 453*91f16700Schasinglulu - ``CurrentEL=0`` (EL0) 454*91f16700Schasinglulu - ``SpSel=0`` (Thread mode) 455*91f16700Schasinglulu - ``NRW=0`` (AArch64) 456*91f16700Schasinglulu 457*91f16700SchasingluluGeneral Purpose Register Setup 458*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 459*91f16700Schasinglulu 460*91f16700SchasingluluSPM will invoke the entry point of a service by executing an ERET instruction. 461*91f16700SchasingluluThis transition into S-EL0 is special since it is not in response to a previous 462*91f16700Schasinglulurequest through a SVC instruction. This is the first entry into S-EL0. The 463*91f16700Schasinglulugeneral purpose register usage at the time of entry will be as specified in the 464*91f16700Schasinglulu"Return State" column of Table 3-1 in Section 3.1 "Register use in AArch64 SMC 465*91f16700Schasinglulucalls" of the `SMC Calling Convention`_ (*Arm DEN 0028B*) specification. In 466*91f16700Schasingluluaddition, certain other restrictions will be applied as described below. 467*91f16700Schasinglulu 468*91f16700Schasinglulu1. ``SP_EL0`` 469*91f16700Schasinglulu 470*91f16700Schasinglulu A non-zero value will indicate that the SPM has initialised the stack pointer 471*91f16700Schasinglulu for the current CPU. 472*91f16700Schasinglulu 473*91f16700Schasinglulu The value will be 0 otherwise. 474*91f16700Schasinglulu 475*91f16700Schasinglulu2. ``X4-X30`` 476*91f16700Schasinglulu 477*91f16700Schasinglulu The values of these registers will be 0. 478*91f16700Schasinglulu 479*91f16700Schasinglulu3. ``X0-X3`` 480*91f16700Schasinglulu 481*91f16700Schasinglulu Parameters passed by the SPM. 482*91f16700Schasinglulu 483*91f16700Schasinglulu - ``X0``: Virtual address of a buffer shared between EL3 and S-EL0. The 484*91f16700Schasinglulu buffer will be mapped in the Secure EL1&0 translation regime with read-only 485*91f16700Schasinglulu memory attributes described earlier. 486*91f16700Schasinglulu 487*91f16700Schasinglulu - ``X1``: Size of the buffer in bytes. 488*91f16700Schasinglulu 489*91f16700Schasinglulu - ``X2``: Cookie value (*IMPLEMENTATION DEFINED*). 490*91f16700Schasinglulu 491*91f16700Schasinglulu - ``X3``: Cookie value (*IMPLEMENTATION DEFINED*). 492*91f16700Schasinglulu 493*91f16700SchasingluluRuntime Event Delegation 494*91f16700Schasinglulu------------------------ 495*91f16700Schasinglulu 496*91f16700SchasingluluThe SPM receives requests for Secure Partition services through a synchronous 497*91f16700Schasingluluinvocation (i.e. a SMC from the Non-secure world). These requests are delegated 498*91f16700Schasingluluto the partition by programming a return from the last 499*91f16700Schasinglulu``MM_SP_EVENT_COMPLETE_AARCH64`` call received from the partition. The last call 500*91f16700Schasingluluwas made to signal either completion of Secure Partition initialisation or 501*91f16700Schasinglulucompletion of a partition service request. 502*91f16700Schasinglulu 503*91f16700Schasinglulu``MM_SP_EVENT_COMPLETE_AARCH64`` 504*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 505*91f16700Schasinglulu 506*91f16700Schasinglulu- Description 507*91f16700Schasinglulu 508*91f16700Schasinglulu Signal completion of the last SP service request. 509*91f16700Schasinglulu 510*91f16700Schasinglulu- Parameters 511*91f16700Schasinglulu 512*91f16700Schasinglulu - **uint32** - Function ID 513*91f16700Schasinglulu 514*91f16700Schasinglulu - SVC64 Version: **0xC4000061** 515*91f16700Schasinglulu 516*91f16700Schasinglulu - **int32** - Event Status Code 517*91f16700Schasinglulu 518*91f16700Schasinglulu Zero or a positive value indicates that the event was handled successfully. 519*91f16700Schasinglulu The values depend upon the original event that was delegated to the Secure 520*91f16700Schasinglulu partition. They are described as follows. 521*91f16700Schasinglulu 522*91f16700Schasinglulu - ``SUCCESS`` : Used to indicate that the Secure Partition was initialised 523*91f16700Schasinglulu or a runtime request was handled successfully. 524*91f16700Schasinglulu 525*91f16700Schasinglulu - Any other value greater than 0 is used to pass a specific Event Status 526*91f16700Schasinglulu code in response to a runtime event. 527*91f16700Schasinglulu 528*91f16700Schasinglulu A negative value indicates an error. The values of Event Status code depend 529*91f16700Schasinglulu on the original event. 530*91f16700Schasinglulu 531*91f16700Schasinglulu- Return parameters 532*91f16700Schasinglulu 533*91f16700Schasinglulu - **int32** - Event ID/Return Code 534*91f16700Schasinglulu 535*91f16700Schasinglulu Zero or a positive value specifies the unique ID of the event being 536*91f16700Schasinglulu delegated to the partition by the SPM. 537*91f16700Schasinglulu 538*91f16700Schasinglulu In the current implementation, this parameter contains the function ID of 539*91f16700Schasinglulu the ``MM_COMMUNICATE`` SMC. This value indicates to the partition that an 540*91f16700Schasinglulu event has been delegated to it in response to an ``MM_COMMUNICATE`` request 541*91f16700Schasinglulu from the Non-secure world. 542*91f16700Schasinglulu 543*91f16700Schasinglulu A negative value indicates an error. The format of the value is as follows: 544*91f16700Schasinglulu 545*91f16700Schasinglulu - ``NOT_SUPPORTED``: Function was called from the Non-secure world. 546*91f16700Schasinglulu 547*91f16700Schasinglulu See `Error Codes`_ for integer values that are associated with each return 548*91f16700Schasinglulu code. 549*91f16700Schasinglulu 550*91f16700Schasinglulu - **uint32** - Event Context Address 551*91f16700Schasinglulu 552*91f16700Schasinglulu Address of a buffer shared between the SPM and Secure Partition to pass 553*91f16700Schasinglulu event specific information. The format of the data populated in the buffer 554*91f16700Schasinglulu is implementation defined. 555*91f16700Schasinglulu 556*91f16700Schasinglulu The buffer is mapped in the Secure EL1&0 translation regime with read-only 557*91f16700Schasinglulu memory attributes described earlier. 558*91f16700Schasinglulu 559*91f16700Schasinglulu For the SVC64 version, this parameter is a 64-bit Virtual Address (VA). 560*91f16700Schasinglulu 561*91f16700Schasinglulu For the SVC32 version, this parameter is a 32-bit Virtual Address (VA). 562*91f16700Schasinglulu 563*91f16700Schasinglulu - **uint32** - Event context size 564*91f16700Schasinglulu 565*91f16700Schasinglulu Size of the memory starting at Event Address. 566*91f16700Schasinglulu 567*91f16700Schasinglulu - **uint32/uint64** - Event Cookie 568*91f16700Schasinglulu 569*91f16700Schasinglulu This is an optional parameter. If unused its value is SBZ. 570*91f16700Schasinglulu 571*91f16700Schasinglulu- Usage 572*91f16700Schasinglulu 573*91f16700Schasinglulu This function signals to the SPM that the handling of the last event delegated 574*91f16700Schasinglulu to a partition has completed. The partition is ready to handle its next event. 575*91f16700Schasinglulu A return from this function is in response to the next event that will be 576*91f16700Schasinglulu delegated to the partition. The return parameters describe the next event. 577*91f16700Schasinglulu 578*91f16700Schasinglulu- Caller responsibilities 579*91f16700Schasinglulu 580*91f16700Schasinglulu A Secure Partition must only call ``MM_SP_EVENT_COMPLETE_AARCH64`` to signal 581*91f16700Schasinglulu completion of a request that was delegated to it by the SPM. 582*91f16700Schasinglulu 583*91f16700Schasinglulu- Callee responsibilities 584*91f16700Schasinglulu 585*91f16700Schasinglulu When the SPM receives this call from a Secure Partition, the corresponding 586*91f16700Schasinglulu syndrome information can be used to return control through an ERET 587*91f16700Schasinglulu instruction, to the instruction immediately after the call in the Secure 588*91f16700Schasinglulu Partition context. This syndrome information comprises of general purpose and 589*91f16700Schasinglulu system register values when the call was made. 590*91f16700Schasinglulu 591*91f16700Schasinglulu The SPM must save this syndrome information and use it to delegate the next 592*91f16700Schasinglulu event to the Secure Partition. The return parameters of this interface must 593*91f16700Schasinglulu specify the properties of the event and be populated in ``X0-X3/W0-W3`` 594*91f16700Schasinglulu registers. 595*91f16700Schasinglulu 596*91f16700SchasingluluSecure Partition Memory Management 597*91f16700Schasinglulu---------------------------------- 598*91f16700Schasinglulu 599*91f16700SchasingluluA Secure Partition executes at S-EL0, which is an unprivileged Exception Level. 600*91f16700SchasingluluThe SPM is responsible for enabling access to regions of memory in the system 601*91f16700Schasingluluaddress map from a Secure Partition. This is done by mapping these regions in 602*91f16700Schasingluluthe Secure EL1&0 Translation regime with appropriate memory attributes. 603*91f16700SchasingluluAttributes refer to memory type, permission, cacheability and shareability 604*91f16700Schasingluluattributes used in the Translation tables. The definitions of these attributes 605*91f16700Schasingluluand their usage can be found in the `Armv8-A ARM`_ (*Arm DDI 0487*). 606*91f16700Schasinglulu 607*91f16700SchasingluluAll memory required by the Secure Partition is allocated upfront in the SPM, 608*91f16700Schasinglulueven before handing over to the Secure Partition for the first time. The initial 609*91f16700Schasingluluaccess permissions of the memory regions are statically provided by the platform 610*91f16700Schasingluluport and should allow the Secure Partition to run its initialisation code. 611*91f16700Schasinglulu 612*91f16700SchasingluluHowever, they might not suit the final needs of the Secure Partition because its 613*91f16700Schasinglulufinal memory layout might not be known until the Secure Partition initialises 614*91f16700Schasingluluitself. As the Secure Partition initialises its runtime environment it might, 615*91f16700Schasinglulufor example, load dynamically some modules. For instance, a Secure Partition 616*91f16700Schasinglulucould implement a loader for a standard executable file format (e.g. an PE-COFF 617*91f16700Schasinglululoader for loading executable files at runtime). These executable files will be 618*91f16700Schasinglulua part of the Secure Partition image. The location of various sections in an 619*91f16700Schasingluluexecutable file and their permission attributes (e.g. read-write data, read-only 620*91f16700Schasingluludata and code) will be known only when the file is loaded into memory. 621*91f16700Schasinglulu 622*91f16700SchasingluluIn this case, the Secure Partition needs a way to change the access permissions 623*91f16700Schasingluluof its memory regions. The SPM provides this feature through the 624*91f16700Schasinglulu``MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64`` SVC interface. This interface is 625*91f16700Schasingluluavailable to the Secure Partition during a specific time window: from the first 626*91f16700Schasingluluentry into the Secure Partition up to the first ``SP_EVENT_COMPLETE`` call that 627*91f16700Schasinglulusignals the Secure Partition has finished its initialisation. Once the 628*91f16700Schasingluluinitialisation is complete, the SPM does not allow changes to the memory 629*91f16700Schasingluluattributes. 630*91f16700Schasinglulu 631*91f16700SchasingluluThis section describes the standard SVC interface that is implemented by the SPM 632*91f16700Schasingluluto determine and change permission attributes of memory regions that belong to a 633*91f16700SchasingluluSecure Partition. 634*91f16700Schasinglulu 635*91f16700Schasinglulu``MM_SP_MEMORY_ATTRIBUTES_GET_AARCH64`` 636*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 637*91f16700Schasinglulu 638*91f16700Schasinglulu- Description 639*91f16700Schasinglulu 640*91f16700Schasinglulu Request the permission attributes of a memory region from S-EL0. 641*91f16700Schasinglulu 642*91f16700Schasinglulu- Parameters 643*91f16700Schasinglulu 644*91f16700Schasinglulu - **uint32** Function ID 645*91f16700Schasinglulu 646*91f16700Schasinglulu - SVC64 Version: **0xC4000064** 647*91f16700Schasinglulu 648*91f16700Schasinglulu - **uint64** Base Address 649*91f16700Schasinglulu 650*91f16700Schasinglulu This parameter is a 64-bit Virtual Address (VA). 651*91f16700Schasinglulu 652*91f16700Schasinglulu There are no alignment restrictions on the Base Address. The permission 653*91f16700Schasinglulu attributes of the translation granule it lies in are returned. 654*91f16700Schasinglulu 655*91f16700Schasinglulu- Return parameters 656*91f16700Schasinglulu 657*91f16700Schasinglulu - **int32** - Memory Attributes/Return Code 658*91f16700Schasinglulu 659*91f16700Schasinglulu On success the format of the Return Code is as follows: 660*91f16700Schasinglulu 661*91f16700Schasinglulu - Bits[1:0] : Data access permission 662*91f16700Schasinglulu 663*91f16700Schasinglulu - b'00 : No access 664*91f16700Schasinglulu - b'01 : Read-Write access 665*91f16700Schasinglulu - b'10 : Reserved 666*91f16700Schasinglulu - b'11 : Read-only access 667*91f16700Schasinglulu 668*91f16700Schasinglulu - Bit[2]: Instruction access permission 669*91f16700Schasinglulu 670*91f16700Schasinglulu - b'0 : Executable 671*91f16700Schasinglulu - b'1 : Non-executable 672*91f16700Schasinglulu 673*91f16700Schasinglulu - Bit[30:3] : Reserved. SBZ. 674*91f16700Schasinglulu 675*91f16700Schasinglulu - Bit[31] : Must be 0 676*91f16700Schasinglulu 677*91f16700Schasinglulu On failure the following error codes are returned: 678*91f16700Schasinglulu 679*91f16700Schasinglulu - ``INVALID_PARAMETERS``: The Secure Partition is not allowed to access the 680*91f16700Schasinglulu memory region the Base Address lies in. 681*91f16700Schasinglulu 682*91f16700Schasinglulu - ``NOT_SUPPORTED`` : The SPM does not support retrieval of attributes of 683*91f16700Schasinglulu any memory page that is accessible by the Secure Partition, or the 684*91f16700Schasinglulu function was called from the Non-secure world. Also returned if it is 685*91f16700Schasinglulu used after ``MM_SP_EVENT_COMPLETE_AARCH64``. 686*91f16700Schasinglulu 687*91f16700Schasinglulu See `Error Codes`_ for integer values that are associated with each return 688*91f16700Schasinglulu code. 689*91f16700Schasinglulu 690*91f16700Schasinglulu- Usage 691*91f16700Schasinglulu 692*91f16700Schasinglulu This function is used to request the permission attributes for S-EL0 on a 693*91f16700Schasinglulu memory region accessible from a Secure Partition. The size of the memory 694*91f16700Schasinglulu region is equal to the Translation Granule size used in the Secure EL1&0 695*91f16700Schasinglulu translation regime. Requests to retrieve other memory region attributes are 696*91f16700Schasinglulu not currently supported. 697*91f16700Schasinglulu 698*91f16700Schasinglulu- Caller responsibilities 699*91f16700Schasinglulu 700*91f16700Schasinglulu The caller must obtain the Translation Granule Size of the Secure EL1&0 701*91f16700Schasinglulu translation regime from the SPM through an implementation defined method. 702*91f16700Schasinglulu 703*91f16700Schasinglulu- Callee responsibilities 704*91f16700Schasinglulu 705*91f16700Schasinglulu The SPM must not return the memory access controls for a page of memory that 706*91f16700Schasinglulu is not accessible from a Secure Partition. 707*91f16700Schasinglulu 708*91f16700Schasinglulu``MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64`` 709*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 710*91f16700Schasinglulu 711*91f16700Schasinglulu- Description 712*91f16700Schasinglulu 713*91f16700Schasinglulu Set the permission attributes of a memory region from S-EL0. 714*91f16700Schasinglulu 715*91f16700Schasinglulu- Parameters 716*91f16700Schasinglulu 717*91f16700Schasinglulu - **uint32** - Function ID 718*91f16700Schasinglulu 719*91f16700Schasinglulu - SVC64 Version: **0xC4000065** 720*91f16700Schasinglulu 721*91f16700Schasinglulu - **uint64** - Base Address 722*91f16700Schasinglulu 723*91f16700Schasinglulu This parameter is a 64-bit Virtual Address (VA). 724*91f16700Schasinglulu 725*91f16700Schasinglulu The alignment of the Base Address must be greater than or equal to the size 726*91f16700Schasinglulu of the Translation Granule Size used in the Secure EL1&0 translation 727*91f16700Schasinglulu regime. 728*91f16700Schasinglulu 729*91f16700Schasinglulu - **uint32** - Page count 730*91f16700Schasinglulu 731*91f16700Schasinglulu Number of pages starting from the Base Address whose memory attributes 732*91f16700Schasinglulu should be changed. The page size is equal to the Translation Granule Size. 733*91f16700Schasinglulu 734*91f16700Schasinglulu - **uint32** - Memory Access Controls 735*91f16700Schasinglulu 736*91f16700Schasinglulu - Bits[1:0] : Data access permission 737*91f16700Schasinglulu 738*91f16700Schasinglulu - b'00 : No access 739*91f16700Schasinglulu - b'01 : Read-Write access 740*91f16700Schasinglulu - b'10 : Reserved 741*91f16700Schasinglulu - b'11 : Read-only access 742*91f16700Schasinglulu 743*91f16700Schasinglulu - Bit[2] : Instruction access permission 744*91f16700Schasinglulu 745*91f16700Schasinglulu - b'0 : Executable 746*91f16700Schasinglulu - b'1 : Non-executable 747*91f16700Schasinglulu 748*91f16700Schasinglulu - Bits[31:3] : Reserved. SBZ. 749*91f16700Schasinglulu 750*91f16700Schasinglulu A combination of attributes that mark the region with RW and Executable 751*91f16700Schasinglulu permissions is prohibited. A request to mark a device memory region with 752*91f16700Schasinglulu Executable permissions is prohibited. 753*91f16700Schasinglulu 754*91f16700Schasinglulu- Return parameters 755*91f16700Schasinglulu 756*91f16700Schasinglulu - **int32** - Return Code 757*91f16700Schasinglulu 758*91f16700Schasinglulu - ``SUCCESS``: The Memory Access Controls were changed successfully. 759*91f16700Schasinglulu 760*91f16700Schasinglulu - ``DENIED``: The SPM is servicing a request to change the attributes of a 761*91f16700Schasinglulu memory region that overlaps with the region specified in this request. 762*91f16700Schasinglulu 763*91f16700Schasinglulu - ``INVALID_PARAMETER``: An invalid combination of Memory Access Controls 764*91f16700Schasinglulu has been specified. The Base Address is not correctly aligned. The Secure 765*91f16700Schasinglulu Partition is not allowed to access part or all of the memory region 766*91f16700Schasinglulu specified in the call. 767*91f16700Schasinglulu 768*91f16700Schasinglulu - ``NO_MEMORY``: The SPM does not have memory resources to change the 769*91f16700Schasinglulu attributes of the memory region in the translation tables. 770*91f16700Schasinglulu 771*91f16700Schasinglulu - ``NOT_SUPPORTED``: The SPM does not permit change of attributes of any 772*91f16700Schasinglulu memory region that is accessible by the Secure Partition. Function was 773*91f16700Schasinglulu called from the Non-secure world. Also returned if it is used after 774*91f16700Schasinglulu ``MM_SP_EVENT_COMPLETE_AARCH64``. 775*91f16700Schasinglulu 776*91f16700Schasinglulu See `Error Codes`_ for integer values that are associated with each return 777*91f16700Schasinglulu code. 778*91f16700Schasinglulu 779*91f16700Schasinglulu- Usage 780*91f16700Schasinglulu 781*91f16700Schasinglulu This function is used to change the permission attributes for S-EL0 on a 782*91f16700Schasinglulu memory region accessible from a Secure Partition. The size of the memory 783*91f16700Schasinglulu region is equal to the Translation Granule size used in the Secure EL1&0 784*91f16700Schasinglulu translation regime. Requests to change other memory region attributes are not 785*91f16700Schasinglulu currently supported. 786*91f16700Schasinglulu 787*91f16700Schasinglulu This function is only available at boot time. This interface is revoked after 788*91f16700Schasinglulu the Secure Partition sends the first ``MM_SP_EVENT_COMPLETE_AARCH64`` to 789*91f16700Schasinglulu signal that it is initialised and ready to receive run-time requests. 790*91f16700Schasinglulu 791*91f16700Schasinglulu- Caller responsibilities 792*91f16700Schasinglulu 793*91f16700Schasinglulu The caller must obtain the Translation Granule Size of the Secure EL1&0 794*91f16700Schasinglulu translation regime from the SPM through an implementation defined method. 795*91f16700Schasinglulu 796*91f16700Schasinglulu- Callee responsibilities 797*91f16700Schasinglulu 798*91f16700Schasinglulu The SPM must preserve the original memory access controls of the region of 799*91f16700Schasinglulu memory in case of an unsuccessful call. The SPM must preserve the consistency 800*91f16700Schasinglulu of the S-EL1 translation regime if this function is called on different PEs 801*91f16700Schasinglulu concurrently and the memory regions specified overlap. 802*91f16700Schasinglulu 803*91f16700SchasingluluError Codes 804*91f16700Schasinglulu----------- 805*91f16700Schasinglulu 806*91f16700Schasinglulu.. csv-table:: 807*91f16700Schasinglulu :header: "Name", "Value" 808*91f16700Schasinglulu 809*91f16700Schasinglulu ``SUCCESS``,0 810*91f16700Schasinglulu ``NOT_SUPPORTED``,-1 811*91f16700Schasinglulu ``INVALID_PARAMETER``,-2 812*91f16700Schasinglulu ``DENIED``,-3 813*91f16700Schasinglulu ``NO_MEMORY``,-5 814*91f16700Schasinglulu ``NOT_PRESENT``,-7 815*91f16700Schasinglulu 816*91f16700Schasinglulu-------------- 817*91f16700Schasinglulu 818*91f16700Schasinglulu*Copyright (c) 2017-2021, Arm Limited and Contributors. All rights reserved.* 819*91f16700Schasinglulu 820*91f16700Schasinglulu.. _Armv8-A ARM: https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile 821*91f16700Schasinglulu.. _instructions in the EDK2 repository: https://github.com/tianocore/edk2-staging/blob/AArch64StandaloneMm/HowtoBuild.MD 822*91f16700Schasinglulu.. _Management Mode Interface Specification: http://infocenter.arm.com/help/topic/com.arm.doc.den0060a/DEN0060A_ARM_MM_Interface_Specification.pdf 823*91f16700Schasinglulu.. _SDEI Specification: http://infocenter.arm.com/help/topic/com.arm.doc.den0054a/ARM_DEN0054A_Software_Delegated_Exception_Interface.pdf 824*91f16700Schasinglulu.. _SMC Calling Convention: https://developer.arm.com/docs/den0028/latest 825*91f16700Schasinglulu 826*91f16700Schasinglulu.. |Image 1| image:: ../resources/diagrams/secure_sw_stack_tos.png 827*91f16700Schasinglulu.. |Image 2| image:: ../resources/diagrams/secure_sw_stack_sp.png 828