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