mardyk01 | f5b4635 | 2023-10-24 16:23:23 -0500 | [diff] [blame] | 1 | /* |
mardyk01 | 7b51dbe | 2024-01-17 15:25:36 -0600 | [diff] [blame^] | 2 | * Copyright (c) 2024, Arm Limited. All rights reserved. |
mardyk01 | f5b4635 | 2023-10-24 16:23:23 -0500 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
mardyk01 | 7b51dbe | 2024-01-17 15:25:36 -0600 | [diff] [blame^] | 6 | #include <fuzz_names.h> |
mardyk01 | f5b4635 | 2023-10-24 16:23:23 -0500 | [diff] [blame] | 7 | #include <tsp_fuzz_helper.h> |
| 8 | |
mardyk01 | 7b51dbe | 2024-01-17 15:25:36 -0600 | [diff] [blame^] | 9 | /* |
| 10 | * Generic TSP based function call for math operations |
| 11 | */ |
mardyk01 | f5b4635 | 2023-10-24 16:23:23 -0500 | [diff] [blame] | 12 | void tftf_test_tsp_smc(uint64_t tsp_id, char *funcstr) |
| 13 | { |
| 14 | uint64_t fn_identifier = TSP_FAST_FID(tsp_id); |
| 15 | uint64_t arg1 = 4; |
| 16 | uint64_t arg2 = 6; |
| 17 | smc_args tsp_svc_params = {fn_identifier, arg1, arg2}; |
| 18 | smc_ret_values tsp_result; |
| 19 | |
| 20 | tsp_result = tftf_smc(&tsp_svc_params); |
| 21 | |
| 22 | if (tsp_result.ret0) { |
| 23 | tftf_testcase_printf("TSP operation 0x%x failed, error:0x%x\n", |
| 24 | (unsigned int) fn_identifier, |
| 25 | (unsigned int) tsp_result.ret0); |
| 26 | } |
| 27 | } |
| 28 | |
mardyk01 | 7b51dbe | 2024-01-17 15:25:36 -0600 | [diff] [blame^] | 29 | /* |
| 30 | * TSP function called from fuzzer |
| 31 | */ |
| 32 | void run_tsp_fuzz(int funcid) |
mardyk01 | f5b4635 | 2023-10-24 16:23:23 -0500 | [diff] [blame] | 33 | { |
mardyk01 | 7b51dbe | 2024-01-17 15:25:36 -0600 | [diff] [blame^] | 34 | if (funcid == tsp_add_op_funcid) { |
mardyk01 | f5b4635 | 2023-10-24 16:23:23 -0500 | [diff] [blame] | 35 | tftf_test_tsp_smc(TSP_ADD, "tsp_add_op"); |
mardyk01 | 7b51dbe | 2024-01-17 15:25:36 -0600 | [diff] [blame^] | 36 | } else if (funcid == tsp_sub_op_funcid) { |
mardyk01 | f5b4635 | 2023-10-24 16:23:23 -0500 | [diff] [blame] | 37 | tftf_test_tsp_smc(TSP_SUB, "tsp_sub_op"); |
mardyk01 | 7b51dbe | 2024-01-17 15:25:36 -0600 | [diff] [blame^] | 38 | } else if (funcid == tsp_mul_op_funcid) { |
mardyk01 | f5b4635 | 2023-10-24 16:23:23 -0500 | [diff] [blame] | 39 | tftf_test_tsp_smc(TSP_MUL, "tsp_mul_op"); |
mardyk01 | 7b51dbe | 2024-01-17 15:25:36 -0600 | [diff] [blame^] | 40 | } else if (funcid == tsp_div_op_funcid) { |
mardyk01 | f5b4635 | 2023-10-24 16:23:23 -0500 | [diff] [blame] | 41 | tftf_test_tsp_smc(TSP_DIV, "tsp_div_op"); |
| 42 | } |
| 43 | } |