Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 1 | # |
Mark Dykes | 5029797 | 2024-03-15 12:49:22 -0500 | [diff] [blame] | 2 | # Copyright (c) 2024, Arm Limited. All rights reserved. |
Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | |
johpow01 | d5c79cc | 2021-06-23 16:10:22 -0500 | [diff] [blame] | 7 | # Generate random fuzzing seeds |
| 8 | # If no instance count is provided, default to 1 instance |
| 9 | # If no seeds are provided, generate them randomly |
| 10 | # The number of seeds provided must match the instance count |
| 11 | SMC_FUZZ_INSTANCE_COUNT ?= 1 |
| 12 | SMC_FUZZ_SEEDS ?= $(shell python -c "from random import randint; seeds = [randint(0, 4294967295) for i in range($(SMC_FUZZ_INSTANCE_COUNT))];print(\",\".join(str(x) for x in seeds));") |
| 13 | SMC_FUZZ_CALLS_PER_INSTANCE ?= 100 |
Alex Liang | 0fa7d21 | 2024-06-18 11:17:01 -0500 | [diff] [blame] | 14 | # ADDED: which fuzz call to start with per instance |
| 15 | SMC_FUZZ_CALL_START ?= 0 |
| 16 | SMC_FUZZ_CALL_END ?= $(SMC_FUZZ_CALLS_PER_INSTANCE) |
| 17 | # ADDED: define whether events should specifically be constrained |
| 18 | EXCLUDE_FUNCID ?= 0 |
Alex Liang | 1d40d72 | 2024-07-23 16:42:16 -0500 | [diff] [blame] | 19 | CONSTRAIN_EVENTS ?= 0 |
Alex Liang | 0fa7d21 | 2024-06-18 11:17:01 -0500 | [diff] [blame] | 20 | INTR_ASSERT ?= 0 |
johpow01 | d5c79cc | 2021-06-23 16:10:22 -0500 | [diff] [blame] | 21 | |
| 22 | # Validate SMC fuzzer parameters |
| 23 | |
| 24 | # Instance count must not be zero |
| 25 | ifeq ($(SMC_FUZZ_INSTANCE_COUNT),0) |
| 26 | $(error SMC_FUZZ_INSTANCE_COUNT must not be zero!) |
| 27 | endif |
| 28 | |
| 29 | # Calls per instance must not be zero |
| 30 | ifeq ($(SMC_FUZZ_CALLS_PER_INSTANCE),0) |
| 31 | $(error SMC_FUZZ_CALLS_PER_INSTANCE must not be zero!) |
| 32 | endif |
| 33 | |
| 34 | # Make sure seed count and instance count match |
| 35 | TEST_SEED_COUNT = $(shell python -c "print(len(\"$(SMC_FUZZ_SEEDS)\".split(\",\")))") |
| 36 | ifneq ($(TEST_SEED_COUNT), $(SMC_FUZZ_INSTANCE_COUNT)) |
| 37 | $(error Number of seeds does not match SMC_FUZZ_INSTANCE_COUNT!) |
| 38 | endif |
| 39 | |
Alex Liang | 0fa7d21 | 2024-06-18 11:17:01 -0500 | [diff] [blame] | 40 | # Start must be nonnegative and less than calls per instance |
| 41 | ifeq ($(shell test $(SMC_FUZZ_CALL_START) -lt 0; echo $$?),0) |
| 42 | $(error SMC_FUZZ_CALL_START must be nonnegative!) |
| 43 | endif |
| 44 | |
| 45 | ifeq ($(shell test $(SMC_FUZZ_CALL_START) -gt $(shell expr $(SMC_FUZZ_CALLS_PER_INSTANCE) - 1); echo $$?),0) |
| 46 | $(error SMC_FUZZ_CALL_START must be less than SMC_FUZZ_CALLS_PER_INSTANCE!) |
| 47 | endif |
| 48 | |
| 49 | # End must be greater than start and less than or equal to calls per instance |
| 50 | ifneq ($(shell test $(SMC_FUZZ_CALL_START) -lt $(SMC_FUZZ_CALL_END); echo $$?),0) |
| 51 | $(error SMC_FUZZ_CALL_END must be greater than SMC_FUZZ_CALL_START!) |
| 52 | endif |
| 53 | |
| 54 | ifeq ($(shell test $(SMC_FUZZ_CALL_END) -gt $(SMC_FUZZ_CALLS_PER_INSTANCE); echo $$?),0) |
| 55 | $(error SMC_FUZZ_CALL_END must not be greater than SMC_FUZZ_CALLS_PER_INSTANCE!) |
| 56 | endif |
| 57 | |
| 58 | |
johpow01 | d5c79cc | 2021-06-23 16:10:22 -0500 | [diff] [blame] | 59 | # Add definitions to TFTF_DEFINES so they can be used in the code |
| 60 | $(eval $(call add_define,TFTF_DEFINES,SMC_FUZZ_SEEDS)) |
| 61 | $(eval $(call add_define,TFTF_DEFINES,SMC_FUZZ_INSTANCE_COUNT)) |
| 62 | $(eval $(call add_define,TFTF_DEFINES,SMC_FUZZ_CALLS_PER_INSTANCE)) |
Mark Dykes | 5029797 | 2024-03-15 12:49:22 -0500 | [diff] [blame] | 63 | ifeq ($(SMC_FUZZER_DEBUG),1) |
| 64 | $(eval $(call add_define,TFTF_DEFINES,SMC_FUZZER_DEBUG)) |
| 65 | endif |
mardyk01 | c14e4ad | 2023-10-11 16:50:19 -0500 | [diff] [blame] | 66 | ifeq ($(MULTI_CPU_SMC_FUZZER),1) |
| 67 | $(eval $(call add_define,TFTF_DEFINES,MULTI_CPU_SMC_FUZZER)) |
| 68 | endif |
Mark Dykes | 5029797 | 2024-03-15 12:49:22 -0500 | [diff] [blame] | 69 | $(eval $(call add_define,TFTF_DEFINES,SMC_FUZZ_SANITY_LEVEL)) |
Alex Liang | 0fa7d21 | 2024-06-18 11:17:01 -0500 | [diff] [blame] | 70 | $(eval $(call add_define,TFTF_DEFINES,SMC_FUZZ_CALL_START)) |
| 71 | $(eval $(call add_define,TFTF_DEFINES,SMC_FUZZ_CALL_END)) |
| 72 | $(eval $(call add_define,TFTF_DEFINES,CONSTRAIN_EVENTS)) |
| 73 | $(eval $(call add_define,TFTF_DEFINES,EXCLUDE_FUNCID)) |
| 74 | $(eval $(call add_define,TFTF_DEFINES,INTR_ASSERT)) |
| 75 | |
| 76 | TESTS_SOURCES += \ |
| 77 | $(addprefix tftf/tests/runtime_services/standard_service/sdei/system_tests/, \ |
| 78 | sdei_entrypoint.S \ |
| 79 | test_sdei.c \ |
| 80 | ) |
johpow01 | d5c79cc | 2021-06-23 16:10:22 -0500 | [diff] [blame] | 81 | |
Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 82 | TESTS_SOURCES += \ |
Kathleen Capella | fb96b98 | 2024-04-25 17:09:33 -0500 | [diff] [blame] | 83 | $(addprefix tftf/tests/runtime_services/secure_service/, \ |
| 84 | ${ARCH}/ffa_arch_helpers.S \ |
| 85 | ffa_helpers.c \ |
| 86 | spm_common.c \ |
| 87 | ) |
| 88 | TESTS_SOURCES += \ |
Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 89 | $(addprefix smc_fuzz/src/, \ |
| 90 | randsmcmod.c \ |
| 91 | smcmalloc.c \ |
| 92 | fifo3d.c \ |
mardyk01 | c14e4ad | 2023-10-11 16:50:19 -0500 | [diff] [blame] | 93 | runtestfunction_helpers.c \ |
mardyk01 | f5b4635 | 2023-10-24 16:23:23 -0500 | [diff] [blame] | 94 | sdei_fuzz_helper.c \ |
Kathleen Capella | fb96b98 | 2024-04-25 17:09:33 -0500 | [diff] [blame] | 95 | ffa_fuzz_helper.c \ |
mardyk01 | f5b4635 | 2023-10-24 16:23:23 -0500 | [diff] [blame] | 96 | tsp_fuzz_helper.c \ |
mardyk01 | 7b51dbe | 2024-01-17 15:25:36 -0600 | [diff] [blame] | 97 | nfifo.c \ |
Mark Dykes | 5029797 | 2024-03-15 12:49:22 -0500 | [diff] [blame] | 98 | constraint.c \ |
Alex Liang | 1d40d72 | 2024-07-23 16:42:16 -0500 | [diff] [blame] | 99 | vendor_fuzz_helper.c \ |
Mark Dykes | e7810b5 | 2020-06-03 15:46:55 -0500 | [diff] [blame] | 100 | ) |