Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 1 | /* |
Ambroise Vincent | b237bca | 2019-02-13 15:58:00 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 7 | #include <assert.h> |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 8 | #include <errno.h> |
Antonio Nino Diaz | b5b585a | 2018-11-08 14:20:07 +0000 | [diff] [blame] | 9 | #include <string.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | |
| 11 | #include <arch_helpers.h> |
| 12 | #include <bl31/bl31.h> |
| 13 | #include <bl31/ehf.h> |
| 14 | #include <bl31/interrupt_mgmt.h> |
| 15 | #include <common/debug.h> |
| 16 | #include <common/runtime_svc.h> |
| 17 | #include <lib/el3_runtime/context_mgmt.h> |
| 18 | #include <lib/smccc.h> |
| 19 | #include <lib/spinlock.h> |
| 20 | #include <lib/utils.h> |
| 21 | #include <lib/xlat_tables/xlat_tables_v2.h> |
| 22 | #include <plat/common/platform.h> |
Ambroise Vincent | b237bca | 2019-02-13 15:58:00 +0000 | [diff] [blame] | 23 | #include <services/spm_svc.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 24 | #include <services/sprt_svc.h> |
| 25 | #include <smccc_helpers.h> |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 26 | |
| 27 | #include "spm_private.h" |
Antonio Nino Diaz | 2ac9a44 | 2018-05-23 11:40:46 +0100 | [diff] [blame] | 28 | |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 29 | /******************************************************************************* |
| 30 | * Secure Partition context information. |
| 31 | ******************************************************************************/ |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 32 | sp_context_t sp_ctx_array[PLAT_SPM_MAX_PARTITIONS]; |
| 33 | |
| 34 | /* Last Secure Partition last used by the CPU */ |
| 35 | sp_context_t *cpu_sp_ctx[PLATFORM_CORE_COUNT]; |
| 36 | |
| 37 | void spm_cpu_set_sp_ctx(unsigned int linear_id, sp_context_t *sp_ctx) |
| 38 | { |
| 39 | assert(linear_id < PLATFORM_CORE_COUNT); |
| 40 | |
| 41 | cpu_sp_ctx[linear_id] = sp_ctx; |
| 42 | } |
| 43 | |
| 44 | sp_context_t *spm_cpu_get_sp_ctx(unsigned int linear_id) |
| 45 | { |
| 46 | assert(linear_id < PLATFORM_CORE_COUNT); |
| 47 | |
| 48 | return cpu_sp_ctx[linear_id]; |
| 49 | } |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 50 | |
| 51 | /******************************************************************************* |
Antonio Nino Diaz | 44ef4eb | 2018-07-03 19:54:59 +0100 | [diff] [blame] | 52 | * Functions to keep track of how many requests a Secure Partition has received |
| 53 | * and hasn't finished. |
| 54 | ******************************************************************************/ |
| 55 | void spm_sp_request_increase(sp_context_t *sp_ctx) |
| 56 | { |
| 57 | spin_lock(&(sp_ctx->request_count_lock)); |
| 58 | sp_ctx->request_count++; |
| 59 | spin_unlock(&(sp_ctx->request_count_lock)); |
| 60 | } |
| 61 | |
| 62 | void spm_sp_request_decrease(sp_context_t *sp_ctx) |
| 63 | { |
| 64 | spin_lock(&(sp_ctx->request_count_lock)); |
| 65 | sp_ctx->request_count--; |
| 66 | spin_unlock(&(sp_ctx->request_count_lock)); |
| 67 | } |
| 68 | |
| 69 | /* Returns 0 if it was originally 0, -1 otherwise. */ |
| 70 | int spm_sp_request_increase_if_zero(sp_context_t *sp_ctx) |
| 71 | { |
| 72 | int ret = -1; |
| 73 | |
| 74 | spin_lock(&(sp_ctx->request_count_lock)); |
| 75 | if (sp_ctx->request_count == 0U) { |
| 76 | sp_ctx->request_count++; |
| 77 | ret = 0U; |
| 78 | } |
| 79 | spin_unlock(&(sp_ctx->request_count_lock)); |
| 80 | |
| 81 | return ret; |
| 82 | } |
| 83 | |
| 84 | /******************************************************************************* |
Antonio Nino Diaz | b5b585a | 2018-11-08 14:20:07 +0000 | [diff] [blame] | 85 | * This function returns a pointer to the context of the Secure Partition that |
| 86 | * handles the service specified by an UUID. It returns NULL if the UUID wasn't |
| 87 | * found. |
| 88 | ******************************************************************************/ |
| 89 | sp_context_t *spm_sp_get_by_uuid(const uint32_t (*svc_uuid)[4]) |
| 90 | { |
| 91 | unsigned int i; |
| 92 | |
| 93 | for (i = 0U; i < PLAT_SPM_MAX_PARTITIONS; i++) { |
| 94 | |
| 95 | sp_context_t *sp_ctx = &sp_ctx_array[i]; |
| 96 | |
| 97 | if (sp_ctx->is_present == 0) { |
| 98 | continue; |
| 99 | } |
| 100 | |
| 101 | struct sp_rd_sect_service *rdsvc; |
| 102 | |
| 103 | for (rdsvc = sp_ctx->rd.service; rdsvc != NULL; |
| 104 | rdsvc = rdsvc->next) { |
| 105 | uint32_t *rd_uuid = (uint32_t *)(rdsvc->uuid); |
| 106 | |
Paul Beesley | b0c9ed1 | 2019-04-08 15:24:43 +0100 | [diff] [blame] | 107 | if (memcmp(rd_uuid, svc_uuid, sizeof(*svc_uuid)) == 0) { |
Antonio Nino Diaz | b5b585a | 2018-11-08 14:20:07 +0000 | [diff] [blame] | 108 | return sp_ctx; |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | return NULL; |
| 114 | } |
| 115 | |
| 116 | /******************************************************************************* |
Antonio Nino Diaz | c4f2752 | 2018-05-23 09:09:41 +0100 | [diff] [blame] | 117 | * Set state of a Secure Partition context. |
| 118 | ******************************************************************************/ |
| 119 | void sp_state_set(sp_context_t *sp_ptr, sp_state_t state) |
| 120 | { |
| 121 | spin_lock(&(sp_ptr->state_lock)); |
| 122 | sp_ptr->state = state; |
| 123 | spin_unlock(&(sp_ptr->state_lock)); |
| 124 | } |
| 125 | |
| 126 | /******************************************************************************* |
| 127 | * Wait until the state of a Secure Partition is the specified one and change it |
| 128 | * to the desired state. |
| 129 | ******************************************************************************/ |
| 130 | void sp_state_wait_switch(sp_context_t *sp_ptr, sp_state_t from, sp_state_t to) |
| 131 | { |
| 132 | int success = 0; |
| 133 | |
| 134 | while (success == 0) { |
| 135 | spin_lock(&(sp_ptr->state_lock)); |
| 136 | |
| 137 | if (sp_ptr->state == from) { |
| 138 | sp_ptr->state = to; |
| 139 | |
| 140 | success = 1; |
| 141 | } |
| 142 | |
| 143 | spin_unlock(&(sp_ptr->state_lock)); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | /******************************************************************************* |
| 148 | * Check if the state of a Secure Partition is the specified one and, if so, |
| 149 | * change it to the desired state. Returns 0 on success, -1 on error. |
| 150 | ******************************************************************************/ |
| 151 | int sp_state_try_switch(sp_context_t *sp_ptr, sp_state_t from, sp_state_t to) |
| 152 | { |
| 153 | int ret = -1; |
| 154 | |
| 155 | spin_lock(&(sp_ptr->state_lock)); |
| 156 | |
| 157 | if (sp_ptr->state == from) { |
| 158 | sp_ptr->state = to; |
| 159 | |
| 160 | ret = 0; |
| 161 | } |
| 162 | |
| 163 | spin_unlock(&(sp_ptr->state_lock)); |
| 164 | |
| 165 | return ret; |
| 166 | } |
| 167 | |
| 168 | /******************************************************************************* |
Antonio Nino Diaz | da50cd0 | 2018-06-15 16:21:01 +0100 | [diff] [blame] | 169 | * This function takes an SP context pointer and performs a synchronous entry |
| 170 | * into it. |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 171 | ******************************************************************************/ |
Antonio Nino Diaz | fb76396 | 2018-07-03 16:54:33 +0100 | [diff] [blame] | 172 | uint64_t spm_sp_synchronous_entry(sp_context_t *sp_ctx, int can_preempt) |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 173 | { |
Antonio Nino Diaz | da50cd0 | 2018-06-15 16:21:01 +0100 | [diff] [blame] | 174 | uint64_t rc; |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 175 | unsigned int linear_id = plat_my_core_pos(); |
Antonio Nino Diaz | da50cd0 | 2018-06-15 16:21:01 +0100 | [diff] [blame] | 176 | |
Antonio Nino Diaz | 2ac9a44 | 2018-05-23 11:40:46 +0100 | [diff] [blame] | 177 | assert(sp_ctx != NULL); |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 178 | |
Antonio Nino Diaz | 2ac9a44 | 2018-05-23 11:40:46 +0100 | [diff] [blame] | 179 | /* Assign the context of the SP to this CPU */ |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 180 | spm_cpu_set_sp_ctx(linear_id, sp_ctx); |
Antonio Nino Diaz | 2ac9a44 | 2018-05-23 11:40:46 +0100 | [diff] [blame] | 181 | cm_set_context(&(sp_ctx->cpu_ctx), SECURE); |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 182 | |
Antonio Nino Diaz | 2ac9a44 | 2018-05-23 11:40:46 +0100 | [diff] [blame] | 183 | /* Restore the context assigned above */ |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 184 | cm_el1_sysregs_context_restore(SECURE); |
| 185 | cm_set_next_eret_context(SECURE); |
| 186 | |
Antonio Nino Diaz | 2ac9a44 | 2018-05-23 11:40:46 +0100 | [diff] [blame] | 187 | /* Invalidate TLBs at EL1. */ |
| 188 | tlbivmalle1(); |
| 189 | dsbish(); |
Antonio Nino Diaz | da50cd0 | 2018-06-15 16:21:01 +0100 | [diff] [blame] | 190 | |
Antonio Nino Diaz | fb76396 | 2018-07-03 16:54:33 +0100 | [diff] [blame] | 191 | if (can_preempt == 1) { |
| 192 | enable_intr_rm_local(INTR_TYPE_NS, SECURE); |
| 193 | } else { |
| 194 | disable_intr_rm_local(INTR_TYPE_NS, SECURE); |
| 195 | } |
| 196 | |
Antonio Nino Diaz | da50cd0 | 2018-06-15 16:21:01 +0100 | [diff] [blame] | 197 | /* Enter Secure Partition */ |
| 198 | rc = spm_secure_partition_enter(&sp_ctx->c_rt_ctx); |
| 199 | |
| 200 | /* Save secure state */ |
| 201 | cm_el1_sysregs_context_save(SECURE); |
| 202 | |
| 203 | return rc; |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 204 | } |
| 205 | |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 206 | /******************************************************************************* |
Antonio Nino Diaz | da50cd0 | 2018-06-15 16:21:01 +0100 | [diff] [blame] | 207 | * This function returns to the place where spm_sp_synchronous_entry() was |
| 208 | * called originally. |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 209 | ******************************************************************************/ |
Antonio Nino Diaz | 8c83ad8 | 2018-11-08 14:21:19 +0000 | [diff] [blame] | 210 | __dead2 void spm_sp_synchronous_exit(uint64_t rc) |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 211 | { |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 212 | /* Get context of the SP in use by this CPU. */ |
| 213 | unsigned int linear_id = plat_my_core_pos(); |
| 214 | sp_context_t *ctx = spm_cpu_get_sp_ctx(linear_id); |
Antonio Nino Diaz | da50cd0 | 2018-06-15 16:21:01 +0100 | [diff] [blame] | 215 | |
| 216 | /* |
| 217 | * The SPM must have initiated the original request through a |
| 218 | * synchronous entry into the secure partition. Jump back to the |
| 219 | * original C runtime context with the value of rc in x0; |
| 220 | */ |
| 221 | spm_secure_partition_exit(ctx->c_rt_ctx, rc); |
| 222 | |
| 223 | panic(); |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | /******************************************************************************* |
Antonio Nino Diaz | fb76396 | 2018-07-03 16:54:33 +0100 | [diff] [blame] | 227 | * This function is the handler registered for Non secure interrupts by the SPM. |
| 228 | * It validates the interrupt and upon success arranges entry into the normal |
| 229 | * world for handling the interrupt. |
| 230 | ******************************************************************************/ |
| 231 | static uint64_t spm_ns_interrupt_handler(uint32_t id, uint32_t flags, |
| 232 | void *handle, void *cookie) |
| 233 | { |
| 234 | /* Check the security state when the exception was generated */ |
| 235 | assert(get_interrupt_src_ss(flags) == SECURE); |
| 236 | |
| 237 | spm_sp_synchronous_exit(SPM_SECURE_PARTITION_PREEMPTED); |
| 238 | } |
| 239 | |
| 240 | /******************************************************************************* |
Antonio Nino Diaz | 2ac9a44 | 2018-05-23 11:40:46 +0100 | [diff] [blame] | 241 | * Jump to each Secure Partition for the first time. |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 242 | ******************************************************************************/ |
Antonio Nino Diaz | e881147 | 2018-04-17 15:10:18 +0100 | [diff] [blame] | 243 | static int32_t spm_init(void) |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 244 | { |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 245 | uint64_t rc = 0; |
Antonio Nino Diaz | 2875931 | 2018-05-22 16:26:48 +0100 | [diff] [blame] | 246 | sp_context_t *ctx; |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 247 | |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 248 | for (unsigned int i = 0U; i < PLAT_SPM_MAX_PARTITIONS; i++) { |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 249 | |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 250 | ctx = &sp_ctx_array[i]; |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 251 | |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 252 | if (ctx->is_present == 0) { |
| 253 | continue; |
| 254 | } |
| 255 | |
| 256 | INFO("Secure Partition %u init...\n", i); |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 257 | |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 258 | ctx->state = SP_STATE_RESET; |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 259 | |
Antonio Nino Diaz | fb76396 | 2018-07-03 16:54:33 +0100 | [diff] [blame] | 260 | rc = spm_sp_synchronous_entry(ctx, 0); |
Antonio Nino Diaz | 8c83ad8 | 2018-11-08 14:21:19 +0000 | [diff] [blame] | 261 | if (rc != SPRT_YIELD_AARCH64) { |
| 262 | ERROR("Unexpected return value 0x%llx\n", rc); |
| 263 | panic(); |
| 264 | } |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 265 | |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 266 | ctx->state = SP_STATE_IDLE; |
| 267 | |
| 268 | INFO("Secure Partition %u initialized.\n", i); |
| 269 | } |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 270 | |
Antonio Nino Diaz | 2ac9a44 | 2018-05-23 11:40:46 +0100 | [diff] [blame] | 271 | return rc; |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | /******************************************************************************* |
Antonio Nino Diaz | 2ac9a44 | 2018-05-23 11:40:46 +0100 | [diff] [blame] | 275 | * Initialize contexts of all Secure Partitions. |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 276 | ******************************************************************************/ |
| 277 | int32_t spm_setup(void) |
| 278 | { |
Antonio Nino Diaz | 840627f | 2018-11-27 08:36:02 +0000 | [diff] [blame] | 279 | int rc; |
Antonio Nino Diaz | 2875931 | 2018-05-22 16:26:48 +0100 | [diff] [blame] | 280 | sp_context_t *ctx; |
Antonio Nino Diaz | 840627f | 2018-11-27 08:36:02 +0000 | [diff] [blame] | 281 | void *sp_base, *rd_base; |
| 282 | size_t sp_size, rd_size; |
Antonio Nino Diaz | fb76396 | 2018-07-03 16:54:33 +0100 | [diff] [blame] | 283 | uint64_t flags = 0U; |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 284 | |
Antonio Nino Diaz | 2ac9a44 | 2018-05-23 11:40:46 +0100 | [diff] [blame] | 285 | /* Disable MMU at EL1 (initialized by BL2) */ |
| 286 | disable_mmu_icache_el1(); |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 287 | |
Antonio Nino Diaz | fb76396 | 2018-07-03 16:54:33 +0100 | [diff] [blame] | 288 | /* |
| 289 | * Non-blocking services can be interrupted by Non-secure interrupts. |
| 290 | * Register an interrupt handler for NS interrupts when generated while |
| 291 | * the CPU is in secure state. They are routed to EL3. |
| 292 | */ |
| 293 | set_interrupt_rm_flag(flags, SECURE); |
| 294 | |
| 295 | uint64_t rc_int = register_interrupt_type_handler(INTR_TYPE_NS, |
| 296 | spm_ns_interrupt_handler, flags); |
| 297 | if (rc_int) { |
| 298 | ERROR("SPM: Failed to register NS interrupt handler with rc = %llx\n", |
| 299 | rc_int); |
| 300 | panic(); |
| 301 | } |
| 302 | |
Antonio Nino Diaz | 37f97a5 | 2019-03-27 11:10:31 +0000 | [diff] [blame] | 303 | /* Setup shim layer */ |
| 304 | spm_exceptions_xlat_init_context(); |
| 305 | |
Antonio Nino Diaz | fb76396 | 2018-07-03 16:54:33 +0100 | [diff] [blame] | 306 | /* |
| 307 | * Setup all Secure Partitions. |
| 308 | */ |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 309 | unsigned int i = 0U; |
| 310 | |
| 311 | while (1) { |
| 312 | rc = plat_spm_sp_get_next_address(&sp_base, &sp_size, |
| 313 | &rd_base, &rd_size); |
| 314 | if (rc < 0) { |
| 315 | /* Reached the end of the package. */ |
| 316 | break; |
| 317 | } |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 318 | |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 319 | if (i >= PLAT_SPM_MAX_PARTITIONS) { |
| 320 | ERROR("Too many partitions in the package.\n"); |
| 321 | panic(); |
| 322 | } |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 323 | |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 324 | ctx = &sp_ctx_array[i]; |
Antonio Nino Diaz | 840627f | 2018-11-27 08:36:02 +0000 | [diff] [blame] | 325 | |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 326 | assert(ctx->is_present == 0); |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 327 | |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 328 | /* Initialize context of the SP */ |
| 329 | INFO("Secure Partition %u context setup start...\n", i); |
Antonio Nino Diaz | 840627f | 2018-11-27 08:36:02 +0000 | [diff] [blame] | 330 | |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 331 | /* Save location of the image in physical memory */ |
| 332 | ctx->image_base = (uintptr_t)sp_base; |
| 333 | ctx->image_size = sp_size; |
| 334 | |
| 335 | rc = plat_spm_sp_rd_load(&ctx->rd, rd_base, rd_size); |
| 336 | if (rc < 0) { |
| 337 | ERROR("Error while loading RD blob.\n"); |
| 338 | panic(); |
| 339 | } |
| 340 | |
| 341 | spm_sp_setup(ctx); |
| 342 | |
| 343 | ctx->is_present = 1; |
| 344 | |
| 345 | INFO("Secure Partition %u setup done.\n", i); |
| 346 | |
| 347 | i++; |
Antonio Nino Diaz | 840627f | 2018-11-27 08:36:02 +0000 | [diff] [blame] | 348 | } |
| 349 | |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 350 | if (i == 0U) { |
| 351 | ERROR("No present partitions in the package.\n"); |
| 352 | panic(); |
| 353 | } |
Antonio Nino Diaz | 2ac9a44 | 2018-05-23 11:40:46 +0100 | [diff] [blame] | 354 | |
| 355 | /* Register init function for deferred init. */ |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 356 | bl31_register_bl32_init(&spm_init); |
| 357 | |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 358 | return 0; |
| 359 | } |