Kathleen Capella | fb96b98 | 2024-04-25 17:09:33 -0500 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2025, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arg_struct_def.h> |
| 8 | #include "constraint.h" |
| 9 | #include <ffa_fuzz_helper.h> |
| 10 | #include <fuzz_names.h> |
| 11 | #include <runtime_services/cactus_test_cmds.h> |
| 12 | #include <runtime_services/ffa_endpoints.h> |
| 13 | #include <runtime_services/spm_common.h> |
| 14 | #include <stdint.h> |
| 15 | |
| 16 | #ifdef FFA_INCLUDE |
| 17 | |
| 18 | #define PRIMARY_LO ffa_get_uuid_lo((struct ffa_uuid){PRIMARY_UUID}) |
| 19 | #define PRIMARY_HI ffa_get_uuid_hi((struct ffa_uuid){PRIMARY_UUID}) |
| 20 | #define SECONDARY_LO ffa_get_uuid_lo((struct ffa_uuid){SECONDARY_UUID}) |
| 21 | #define SECONDARY_HI ffa_get_uuid_hi((struct ffa_uuid){SECONDARY_UUID}) |
| 22 | #define TERTIARY_LO ffa_get_uuid_lo((struct ffa_uuid){TERTIARY_UUID}) |
| 23 | #define TERTIARY_HI ffa_get_uuid_hi((struct ffa_uuid){TERTIARY_UUID}) |
| 24 | |
| 25 | #define FFA_FUNC_ID_MIN 0x84000060 |
| 26 | #define FFA_FUNC_ID_MAX 0x8400008C |
| 27 | #define MAX_VM_ID ((UINT64_C(1) << 16) - 1) |
| 28 | #define FFA_FEAT_ID_MIN 0x0 |
| 29 | #define FFA_FEAT_ID_MAX 0xFF |
| 30 | #define MAX_NUM_VCPUS 8 |
| 31 | #define MIN_VCPU_ID 0 |
| 32 | #define MAX_VCPU_ID (MAX_NUM_VCPUS - 1) |
| 33 | |
| 34 | void inputparameters_to_ffa_value(struct inputparameters ip, |
| 35 | struct ffa_value *args) |
| 36 | { |
| 37 | args->arg1 = ip.x1; |
| 38 | args->arg2 = ip.x2; |
| 39 | args->arg3 = ip.x3; |
| 40 | args->arg4 = ip.x4; |
| 41 | args->arg5 = ip.x5; |
| 42 | args->arg6 = ip.x6; |
| 43 | args->arg7 = ip.x7; |
| 44 | args->arg8 = ip.x8; |
| 45 | args->arg9 = ip.x9; |
| 46 | args->arg10 = ip.x10; |
| 47 | args->arg11 = ip.x12; |
| 48 | args->arg12 = ip.x12; |
| 49 | args->arg13 = ip.x13; |
| 50 | args->arg14 = ip.x14; |
| 51 | args->arg15 = ip.x15; |
| 52 | args->arg16 = ip.x16; |
| 53 | args->arg17 = ip.x17; |
| 54 | } |
| 55 | |
| 56 | static struct ffa_value ffa_call_with_params(struct inputparameters ip, |
| 57 | uint64_t ffa_function_id) |
| 58 | { |
| 59 | struct ffa_value args = {.fid = ffa_function_id}; |
| 60 | |
| 61 | inputparameters_to_ffa_value(ip, &args); |
| 62 | |
| 63 | return ffa_service_call(&args); |
| 64 | } |
| 65 | |
| 66 | static bool is_info_get_regs_valid(struct inputparameters ip) |
| 67 | { |
| 68 | uint64_t uuid_lo = ip.x1; |
| 69 | uint64_t uuid_hi = ip.x2; |
| 70 | uint64_t start = get_generated_value( |
| 71 | FFA_PARTITION_INFO_GET_REGS_CALL_ARG3_START, ip); |
| 72 | uint64_t tag = get_generated_value( |
| 73 | FFA_PARTITION_INFO_GET_REGS_CALL_ARG3_TAG, ip); |
| 74 | |
| 75 | if ((uuid_lo == PRIMARY_LO && uuid_hi == PRIMARY_HI) || |
| 76 | (uuid_lo == SECONDARY_LO && uuid_hi == SECONDARY_HI) || |
| 77 | (uuid_lo == TERTIARY_LO && uuid_hi == TERTIARY_HI)) { |
| 78 | return (start == 0 && tag == 0); |
| 79 | } else if (uuid_lo == 0 && uuid_hi == 0) { |
| 80 | if (start == 0) { |
| 81 | return (tag == 0); |
| 82 | } |
| 83 | return (start < 4); |
| 84 | } |
| 85 | return false; |
| 86 | } |
| 87 | |
| 88 | void run_ffa_fuzz(int funcid, struct memmod *mmod) |
| 89 | { |
| 90 | /* |
| 91 | * For the SMC function id, apply constraints and generate input |
| 92 | * arguments based on sanity level, call the SMC, and do basic analysis |
| 93 | * and reporting of return results. |
| 94 | * |
| 95 | * An error return may not be a failure if the inputs are invalid, |
| 96 | * therefore failures are marked explicitly. |
| 97 | */ |
| 98 | switch (funcid) { |
| 99 | case ffa_id_get_funcid: { |
| 100 | struct ffa_value args; |
| 101 | struct ffa_value ret; |
| 102 | |
| 103 | args = (struct ffa_value){.fid = FFA_ID_GET}; |
| 104 | ret = ffa_service_call(&args); |
| 105 | |
| 106 | if (ret.fid == FFA_ERROR) { |
| 107 | printf("FAIL error code %d\n", ffa_error_code(ret)); |
| 108 | } |
| 109 | break; |
| 110 | } |
| 111 | case ffa_partition_info_get_regs_funcid: { |
| 112 | uint64_t uuid_lo_values[] = {0, PRIMARY_LO, SECONDARY_LO, |
| 113 | TERTIARY_LO}; |
| 114 | uint64_t uuid_hi_values[] = {0, PRIMARY_HI, SECONDARY_HI, |
| 115 | TERTIARY_HI}; |
| 116 | struct inputparameters ip; |
| 117 | struct ffa_value args; |
| 118 | struct ffa_value ret; |
| 119 | |
| 120 | setconstraint(FUZZER_CONSTRAINT_VECTOR, uuid_lo_values, 2, |
| 121 | FFA_PARTITION_INFO_GET_REGS_CALL_ARG1_UUID_LO, |
| 122 | mmod, FUZZER_CONSTRAINT_EXCMODE); |
| 123 | setconstraint(FUZZER_CONSTRAINT_VECTOR, uuid_hi_values, 2, |
| 124 | FFA_PARTITION_INFO_GET_REGS_CALL_ARG2_UUID_HI, |
| 125 | mmod, FUZZER_CONSTRAINT_EXCMODE); |
| 126 | |
| 127 | ip = generate_args(FFA_PARTITION_INFO_GET_REGS_CALL, |
| 128 | SMC_FUZZ_SANITY_LEVEL); |
| 129 | inputparameters_to_ffa_value(ip, &args); |
| 130 | args.fid = FFA_PARTITION_INFO_GET_REGS_SMC64; |
| 131 | |
| 132 | ret = ffa_service_call(&args); |
| 133 | |
| 134 | if (is_info_get_regs_valid(ip) && ret.fid == FFA_ERROR) { |
| 135 | printf("FAIL error code %d\n", ffa_error_code(ret)); |
| 136 | } |
| 137 | break; |
| 138 | } |
| 139 | case ffa_version_funcid: { |
| 140 | struct inputparameters ip; |
| 141 | struct ffa_value ret; |
| 142 | uint32_t version; |
| 143 | |
| 144 | ip = generate_args(FFA_VERSION_CALL, SMC_FUZZ_SANITY_LEVEL); |
| 145 | ret = ffa_call_with_params(ip, FFA_VERSION); |
| 146 | version = ret.fid; |
| 147 | |
| 148 | if (version == FFA_ERROR_NOT_SUPPORTED) { |
| 149 | printf("FFA_VERSION_NOT_SUPPORTED\n"); |
| 150 | } |
| 151 | break; |
| 152 | } |
| 153 | case ffa_msg_send_direct_req_32_funcid: |
| 154 | case ffa_msg_send_direct_req_64_funcid: { |
| 155 | uint64_t receiver_ids[] = {SP_ID(1), SP_ID(2), SP_ID(3)}; |
| 156 | uint64_t sender_id[] = {HYP_ID}; |
| 157 | uint64_t message_type[] = {0, 1}; |
| 158 | uint64_t frmwrk_msg_type[] = {0, 1}; |
| 159 | uint64_t msg_0_input[] = {CACTUS_ECHO_CMD, |
| 160 | CACTUS_REQ_ECHO_CMD}; /* Cactus cmd */ |
| 161 | uint64_t msg_1_input[] = {100, |
| 162 | 200}; /* for echo cmds, echo_val */ |
| 163 | struct inputparameters ip; |
| 164 | struct ffa_value ret; |
| 165 | uint64_t req_function_id; |
| 166 | uint64_t call_id; |
| 167 | uint64_t sender_arg; |
| 168 | uint64_t receiver_arg; |
| 169 | uint64_t msg_type_arg; |
| 170 | uint64_t frmwk_msg_type_arg; |
| 171 | uint64_t msg_0_arg; |
| 172 | uint64_t msg_1_arg; |
| 173 | |
| 174 | if (funcid == ffa_msg_send_direct_req_32_funcid) { |
| 175 | req_function_id = FFA_MSG_SEND_DIRECT_REQ_SMC32; |
| 176 | call_id = FFA_MSG_SEND_DIRECT_REQ_32_CALL; |
| 177 | sender_arg = |
| 178 | FFA_MSG_SEND_DIRECT_REQ_32_CALL_ARG1_SENDER_ID; |
| 179 | receiver_arg = |
| 180 | FFA_MSG_SEND_DIRECT_REQ_32_CALL_ARG1_RECEIVER_ID; |
| 181 | msg_type_arg = |
| 182 | FFA_MSG_SEND_DIRECT_REQ_32_CALL_ARG2_MESSAGE_TYPE; |
| 183 | frmwk_msg_type_arg = |
| 184 | FFA_MSG_SEND_DIRECT_REQ_32_CALL_ARG2_FRMWK_MSG_TYPE; |
| 185 | msg_0_arg = FFA_MSG_SEND_DIRECT_REQ_32_CALL_ARG3_MSG_0; |
| 186 | msg_1_arg = FFA_MSG_SEND_DIRECT_REQ_32_CALL_ARG4_MSG_1; |
| 187 | } else { |
| 188 | req_function_id = FFA_MSG_SEND_DIRECT_REQ_SMC64; |
| 189 | call_id = FFA_MSG_SEND_DIRECT_REQ_64_CALL; |
| 190 | sender_arg = |
| 191 | FFA_MSG_SEND_DIRECT_REQ_64_CALL_ARG1_SENDER_ID; |
| 192 | receiver_arg = |
| 193 | FFA_MSG_SEND_DIRECT_REQ_64_CALL_ARG1_RECEIVER_ID; |
| 194 | msg_type_arg = |
| 195 | FFA_MSG_SEND_DIRECT_REQ_64_CALL_ARG2_MESSAGE_TYPE; |
| 196 | frmwk_msg_type_arg = |
| 197 | FFA_MSG_SEND_DIRECT_REQ_64_CALL_ARG2_FRMWK_MSG_TYPE; |
| 198 | msg_0_arg = FFA_MSG_SEND_DIRECT_REQ_64_CALL_ARG3_MSG_0; |
| 199 | msg_1_arg = FFA_MSG_SEND_DIRECT_REQ_64_CALL_ARG4_MSG_1; |
| 200 | } |
| 201 | |
| 202 | setconstraint(FUZZER_CONSTRAINT_SVALUE, sender_id, 1, |
| 203 | sender_arg, mmod, FUZZER_CONSTRAINT_EXCMODE); |
| 204 | setconstraint(FUZZER_CONSTRAINT_VECTOR, receiver_ids, 3, |
| 205 | receiver_arg, mmod, FUZZER_CONSTRAINT_EXCMODE); |
| 206 | setconstraint(FUZZER_CONSTRAINT_VECTOR, message_type, 2, |
| 207 | msg_type_arg, mmod, FUZZER_CONSTRAINT_EXCMODE); |
| 208 | setconstraint(FUZZER_CONSTRAINT_VECTOR, frmwrk_msg_type, 2, |
| 209 | frmwk_msg_type_arg, mmod, |
| 210 | FUZZER_CONSTRAINT_EXCMODE); |
| 211 | setconstraint(FUZZER_CONSTRAINT_VECTOR, msg_0_input, 2, |
| 212 | msg_0_arg, mmod, FUZZER_CONSTRAINT_EXCMODE); |
| 213 | setconstraint(FUZZER_CONSTRAINT_RANGE, msg_1_input, 2, |
| 214 | msg_1_arg, mmod, FUZZER_CONSTRAINT_EXCMODE); |
| 215 | |
| 216 | ip = generate_args(call_id, SMC_FUZZ_SANITY_LEVEL); |
| 217 | ret = ffa_call_with_params(ip, req_function_id); |
| 218 | |
| 219 | switch (ret.fid) { |
| 220 | case FFA_MSG_SEND_DIRECT_RESP_SMC64: |
| 221 | case FFA_MSG_SEND_DIRECT_RESP_SMC32: |
| 222 | printf("Received direct response, ret.arg4 = %ld\n", |
| 223 | ret.arg4); |
| 224 | break; |
| 225 | case FFA_ERROR: |
| 226 | printf("Direct request returned with FFA_ERROR code %d\n", |
| 227 | ffa_error_code(ret)); |
| 228 | break; |
| 229 | case FFA_MSG_YIELD: |
| 230 | printf("FFA_MSG_SEND_DIRECT_REQ returned with FFA_MSG_YIELD\n"); |
| 231 | break; |
| 232 | case FFA_INTERRUPT: |
| 233 | printf("FFA_MSG_SEND_DIRECT_REQ returned with FFA_INTERRUPT\n"); |
| 234 | break; |
| 235 | default: |
| 236 | printf("FAIL FFA_MSG_SEND_DIRECT_REQ returned with 0x%lx\n", |
| 237 | ret.fid); |
| 238 | break; |
| 239 | } |
| 240 | break; |
| 241 | } |
| 242 | case ffa_msg_send_direct_resp_32_funcid: |
| 243 | case ffa_msg_send_direct_resp_64_funcid: { |
| 244 | uint64_t receiver_ids[] = {SP_ID(1), SP_ID(2), SP_ID(3)}; |
| 245 | uint64_t sender_id[] = {HYP_ID}; |
| 246 | struct inputparameters ip; |
| 247 | struct ffa_value ret; |
| 248 | uint64_t resp_function_id; |
| 249 | uint64_t call_id; |
| 250 | uint64_t sender_arg; |
| 251 | uint64_t receiver_arg; |
| 252 | if (funcid == ffa_msg_send_direct_resp_32_funcid) { |
| 253 | resp_function_id = FFA_MSG_SEND_DIRECT_RESP_SMC32; |
| 254 | call_id = FFA_MSG_SEND_DIRECT_RESP_32_CALL; |
| 255 | sender_arg = |
| 256 | FFA_MSG_SEND_DIRECT_RESP_32_CALL_ARG1_SENDER_ID; |
| 257 | receiver_arg = |
| 258 | FFA_MSG_SEND_DIRECT_RESP_32_CALL_ARG1_RECEIVER_ID; |
| 259 | } else { |
| 260 | resp_function_id = FFA_MSG_SEND_DIRECT_RESP_SMC64; |
| 261 | call_id = FFA_MSG_SEND_DIRECT_RESP_64_CALL; |
| 262 | sender_arg = |
| 263 | FFA_MSG_SEND_DIRECT_RESP_64_CALL_ARG1_SENDER_ID; |
| 264 | receiver_arg = |
| 265 | FFA_MSG_SEND_DIRECT_RESP_64_CALL_ARG1_RECEIVER_ID; |
| 266 | } |
| 267 | |
| 268 | setconstraint(FUZZER_CONSTRAINT_SVALUE, sender_id, 1, |
| 269 | sender_arg, mmod, FUZZER_CONSTRAINT_EXCMODE); |
| 270 | setconstraint(FUZZER_CONSTRAINT_VECTOR, receiver_ids, 3, |
| 271 | receiver_arg, mmod, FUZZER_CONSTRAINT_EXCMODE); |
| 272 | |
| 273 | ip = generate_args(call_id, SMC_FUZZ_SANITY_LEVEL); |
| 274 | ret = ffa_call_with_params(ip, resp_function_id); |
| 275 | |
| 276 | /* NWd cannot send a direct response. */ |
| 277 | if (ret.fid == FFA_ERROR) { |
| 278 | printf("Direct response returned with FFA_ERROR code %d\n", |
| 279 | ffa_error_code(ret)); |
| 280 | } else { |
| 281 | printf("FAIL FFA_MSG_SEND_DIRECT_RESP returned with 0x%lx\n", |
| 282 | ret.fid); |
| 283 | } |
| 284 | break; |
| 285 | } |
| 286 | case ffa_features_feat_id_funcid: { |
| 287 | /* Allow feature_ids in range of 8bits */ |
| 288 | uint64_t feat_ids_range[] = {FFA_FEAT_ID_MIN, FFA_FEAT_ID_MAX}; |
| 289 | struct inputparameters ip; |
| 290 | struct ffa_value ret; |
| 291 | |
| 292 | setconstraint(FUZZER_CONSTRAINT_RANGE, feat_ids_range, 2, |
| 293 | FFA_FEATURES_FEAT_ID_CALL_ARG1_FEAT_ID, mmod, |
| 294 | FUZZER_CONSTRAINT_EXCMODE); |
| 295 | |
| 296 | ip = generate_args(FFA_FEATURES_FEAT_ID_CALL, |
| 297 | SMC_FUZZ_SANITY_LEVEL); |
| 298 | ret = ffa_call_with_params(ip, FFA_FEATURES); |
| 299 | printf("ret.fid: { 0x%lx\n", ret.fid); |
| 300 | break; |
| 301 | } |
| 302 | case ffa_features_func_id_funcid: { |
| 303 | uint64_t ffa_funcid_range[] = {FFA_FUNC_ID_MIN, |
| 304 | FFA_FUNC_ID_MAX}; |
| 305 | struct inputparameters ip; |
| 306 | struct ffa_value ret; |
| 307 | uint64_t funcid_gen_input; |
| 308 | |
| 309 | setconstraint(FUZZER_CONSTRAINT_RANGE, ffa_funcid_range, 2, |
| 310 | FFA_FEATURES_FUNC_ID_CALL_ARG1_FUNC_ID, mmod, |
| 311 | FUZZER_CONSTRAINT_EXCMODE); |
| 312 | |
| 313 | ip = generate_args(FFA_FEATURES_FUNC_ID_CALL, |
| 314 | SMC_FUZZ_SANITY_LEVEL); |
| 315 | |
| 316 | /* |
| 317 | * TODO: Would be a good use case for future fuzzing |
| 318 | * functionality having one field constraint dependent |
| 319 | * on value of another generated field. |
| 320 | */ |
| 321 | funcid_gen_input = get_generated_value( |
| 322 | FFA_FEATURES_FUNC_ID_CALL_ARG1_FUNC_ID, ip); |
| 323 | if (SMC_FUZZ_SANITY_LEVEL == SANITY_LEVEL_3 && |
| 324 | funcid_gen_input == FFA_MEM_RETRIEVE_REQ_SMC32) { |
| 325 | // Set arg2 to a certain value |
| 326 | ip.x2 = 0x10; |
| 327 | } |
| 328 | |
| 329 | ret = ffa_call_with_params(ip, FFA_FEATURES); |
| 330 | printf("ret.fid: { 0x%lx\n", ret.fid); |
| 331 | break; |
| 332 | } |
| 333 | case ffa_run_funcid: { |
| 334 | uint64_t target_ids[] = {SP_ID(1), SP_ID(2), SP_ID(3)}; |
| 335 | uint64_t target_vcpu_ids[] = {MIN_VCPU_ID, MAX_VCPU_ID}; |
| 336 | struct inputparameters ip; |
| 337 | struct ffa_value ret; |
| 338 | |
| 339 | setconstraint(FUZZER_CONSTRAINT_VECTOR, target_ids, 3, |
| 340 | FFA_RUN_CALL_ARG1_TARGET_VM_ID, mmod, |
| 341 | FUZZER_CONSTRAINT_EXCMODE); |
| 342 | setconstraint(FUZZER_CONSTRAINT_RANGE, target_vcpu_ids, 2, |
| 343 | FFA_RUN_CALL_ARG1_TARGET_VCPU_ID, mmod, |
| 344 | FUZZER_CONSTRAINT_EXCMODE); |
| 345 | ip = generate_args(FFA_RUN_CALL, SMC_FUZZ_SANITY_LEVEL); |
| 346 | ret = ffa_call_with_params(ip, FFA_RUN); |
| 347 | |
| 348 | switch (ret.fid) { |
| 349 | case FFA_ERROR: |
| 350 | printf("FFA_RUN returned with FFA_ERROR code %d\n", |
| 351 | ffa_error_code(ret)); |
| 352 | break; |
| 353 | |
| 354 | case FFA_INTERRUPT: |
| 355 | case FFA_MSG_WAIT: |
| 356 | case FFA_MSG_YIELD: |
| 357 | case FFA_MSG_SEND_DIRECT_RESP_SMC64: |
| 358 | case FFA_MSG_SEND_DIRECT_RESP_SMC32: |
| 359 | printf("FFA_RUN successfully returned with 0x%lx\n", |
| 360 | ret.fid); |
| 361 | break; |
| 362 | default: |
| 363 | printf("FAIL FFA_RUN returned with 0x%lx\n", ret.fid); |
| 364 | break; |
| 365 | } |
| 366 | break; |
| 367 | } |
| 368 | case ffa_notification_bitmap_create_funcid: { |
| 369 | uint64_t vm_id[] = {0, MAX_VM_ID}; |
| 370 | uint64_t n_vcpus[] = {0, MAX_NUM_VCPUS}; |
| 371 | struct inputparameters ip; |
| 372 | struct ffa_value ret; |
| 373 | uint64_t gen_vm_id; |
| 374 | uint64_t gen_n_vcpus; |
| 375 | |
| 376 | setconstraint(FUZZER_CONSTRAINT_RANGE, n_vcpus, 2, |
| 377 | FFA_NOTIFICATION_BITMAP_CREATE_CALL_ARG2_N_VCPUS, |
| 378 | mmod, FUZZER_CONSTRAINT_EXCMODE); |
| 379 | setconstraint(FUZZER_CONSTRAINT_RANGE, vm_id, 2, |
| 380 | FFA_NOTIFICATION_BITMAP_CREATE_CALL_ARG1_VM_ID, |
| 381 | mmod, FUZZER_CONSTRAINT_EXCMODE); |
| 382 | |
| 383 | ip = generate_args(FFA_NOTIFICATION_BITMAP_CREATE_CALL, |
| 384 | SMC_FUZZ_SANITY_LEVEL); |
| 385 | ret = ffa_call_with_params(ip, FFA_NOTIFICATION_BITMAP_CREATE); |
| 386 | |
| 387 | gen_vm_id = get_generated_value( |
| 388 | FFA_NOTIFICATION_BITMAP_CREATE_CALL_ARG1_VM_ID, ip); |
| 389 | gen_n_vcpus = get_generated_value( |
| 390 | FFA_NOTIFICATION_BITMAP_CREATE_CALL_ARG2_N_VCPUS, ip); |
| 391 | |
| 392 | if (ret.fid == FFA_SUCCESS_SMC32 || |
| 393 | ret.fid == FFA_SUCCESS_SMC64) { |
| 394 | printf("FFA_NOTIFICATION_BITMAP_CREATE succeeded for " |
| 395 | "VM %lld with vCPU count %lld\n", |
| 396 | gen_vm_id, gen_n_vcpus); |
| 397 | } else if (ret.fid == FFA_ERROR) { |
| 398 | printf("FFA_NOTIFICATION_BITMAP_CREATE returned with " |
| 399 | "FFA_ERROR code %d\n", |
| 400 | ffa_error_code(ret)); |
| 401 | } else { |
| 402 | printf("FAIL FFA_NOTIFICATION_BITMAP_CREATE returned with 0x%lx\n", |
| 403 | ret.fid); |
| 404 | } |
| 405 | break; |
| 406 | } |
| 407 | case ffa_notification_bind_funcid: { |
| 408 | uint64_t sps[] = {SP_ID(1), SP_ID(2), SP_ID(3)}; |
| 409 | uint64_t vm_ids[] = {0, MAX_VM_ID}; |
| 410 | uint64_t max_bitmap_value = 0xFFFFFFFF; |
| 411 | uint64_t bitmap_range[] = {0, max_bitmap_value}; |
| 412 | struct inputparameters ip; |
| 413 | struct ffa_value ret; |
| 414 | |
| 415 | setconstraint(FUZZER_CONSTRAINT_RANGE, vm_ids, 2, |
| 416 | FFA_NOTIFICATION_BIND_CALL_ARG1_RECEIVER_ID, mmod, |
| 417 | FUZZER_CONSTRAINT_ACCMODE); |
| 418 | setconstraint(FUZZER_CONSTRAINT_RANGE, vm_ids, 2, |
| 419 | FFA_NOTIFICATION_BIND_CALL_ARG1_SENDER_ID, mmod, |
| 420 | FUZZER_CONSTRAINT_ACCMODE); |
| 421 | setconstraint(FUZZER_CONSTRAINT_VECTOR, sps, 3, |
| 422 | FFA_NOTIFICATION_BIND_CALL_ARG1_RECEIVER_ID, mmod, |
| 423 | FUZZER_CONSTRAINT_ACCMODE); |
| 424 | setconstraint(FUZZER_CONSTRAINT_VECTOR, sps, 3, |
| 425 | FFA_NOTIFICATION_BIND_CALL_ARG1_SENDER_ID, mmod, |
| 426 | FUZZER_CONSTRAINT_ACCMODE); |
| 427 | setconstraint(FUZZER_CONSTRAINT_RANGE, bitmap_range, 2, |
| 428 | FFA_NOTIFICATION_BIND_CALL_ARG3_BITMAP, mmod, |
| 429 | FUZZER_CONSTRAINT_EXCMODE); |
| 430 | setconstraint(FUZZER_CONSTRAINT_RANGE, bitmap_range, 2, |
| 431 | FFA_NOTIFICATION_BIND_CALL_ARG4_BITMAP, mmod, |
| 432 | FUZZER_CONSTRAINT_EXCMODE); |
| 433 | ip = generate_args(FFA_NOTIFICATION_BIND_CALL, |
| 434 | SMC_FUZZ_SANITY_LEVEL); |
| 435 | ret = ffa_call_with_params(ip, FFA_NOTIFICATION_BIND); |
| 436 | |
| 437 | if (ret.fid == FFA_SUCCESS_SMC32 || |
| 438 | ret.fid == FFA_SUCCESS_SMC64) { |
| 439 | printf("FFA_NOTIFICATION_BIND succeeded\n"); |
| 440 | } else if (ret.fid == FFA_ERROR) { |
| 441 | printf("FFA_NOTIFICATION_BIND returned with FFA_ERROR code %d\n", |
| 442 | ffa_error_code(ret)); |
| 443 | } else { |
| 444 | printf("FAIL FFA_NOTIFICATION_BIND returned with 0x%lx\n", |
| 445 | ret.fid); |
| 446 | } |
| 447 | break; |
| 448 | } |
| 449 | case ffa_notification_bitmap_destroy_funcid: { |
| 450 | uint64_t vm_id[] = {0, MAX_VM_ID}; |
| 451 | struct inputparameters ip; |
| 452 | struct ffa_value ret; |
| 453 | uint64_t gen_vm_id; |
| 454 | |
| 455 | gen_vm_id = get_generated_value( |
| 456 | FFA_NOTIFICATION_BITMAP_DESTROY_CALL_ARG1_VM_ID, ip); |
| 457 | |
| 458 | setconstraint(FUZZER_CONSTRAINT_RANGE, vm_id, 2, |
| 459 | FFA_NOTIFICATION_BITMAP_DESTROY_CALL_ARG1_VM_ID, |
| 460 | mmod, FUZZER_CONSTRAINT_EXCMODE); |
| 461 | ip = generate_args(FFA_NOTIFICATION_BITMAP_DESTROY_CALL, |
| 462 | SMC_FUZZ_SANITY_LEVEL); |
| 463 | ret = ffa_call_with_params(ip, FFA_NOTIFICATION_BITMAP_DESTROY); |
| 464 | |
| 465 | gen_vm_id = get_generated_value( |
| 466 | FFA_NOTIFICATION_BITMAP_DESTROY_CALL_ARG1_VM_ID, ip); |
| 467 | |
| 468 | if (ret.fid == FFA_SUCCESS_SMC32 || |
| 469 | ret.fid == FFA_SUCCESS_SMC64) { |
| 470 | printf("FFA_NOTIFICATION_BITMAP_DESTROY succeeded for VM %lld\n", |
| 471 | gen_vm_id); |
| 472 | } else if (ret.fid == FFA_ERROR) { |
| 473 | printf("FFA_NOTIFICATION_BITMAP_CREATE returned with FFA_ERROR code %d\n", |
| 474 | ffa_error_code(ret)); |
| 475 | } else { |
| 476 | printf("FAIL FFA_NOTIFICATION_BITMAP_CREATE returned with 0x%lx\n", |
| 477 | ret.fid); |
| 478 | } |
| 479 | break; |
| 480 | } |
| 481 | default: |
| 482 | break; |
| 483 | } |
| 484 | } |
| 485 | #endif |