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