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 | |
| 32 | bool plat_ffa_is_direct_request_valid(struct vcpu *current, |
| 33 | ffa_vm_id_t sender_vm_id, |
| 34 | ffa_vm_id_t receiver_vm_id) |
| 35 | { |
| 36 | (void)current; |
| 37 | (void)sender_vm_id; |
| 38 | (void)receiver_vm_id; |
| 39 | |
| 40 | return true; |
| 41 | } |
| 42 | |
J-Alves | 439ac97 | 2021-11-18 17:32:03 +0000 | [diff] [blame^] | 43 | bool plat_ffa_is_direct_request_supported(struct vm *sender_vm, |
| 44 | struct vm *receiver_vm) |
| 45 | { |
| 46 | (void)sender_vm; |
| 47 | (void)receiver_vm; |
| 48 | |
| 49 | return false; |
| 50 | } |
| 51 | |
Olivier Deprez | 55a189e | 2021-06-09 15:45:27 +0200 | [diff] [blame] | 52 | bool plat_ffa_is_direct_response_valid(struct vcpu *current, |
| 53 | ffa_vm_id_t sender_vm_id, |
| 54 | ffa_vm_id_t receiver_vm_id) |
| 55 | { |
| 56 | (void)current; |
| 57 | (void)sender_vm_id; |
| 58 | (void)receiver_vm_id; |
| 59 | |
| 60 | return true; |
| 61 | } |
| 62 | |
Raghu Krishnamurthy | 62f97a7 | 2021-07-27 02:14:59 -0700 | [diff] [blame] | 63 | bool plat_ffa_run_forward(ffa_vm_id_t vm_id, ffa_vcpu_index_t vcpu_idx, |
| 64 | struct ffa_value *ret) |
| 65 | { |
| 66 | (void)vm_id; |
| 67 | (void)vcpu_idx; |
| 68 | (void)ret; |
| 69 | |
| 70 | return false; |
| 71 | } |
| 72 | |
Olivier Deprez | 55a189e | 2021-06-09 15:45:27 +0200 | [diff] [blame] | 73 | bool plat_ffa_direct_request_forward(ffa_vm_id_t receiver_vm_id, |
| 74 | struct ffa_value args, |
| 75 | struct ffa_value *ret) |
| 76 | { |
| 77 | (void)receiver_vm_id; |
| 78 | (void)args; |
| 79 | (void)ret; |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | ffa_memory_handle_t plat_ffa_memory_handle_make(uint64_t index) |
| 84 | { |
| 85 | return index; |
| 86 | } |
| 87 | |
| 88 | bool plat_ffa_memory_handle_allocated_by_current_world( |
| 89 | ffa_memory_handle_t handle) |
| 90 | { |
| 91 | (void)handle; |
| 92 | return false; |
| 93 | } |
Maksims Svecovs | b596eab | 2021-04-27 00:52:27 +0100 | [diff] [blame] | 94 | |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 95 | bool plat_ffa_is_notifications_bind_valid(struct vcpu *current, |
| 96 | ffa_vm_id_t sender_id, |
| 97 | ffa_vm_id_t receiver_id) |
| 98 | { |
| 99 | (void)current; |
| 100 | (void)sender_id; |
| 101 | (void)receiver_id; |
| 102 | return false; |
| 103 | } |
| 104 | |
J-Alves | b15e940 | 2021-09-08 11:44:42 +0100 | [diff] [blame] | 105 | bool plat_ffa_notifications_update_bindings_forward( |
| 106 | ffa_vm_id_t receiver_id, ffa_vm_id_t sender_id, uint32_t flags, |
| 107 | ffa_notifications_bitmap_t bitmap, bool is_bind, struct ffa_value *ret) |
| 108 | { |
| 109 | (void)ret; |
| 110 | (void)receiver_id; |
| 111 | (void)sender_id; |
| 112 | (void)flags; |
| 113 | (void)bitmap; |
| 114 | (void)is_bind; |
| 115 | (void)ret; |
| 116 | |
| 117 | return false; |
| 118 | } |
| 119 | |
Maksims Svecovs | b596eab | 2021-04-27 00:52:27 +0100 | [diff] [blame] | 120 | ffa_partition_properties_t plat_ffa_partition_properties( |
J-Alves | fa78209 | 2021-10-13 16:02:16 +0100 | [diff] [blame] | 121 | ffa_vm_id_t vm_id, const struct vm *target) |
Maksims Svecovs | b596eab | 2021-04-27 00:52:27 +0100 | [diff] [blame] | 122 | { |
J-Alves | fa78209 | 2021-10-13 16:02:16 +0100 | [diff] [blame] | 123 | (void)vm_id; |
Maksims Svecovs | b596eab | 2021-04-27 00:52:27 +0100 | [diff] [blame] | 124 | (void)target; |
| 125 | return 0; |
| 126 | } |
Maksims Svecovs | 9ddf86a | 2021-05-06 17:17:21 +0100 | [diff] [blame] | 127 | |
| 128 | bool plat_ffa_vm_managed_exit_supported(struct vm *vm) |
| 129 | { |
| 130 | (void)vm; |
| 131 | return false; |
| 132 | } |
J-Alves | a0f317d | 2021-06-09 13:31:59 +0100 | [diff] [blame] | 133 | |
| 134 | bool plat_ffa_is_notifications_create_valid(struct vcpu *current, |
| 135 | ffa_vm_id_t vm_id) |
| 136 | { |
| 137 | (void)current; |
| 138 | (void)vm_id; |
| 139 | |
| 140 | return false; |
| 141 | } |
| 142 | |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 143 | bool plat_ffa_is_notification_set_valid(struct vcpu *current, |
| 144 | ffa_vm_id_t sender_id, |
| 145 | ffa_vm_id_t receiver_id) |
| 146 | { |
| 147 | (void)current; |
| 148 | (void)sender_id; |
| 149 | (void)receiver_id; |
| 150 | return false; |
| 151 | } |
| 152 | |
| 153 | bool plat_ffa_is_notification_get_valid(struct vcpu *current, |
| 154 | ffa_vm_id_t receiver_id) |
| 155 | { |
| 156 | (void)current; |
| 157 | (void)receiver_id; |
| 158 | return false; |
| 159 | } |
| 160 | |
J-Alves | 98ff956 | 2021-09-09 14:39:41 +0100 | [diff] [blame] | 161 | bool plat_ffa_notifications_get_from_sp( |
| 162 | struct vm_locked receiver_locked, ffa_vcpu_index_t vcpu_id, |
J-Alves | fa78209 | 2021-10-13 16:02:16 +0100 | [diff] [blame] | 163 | ffa_notifications_bitmap_t *from_sp, // NOLINT |
| 164 | struct ffa_value *ret) // NOLINT |
J-Alves | 98ff956 | 2021-09-09 14:39:41 +0100 | [diff] [blame] | 165 | { |
| 166 | (void)receiver_locked; |
| 167 | (void)vcpu_id; |
| 168 | (void)from_sp; |
| 169 | (void)ret; |
| 170 | |
| 171 | return false; |
| 172 | } |
| 173 | |
J-Alves | de7bd2f | 2021-09-09 19:54:35 +0100 | [diff] [blame] | 174 | bool plat_ffa_notification_set_forward(ffa_vm_id_t sender_vm_id, |
| 175 | ffa_vm_id_t receiver_vm_id, |
| 176 | uint32_t flags, |
| 177 | ffa_notifications_bitmap_t bitmap, |
| 178 | struct ffa_value *ret) |
| 179 | { |
| 180 | (void)sender_vm_id; |
| 181 | (void)receiver_vm_id; |
| 182 | (void)flags; |
| 183 | (void)bitmap; |
| 184 | (void)ret; |
| 185 | |
| 186 | return false; |
| 187 | } |
| 188 | |
J-Alves | a0f317d | 2021-06-09 13:31:59 +0100 | [diff] [blame] | 189 | struct ffa_value plat_ffa_notifications_bitmap_create( |
| 190 | ffa_vm_id_t vm_id, ffa_vcpu_count_t vcpu_count) |
| 191 | { |
| 192 | (void)vm_id; |
| 193 | (void)vcpu_count; |
| 194 | |
| 195 | return ffa_error(FFA_NOT_SUPPORTED); |
| 196 | } |
| 197 | |
| 198 | struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_vm_id_t vm_id) |
| 199 | { |
| 200 | (void)vm_id; |
| 201 | |
| 202 | return ffa_error(FFA_NOT_SUPPORTED); |
| 203 | } |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 204 | |
| 205 | struct vm_locked plat_ffa_vm_find_locked(ffa_vm_id_t vm_id) |
| 206 | { |
| 207 | (void)vm_id; |
| 208 | return (struct vm_locked){.vm = NULL}; |
| 209 | } |
| 210 | |
| 211 | bool plat_ffa_is_vm_id(ffa_vm_id_t vm_id) |
| 212 | { |
| 213 | (void)vm_id; |
| 214 | return false; |
| 215 | } |
J-Alves | c8e8a22 | 2021-06-08 17:33:52 +0100 | [diff] [blame] | 216 | |
J-Alves | fa78209 | 2021-10-13 16:02:16 +0100 | [diff] [blame] | 217 | bool plat_ffa_vm_notifications_info_get( // NOLINTNEXTLINE |
| 218 | uint16_t *ids, uint32_t *ids_count, // NOLINTNEXTLINE |
| 219 | uint32_t *lists_sizes, // NOLINTNEXTLINE |
| 220 | uint32_t *lists_count, const uint32_t ids_count_max) |
J-Alves | c8e8a22 | 2021-06-08 17:33:52 +0100 | [diff] [blame] | 221 | { |
| 222 | (void)ids; |
| 223 | (void)ids_count; |
| 224 | (void)lists_sizes; |
| 225 | (void)lists_count; |
| 226 | (void)ids_count_max; |
| 227 | |
| 228 | return false; |
| 229 | } |
Raghu Krishnamurthy | ea6d25f | 2021-09-14 15:27:06 -0700 | [diff] [blame] | 230 | |
| 231 | bool plat_ffa_is_mem_perm_get_valid(const struct vcpu *current) |
| 232 | { |
| 233 | (void)current; |
| 234 | return false; |
| 235 | } |
| 236 | |
| 237 | bool plat_ffa_is_mem_perm_set_valid(const struct vcpu *current) |
| 238 | { |
| 239 | (void)current; |
| 240 | return false; |
| 241 | } |
Madhukar Pappireddy | b11e0d1 | 2021-08-02 19:44:35 -0500 | [diff] [blame] | 242 | |
| 243 | /** |
| 244 | * Check if current VM can resume target VM/SP using FFA_RUN ABI. |
| 245 | */ |
| 246 | 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] | 247 | ffa_vcpu_index_t vcpu_idx, struct ffa_value *run_ret, |
| 248 | struct vcpu **next) |
Madhukar Pappireddy | b11e0d1 | 2021-08-02 19:44:35 -0500 | [diff] [blame] | 249 | { |
| 250 | (void)current; |
| 251 | (void)target_vm_id; |
| 252 | (void)run_ret; |
| 253 | (void)next; |
Raghu Krishnamurthy | 048d63f | 2021-12-11 12:45:41 -0800 | [diff] [blame] | 254 | (void)vcpu_idx; |
Madhukar Pappireddy | b11e0d1 | 2021-08-02 19:44:35 -0500 | [diff] [blame] | 255 | return true; |
| 256 | } |
J-Alves | ca058c2 | 2021-09-10 14:02:07 +0100 | [diff] [blame] | 257 | |
| 258 | void plat_ffa_notification_info_get_forward( // NOLINTNEXTLINE |
| 259 | uint16_t *ids, uint32_t *ids_count, // NOLINTNEXTLINE |
| 260 | uint32_t *lists_sizes, uint32_t *lists_count, |
| 261 | const uint32_t ids_count_max) |
| 262 | { |
| 263 | (void)ids; |
| 264 | (void)ids_count; |
| 265 | (void)lists_sizes; |
| 266 | (void)lists_count; |
| 267 | (void)ids_count_max; |
| 268 | } |
J-Alves | 1339402 | 2021-06-30 13:48:49 +0100 | [diff] [blame] | 269 | |
| 270 | void plat_ffa_sri_state_set(enum plat_ffa_sri_state state) |
| 271 | { |
| 272 | (void)state; |
| 273 | } |
| 274 | |
| 275 | void plat_ffa_sri_trigger_if_delayed(struct cpu *cpu) |
| 276 | { |
| 277 | (void)cpu; |
| 278 | } |
| 279 | |
| 280 | void plat_ffa_sri_trigger_not_delayed(struct cpu *cpu) |
| 281 | { |
| 282 | (void)cpu; |
| 283 | } |
| 284 | |
| 285 | void plat_ffa_sri_init(struct cpu *cpu) |
| 286 | { |
| 287 | (void)cpu; |
| 288 | } |
J-Alves | 7461ef2 | 2021-10-18 17:21:33 +0100 | [diff] [blame] | 289 | |
| 290 | void plat_ffa_inject_notification_pending_interrupt_context_switch( |
| 291 | struct vcpu *next, struct vcpu *current) |
| 292 | { |
| 293 | (void)next; |
| 294 | (void)current; |
| 295 | } |
Olivier Deprez | e562e54 | 2020-06-11 17:31:54 +0200 | [diff] [blame] | 296 | |
| 297 | void plat_ffa_partition_info_get_forward( // NOLINTNEXTLINE |
| 298 | const struct ffa_uuid *uuid, // NOLINTNEXTLINE |
Daniel Boulby | b46cad1 | 2021-12-13 17:47:21 +0000 | [diff] [blame] | 299 | const uint32_t flags, // NOLINTNEXTLINE |
Olivier Deprez | e562e54 | 2020-06-11 17:31:54 +0200 | [diff] [blame] | 300 | struct ffa_partition_info *partitions, ffa_vm_count_t *ret_count) |
| 301 | { |
| 302 | (void)uuid; |
Daniel Boulby | b46cad1 | 2021-12-13 17:47:21 +0000 | [diff] [blame] | 303 | (void)flags; |
Olivier Deprez | e562e54 | 2020-06-11 17:31:54 +0200 | [diff] [blame] | 304 | (void)partitions; |
| 305 | (void)ret_count; |
| 306 | } |