blob: ca9346927f77a172121929ade9c552745f686e4b [file] [log] [blame]
Mark Dykese7810b52020-06-03 15:46:55 -05001#
Mark Dykes50297972024-03-15 12:49:22 -05002# Copyright (c) 2024, Arm Limited. All rights reserved.
Mark Dykese7810b52020-06-03 15:46:55 -05003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
johpow01d5c79cc2021-06-23 16:10:22 -05007# 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
11SMC_FUZZ_INSTANCE_COUNT ?= 1
12SMC_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));")
13SMC_FUZZ_CALLS_PER_INSTANCE ?= 100
Alex Liang0fa7d212024-06-18 11:17:01 -050014# ADDED: which fuzz call to start with per instance
15SMC_FUZZ_CALL_START ?= 0
16SMC_FUZZ_CALL_END ?= $(SMC_FUZZ_CALLS_PER_INSTANCE)
17# ADDED: define whether events should specifically be constrained
18EXCLUDE_FUNCID ?= 0
Alex Liang1d40d722024-07-23 16:42:16 -050019CONSTRAIN_EVENTS ?= 0
Alex Liang0fa7d212024-06-18 11:17:01 -050020INTR_ASSERT ?= 0
johpow01d5c79cc2021-06-23 16:10:22 -050021
22# Validate SMC fuzzer parameters
23
24# Instance count must not be zero
25ifeq ($(SMC_FUZZ_INSTANCE_COUNT),0)
26$(error SMC_FUZZ_INSTANCE_COUNT must not be zero!)
27endif
28
29# Calls per instance must not be zero
30ifeq ($(SMC_FUZZ_CALLS_PER_INSTANCE),0)
31$(error SMC_FUZZ_CALLS_PER_INSTANCE must not be zero!)
32endif
33
34# Make sure seed count and instance count match
35TEST_SEED_COUNT = $(shell python -c "print(len(\"$(SMC_FUZZ_SEEDS)\".split(\",\")))")
36ifneq ($(TEST_SEED_COUNT), $(SMC_FUZZ_INSTANCE_COUNT))
37$(error Number of seeds does not match SMC_FUZZ_INSTANCE_COUNT!)
38endif
39
Alex Liang0fa7d212024-06-18 11:17:01 -050040# Start must be nonnegative and less than calls per instance
41ifeq ($(shell test $(SMC_FUZZ_CALL_START) -lt 0; echo $$?),0)
42$(error SMC_FUZZ_CALL_START must be nonnegative!)
43endif
44
45ifeq ($(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!)
47endif
48
49# End must be greater than start and less than or equal to calls per instance
50ifneq ($(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!)
52endif
53
54ifeq ($(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!)
56endif
57
58
johpow01d5c79cc2021-06-23 16:10:22 -050059# 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 Dykes50297972024-03-15 12:49:22 -050063ifeq ($(SMC_FUZZER_DEBUG),1)
64$(eval $(call add_define,TFTF_DEFINES,SMC_FUZZER_DEBUG))
65endif
mardyk01c14e4ad2023-10-11 16:50:19 -050066ifeq ($(MULTI_CPU_SMC_FUZZER),1)
67$(eval $(call add_define,TFTF_DEFINES,MULTI_CPU_SMC_FUZZER))
68endif
Mark Dykes50297972024-03-15 12:49:22 -050069$(eval $(call add_define,TFTF_DEFINES,SMC_FUZZ_SANITY_LEVEL))
Alex Liang0fa7d212024-06-18 11:17:01 -050070$(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
76TESTS_SOURCES += \
77 $(addprefix tftf/tests/runtime_services/standard_service/sdei/system_tests/, \
78 sdei_entrypoint.S \
79 test_sdei.c \
80 )
johpow01d5c79cc2021-06-23 16:10:22 -050081
Mark Dykese7810b52020-06-03 15:46:55 -050082TESTS_SOURCES += \
Kathleen Capellafb96b982024-04-25 17:09:33 -050083 $(addprefix tftf/tests/runtime_services/secure_service/, \
84 ${ARCH}/ffa_arch_helpers.S \
85 ffa_helpers.c \
86 spm_common.c \
87 )
88TESTS_SOURCES += \
Mark Dykese7810b52020-06-03 15:46:55 -050089 $(addprefix smc_fuzz/src/, \
90 randsmcmod.c \
91 smcmalloc.c \
92 fifo3d.c \
mardyk01c14e4ad2023-10-11 16:50:19 -050093 runtestfunction_helpers.c \
mardyk01f5b46352023-10-24 16:23:23 -050094 sdei_fuzz_helper.c \
Kathleen Capellafb96b982024-04-25 17:09:33 -050095 ffa_fuzz_helper.c \
mardyk01f5b46352023-10-24 16:23:23 -050096 tsp_fuzz_helper.c \
mardyk017b51dbe2024-01-17 15:25:36 -060097 nfifo.c \
Mark Dykes50297972024-03-15 12:49:22 -050098 constraint.c \
Alex Liang1d40d722024-07-23 16:42:16 -050099 vendor_fuzz_helper.c \
Mark Dykese7810b52020-06-03 15:46:55 -0500100 )