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