xref: /arm-trusted-firmware/docs/components/firmware-update.rst (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700SchasingluluFirmware Update (FWU)
2*91f16700Schasinglulu=====================
3*91f16700Schasinglulu
4*91f16700SchasingluluThis document describes the design of the various Firmware Update (FWU)
5*91f16700Schasinglulumechanisms available in TF-A.
6*91f16700Schasinglulu
7*91f16700Schasinglulu1. PSA Firmware Update (PSA FWU)
8*91f16700Schasinglulu2. TBBR Firmware Update (TBBR FWU)
9*91f16700Schasinglulu
10*91f16700SchasingluluPSA Firmware Update implements the specification of the same name (Arm document
11*91f16700SchasingluluIHI 0093), which defines a standard firmware interface for installing firmware
12*91f16700Schasingluluupdates.
13*91f16700SchasingluluOn the other hand, TBBR Firmware Update only covers firmware recovery. Arguably,
14*91f16700Schasingluluits name is somewhat misleading but the TBBR specification and terminology
15*91f16700Schasinglulupredates PSA FWU. Both mechanisms are complementary in the sense that PSA FWU
16*91f16700Schasingluluassumes that the device has a backup or recovery capability in the event of a
17*91f16700Schasinglulufailed update, which can be fulfilled with TBBR FWU implementation.
18*91f16700Schasinglulu
19*91f16700Schasinglulu.. _PSA Firmware Update:
20*91f16700Schasinglulu
21*91f16700SchasingluluPSA Firmware Update (PSA FWU)
22*91f16700Schasinglulu-----------------------------
23*91f16700Schasinglulu
24*91f16700SchasingluluIntroduction
25*91f16700Schasinglulu~~~~~~~~~~~~
26*91f16700SchasingluluThe `PSA FW update specification`_ defines the concepts of ``Firmware Update
27*91f16700SchasingluluClient`` and ``Firmware Update Agent``.
28*91f16700SchasingluluThe new firmware images are provided by the ``Client`` to the ``Update Agent``
29*91f16700Schasingluluto flash them in non-volatile storage.
30*91f16700Schasinglulu
31*91f16700SchasingluluA common system design will place the ``Update Agent`` in the Secure-world
32*91f16700Schasingluluwhile the ``Client`` executes in the Normal-world.
33*91f16700SchasingluluThe `PSA FW update specification`_ provides ABIs meant for a Normal-world
34*91f16700Schasingluluentity aka ``Client`` to transmit the firmware images to the ``Update Agent``.
35*91f16700Schasinglulu
36*91f16700SchasingluluScope
37*91f16700Schasinglulu~~~~~
38*91f16700SchasingluluThe design of the ``Client`` and ``Update Agent`` is out of scope of this
39*91f16700Schasingluludocument.
40*91f16700SchasingluluThis document mainly covers ``Platform Boot`` details i.e. the role of
41*91f16700Schasingluluthe second stage Bootloader after FWU has been done by ``Client`` and
42*91f16700Schasinglulu``Update Agent``.
43*91f16700Schasinglulu
44*91f16700SchasingluluOverview
45*91f16700Schasinglulu~~~~~~~~
46*91f16700Schasinglulu
47*91f16700SchasingluluThere are active and update banks in the non-volatile storage identified
48*91f16700Schasingluluby the ``active_index`` and the ``update_index`` respectively.
49*91f16700SchasingluluAn active bank stores running firmware, whereas an update bank contains
50*91f16700Schasinglulufirmware updates.
51*91f16700Schasinglulu
52*91f16700SchasingluluOnce Firmwares are updated in the update bank of the non-volatile
53*91f16700Schasinglulustorage, then ``Update Agent`` marks the update bank as the active bank,
54*91f16700Schasingluluand write updated FWU metadata in non-volatile storage.
55*91f16700SchasingluluOn subsequent reboot, the second stage Bootloader (BL2) performs the
56*91f16700Schasinglulufollowing actions:
57*91f16700Schasinglulu
58*91f16700Schasinglulu-  Read FWU metadata in memory
59*91f16700Schasinglulu-  Retrieve the image specification (offset and length) of updated images
60*91f16700Schasinglulu   present in non-volatile storage with the help of FWU metadata
61*91f16700Schasinglulu-  Set these image specification in the corresponding I/O policies of the
62*91f16700Schasinglulu   updated images using the FWU platform functions
63*91f16700Schasinglulu   ``plat_fwu_set_images_source()`` and ``plat_fwu_set_metadata_image_source()``,
64*91f16700Schasinglulu   please refer :ref:`Porting Guide`
65*91f16700Schasinglulu-  Use these I/O policies to read the images from this address into the memory
66*91f16700Schasinglulu
67*91f16700SchasingluluBy default, the platform uses the active bank of non-volatile storage to boot
68*91f16700Schasingluluthe images in ``trial state``. If images pass through the authentication check
69*91f16700Schasingluluand also if the system successfully booted the Normal-world image then
70*91f16700Schasinglulu``Update Agent`` marks this update as accepted after further sanitisation
71*91f16700Schasingluluchecking at Normal-world.
72*91f16700Schasinglulu
73*91f16700SchasingluluThe second stage Bootloader (BL2) avoids upgrading the platform NV-counter until
74*91f16700Schasingluluit's been confirmed that given update is accepted.
75*91f16700Schasinglulu
76*91f16700SchasingluluThe following sequence diagram shows platform-boot flow:
77*91f16700Schasinglulu
78*91f16700Schasinglulu.. image:: ../resources/diagrams/PSA-FWU.png
79*91f16700Schasinglulu
80*91f16700SchasingluluIf the platform fails to boot from active bank due to any reasons such
81*91f16700Schasingluluas authentication failure or non-fuctionality of Normal-world software then the
82*91f16700Schasingluluwatchdog will reset to give a chance to the platform to fix the issue. This
83*91f16700Schasingluluboot failure & reset sequence might be repeated up to ``trial state`` times.
84*91f16700SchasingluluAfter that, the platform can decide to boot from the ``previous_active_index``
85*91f16700Schasinglulubank.
86*91f16700Schasinglulu
87*91f16700SchasingluluIf the images still does not boot successfully from the ``previous_active_index``
88*91f16700Schasinglulubank (e.g. due to ageing effect of non-volatile storage) then the platform can
89*91f16700Schasingluluchoose firmware recovery mechanism :ref:`TBBR Firmware Update` to bring system
90*91f16700Schasingluluback to life.
91*91f16700Schasinglulu
92*91f16700Schasinglulu.. _TBBR Firmware Update:
93*91f16700Schasinglulu
94*91f16700SchasingluluTBBR Firmware Update (TBBR FWU)
95*91f16700Schasinglulu-------------------------------
96*91f16700Schasinglulu
97*91f16700SchasingluluIntroduction
98*91f16700Schasinglulu~~~~~~~~~~~~
99*91f16700Schasinglulu
100*91f16700SchasingluluThis technique enables authenticated firmware to update firmware images from
101*91f16700Schasingluluexternal interfaces such as USB, UART, SD-eMMC, NAND, NOR or Ethernet to SoC
102*91f16700SchasingluluNon-Volatile memories such as NAND Flash, LPDDR2-NVM or any memory determined
103*91f16700Schasingluluby the platform.
104*91f16700SchasingluluThis feature functions even when the current firmware in the system is corrupt
105*91f16700Schasingluluor missing; it therefore may be used as a recovery mode. It may also be
106*91f16700Schasinglulucomplemented by other, higher level firmware update software.
107*91f16700Schasinglulu
108*91f16700SchasingluluFWU implements a specific part of the Trusted Board Boot Requirements (TBBR)
109*91f16700Schasingluluspecification, Arm DEN0006C-1. It should be used in conjunction with the
110*91f16700Schasinglulu:ref:`Trusted Board Boot` design document, which describes the image
111*91f16700Schasingluluauthentication parts of the Trusted Firmware-A (TF-A) TBBR implementation.
112*91f16700Schasinglulu
113*91f16700SchasingluluIt can be used as a last resort when all firmware updates that are carried out
114*91f16700Schasingluluas part of the :ref:`PSA Firmware Update` procedure have failed to function.
115*91f16700Schasinglulu
116*91f16700SchasingluluScope
117*91f16700Schasinglulu~~~~~
118*91f16700Schasinglulu
119*91f16700SchasingluluThis document describes the secure world FWU design. It is beyond its scope to
120*91f16700Schasingluludescribe how normal world FWU images should operate. To implement normal world
121*91f16700SchasingluluFWU images, please refer to the "Non-Trusted Firmware Updater" requirements in
122*91f16700Schasingluluthe TBBR.
123*91f16700Schasinglulu
124*91f16700SchasingluluOverview
125*91f16700Schasinglulu~~~~~~~~
126*91f16700Schasinglulu
127*91f16700SchasingluluThe FWU boot flow is primarily mediated by BL1. Since BL1 executes in ROM, and
128*91f16700Schasingluluit is usually desirable to minimize the amount of ROM code, the design allows
129*91f16700Schasinglulusome parts of FWU to be implemented in other secure and normal world images.
130*91f16700SchasingluluPlatform code may choose which parts are implemented in which images but the
131*91f16700Schasinglulugeneral expectation is:
132*91f16700Schasinglulu
133*91f16700Schasinglulu-  BL1 handles:
134*91f16700Schasinglulu
135*91f16700Schasinglulu   -  Detection and initiation of the FWU boot flow.
136*91f16700Schasinglulu   -  Copying images from non-secure to secure memory
137*91f16700Schasinglulu   -  FWU image authentication
138*91f16700Schasinglulu   -  Context switching between the normal and secure world during the FWU
139*91f16700Schasinglulu      process.
140*91f16700Schasinglulu
141*91f16700Schasinglulu-  Other secure world FWU images handle platform initialization required by
142*91f16700Schasinglulu   the FWU process.
143*91f16700Schasinglulu-  Normal world FWU images handle loading of firmware images from external
144*91f16700Schasinglulu   interfaces to non-secure memory.
145*91f16700Schasinglulu
146*91f16700SchasingluluThe primary requirements of the FWU feature are:
147*91f16700Schasinglulu
148*91f16700Schasinglulu#. Export a BL1 SMC interface to interoperate with other FWU images executing
149*91f16700Schasinglulu   at other Exception Levels.
150*91f16700Schasinglulu#. Export a platform interface to provide FWU common code with the information
151*91f16700Schasinglulu   it needs, and to enable platform specific FWU functionality. See the
152*91f16700Schasinglulu   :ref:`Porting Guide` for details of this interface.
153*91f16700Schasinglulu
154*91f16700SchasingluluTF-A uses abbreviated image terminology for FWU images like for other TF-A
155*91f16700Schasingluluimages. See the :ref:`Image Terminology` document for an explanation of these
156*91f16700Schasingluluterms.
157*91f16700Schasinglulu
158*91f16700SchasingluluThe following diagram shows the FWU boot flow for Arm development platforms.
159*91f16700SchasingluluArm CSS platforms like Juno have a System Control Processor (SCP), and these
160*91f16700Schasingluluuse all defined FWU images. Other platforms may use a subset of these.
161*91f16700Schasinglulu
162*91f16700Schasinglulu|Flow Diagram|
163*91f16700Schasinglulu
164*91f16700SchasingluluImage Identification
165*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~
166*91f16700Schasinglulu
167*91f16700SchasingluluEach FWU image and certificate is identified by a unique ID, defined by the
168*91f16700Schasingluluplatform, which BL1 uses to fetch an image descriptor (``image_desc_t``) via a
169*91f16700Schasinglulucall to ``bl1_plat_get_image_desc()``. The same ID is also used to prepare the
170*91f16700SchasingluluChain of Trust (Refer to the :ref:`Authentication Framework & Chain of Trust`
171*91f16700Schasingluludocument for more information).
172*91f16700Schasinglulu
173*91f16700SchasingluluThe image descriptor includes the following information:
174*91f16700Schasinglulu
175*91f16700Schasinglulu-  Executable or non-executable image. This indicates whether the normal world
176*91f16700Schasinglulu   is permitted to request execution of a secure world FWU image (after
177*91f16700Schasinglulu   authentication). Secure world certificates and non-AP images are examples
178*91f16700Schasinglulu   of non-executable images.
179*91f16700Schasinglulu-  Secure or non-secure image. This indicates whether the image is
180*91f16700Schasinglulu   authenticated/executed in secure or non-secure memory.
181*91f16700Schasinglulu-  Image base address and size.
182*91f16700Schasinglulu-  Image entry point configuration (an ``entry_point_info_t``).
183*91f16700Schasinglulu-  FWU image state.
184*91f16700Schasinglulu
185*91f16700SchasingluluBL1 uses the FWU image descriptors to:
186*91f16700Schasinglulu
187*91f16700Schasinglulu-  Validate the arguments of FWU SMCs
188*91f16700Schasinglulu-  Manage the state of the FWU process
189*91f16700Schasinglulu-  Initialize the execution state of the next FWU image.
190*91f16700Schasinglulu
191*91f16700SchasingluluFWU State Machine
192*91f16700Schasinglulu~~~~~~~~~~~~~~~~~
193*91f16700Schasinglulu
194*91f16700SchasingluluBL1 maintains state for each FWU image during FWU execution. FWU images at lower
195*91f16700SchasingluluException Levels raise SMCs to invoke FWU functionality in BL1, which causes
196*91f16700SchasingluluBL1 to update its FWU image state. The BL1 image states and valid state
197*91f16700Schasinglulutransitions are shown in the diagram below. Note that secure images have a more
198*91f16700Schasinglulucomplex state machine than non-secure images.
199*91f16700Schasinglulu
200*91f16700Schasinglulu|FWU state machine|
201*91f16700Schasinglulu
202*91f16700SchasingluluThe following is a brief description of the supported states:
203*91f16700Schasinglulu
204*91f16700Schasinglulu-  RESET: This is the initial state of every image at the start of FWU.
205*91f16700Schasinglulu   Authentication failure also leads to this state. A secure
206*91f16700Schasinglulu   image may yield to this state if it has completed execution.
207*91f16700Schasinglulu   It can also be reached by using ``FWU_SMC_IMAGE_RESET``.
208*91f16700Schasinglulu
209*91f16700Schasinglulu-  COPYING: This is the state of a secure image while BL1 is copying it
210*91f16700Schasinglulu   in blocks from non-secure to secure memory.
211*91f16700Schasinglulu
212*91f16700Schasinglulu-  COPIED: This is the state of a secure image when BL1 has completed
213*91f16700Schasinglulu   copying it to secure memory.
214*91f16700Schasinglulu
215*91f16700Schasinglulu-  AUTHENTICATED: This is the state of an image when BL1 has successfully
216*91f16700Schasinglulu   authenticated it.
217*91f16700Schasinglulu
218*91f16700Schasinglulu-  EXECUTED: This is the state of a secure, executable image when BL1 has
219*91f16700Schasinglulu   passed execution control to it.
220*91f16700Schasinglulu
221*91f16700Schasinglulu-  INTERRUPTED: This is the state of a secure, executable image after it has
222*91f16700Schasinglulu   requested BL1 to resume normal world execution.
223*91f16700Schasinglulu
224*91f16700SchasingluluBL1 SMC Interface
225*91f16700Schasinglulu~~~~~~~~~~~~~~~~~
226*91f16700Schasinglulu
227*91f16700SchasingluluBL1_SMC_CALL_COUNT
228*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^
229*91f16700Schasinglulu
230*91f16700Schasinglulu::
231*91f16700Schasinglulu
232*91f16700Schasinglulu    Arguments:
233*91f16700Schasinglulu        uint32_t function ID : 0x0
234*91f16700Schasinglulu
235*91f16700Schasinglulu    Return:
236*91f16700Schasinglulu        uint32_t
237*91f16700Schasinglulu
238*91f16700SchasingluluThis SMC returns the number of SMCs supported by BL1.
239*91f16700Schasinglulu
240*91f16700SchasingluluBL1_SMC_UID
241*91f16700Schasinglulu^^^^^^^^^^^
242*91f16700Schasinglulu
243*91f16700Schasinglulu::
244*91f16700Schasinglulu
245*91f16700Schasinglulu    Arguments:
246*91f16700Schasinglulu        uint32_t function ID : 0x1
247*91f16700Schasinglulu
248*91f16700Schasinglulu    Return:
249*91f16700Schasinglulu        UUID : 32 bits in each of w0-w3 (or r0-r3 for AArch32 callers)
250*91f16700Schasinglulu
251*91f16700SchasingluluThis SMC returns the 128-bit `Universally Unique Identifier`_ for the
252*91f16700SchasingluluBL1 SMC service.
253*91f16700Schasinglulu
254*91f16700SchasingluluBL1_SMC_VERSION
255*91f16700Schasinglulu^^^^^^^^^^^^^^^
256*91f16700Schasinglulu
257*91f16700Schasinglulu::
258*91f16700Schasinglulu
259*91f16700Schasinglulu    Argument:
260*91f16700Schasinglulu        uint32_t function ID : 0x3
261*91f16700Schasinglulu
262*91f16700Schasinglulu    Return:
263*91f16700Schasinglulu        uint32_t : Bits [31:16] Major Version
264*91f16700Schasinglulu                   Bits [15:0] Minor Version
265*91f16700Schasinglulu
266*91f16700SchasingluluThis SMC returns the current version of the BL1 SMC service.
267*91f16700Schasinglulu
268*91f16700SchasingluluBL1_SMC_RUN_IMAGE
269*91f16700Schasinglulu^^^^^^^^^^^^^^^^^
270*91f16700Schasinglulu
271*91f16700Schasinglulu::
272*91f16700Schasinglulu
273*91f16700Schasinglulu    Arguments:
274*91f16700Schasinglulu        uint32_t           function ID : 0x4
275*91f16700Schasinglulu        entry_point_info_t *ep_info
276*91f16700Schasinglulu
277*91f16700Schasinglulu    Return:
278*91f16700Schasinglulu        void
279*91f16700Schasinglulu
280*91f16700Schasinglulu    Pre-conditions:
281*91f16700Schasinglulu        if (normal world caller) synchronous exception
282*91f16700Schasinglulu        if (ep_info not EL3) synchronous exception
283*91f16700Schasinglulu
284*91f16700SchasingluluThis SMC passes execution control to an EL3 image described by the provided
285*91f16700Schasinglulu``entry_point_info_t`` structure. In the normal TF-A boot flow, BL2 invokes
286*91f16700Schasingluluthis SMC for BL1 to pass execution control to BL31.
287*91f16700Schasinglulu
288*91f16700SchasingluluFWU_SMC_IMAGE_COPY
289*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^
290*91f16700Schasinglulu
291*91f16700Schasinglulu::
292*91f16700Schasinglulu
293*91f16700Schasinglulu    Arguments:
294*91f16700Schasinglulu        uint32_t     function ID : 0x10
295*91f16700Schasinglulu        unsigned int image_id
296*91f16700Schasinglulu        uintptr_t    image_addr
297*91f16700Schasinglulu        unsigned int block_size
298*91f16700Schasinglulu        unsigned int image_size
299*91f16700Schasinglulu
300*91f16700Schasinglulu    Return:
301*91f16700Schasinglulu        int : 0 (Success)
302*91f16700Schasinglulu            : -ENOMEM
303*91f16700Schasinglulu            : -EPERM
304*91f16700Schasinglulu
305*91f16700Schasinglulu    Pre-conditions:
306*91f16700Schasinglulu        if (image_id is invalid) return -EPERM
307*91f16700Schasinglulu        if (image_id is non-secure image) return -EPERM
308*91f16700Schasinglulu        if (image_id state is not (RESET or COPYING)) return -EPERM
309*91f16700Schasinglulu        if (secure world caller) return -EPERM
310*91f16700Schasinglulu        if (image_addr + block_size overflows) return -ENOMEM
311*91f16700Schasinglulu        if (image destination address + image_size overflows) return -ENOMEM
312*91f16700Schasinglulu        if (source block is in secure memory) return -ENOMEM
313*91f16700Schasinglulu        if (source block is not mapped into BL1) return -ENOMEM
314*91f16700Schasinglulu        if (image_size > free secure memory) return -ENOMEM
315*91f16700Schasinglulu        if (image overlaps another image) return -EPERM
316*91f16700Schasinglulu
317*91f16700SchasingluluThis SMC copies the secure image indicated by ``image_id`` from non-secure memory
318*91f16700Schasingluluto secure memory for later authentication. The image may be copied in a single
319*91f16700Schasinglulublock or multiple blocks. In either case, the total size of the image must be
320*91f16700Schasingluluprovided in ``image_size`` when invoking this SMC for the first time for each
321*91f16700Schasingluluimage; it is ignored in subsequent calls (if any) for the same image.
322*91f16700Schasinglulu
323*91f16700SchasingluluThe ``image_addr`` and ``block_size`` specify the source memory block to copy from.
324*91f16700SchasingluluThe destination address is provided by the platform code.
325*91f16700Schasinglulu
326*91f16700SchasingluluIf ``block_size`` is greater than the amount of remaining bytes to copy for this
327*91f16700Schasingluluimage then the former is truncated to the latter. The copy operation is then
328*91f16700Schasingluluconsidered as complete and the FWU state machine transitions to the "COPIED"
329*91f16700Schasinglulustate. If there is still more to copy, the FWU state machine stays in or
330*91f16700Schasinglulutransitions to the COPYING state (depending on the previous state).
331*91f16700Schasinglulu
332*91f16700SchasingluluWhen using multiple blocks, the source blocks do not necessarily need to be in
333*91f16700Schasinglulucontiguous memory.
334*91f16700Schasinglulu
335*91f16700SchasingluluOnce the SMC is handled, BL1 returns from exception to the normal world caller.
336*91f16700Schasinglulu
337*91f16700SchasingluluFWU_SMC_IMAGE_AUTH
338*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^
339*91f16700Schasinglulu
340*91f16700Schasinglulu::
341*91f16700Schasinglulu
342*91f16700Schasinglulu    Arguments:
343*91f16700Schasinglulu        uint32_t     function ID : 0x11
344*91f16700Schasinglulu        unsigned int image_id
345*91f16700Schasinglulu        uintptr_t    image_addr
346*91f16700Schasinglulu        unsigned int image_size
347*91f16700Schasinglulu
348*91f16700Schasinglulu    Return:
349*91f16700Schasinglulu        int : 0 (Success)
350*91f16700Schasinglulu            : -ENOMEM
351*91f16700Schasinglulu            : -EPERM
352*91f16700Schasinglulu            : -EAUTH
353*91f16700Schasinglulu
354*91f16700Schasinglulu    Pre-conditions:
355*91f16700Schasinglulu        if (image_id is invalid) return -EPERM
356*91f16700Schasinglulu        if (secure world caller)
357*91f16700Schasinglulu            if (image_id state is not RESET) return -EPERM
358*91f16700Schasinglulu            if (image_addr/image_size is not mapped into BL1) return -ENOMEM
359*91f16700Schasinglulu        else // normal world caller
360*91f16700Schasinglulu            if (image_id is secure image)
361*91f16700Schasinglulu                if (image_id state is not COPIED) return -EPERM
362*91f16700Schasinglulu            else // image_id is non-secure image
363*91f16700Schasinglulu                if (image_id state is not RESET) return -EPERM
364*91f16700Schasinglulu                if (image_addr/image_size is in secure memory) return -ENOMEM
365*91f16700Schasinglulu                if (image_addr/image_size not mapped into BL1) return -ENOMEM
366*91f16700Schasinglulu
367*91f16700SchasingluluThis SMC authenticates the image specified by ``image_id``. If the image is in the
368*91f16700SchasingluluRESET state, BL1 authenticates the image in place using the provided
369*91f16700Schasinglulu``image_addr`` and ``image_size``. If the image is a secure image in the COPIED
370*91f16700Schasinglulustate, BL1 authenticates the image from the secure memory that BL1 previously
371*91f16700Schasinglulucopied the image into.
372*91f16700Schasinglulu
373*91f16700SchasingluluBL1 returns from exception to the caller. If authentication succeeds then BL1
374*91f16700Schasinglulusets the image state to AUTHENTICATED. If authentication fails then BL1 returns
375*91f16700Schasingluluthe -EAUTH error and sets the image state back to RESET.
376*91f16700Schasinglulu
377*91f16700SchasingluluFWU_SMC_IMAGE_EXECUTE
378*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^^
379*91f16700Schasinglulu
380*91f16700Schasinglulu::
381*91f16700Schasinglulu
382*91f16700Schasinglulu    Arguments:
383*91f16700Schasinglulu        uint32_t     function ID : 0x12
384*91f16700Schasinglulu        unsigned int image_id
385*91f16700Schasinglulu
386*91f16700Schasinglulu    Return:
387*91f16700Schasinglulu        int : 0 (Success)
388*91f16700Schasinglulu            : -EPERM
389*91f16700Schasinglulu
390*91f16700Schasinglulu    Pre-conditions:
391*91f16700Schasinglulu        if (image_id is invalid) return -EPERM
392*91f16700Schasinglulu        if (secure world caller) return -EPERM
393*91f16700Schasinglulu        if (image_id is non-secure image) return -EPERM
394*91f16700Schasinglulu        if (image_id is non-executable image) return -EPERM
395*91f16700Schasinglulu        if (image_id state is not AUTHENTICATED) return -EPERM
396*91f16700Schasinglulu
397*91f16700SchasingluluThis SMC initiates execution of a previously authenticated image specified by
398*91f16700Schasinglulu``image_id``, in the other security world to the caller. The current
399*91f16700Schasingluluimplementation only supports normal world callers initiating execution of a
400*91f16700Schasinglulusecure world image.
401*91f16700Schasinglulu
402*91f16700SchasingluluBL1 saves the normal world caller's context, sets the secure image state to
403*91f16700SchasingluluEXECUTED, and returns from exception to the secure image.
404*91f16700Schasinglulu
405*91f16700SchasingluluFWU_SMC_IMAGE_RESUME
406*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^
407*91f16700Schasinglulu
408*91f16700Schasinglulu::
409*91f16700Schasinglulu
410*91f16700Schasinglulu    Arguments:
411*91f16700Schasinglulu        uint32_t   function ID : 0x13
412*91f16700Schasinglulu        register_t image_param
413*91f16700Schasinglulu
414*91f16700Schasinglulu    Return:
415*91f16700Schasinglulu        register_t : image_param (Success)
416*91f16700Schasinglulu                   : -EPERM
417*91f16700Schasinglulu
418*91f16700Schasinglulu    Pre-conditions:
419*91f16700Schasinglulu        if (normal world caller and no INTERRUPTED secure image) return -EPERM
420*91f16700Schasinglulu
421*91f16700SchasingluluThis SMC resumes execution in the other security world while there is a secure
422*91f16700Schasingluluimage in the EXECUTED/INTERRUPTED state.
423*91f16700Schasinglulu
424*91f16700SchasingluluFor normal world callers, BL1 sets the previously interrupted secure image state
425*91f16700Schasingluluto EXECUTED. For secure world callers, BL1 sets the previously executing secure
426*91f16700Schasingluluimage state to INTERRUPTED. In either case, BL1 saves the calling world's
427*91f16700Schasinglulucontext, restores the resuming world's context and returns from exception into
428*91f16700Schasingluluthe resuming world. If the call is successful then the caller provided
429*91f16700Schasinglulu``image_param`` is returned to the resumed world, otherwise an error code is
430*91f16700Schasinglulureturned to the caller.
431*91f16700Schasinglulu
432*91f16700SchasingluluFWU_SMC_SEC_IMAGE_DONE
433*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^^^
434*91f16700Schasinglulu
435*91f16700Schasinglulu::
436*91f16700Schasinglulu
437*91f16700Schasinglulu    Arguments:
438*91f16700Schasinglulu        uint32_t function ID : 0x14
439*91f16700Schasinglulu
440*91f16700Schasinglulu    Return:
441*91f16700Schasinglulu        int : 0 (Success)
442*91f16700Schasinglulu            : -EPERM
443*91f16700Schasinglulu
444*91f16700Schasinglulu    Pre-conditions:
445*91f16700Schasinglulu        if (normal world caller) return -EPERM
446*91f16700Schasinglulu
447*91f16700SchasingluluThis SMC indicates completion of a previously executing secure image.
448*91f16700Schasinglulu
449*91f16700SchasingluluBL1 sets the previously executing secure image state to the RESET state,
450*91f16700Schasinglulurestores the normal world context and returns from exception into the normal
451*91f16700Schasingluluworld.
452*91f16700Schasinglulu
453*91f16700SchasingluluFWU_SMC_UPDATE_DONE
454*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^
455*91f16700Schasinglulu
456*91f16700Schasinglulu::
457*91f16700Schasinglulu
458*91f16700Schasinglulu    Arguments:
459*91f16700Schasinglulu        uint32_t   function ID : 0x15
460*91f16700Schasinglulu        register_t client_cookie
461*91f16700Schasinglulu
462*91f16700Schasinglulu    Return:
463*91f16700Schasinglulu        N/A
464*91f16700Schasinglulu
465*91f16700SchasingluluThis SMC completes the firmware update process. BL1 calls the platform specific
466*91f16700Schasinglulufunction ``bl1_plat_fwu_done``, passing the optional argument ``client_cookie`` as
467*91f16700Schasinglulua ``void *``. The SMC does not return.
468*91f16700Schasinglulu
469*91f16700SchasingluluFWU_SMC_IMAGE_RESET
470*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^
471*91f16700Schasinglulu
472*91f16700Schasinglulu::
473*91f16700Schasinglulu
474*91f16700Schasinglulu    Arguments:
475*91f16700Schasinglulu        uint32_t     function ID : 0x16
476*91f16700Schasinglulu        unsigned int image_id
477*91f16700Schasinglulu
478*91f16700Schasinglulu    Return:
479*91f16700Schasinglulu        int : 0 (Success)
480*91f16700Schasinglulu            : -EPERM
481*91f16700Schasinglulu
482*91f16700Schasinglulu    Pre-conditions:
483*91f16700Schasinglulu        if (secure world caller) return -EPERM
484*91f16700Schasinglulu        if (image in EXECUTED) return -EPERM
485*91f16700Schasinglulu
486*91f16700SchasingluluThis SMC sets the state of an image to RESET and zeroes the memory used by it.
487*91f16700Schasinglulu
488*91f16700SchasingluluThis is only allowed if the image is not being executed.
489*91f16700Schasinglulu
490*91f16700Schasinglulu--------------
491*91f16700Schasinglulu
492*91f16700Schasinglulu*Copyright (c) 2015-2022, Arm Limited and Contributors. All rights reserved.*
493*91f16700Schasinglulu
494*91f16700Schasinglulu.. _Universally Unique Identifier: https://tools.ietf.org/rfc/rfc4122.txt
495*91f16700Schasinglulu.. |Flow Diagram| image:: ../resources/diagrams/fwu_flow.png
496*91f16700Schasinglulu.. |FWU state machine| image:: ../resources/diagrams/fwu_states.png
497*91f16700Schasinglulu.. _PSA FW update specification: https://developer.arm.com/documentation/den0118/a/
498