Daniel Boulby | b2fb80e | 2021-02-03 15:09:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021 The Hafnium Authors. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style |
| 5 | * license that can be found in the LICENSE file or at |
| 6 | * https://opensource.org/licenses/BSD-3-Clause. |
| 7 | */ |
| 8 | |
| 9 | #include "hf/ffa.h" |
| 10 | |
J-Alves | fa78209 | 2021-10-13 16:02:16 +0100 | [diff] [blame] | 11 | #include "hf/arch/plat/ffa.h" |
| 12 | |
J-Alves | a0f317d | 2021-06-09 13:31:59 +0100 | [diff] [blame] | 13 | #include "hf/ffa_internal.h" |
Olivier Deprez | 55a189e | 2021-06-09 15:45:27 +0200 | [diff] [blame] | 14 | #include "hf/vcpu.h" |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 15 | #include "hf/vm.h" |
Daniel Boulby | b2fb80e | 2021-02-03 15:09:23 +0000 | [diff] [blame] | 16 | |
Daniel Boulby | 87b2dc8 | 2021-08-04 14:07:43 +0100 | [diff] [blame] | 17 | struct ffa_value arch_ffa_features(uint32_t function_id) |
| 18 | { |
| 19 | (void)function_id; |
| 20 | return ffa_error(FFA_NOT_SUPPORTED); |
| 21 | } |
| 22 | |
Daniel Boulby | b2fb80e | 2021-02-03 15:09:23 +0000 | [diff] [blame] | 23 | ffa_vm_id_t arch_ffa_spmc_id_get(void) |
| 24 | { |
| 25 | return HF_SPMC_VM_ID; |
| 26 | } |
Olivier Deprez | 55a189e | 2021-06-09 15:45:27 +0200 | [diff] [blame] | 27 | |
| 28 | void plat_ffa_log_init(void) |
| 29 | { |
| 30 | } |
| 31 | |
Maksims Svecovs | a3d570c | 2021-12-08 11:16:32 +0000 | [diff] [blame] | 32 | bool plat_ffa_is_memory_send_valid(ffa_vm_id_t receiver_vm_id, |
| 33 | uint32_t share_func) |
| 34 | { |
| 35 | (void)receiver_vm_id; |
| 36 | (void)share_func; |
| 37 | |
| 38 | return true; |
| 39 | } |
| 40 | |
Olivier Deprez | 55a189e | 2021-06-09 15:45:27 +0200 | [diff] [blame] | 41 | bool plat_ffa_is_direct_request_valid(struct vcpu *current, |
| 42 | ffa_vm_id_t sender_vm_id, |
| 43 | ffa_vm_id_t receiver_vm_id) |
| 44 | { |
| 45 | (void)current; |
| 46 | (void)sender_vm_id; |
| 47 | (void)receiver_vm_id; |
| 48 | |
| 49 | return true; |
| 50 | } |
| 51 | |
J-Alves | 439ac97 | 2021-11-18 17:32:03 +0000 | [diff] [blame] | 52 | bool plat_ffa_is_direct_request_supported(struct vm *sender_vm, |
| 53 | struct vm *receiver_vm) |
| 54 | { |
| 55 | (void)sender_vm; |
| 56 | (void)receiver_vm; |
| 57 | |
| 58 | return false; |
| 59 | } |
| 60 | |
Olivier Deprez | 55a189e | 2021-06-09 15:45:27 +0200 | [diff] [blame] | 61 | bool plat_ffa_is_direct_response_valid(struct vcpu *current, |
| 62 | ffa_vm_id_t sender_vm_id, |
| 63 | ffa_vm_id_t receiver_vm_id) |
| 64 | { |
| 65 | (void)current; |
| 66 | (void)sender_vm_id; |
| 67 | (void)receiver_vm_id; |
| 68 | |
| 69 | return true; |
| 70 | } |
| 71 | |
Raghu Krishnamurthy | 62f97a7 | 2021-07-27 02:14:59 -0700 | [diff] [blame] | 72 | bool plat_ffa_run_forward(ffa_vm_id_t vm_id, ffa_vcpu_index_t vcpu_idx, |
| 73 | struct ffa_value *ret) |
| 74 | { |
| 75 | (void)vm_id; |
| 76 | (void)vcpu_idx; |
| 77 | (void)ret; |
| 78 | |
| 79 | return false; |
| 80 | } |
| 81 | |
Federico Recanati | 10bd06c | 2022-02-23 17:32:59 +0100 | [diff] [blame] | 82 | void plat_ffa_vm_destroy(struct vm_locked to_destroy_locked) |
| 83 | { |
| 84 | (void)to_destroy_locked; |
| 85 | } |
| 86 | |
Federico Recanati | 8da9e33 | 2022-02-10 11:00:17 +0100 | [diff] [blame] | 87 | void plat_ffa_rxtx_unmap_forward(ffa_vm_id_t id) |
| 88 | { |
| 89 | (void)id; |
| 90 | } |
| 91 | |
Olivier Deprez | 55a189e | 2021-06-09 15:45:27 +0200 | [diff] [blame] | 92 | bool plat_ffa_direct_request_forward(ffa_vm_id_t receiver_vm_id, |
| 93 | struct ffa_value args, |
| 94 | struct ffa_value *ret) |
| 95 | { |
| 96 | (void)receiver_vm_id; |
| 97 | (void)args; |
| 98 | (void)ret; |
| 99 | return false; |
| 100 | } |
| 101 | |
Federico Recanati | 25053ee | 2022-03-14 15:01:53 +0100 | [diff] [blame^] | 102 | bool plat_ffa_is_indirect_msg_supported(struct vm_locked sender_locked, |
| 103 | struct vm_locked receiver_locked) |
| 104 | { |
| 105 | (void)sender_locked; |
| 106 | (void)receiver_locked; |
| 107 | |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | bool plat_ffa_msg_send2_forward(ffa_vm_id_t receiver_vm_id, |
| 112 | ffa_vm_id_t sender_vm_id, struct ffa_value *ret) |
| 113 | { |
| 114 | (void)receiver_vm_id; |
| 115 | (void)sender_vm_id; |
| 116 | (void)ret; |
| 117 | |
| 118 | return false; |
| 119 | } |
| 120 | |
Olivier Deprez | 55a189e | 2021-06-09 15:45:27 +0200 | [diff] [blame] | 121 | ffa_memory_handle_t plat_ffa_memory_handle_make(uint64_t index) |
| 122 | { |
| 123 | return index; |
| 124 | } |
| 125 | |
| 126 | bool plat_ffa_memory_handle_allocated_by_current_world( |
| 127 | ffa_memory_handle_t handle) |
| 128 | { |
| 129 | (void)handle; |
| 130 | return false; |
| 131 | } |
Maksims Svecovs | b596eab | 2021-04-27 00:52:27 +0100 | [diff] [blame] | 132 | |
J-Alves | 7db3200 | 2021-12-14 14:44:50 +0000 | [diff] [blame] | 133 | uint32_t plat_ffa_other_world_mode(void) |
| 134 | { |
| 135 | return 0U; |
| 136 | } |
| 137 | |
| 138 | uint32_t plat_ffa_owner_world_mode(ffa_vm_id_t owner_id) |
| 139 | { |
| 140 | (void)owner_id; |
| 141 | return 0U; |
| 142 | } |
| 143 | |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 144 | bool plat_ffa_is_notifications_bind_valid(struct vcpu *current, |
| 145 | ffa_vm_id_t sender_id, |
| 146 | ffa_vm_id_t receiver_id) |
| 147 | { |
| 148 | (void)current; |
| 149 | (void)sender_id; |
| 150 | (void)receiver_id; |
| 151 | return false; |
| 152 | } |
| 153 | |
J-Alves | b15e940 | 2021-09-08 11:44:42 +0100 | [diff] [blame] | 154 | bool plat_ffa_notifications_update_bindings_forward( |
| 155 | ffa_vm_id_t receiver_id, ffa_vm_id_t sender_id, uint32_t flags, |
| 156 | ffa_notifications_bitmap_t bitmap, bool is_bind, struct ffa_value *ret) |
| 157 | { |
| 158 | (void)ret; |
| 159 | (void)receiver_id; |
| 160 | (void)sender_id; |
| 161 | (void)flags; |
| 162 | (void)bitmap; |
| 163 | (void)is_bind; |
| 164 | (void)ret; |
| 165 | |
| 166 | return false; |
| 167 | } |
| 168 | |
Federico Recanati | 8d8b1cf | 2022-04-14 13:16:00 +0200 | [diff] [blame] | 169 | void plat_ffa_rxtx_map_forward(struct vm_locked vm_locked) |
| 170 | { |
| 171 | (void)vm_locked; |
| 172 | } |
| 173 | |
Maksims Svecovs | b596eab | 2021-04-27 00:52:27 +0100 | [diff] [blame] | 174 | ffa_partition_properties_t plat_ffa_partition_properties( |
J-Alves | fa78209 | 2021-10-13 16:02:16 +0100 | [diff] [blame] | 175 | ffa_vm_id_t vm_id, const struct vm *target) |
Maksims Svecovs | b596eab | 2021-04-27 00:52:27 +0100 | [diff] [blame] | 176 | { |
J-Alves | fa78209 | 2021-10-13 16:02:16 +0100 | [diff] [blame] | 177 | (void)vm_id; |
Maksims Svecovs | b596eab | 2021-04-27 00:52:27 +0100 | [diff] [blame] | 178 | (void)target; |
| 179 | return 0; |
| 180 | } |
Maksims Svecovs | 9ddf86a | 2021-05-06 17:17:21 +0100 | [diff] [blame] | 181 | |
| 182 | bool plat_ffa_vm_managed_exit_supported(struct vm *vm) |
| 183 | { |
| 184 | (void)vm; |
| 185 | return false; |
| 186 | } |
J-Alves | a0f317d | 2021-06-09 13:31:59 +0100 | [diff] [blame] | 187 | |
| 188 | bool plat_ffa_is_notifications_create_valid(struct vcpu *current, |
| 189 | ffa_vm_id_t vm_id) |
| 190 | { |
| 191 | (void)current; |
| 192 | (void)vm_id; |
| 193 | |
| 194 | return false; |
| 195 | } |
| 196 | |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 197 | bool plat_ffa_is_notification_set_valid(struct vcpu *current, |
| 198 | ffa_vm_id_t sender_id, |
| 199 | ffa_vm_id_t receiver_id) |
| 200 | { |
| 201 | (void)current; |
| 202 | (void)sender_id; |
| 203 | (void)receiver_id; |
| 204 | return false; |
| 205 | } |
| 206 | |
| 207 | bool plat_ffa_is_notification_get_valid(struct vcpu *current, |
J-Alves | fc95a30 | 2022-04-22 14:18:23 +0100 | [diff] [blame] | 208 | ffa_vm_id_t receiver_id, uint32_t flags) |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 209 | { |
J-Alves | fc95a30 | 2022-04-22 14:18:23 +0100 | [diff] [blame] | 210 | (void)flags; |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 211 | (void)current; |
| 212 | (void)receiver_id; |
| 213 | return false; |
| 214 | } |
| 215 | |
J-Alves | 98ff956 | 2021-09-09 14:39:41 +0100 | [diff] [blame] | 216 | bool plat_ffa_notifications_get_from_sp( |
| 217 | struct vm_locked receiver_locked, ffa_vcpu_index_t vcpu_id, |
J-Alves | fa78209 | 2021-10-13 16:02:16 +0100 | [diff] [blame] | 218 | ffa_notifications_bitmap_t *from_sp, // NOLINT |
| 219 | struct ffa_value *ret) // NOLINT |
J-Alves | 98ff956 | 2021-09-09 14:39:41 +0100 | [diff] [blame] | 220 | { |
| 221 | (void)receiver_locked; |
| 222 | (void)vcpu_id; |
| 223 | (void)from_sp; |
| 224 | (void)ret; |
| 225 | |
| 226 | return false; |
| 227 | } |
| 228 | |
J-Alves | d605a09 | 2022-03-28 14:20:48 +0100 | [diff] [blame] | 229 | bool plat_ffa_notifications_get_framework_notifications( |
| 230 | struct vm_locked receiver_locked, |
| 231 | ffa_notifications_bitmap_t *from_fwk, // NOLINT |
| 232 | uint32_t flags, ffa_vcpu_index_t vcpu_id, struct ffa_value *ret) |
| 233 | { |
| 234 | (void)receiver_locked; |
| 235 | (void)from_fwk; |
| 236 | (void)flags; |
| 237 | (void)vcpu_id; |
| 238 | (void)ret; |
| 239 | |
| 240 | return false; |
| 241 | } |
| 242 | |
J-Alves | de7bd2f | 2021-09-09 19:54:35 +0100 | [diff] [blame] | 243 | bool plat_ffa_notification_set_forward(ffa_vm_id_t sender_vm_id, |
| 244 | ffa_vm_id_t receiver_vm_id, |
| 245 | uint32_t flags, |
| 246 | ffa_notifications_bitmap_t bitmap, |
| 247 | struct ffa_value *ret) |
| 248 | { |
| 249 | (void)sender_vm_id; |
| 250 | (void)receiver_vm_id; |
| 251 | (void)flags; |
| 252 | (void)bitmap; |
| 253 | (void)ret; |
| 254 | |
| 255 | return false; |
| 256 | } |
| 257 | |
J-Alves | a0f317d | 2021-06-09 13:31:59 +0100 | [diff] [blame] | 258 | struct ffa_value plat_ffa_notifications_bitmap_create( |
| 259 | ffa_vm_id_t vm_id, ffa_vcpu_count_t vcpu_count) |
| 260 | { |
| 261 | (void)vm_id; |
| 262 | (void)vcpu_count; |
| 263 | |
| 264 | return ffa_error(FFA_NOT_SUPPORTED); |
| 265 | } |
| 266 | |
| 267 | struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_vm_id_t vm_id) |
| 268 | { |
| 269 | (void)vm_id; |
| 270 | |
| 271 | return ffa_error(FFA_NOT_SUPPORTED); |
| 272 | } |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 273 | |
| 274 | struct vm_locked plat_ffa_vm_find_locked(ffa_vm_id_t vm_id) |
| 275 | { |
| 276 | (void)vm_id; |
| 277 | return (struct vm_locked){.vm = NULL}; |
| 278 | } |
| 279 | |
Federico Recanati | 8d8b1cf | 2022-04-14 13:16:00 +0200 | [diff] [blame] | 280 | struct vm_locked plat_ffa_vm_find_locked_create(ffa_vm_id_t vm_id) |
| 281 | { |
| 282 | (void)vm_id; |
| 283 | return (struct vm_locked){.vm = NULL}; |
| 284 | } |
| 285 | |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 286 | bool plat_ffa_is_vm_id(ffa_vm_id_t vm_id) |
| 287 | { |
| 288 | (void)vm_id; |
| 289 | return false; |
| 290 | } |
J-Alves | c8e8a22 | 2021-06-08 17:33:52 +0100 | [diff] [blame] | 291 | |
J-Alves | fa78209 | 2021-10-13 16:02:16 +0100 | [diff] [blame] | 292 | bool plat_ffa_vm_notifications_info_get( // NOLINTNEXTLINE |
| 293 | uint16_t *ids, uint32_t *ids_count, // NOLINTNEXTLINE |
| 294 | uint32_t *lists_sizes, // NOLINTNEXTLINE |
| 295 | uint32_t *lists_count, const uint32_t ids_count_max) |
J-Alves | c8e8a22 | 2021-06-08 17:33:52 +0100 | [diff] [blame] | 296 | { |
| 297 | (void)ids; |
| 298 | (void)ids_count; |
| 299 | (void)lists_sizes; |
| 300 | (void)lists_count; |
| 301 | (void)ids_count_max; |
| 302 | |
| 303 | return false; |
| 304 | } |
Raghu Krishnamurthy | ea6d25f | 2021-09-14 15:27:06 -0700 | [diff] [blame] | 305 | |
| 306 | bool plat_ffa_is_mem_perm_get_valid(const struct vcpu *current) |
| 307 | { |
| 308 | (void)current; |
| 309 | return false; |
| 310 | } |
| 311 | |
| 312 | bool plat_ffa_is_mem_perm_set_valid(const struct vcpu *current) |
| 313 | { |
| 314 | (void)current; |
| 315 | return false; |
| 316 | } |
Madhukar Pappireddy | b11e0d1 | 2021-08-02 19:44:35 -0500 | [diff] [blame] | 317 | |
| 318 | /** |
| 319 | * Check if current VM can resume target VM/SP using FFA_RUN ABI. |
| 320 | */ |
| 321 | bool plat_ffa_run_checks(struct vcpu *current, ffa_vm_id_t target_vm_id, |
Raghu Krishnamurthy | 048d63f | 2021-12-11 12:45:41 -0800 | [diff] [blame] | 322 | ffa_vcpu_index_t vcpu_idx, struct ffa_value *run_ret, |
| 323 | struct vcpu **next) |
Madhukar Pappireddy | b11e0d1 | 2021-08-02 19:44:35 -0500 | [diff] [blame] | 324 | { |
| 325 | (void)current; |
| 326 | (void)target_vm_id; |
| 327 | (void)run_ret; |
| 328 | (void)next; |
Raghu Krishnamurthy | 048d63f | 2021-12-11 12:45:41 -0800 | [diff] [blame] | 329 | (void)vcpu_idx; |
Madhukar Pappireddy | b11e0d1 | 2021-08-02 19:44:35 -0500 | [diff] [blame] | 330 | return true; |
| 331 | } |
J-Alves | ca058c2 | 2021-09-10 14:02:07 +0100 | [diff] [blame] | 332 | |
| 333 | void plat_ffa_notification_info_get_forward( // NOLINTNEXTLINE |
| 334 | uint16_t *ids, uint32_t *ids_count, // NOLINTNEXTLINE |
| 335 | uint32_t *lists_sizes, uint32_t *lists_count, |
| 336 | const uint32_t ids_count_max) |
| 337 | { |
| 338 | (void)ids; |
| 339 | (void)ids_count; |
| 340 | (void)lists_sizes; |
| 341 | (void)lists_count; |
| 342 | (void)ids_count_max; |
| 343 | } |
J-Alves | 1339402 | 2021-06-30 13:48:49 +0100 | [diff] [blame] | 344 | |
| 345 | void plat_ffa_sri_state_set(enum plat_ffa_sri_state state) |
| 346 | { |
| 347 | (void)state; |
| 348 | } |
| 349 | |
| 350 | void plat_ffa_sri_trigger_if_delayed(struct cpu *cpu) |
| 351 | { |
| 352 | (void)cpu; |
| 353 | } |
| 354 | |
| 355 | void plat_ffa_sri_trigger_not_delayed(struct cpu *cpu) |
| 356 | { |
| 357 | (void)cpu; |
| 358 | } |
| 359 | |
| 360 | void plat_ffa_sri_init(struct cpu *cpu) |
| 361 | { |
| 362 | (void)cpu; |
| 363 | } |
J-Alves | 7461ef2 | 2021-10-18 17:21:33 +0100 | [diff] [blame] | 364 | |
J-Alves | 6e2abc6 | 2021-12-02 14:58:56 +0000 | [diff] [blame] | 365 | bool plat_ffa_inject_notification_pending_interrupt( |
| 366 | struct vcpu_locked target_locked, struct vcpu *current, |
| 367 | struct vm_locked receiver_locked) |
J-Alves | 7461ef2 | 2021-10-18 17:21:33 +0100 | [diff] [blame] | 368 | { |
J-Alves | 6e2abc6 | 2021-12-02 14:58:56 +0000 | [diff] [blame] | 369 | (void)target_locked; |
J-Alves | 7461ef2 | 2021-10-18 17:21:33 +0100 | [diff] [blame] | 370 | (void)current; |
J-Alves | 6e2abc6 | 2021-12-02 14:58:56 +0000 | [diff] [blame] | 371 | (void)receiver_locked; |
| 372 | |
| 373 | return false; |
J-Alves | 7461ef2 | 2021-10-18 17:21:33 +0100 | [diff] [blame] | 374 | } |
Olivier Deprez | e562e54 | 2020-06-11 17:31:54 +0200 | [diff] [blame] | 375 | |
| 376 | void plat_ffa_partition_info_get_forward( // NOLINTNEXTLINE |
| 377 | const struct ffa_uuid *uuid, // NOLINTNEXTLINE |
Daniel Boulby | b46cad1 | 2021-12-13 17:47:21 +0000 | [diff] [blame] | 378 | const uint32_t flags, // NOLINTNEXTLINE |
Olivier Deprez | e562e54 | 2020-06-11 17:31:54 +0200 | [diff] [blame] | 379 | struct ffa_partition_info *partitions, ffa_vm_count_t *ret_count) |
| 380 | { |
| 381 | (void)uuid; |
Daniel Boulby | b46cad1 | 2021-12-13 17:47:21 +0000 | [diff] [blame] | 382 | (void)flags; |
Olivier Deprez | e562e54 | 2020-06-11 17:31:54 +0200 | [diff] [blame] | 383 | (void)partitions; |
| 384 | (void)ret_count; |
| 385 | } |
Olivier Deprez | d614d32 | 2021-06-18 15:21:00 +0200 | [diff] [blame] | 386 | |
| 387 | bool plat_ffa_is_secondary_ep_register_supported(void) |
| 388 | { |
| 389 | return false; |
| 390 | } |
Madhukar Pappireddy | 5522c67 | 2021-12-17 16:35:51 -0600 | [diff] [blame] | 391 | bool plat_ffa_msg_wait_prepare(struct vcpu *current, struct vcpu **next, |
| 392 | struct ffa_value *ret_args) |
| 393 | { |
| 394 | (void)current; |
| 395 | (void)next; |
| 396 | (void)ret_args; |
| 397 | |
| 398 | return false; |
| 399 | } |