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 | |
Olivier Deprez | 55a189e | 2021-06-09 15:45:27 +0200 | [diff] [blame] | 82 | bool plat_ffa_direct_request_forward(ffa_vm_id_t receiver_vm_id, |
| 83 | struct ffa_value args, |
| 84 | struct ffa_value *ret) |
| 85 | { |
| 86 | (void)receiver_vm_id; |
| 87 | (void)args; |
| 88 | (void)ret; |
| 89 | return false; |
| 90 | } |
| 91 | |
| 92 | ffa_memory_handle_t plat_ffa_memory_handle_make(uint64_t index) |
| 93 | { |
| 94 | return index; |
| 95 | } |
| 96 | |
| 97 | bool plat_ffa_memory_handle_allocated_by_current_world( |
| 98 | ffa_memory_handle_t handle) |
| 99 | { |
| 100 | (void)handle; |
| 101 | return false; |
| 102 | } |
Maksims Svecovs | b596eab | 2021-04-27 00:52:27 +0100 | [diff] [blame] | 103 | |
J-Alves | 7db3200 | 2021-12-14 14:44:50 +0000 | [diff] [blame] | 104 | uint32_t plat_ffa_other_world_mode(void) |
| 105 | { |
| 106 | return 0U; |
| 107 | } |
| 108 | |
| 109 | uint32_t plat_ffa_owner_world_mode(ffa_vm_id_t owner_id) |
| 110 | { |
| 111 | (void)owner_id; |
| 112 | return 0U; |
| 113 | } |
| 114 | |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 115 | bool plat_ffa_is_notifications_bind_valid(struct vcpu *current, |
| 116 | ffa_vm_id_t sender_id, |
| 117 | ffa_vm_id_t receiver_id) |
| 118 | { |
| 119 | (void)current; |
| 120 | (void)sender_id; |
| 121 | (void)receiver_id; |
| 122 | return false; |
| 123 | } |
| 124 | |
J-Alves | b15e940 | 2021-09-08 11:44:42 +0100 | [diff] [blame] | 125 | bool plat_ffa_notifications_update_bindings_forward( |
| 126 | ffa_vm_id_t receiver_id, ffa_vm_id_t sender_id, uint32_t flags, |
| 127 | ffa_notifications_bitmap_t bitmap, bool is_bind, struct ffa_value *ret) |
| 128 | { |
| 129 | (void)ret; |
| 130 | (void)receiver_id; |
| 131 | (void)sender_id; |
| 132 | (void)flags; |
| 133 | (void)bitmap; |
| 134 | (void)is_bind; |
| 135 | (void)ret; |
| 136 | |
| 137 | return false; |
| 138 | } |
| 139 | |
Federico Recanati | 8d8b1cf | 2022-04-14 13:16:00 +0200 | [diff] [blame^] | 140 | void plat_ffa_rxtx_map_forward(struct vm_locked vm_locked) |
| 141 | { |
| 142 | (void)vm_locked; |
| 143 | } |
| 144 | |
Maksims Svecovs | b596eab | 2021-04-27 00:52:27 +0100 | [diff] [blame] | 145 | ffa_partition_properties_t plat_ffa_partition_properties( |
J-Alves | fa78209 | 2021-10-13 16:02:16 +0100 | [diff] [blame] | 146 | ffa_vm_id_t vm_id, const struct vm *target) |
Maksims Svecovs | b596eab | 2021-04-27 00:52:27 +0100 | [diff] [blame] | 147 | { |
J-Alves | fa78209 | 2021-10-13 16:02:16 +0100 | [diff] [blame] | 148 | (void)vm_id; |
Maksims Svecovs | b596eab | 2021-04-27 00:52:27 +0100 | [diff] [blame] | 149 | (void)target; |
| 150 | return 0; |
| 151 | } |
Maksims Svecovs | 9ddf86a | 2021-05-06 17:17:21 +0100 | [diff] [blame] | 152 | |
| 153 | bool plat_ffa_vm_managed_exit_supported(struct vm *vm) |
| 154 | { |
| 155 | (void)vm; |
| 156 | return false; |
| 157 | } |
J-Alves | a0f317d | 2021-06-09 13:31:59 +0100 | [diff] [blame] | 158 | |
| 159 | bool plat_ffa_is_notifications_create_valid(struct vcpu *current, |
| 160 | ffa_vm_id_t vm_id) |
| 161 | { |
| 162 | (void)current; |
| 163 | (void)vm_id; |
| 164 | |
| 165 | return false; |
| 166 | } |
| 167 | |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 168 | bool plat_ffa_is_notification_set_valid(struct vcpu *current, |
| 169 | ffa_vm_id_t sender_id, |
| 170 | ffa_vm_id_t receiver_id) |
| 171 | { |
| 172 | (void)current; |
| 173 | (void)sender_id; |
| 174 | (void)receiver_id; |
| 175 | return false; |
| 176 | } |
| 177 | |
| 178 | bool plat_ffa_is_notification_get_valid(struct vcpu *current, |
J-Alves | fc95a30 | 2022-04-22 14:18:23 +0100 | [diff] [blame] | 179 | ffa_vm_id_t receiver_id, uint32_t flags) |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 180 | { |
J-Alves | fc95a30 | 2022-04-22 14:18:23 +0100 | [diff] [blame] | 181 | (void)flags; |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 182 | (void)current; |
| 183 | (void)receiver_id; |
| 184 | return false; |
| 185 | } |
| 186 | |
J-Alves | 98ff956 | 2021-09-09 14:39:41 +0100 | [diff] [blame] | 187 | bool plat_ffa_notifications_get_from_sp( |
| 188 | struct vm_locked receiver_locked, ffa_vcpu_index_t vcpu_id, |
J-Alves | fa78209 | 2021-10-13 16:02:16 +0100 | [diff] [blame] | 189 | ffa_notifications_bitmap_t *from_sp, // NOLINT |
| 190 | struct ffa_value *ret) // NOLINT |
J-Alves | 98ff956 | 2021-09-09 14:39:41 +0100 | [diff] [blame] | 191 | { |
| 192 | (void)receiver_locked; |
| 193 | (void)vcpu_id; |
| 194 | (void)from_sp; |
| 195 | (void)ret; |
| 196 | |
| 197 | return false; |
| 198 | } |
| 199 | |
J-Alves | de7bd2f | 2021-09-09 19:54:35 +0100 | [diff] [blame] | 200 | bool plat_ffa_notification_set_forward(ffa_vm_id_t sender_vm_id, |
| 201 | ffa_vm_id_t receiver_vm_id, |
| 202 | uint32_t flags, |
| 203 | ffa_notifications_bitmap_t bitmap, |
| 204 | struct ffa_value *ret) |
| 205 | { |
| 206 | (void)sender_vm_id; |
| 207 | (void)receiver_vm_id; |
| 208 | (void)flags; |
| 209 | (void)bitmap; |
| 210 | (void)ret; |
| 211 | |
| 212 | return false; |
| 213 | } |
| 214 | |
J-Alves | a0f317d | 2021-06-09 13:31:59 +0100 | [diff] [blame] | 215 | struct ffa_value plat_ffa_notifications_bitmap_create( |
| 216 | ffa_vm_id_t vm_id, ffa_vcpu_count_t vcpu_count) |
| 217 | { |
| 218 | (void)vm_id; |
| 219 | (void)vcpu_count; |
| 220 | |
| 221 | return ffa_error(FFA_NOT_SUPPORTED); |
| 222 | } |
| 223 | |
| 224 | struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_vm_id_t vm_id) |
| 225 | { |
| 226 | (void)vm_id; |
| 227 | |
| 228 | return ffa_error(FFA_NOT_SUPPORTED); |
| 229 | } |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 230 | |
| 231 | struct vm_locked plat_ffa_vm_find_locked(ffa_vm_id_t vm_id) |
| 232 | { |
| 233 | (void)vm_id; |
| 234 | return (struct vm_locked){.vm = NULL}; |
| 235 | } |
| 236 | |
Federico Recanati | 8d8b1cf | 2022-04-14 13:16:00 +0200 | [diff] [blame^] | 237 | struct vm_locked plat_ffa_vm_find_locked_create(ffa_vm_id_t vm_id) |
| 238 | { |
| 239 | (void)vm_id; |
| 240 | return (struct vm_locked){.vm = NULL}; |
| 241 | } |
| 242 | |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 243 | bool plat_ffa_is_vm_id(ffa_vm_id_t vm_id) |
| 244 | { |
| 245 | (void)vm_id; |
| 246 | return false; |
| 247 | } |
J-Alves | c8e8a22 | 2021-06-08 17:33:52 +0100 | [diff] [blame] | 248 | |
J-Alves | fa78209 | 2021-10-13 16:02:16 +0100 | [diff] [blame] | 249 | bool plat_ffa_vm_notifications_info_get( // NOLINTNEXTLINE |
| 250 | uint16_t *ids, uint32_t *ids_count, // NOLINTNEXTLINE |
| 251 | uint32_t *lists_sizes, // NOLINTNEXTLINE |
| 252 | uint32_t *lists_count, const uint32_t ids_count_max) |
J-Alves | c8e8a22 | 2021-06-08 17:33:52 +0100 | [diff] [blame] | 253 | { |
| 254 | (void)ids; |
| 255 | (void)ids_count; |
| 256 | (void)lists_sizes; |
| 257 | (void)lists_count; |
| 258 | (void)ids_count_max; |
| 259 | |
| 260 | return false; |
| 261 | } |
Raghu Krishnamurthy | ea6d25f | 2021-09-14 15:27:06 -0700 | [diff] [blame] | 262 | |
| 263 | bool plat_ffa_is_mem_perm_get_valid(const struct vcpu *current) |
| 264 | { |
| 265 | (void)current; |
| 266 | return false; |
| 267 | } |
| 268 | |
| 269 | bool plat_ffa_is_mem_perm_set_valid(const struct vcpu *current) |
| 270 | { |
| 271 | (void)current; |
| 272 | return false; |
| 273 | } |
Madhukar Pappireddy | b11e0d1 | 2021-08-02 19:44:35 -0500 | [diff] [blame] | 274 | |
| 275 | /** |
| 276 | * Check if current VM can resume target VM/SP using FFA_RUN ABI. |
| 277 | */ |
| 278 | 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] | 279 | ffa_vcpu_index_t vcpu_idx, struct ffa_value *run_ret, |
| 280 | struct vcpu **next) |
Madhukar Pappireddy | b11e0d1 | 2021-08-02 19:44:35 -0500 | [diff] [blame] | 281 | { |
| 282 | (void)current; |
| 283 | (void)target_vm_id; |
| 284 | (void)run_ret; |
| 285 | (void)next; |
Raghu Krishnamurthy | 048d63f | 2021-12-11 12:45:41 -0800 | [diff] [blame] | 286 | (void)vcpu_idx; |
Madhukar Pappireddy | b11e0d1 | 2021-08-02 19:44:35 -0500 | [diff] [blame] | 287 | return true; |
| 288 | } |
J-Alves | ca058c2 | 2021-09-10 14:02:07 +0100 | [diff] [blame] | 289 | |
| 290 | void plat_ffa_notification_info_get_forward( // NOLINTNEXTLINE |
| 291 | uint16_t *ids, uint32_t *ids_count, // NOLINTNEXTLINE |
| 292 | uint32_t *lists_sizes, uint32_t *lists_count, |
| 293 | const uint32_t ids_count_max) |
| 294 | { |
| 295 | (void)ids; |
| 296 | (void)ids_count; |
| 297 | (void)lists_sizes; |
| 298 | (void)lists_count; |
| 299 | (void)ids_count_max; |
| 300 | } |
J-Alves | 1339402 | 2021-06-30 13:48:49 +0100 | [diff] [blame] | 301 | |
| 302 | void plat_ffa_sri_state_set(enum plat_ffa_sri_state state) |
| 303 | { |
| 304 | (void)state; |
| 305 | } |
| 306 | |
| 307 | void plat_ffa_sri_trigger_if_delayed(struct cpu *cpu) |
| 308 | { |
| 309 | (void)cpu; |
| 310 | } |
| 311 | |
| 312 | void plat_ffa_sri_trigger_not_delayed(struct cpu *cpu) |
| 313 | { |
| 314 | (void)cpu; |
| 315 | } |
| 316 | |
| 317 | void plat_ffa_sri_init(struct cpu *cpu) |
| 318 | { |
| 319 | (void)cpu; |
| 320 | } |
J-Alves | 7461ef2 | 2021-10-18 17:21:33 +0100 | [diff] [blame] | 321 | |
J-Alves | 6e2abc6 | 2021-12-02 14:58:56 +0000 | [diff] [blame] | 322 | bool plat_ffa_inject_notification_pending_interrupt( |
| 323 | struct vcpu_locked target_locked, struct vcpu *current, |
| 324 | struct vm_locked receiver_locked) |
J-Alves | 7461ef2 | 2021-10-18 17:21:33 +0100 | [diff] [blame] | 325 | { |
J-Alves | 6e2abc6 | 2021-12-02 14:58:56 +0000 | [diff] [blame] | 326 | (void)target_locked; |
J-Alves | 7461ef2 | 2021-10-18 17:21:33 +0100 | [diff] [blame] | 327 | (void)current; |
J-Alves | 6e2abc6 | 2021-12-02 14:58:56 +0000 | [diff] [blame] | 328 | (void)receiver_locked; |
| 329 | |
| 330 | return false; |
J-Alves | 7461ef2 | 2021-10-18 17:21:33 +0100 | [diff] [blame] | 331 | } |
Olivier Deprez | e562e54 | 2020-06-11 17:31:54 +0200 | [diff] [blame] | 332 | |
| 333 | void plat_ffa_partition_info_get_forward( // NOLINTNEXTLINE |
| 334 | const struct ffa_uuid *uuid, // NOLINTNEXTLINE |
Daniel Boulby | b46cad1 | 2021-12-13 17:47:21 +0000 | [diff] [blame] | 335 | const uint32_t flags, // NOLINTNEXTLINE |
Olivier Deprez | e562e54 | 2020-06-11 17:31:54 +0200 | [diff] [blame] | 336 | struct ffa_partition_info *partitions, ffa_vm_count_t *ret_count) |
| 337 | { |
| 338 | (void)uuid; |
Daniel Boulby | b46cad1 | 2021-12-13 17:47:21 +0000 | [diff] [blame] | 339 | (void)flags; |
Olivier Deprez | e562e54 | 2020-06-11 17:31:54 +0200 | [diff] [blame] | 340 | (void)partitions; |
| 341 | (void)ret_count; |
| 342 | } |
Olivier Deprez | d614d32 | 2021-06-18 15:21:00 +0200 | [diff] [blame] | 343 | |
| 344 | bool plat_ffa_is_secondary_ep_register_supported(void) |
| 345 | { |
| 346 | return false; |
| 347 | } |
Madhukar Pappireddy | 5522c67 | 2021-12-17 16:35:51 -0600 | [diff] [blame] | 348 | bool plat_ffa_msg_wait_prepare(struct vcpu *current, struct vcpu **next, |
| 349 | struct ffa_value *ret_args) |
| 350 | { |
| 351 | (void)current; |
| 352 | (void)next; |
| 353 | (void)ret_args; |
| 354 | |
| 355 | return false; |
| 356 | } |