blob: b6a6a1aaf4021ab1546b9e44d3f2d2acb7a025f1 [file] [log] [blame]
Daniel Boulbyb2fb80e2021-02-03 15:09:23 +00001/*
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-Alvesfa782092021-10-13 16:02:16 +010011#include "hf/arch/plat/ffa.h"
12
J-Alvesa0f317d2021-06-09 13:31:59 +010013#include "hf/ffa_internal.h"
Olivier Deprez55a189e2021-06-09 15:45:27 +020014#include "hf/vcpu.h"
J-Alvesc003a7a2021-03-18 13:06:53 +000015#include "hf/vm.h"
Daniel Boulbyb2fb80e2021-02-03 15:09:23 +000016
Daniel Boulby87b2dc82021-08-04 14:07:43 +010017struct ffa_value arch_ffa_features(uint32_t function_id)
18{
19 (void)function_id;
20 return ffa_error(FFA_NOT_SUPPORTED);
21}
22
Daniel Boulbyb2fb80e2021-02-03 15:09:23 +000023ffa_vm_id_t arch_ffa_spmc_id_get(void)
24{
25 return HF_SPMC_VM_ID;
26}
Olivier Deprez55a189e2021-06-09 15:45:27 +020027
28void plat_ffa_log_init(void)
29{
30}
31
Maksims Svecovsa3d570c2021-12-08 11:16:32 +000032bool 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 Deprez55a189e2021-06-09 15:45:27 +020041bool 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-Alves439ac972021-11-18 17:32:03 +000052bool 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 Deprez55a189e2021-06-09 15:45:27 +020061bool 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 Krishnamurthy62f97a72021-07-27 02:14:59 -070072bool 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 Recanati10bd06c2022-02-23 17:32:59 +010082void plat_ffa_vm_destroy(struct vm_locked to_destroy_locked)
83{
84 (void)to_destroy_locked;
85}
86
J-Alves70079932022-12-07 17:32:20 +000087void plat_ffa_rxtx_unmap_forward(struct vm_locked vm_locked)
Federico Recanati8da9e332022-02-10 11:00:17 +010088{
J-Alves70079932022-12-07 17:32:20 +000089 (void)vm_locked;
Federico Recanati8da9e332022-02-10 11:00:17 +010090}
91
Olivier Deprez55a189e2021-06-09 15:45:27 +020092bool 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 Recanati7bef0b92022-03-17 14:56:22 +0100102bool plat_ffa_rx_release_forward(struct vm_locked vm_locked,
103 struct ffa_value *ret)
104{
105 (void)vm_locked;
106 (void)ret;
107
108 return false;
109}
110
111bool plat_ffa_rx_release_forwarded(struct vm_locked vm_locked)
112{
113 (void)vm_locked;
114
115 return false;
116}
117
Federico Recanati644f0462022-03-17 12:04:00 +0100118bool plat_ffa_acquire_receiver_rx(struct vm_locked to_locked,
119 struct ffa_value *ret)
120{
121 (void)to_locked;
122 (void)ret;
123
124 return false;
125}
126
Federico Recanati25053ee2022-03-14 15:01:53 +0100127bool plat_ffa_is_indirect_msg_supported(struct vm_locked sender_locked,
128 struct vm_locked receiver_locked)
129{
130 (void)sender_locked;
131 (void)receiver_locked;
132
133 return false;
134}
135
136bool plat_ffa_msg_send2_forward(ffa_vm_id_t receiver_vm_id,
137 ffa_vm_id_t sender_vm_id, struct ffa_value *ret)
138{
139 (void)receiver_vm_id;
140 (void)sender_vm_id;
141 (void)ret;
142
143 return false;
144}
145
Olivier Deprez55a189e2021-06-09 15:45:27 +0200146ffa_memory_handle_t plat_ffa_memory_handle_make(uint64_t index)
147{
148 return index;
149}
150
151bool plat_ffa_memory_handle_allocated_by_current_world(
152 ffa_memory_handle_t handle)
153{
154 (void)handle;
155 return false;
156}
Maksims Svecovsb596eab2021-04-27 00:52:27 +0100157
J-Alves7db32002021-12-14 14:44:50 +0000158uint32_t plat_ffa_other_world_mode(void)
159{
160 return 0U;
161}
162
163uint32_t plat_ffa_owner_world_mode(ffa_vm_id_t owner_id)
164{
165 (void)owner_id;
166 return 0U;
167}
168
J-Alvesc003a7a2021-03-18 13:06:53 +0000169bool plat_ffa_is_notifications_bind_valid(struct vcpu *current,
170 ffa_vm_id_t sender_id,
171 ffa_vm_id_t receiver_id)
172{
173 (void)current;
174 (void)sender_id;
175 (void)receiver_id;
176 return false;
177}
178
J-Alvesb15e9402021-09-08 11:44:42 +0100179bool plat_ffa_notifications_update_bindings_forward(
180 ffa_vm_id_t receiver_id, ffa_vm_id_t sender_id, uint32_t flags,
181 ffa_notifications_bitmap_t bitmap, bool is_bind, struct ffa_value *ret)
182{
183 (void)ret;
184 (void)receiver_id;
185 (void)sender_id;
186 (void)flags;
187 (void)bitmap;
188 (void)is_bind;
189 (void)ret;
190
191 return false;
192}
193
Federico Recanati8d8b1cf2022-04-14 13:16:00 +0200194void plat_ffa_rxtx_map_forward(struct vm_locked vm_locked)
195{
196 (void)vm_locked;
197}
198
Maksims Svecovsb596eab2021-04-27 00:52:27 +0100199ffa_partition_properties_t plat_ffa_partition_properties(
J-Alvesfa782092021-10-13 16:02:16 +0100200 ffa_vm_id_t vm_id, const struct vm *target)
Maksims Svecovsb596eab2021-04-27 00:52:27 +0100201{
J-Alvesfa782092021-10-13 16:02:16 +0100202 (void)vm_id;
Maksims Svecovsb596eab2021-04-27 00:52:27 +0100203 (void)target;
204 return 0;
205}
Maksims Svecovs9ddf86a2021-05-06 17:17:21 +0100206
207bool plat_ffa_vm_managed_exit_supported(struct vm *vm)
208{
209 (void)vm;
210 return false;
211}
J-Alvesa0f317d2021-06-09 13:31:59 +0100212
213bool plat_ffa_is_notifications_create_valid(struct vcpu *current,
214 ffa_vm_id_t vm_id)
215{
216 (void)current;
217 (void)vm_id;
218
219 return false;
220}
221
J-Alvesaa79c012021-07-09 14:29:45 +0100222bool plat_ffa_is_notification_set_valid(struct vcpu *current,
223 ffa_vm_id_t sender_id,
224 ffa_vm_id_t receiver_id)
225{
226 (void)current;
227 (void)sender_id;
228 (void)receiver_id;
229 return false;
230}
231
232bool plat_ffa_is_notification_get_valid(struct vcpu *current,
J-Alvesfc95a302022-04-22 14:18:23 +0100233 ffa_vm_id_t receiver_id, uint32_t flags)
J-Alvesaa79c012021-07-09 14:29:45 +0100234{
J-Alvesfc95a302022-04-22 14:18:23 +0100235 (void)flags;
J-Alvesaa79c012021-07-09 14:29:45 +0100236 (void)current;
237 (void)receiver_id;
238 return false;
239}
240
J-Alves98ff9562021-09-09 14:39:41 +0100241bool plat_ffa_notifications_get_from_sp(
242 struct vm_locked receiver_locked, ffa_vcpu_index_t vcpu_id,
J-Alvesfa782092021-10-13 16:02:16 +0100243 ffa_notifications_bitmap_t *from_sp, // NOLINT
244 struct ffa_value *ret) // NOLINT
J-Alves98ff9562021-09-09 14:39:41 +0100245{
246 (void)receiver_locked;
247 (void)vcpu_id;
248 (void)from_sp;
249 (void)ret;
250
251 return false;
252}
253
J-Alvesd605a092022-03-28 14:20:48 +0100254bool plat_ffa_notifications_get_framework_notifications(
255 struct vm_locked receiver_locked,
256 ffa_notifications_bitmap_t *from_fwk, // NOLINT
257 uint32_t flags, ffa_vcpu_index_t vcpu_id, struct ffa_value *ret)
258{
259 (void)receiver_locked;
260 (void)from_fwk;
261 (void)flags;
262 (void)vcpu_id;
263 (void)ret;
264
265 return false;
266}
267
J-Alvesde7bd2f2021-09-09 19:54:35 +0100268bool plat_ffa_notification_set_forward(ffa_vm_id_t sender_vm_id,
269 ffa_vm_id_t receiver_vm_id,
270 uint32_t flags,
271 ffa_notifications_bitmap_t bitmap,
272 struct ffa_value *ret)
273{
274 (void)sender_vm_id;
275 (void)receiver_vm_id;
276 (void)flags;
277 (void)bitmap;
278 (void)ret;
279
280 return false;
281}
282
J-Alvesa0f317d2021-06-09 13:31:59 +0100283struct ffa_value plat_ffa_notifications_bitmap_create(
284 ffa_vm_id_t vm_id, ffa_vcpu_count_t vcpu_count)
285{
286 (void)vm_id;
287 (void)vcpu_count;
288
289 return ffa_error(FFA_NOT_SUPPORTED);
290}
291
292struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_vm_id_t vm_id)
293{
294 (void)vm_id;
295
296 return ffa_error(FFA_NOT_SUPPORTED);
297}
J-Alvesc003a7a2021-03-18 13:06:53 +0000298
299struct vm_locked plat_ffa_vm_find_locked(ffa_vm_id_t vm_id)
300{
301 (void)vm_id;
302 return (struct vm_locked){.vm = NULL};
303}
304
Federico Recanati8d8b1cf2022-04-14 13:16:00 +0200305struct vm_locked plat_ffa_vm_find_locked_create(ffa_vm_id_t vm_id)
306{
307 (void)vm_id;
308 return (struct vm_locked){.vm = NULL};
309}
310
J-Alvesc003a7a2021-03-18 13:06:53 +0000311bool plat_ffa_is_vm_id(ffa_vm_id_t vm_id)
312{
313 (void)vm_id;
314 return false;
315}
J-Alvesc8e8a222021-06-08 17:33:52 +0100316
J-Alvesfa782092021-10-13 16:02:16 +0100317bool plat_ffa_vm_notifications_info_get( // NOLINTNEXTLINE
318 uint16_t *ids, uint32_t *ids_count, // NOLINTNEXTLINE
319 uint32_t *lists_sizes, // NOLINTNEXTLINE
320 uint32_t *lists_count, const uint32_t ids_count_max)
J-Alvesc8e8a222021-06-08 17:33:52 +0100321{
322 (void)ids;
323 (void)ids_count;
324 (void)lists_sizes;
325 (void)lists_count;
326 (void)ids_count_max;
327
328 return false;
329}
Raghu Krishnamurthyea6d25f2021-09-14 15:27:06 -0700330
331bool plat_ffa_is_mem_perm_get_valid(const struct vcpu *current)
332{
333 (void)current;
334 return false;
335}
336
337bool plat_ffa_is_mem_perm_set_valid(const struct vcpu *current)
338{
339 (void)current;
340 return false;
341}
Madhukar Pappireddyb11e0d12021-08-02 19:44:35 -0500342
343/**
344 * Check if current VM can resume target VM/SP using FFA_RUN ABI.
345 */
346bool plat_ffa_run_checks(struct vcpu *current, ffa_vm_id_t target_vm_id,
Raghu Krishnamurthy048d63f2021-12-11 12:45:41 -0800347 ffa_vcpu_index_t vcpu_idx, struct ffa_value *run_ret,
348 struct vcpu **next)
Madhukar Pappireddyb11e0d12021-08-02 19:44:35 -0500349{
350 (void)current;
351 (void)target_vm_id;
352 (void)run_ret;
353 (void)next;
Raghu Krishnamurthy048d63f2021-12-11 12:45:41 -0800354 (void)vcpu_idx;
Madhukar Pappireddyb11e0d12021-08-02 19:44:35 -0500355 return true;
356}
J-Alvesca058c22021-09-10 14:02:07 +0100357
358void plat_ffa_notification_info_get_forward( // NOLINTNEXTLINE
359 uint16_t *ids, uint32_t *ids_count, // NOLINTNEXTLINE
360 uint32_t *lists_sizes, uint32_t *lists_count,
361 const uint32_t ids_count_max)
362{
363 (void)ids;
364 (void)ids_count;
365 (void)lists_sizes;
366 (void)lists_count;
367 (void)ids_count_max;
368}
J-Alves13394022021-06-30 13:48:49 +0100369
370void plat_ffa_sri_state_set(enum plat_ffa_sri_state state)
371{
372 (void)state;
373}
374
375void plat_ffa_sri_trigger_if_delayed(struct cpu *cpu)
376{
377 (void)cpu;
378}
379
380void plat_ffa_sri_trigger_not_delayed(struct cpu *cpu)
381{
382 (void)cpu;
383}
384
J-Alves6e2abc62021-12-02 14:58:56 +0000385bool plat_ffa_inject_notification_pending_interrupt(
386 struct vcpu_locked target_locked, struct vcpu *current,
387 struct vm_locked receiver_locked)
J-Alves7461ef22021-10-18 17:21:33 +0100388{
J-Alves6e2abc62021-12-02 14:58:56 +0000389 (void)target_locked;
J-Alves7461ef22021-10-18 17:21:33 +0100390 (void)current;
J-Alves6e2abc62021-12-02 14:58:56 +0000391 (void)receiver_locked;
392
393 return false;
J-Alves7461ef22021-10-18 17:21:33 +0100394}
Olivier Depreze562e542020-06-11 17:31:54 +0200395
Raghu Krishnamurthyef432cb2022-12-29 06:56:32 -0800396bool plat_ffa_partition_info_get_regs_forward( // NOLINTNEXTLINE
397 const struct ffa_uuid *uuid,
398 const uint16_t start_index, // NOLINTNEXTLINE
399 const uint16_t tag,
400 struct ffa_partition_info *partitions, // NOLINTNEXTLINE
401 uint16_t partitions_len, ffa_vm_count_t *ret_count)
402{
403 (void)uuid;
404 (void)start_index;
405 (void)tag;
406 (void)partitions;
407 (void)partitions_len;
408 (void)ret_count;
409 return true;
410}
411
Olivier Depreze562e542020-06-11 17:31:54 +0200412void plat_ffa_partition_info_get_forward( // NOLINTNEXTLINE
413 const struct ffa_uuid *uuid, // NOLINTNEXTLINE
Daniel Boulbyb46cad12021-12-13 17:47:21 +0000414 const uint32_t flags, // NOLINTNEXTLINE
Olivier Depreze562e542020-06-11 17:31:54 +0200415 struct ffa_partition_info *partitions, ffa_vm_count_t *ret_count)
416{
417 (void)uuid;
Daniel Boulbyb46cad12021-12-13 17:47:21 +0000418 (void)flags;
Olivier Depreze562e542020-06-11 17:31:54 +0200419 (void)partitions;
420 (void)ret_count;
421}
Olivier Deprezd614d322021-06-18 15:21:00 +0200422
423bool plat_ffa_is_secondary_ep_register_supported(void)
424{
425 return false;
426}
Madhukar Pappireddydd883202022-10-24 16:49:28 -0500427
428struct ffa_value plat_ffa_msg_wait_prepare(struct vcpu *current,
429 struct vcpu **next)
Madhukar Pappireddy5522c672021-12-17 16:35:51 -0600430{
431 (void)current;
432 (void)next;
Madhukar Pappireddy5522c672021-12-17 16:35:51 -0600433
Madhukar Pappireddydd883202022-10-24 16:49:28 -0500434 return (struct ffa_value){.func = FFA_INTERRUPT_32};
Madhukar Pappireddy5522c672021-12-17 16:35:51 -0600435}
Madhukar Pappireddy0ea239a2022-06-21 17:26:57 -0500436
437bool plat_ffa_check_runtime_state_transition(struct vcpu *current,
438 ffa_vm_id_t vm_id,
439 ffa_vm_id_t receiver_vm_id,
440 struct vcpu *receiver_vcpu,
441 uint32_t func, // NOLINTNEXTLINE
442 enum vcpu_state *next_state)
443{
444 /* Perform state transition checks only for Secure Partitions. */
445 (void)current;
446 (void)vm_id;
447 (void)receiver_vm_id;
448 (void)receiver_vcpu;
449 (void)func;
450 (void)next_state;
451
452 return true;
453}
Madhukar Pappireddy49fe6702022-06-21 17:52:23 -0500454
Madhukar Pappireddy1480fce2022-06-21 18:09:25 -0500455void plat_ffa_init_schedule_mode_ffa_run(struct vcpu *current,
456 struct vcpu_locked target_locked)
457{
458 /* Scheduling mode not supported in the Hypervisor/VMs. */
459 (void)current;
460 (void)target_locked;
461}
462
Madhukar Pappireddy49fe6702022-06-21 17:52:23 -0500463void plat_ffa_wind_call_chain_ffa_direct_req(
464 struct vcpu_locked current_locked,
465 struct vcpu_locked receiver_vcpu_locked)
466{
467 /* Calls chains not supported in the Hypervisor/VMs. */
468 (void)current_locked;
469 (void)receiver_vcpu_locked;
470}
Madhukar Pappireddyc0fb87e2022-06-21 17:59:15 -0500471
472void plat_ffa_unwind_call_chain_ffa_direct_resp(struct vcpu *current,
473 struct vcpu *next)
474{
475 /* Calls chains not supported in the Hypervisor/VMs. */
476 (void)current;
477 (void)next;
478}
Madhukar Pappireddy046dad02022-06-21 18:43:33 -0500479
Madhukar Pappireddy2f76e492022-09-06 15:21:59 -0500480bool plat_ffa_intercept_direct_response(struct vcpu_locked current_locked,
481 struct vcpu **next,
482 struct ffa_value to_ret,
483 struct ffa_value *signal_interrupt)
484{
485 /*
486 * Only applicable to SPMC as it signals virtual secure interrupt to
487 * S-EL0 partitions.
488 */
489 (void)current_locked;
490 (void)next;
491 (void)to_ret;
492 (void)signal_interrupt;
493
494 return false;
495}
496
Madhukar Pappireddy486360d2022-09-06 15:32:24 -0500497void plat_ffa_enable_virtual_interrupts(struct vcpu_locked current_locked,
498 struct vm_locked vm_locked)
Madhukar Pappireddy046dad02022-06-21 18:43:33 -0500499{
500 (void)current_locked;
Madhukar Pappireddy486360d2022-09-06 15:32:24 -0500501 (void)vm_locked;
Madhukar Pappireddy046dad02022-06-21 18:43:33 -0500502}
J-Alves66652252022-07-06 09:49:51 +0100503
Madhukar Pappireddy5fd32482022-01-07 14:53:26 -0600504bool plat_ffa_is_direct_response_interrupted(struct vcpu *current)
505{
506 (void)current;
507 return false;
508}
509
J-Alves66652252022-07-06 09:49:51 +0100510struct ffa_value plat_ffa_other_world_mem_send(
511 struct vm *from, uint32_t share_func,
512 struct ffa_memory_region **memory_region, uint32_t length,
513 uint32_t fragment_length, struct mpool *page_pool)
514{
515 (void)from;
516 (void)memory_region;
517 (void)length;
518 (void)fragment_length;
519 (void)page_pool;
520 (void)share_func;
521
522 return (struct ffa_value){0};
523}
J-Alvesfc19b372022-07-06 12:17:35 +0100524
525struct ffa_value plat_ffa_other_world_mem_reclaim(
526 struct vm *to, ffa_memory_handle_t handle,
527 ffa_memory_region_flags_t flags, struct mpool *page_pool)
528{
529 (void)handle;
530 (void)flags;
531 (void)page_pool;
532 (void)to;
533
534 return ffa_error(FFA_INVALID_PARAMETERS);
535}
J-Alvesb5084cf2022-07-06 14:20:12 +0100536
537struct ffa_value plat_ffa_other_world_mem_retrieve(
538 struct vm_locked to_locked, struct ffa_memory_region *retrieve_request,
539 uint32_t length, struct mpool *page_pool)
540{
541 (void)to_locked;
542 (void)retrieve_request;
543 (void)length;
544 (void)page_pool;
545
546 return ffa_error(FFA_INVALID_PARAMETERS);
547}
J-Alvesfdd29272022-07-19 13:16:31 +0100548
549struct ffa_value plat_ffa_other_world_mem_send_continue(
550 struct vm *from, void *fragment, uint32_t fragment_length,
551 ffa_memory_handle_t handle, struct mpool *page_pool)
552{
553 (void)from;
554 (void)fragment;
555 (void)fragment_length;
556 (void)handle;
557 (void)page_pool;
558
559 return ffa_error(FFA_INVALID_PARAMETERS);
560}
J-Alves27b71962022-12-12 15:29:58 +0000561
562struct ffa_value plat_ffa_msg_send(ffa_vm_id_t sender_vm_id,
563 ffa_vm_id_t receiver_vm_id, uint32_t size,
564 struct vcpu *current, struct vcpu **next)
565{
566 (void)sender_vm_id;
567 (void)receiver_vm_id;
568 (void)size;
569 (void)current;
570 (void)next;
571
572 return ffa_error(FFA_NOT_SUPPORTED);
573}