Mark Horvath | 008ecb7 | 2020-09-10 12:35:05 +0200 | [diff] [blame] | 1 | ############################################## |
| 2 | Secure Enclave solution for Trusted Firmware-M |
| 3 | ############################################## |
| 4 | |
| 5 | :Author: Mark Horvath |
| 6 | :Organization: Arm Limited |
| 7 | :Contact: Mark Horvath <mark.horvath@arm.com> |
| 8 | :Status: Draft |
| 9 | |
| 10 | ******** |
| 11 | Abstract |
| 12 | ******** |
| 13 | |
| 14 | This document summarizes the design goals and one possible implementation |
| 15 | of the TF-M Secure Enclave solution. |
| 16 | |
| 17 | ************ |
| 18 | Introduction |
| 19 | ************ |
| 20 | |
| 21 | If a separate subsystem can provide the PSA Root of Trust (RoT) in a system |
| 22 | then an additional physical separation exists between the most trusted and |
| 23 | other domains. In such a system at least two subsystems are present, a Secure |
| 24 | Enclave (SE) whose only task is to provide PSA RoT and an application core |
| 25 | where any other application specific functionality can be placed. The latter |
| 26 | core (or cores) are referred as *Host* in this document. |
| 27 | |
| 28 | The current design assumes that Host is a v8-m core with security extension. |
| 29 | |
| 30 | ************ |
| 31 | Requirements |
| 32 | ************ |
| 33 | |
| 34 | - Secure Enclave shall implement secure boot-flow (start-up first at reset and |
| 35 | validate its own and the Host image or images before release Host from reset) |
| 36 | - Secure Enclave shall provide the PSA RoT services |
| 37 | - Host shall provide not just the non-secure context but the Application RoT as |
| 38 | well |
| 39 | - It shall be transparent to the (secure or non-secure) applications running on |
| 40 | host whether the RoT services are provided by the same subsystem or by a |
| 41 | Secure Enclave. |
| 42 | |
| 43 | .. Note:: |
| 44 | |
| 45 | In comparison, in a Dual Core system the whole secure context is placed on a |
| 46 | separate subsystem, while a Secure Enclave only implements the PSA RoT |
| 47 | security domain. |
| 48 | |
| 49 | *************** |
| 50 | Proposed design |
| 51 | *************** |
| 52 | |
| 53 | As the clients and the services are running on different cores only the IPC |
| 54 | model can be used on both Secure Enclave and Host. |
| 55 | |
| 56 | Secure Enclave |
| 57 | ============== |
| 58 | |
| 59 | To provide the required functionality it is enough to run the current PSA RoT |
| 60 | secure partitions on the Secure Enclave, so no need for non-secure context |
| 61 | there. (It is enough if the Secure Enclave's architecture is v6-m, v7-m or v8-m |
| 62 | without the security extension.) |
| 63 | |
| 64 | Secure Enclave can treat all clients running on Host as non-secure (even the |
| 65 | services running on Host's secure side). This means that fom Secure Enclave's |
| 66 | point of view all Host images, Host's RAM and shared memory between Host and |
| 67 | Secure Enclave if present are treated as non-secure. (Just like in the Dual CPU |
| 68 | solution.) But the clients need to be distinguished, otherwise some |
| 69 | functionalities are not working, for example: |
| 70 | - Protected Storage partition shall run on Host, but the PS area is handled by |
| 71 | Internal Trusted Storage partition (running on Secure Enclave). ITS partition |
| 72 | decides whether it should work on PS or ITS assets by checking the client ID. |
| 73 | - If a secure partition on host creates a crypto key, no other client shall be |
| 74 | able to destroy it. |
| 75 | |
| 76 | Communication |
| 77 | ============= |
| 78 | |
| 79 | To communicate between Host and Secure Enclave, the existing mailbox solution |
| 80 | can be reused as it is. |
| 81 | |
| 82 | Host |
| 83 | ==== |
| 84 | |
| 85 | On Host the current TF-M software architecture can be placed to provide |
| 86 | non-secure context and Application RoT domain. |
| 87 | |
| 88 | One solution to forward a PSA RoT IPC message from a client running on Host to |
| 89 | the Secure Enclave is to add a proxy partition to the secure side. This PSA |
| 90 | Proxy partition can provide all the RoT services to the system by forwarding |
| 91 | the messages over the mailbox solution. |
| 92 | |
| 93 | If the new partition's manifest contains all the PSA RoT service IDs SPM will |
| 94 | deliver all IPC messages there. Then the messages just must be blindly copied |
| 95 | into the mailbox. PSA proxy can use the non-secure interface of the mailbox, |
| 96 | but it is placed on the secure side of Host. (From SE's point of view this is |
| 97 | in fact the non-secure side of the mailbox as whole Host is treated as |
| 98 | non-secure.) |
| 99 | |
| 100 | It is important to verify IOVECs before forwarding them to SE, otherwise a |
| 101 | malicous actor could use SE to access a memory area otherwise unaccessable. If |
| 102 | PSA proxy uses the current secure partition interface then this is ensured by |
| 103 | Host's SPM. |
| 104 | |
| 105 | SE treats all clients of Host as non-secure, so all PSA messages shall have a |
| 106 | negative client ID when pushed into SE's SPM. This is given for the clients on |
| 107 | the non-secure side of Host, but the secure side clients of Host have positive |
| 108 | client IDs. The straightforward solution is to translate the positive client |
| 109 | IDs into a predefined negative range in PSA proxy, and push the translated |
| 110 | values into the mailbox. Of course this range shall be reserved for this use |
| 111 | only and no clients on non-secure side of Host shall have client ID from this |
| 112 | range. |
| 113 | |
| 114 | To avoid blocking Host when a message is sent PSA Proxy shall handle the |
| 115 | service requests in non-blocking mode. And to maximize bandwidth PSA Proxy |
| 116 | shall be able to push new messages into the mailbox, while others still not |
| 117 | answered. To achieve these the mailbox interrupts needs to be handled in the |
| 118 | PSA Proxy partition. |
| 119 | |
| 120 | -------------- |
| 121 | |
| 122 | *Copyright (c) 2020, Arm Limited. All rights reserved.* |