xref: /rk3399_ARM-atf/make_helpers/constraints.mk (revision 38e580e6411c7a2eb2801a6aacb0a19bb9b1ac46)
1#
2# Copyright (c) 2025, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7ifneq ($(AARCH32_INSTRUCTION_SET),$(filter $(AARCH32_INSTRUCTION_SET),A32 T32))
8         $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
9endif
10
11# Make sure RME configuration is valid
12ifeq (${ENABLE_RME},1)
13	ifneq (${SEPARATE_CODE_AND_RODATA},1)
14                $(error ENABLE_RME requires SEPARATE_CODE_AND_RODATA)
15	endif
16
17	ifneq (${ARCH},aarch64)
18                $(error ENABLE_RME requires AArch64)
19	endif
20
21	ifeq ($(SPMC_AT_EL3),1)
22                $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
23	endif
24
25	ifneq (${SPD}, none)
26		ifneq (${SPD}, spmd)
27                        $(error ENABLE_RME is incompatible with SPD=${SPD}. Use SPD=spmd)
28		endif
29	endif
30else
31	ifeq (${ENABLE_FEAT_RME_GDI},1)
32                $(error ENABLE_FEAT_RME_GDI requires ENABLE_RME)
33	endif
34endif
35
36ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
37	ifeq (${SPD},none)
38		ifeq (${ENABLE_RME},0)
39                        $(error CTX_INCLUDE_EL2_REGS is available only when SPD \
40                        or RME is enabled)
41		endif
42	endif
43endif
44
45################################################################################
46# Verify FEAT_RME, FEAT_SCTLR2 and FEAT_TCR2 are enabled if FEAT_MEC is enabled.
47################################################################################
48
49ifneq (${ENABLE_FEAT_MEC},0)
50    ifeq (${ENABLE_RME},0)
51        $(error FEAT_RME must be enabled when FEAT_MEC is enabled.)
52    endif
53    ifeq (${ENABLE_FEAT_TCR2},0)
54        $(error FEAT_TCR2 must be enabled when FEAT_MEC is enabled.)
55    endif
56    ifeq (${ENABLE_FEAT_SCTLR2},0)
57        $(error FEAT_SCTLR2 must be enabled when FEAT_MEC is enabled.)
58    endif
59endif
60
61# Handle all invalid build configurations with SPMD usage.
62ifeq (${ENABLE_SPMD_LP}, 1)
63ifneq (${SPD},spmd)
64        $(error Error: ENABLE_SPMD_LP requires SPD=spmd.)
65endif
66ifeq ($(SPMC_AT_EL3),1)
67        $(error SPMC at EL3 not supported when enabling SPMD Logical partitions.)
68endif
69endif
70
71ifneq (${SPD},none)
72ifeq (${ARCH},aarch32)
73        $(error "Error: SPD is incompatible with AArch32.")
74endif
75ifdef EL3_PAYLOAD_BASE
76        $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
77        $(warning "The SPD and its BL32 companion will be present but ignored.")
78endif
79ifeq (${SPD},spmd)
80ifeq ($(SPMD_SPM_AT_SEL2),1)
81        ifeq ($(SPMC_AT_EL3),1)
82                $(error SPM cannot be enabled in both S-EL2 and EL3.)
83        endif
84        ifeq ($(CTX_INCLUDE_SVE_REGS),1)
85                $(error SVE context management not needed with Hafnium SPMC.)
86        endif
87endif
88
89ifeq ($(SPMC_AT_EL3_SEL0_SP),1)
90        ifneq ($(SPMC_AT_EL3),1)
91                $(error SEL0 SP cannot be enabled without SPMC at EL3)
92        endif
93endif
94endif #(SPD=spmd)
95endif #(SPD!=none)
96
97# USE_DEBUGFS experimental feature recommended only in debug builds
98ifeq (${USE_DEBUGFS},1)
99        ifeq (${DEBUG},1)
100                $(warning DEBUGFS experimental feature is enabled.)
101        else
102                $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
103        endif
104endif #(USE_DEBUGFS)
105
106# USE_SPINLOCK_CAS requires AArch64 build
107ifeq (${USE_SPINLOCK_CAS},1)
108        ifneq (${ARCH},aarch64)
109               $(error USE_SPINLOCK_CAS requires AArch64)
110        endif
111endif #(USE_SPINLOCK_CAS)
112
113ifdef EL3_PAYLOAD_BASE
114	ifdef PRELOADED_BL33_BASE
115                $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
116                incompatible build options. EL3_PAYLOAD_BASE has priority.")
117	endif
118	ifneq (${GENERATE_COT},0)
119                $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible \
120                build options.")
121	endif
122	ifneq (${TRUSTED_BOARD_BOOT},0)
123                $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are \
124                incompatible \ build options.")
125	endif
126endif #(EL3_PAYLOAD_BASE)
127
128ifeq (${NEED_BL33},yes)
129	ifdef EL3_PAYLOAD_BASE
130                $(warning "BL33 image is not needed when option \
131                BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
132	endif
133	ifdef PRELOADED_BL33_BASE
134                $(warning "BL33 image is not needed when option \
135                PRELOADED_BL33_BASE is used and won't be added to the FIP file.")
136	endif
137endif #(NEED_BL33)
138
139# When building for systems with hardware-assisted coherency, there's no need to
140# use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
141ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
142        $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
143endif
144
145#For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
146ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
147        $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
148endif
149
150# RAS_EXTENSION is deprecated, provide alternate build options
151ifeq ($(RAS_EXTENSION),1)
152        $(error "RAS_EXTENSION is now deprecated, please use ENABLE_FEAT_RAS \
153        and HANDLE_EA_EL3_FIRST_NS instead")
154endif
155
156
157# When FAULT_INJECTION_SUPPORT is used, require that FEAT_RAS is enabled
158ifeq ($(FAULT_INJECTION_SUPPORT),1)
159	ifeq ($(ENABLE_FEAT_RAS),0)
160                $(error For FAULT_INJECTION_SUPPORT, ENABLE_FEAT_RAS must not be 0)
161	endif
162endif #(FAULT_INJECTION_SUPPORT)
163
164# DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
165ifeq ($(DYN_DISABLE_AUTH), 1)
166	ifeq (${TRUSTED_BOARD_BOOT}, 0)
167                $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH \
168                to be set.")
169	endif
170endif #(DYN_DISABLE_AUTH)
171
172# SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
173ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
174        $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
175endif
176
177# If pointer authentication is used in the firmware, make sure that all the
178# registers associated to it are also saved and restored.
179# Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
180ifneq ($(ENABLE_PAUTH),0)
181	ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
182                $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS to be enabled)
183	endif
184endif #(ENABLE_PAUTH)
185
186ifneq ($(CTX_INCLUDE_PAUTH_REGS),0)
187	ifneq (${ARCH},aarch64)
188                $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
189	endif
190endif #(CTX_INCLUDE_PAUTH_REGS)
191
192# Check ENABLE_FEAT_PAUTH_LR
193ifneq (${ENABLE_FEAT_PAUTH_LR},0)
194
195# Make sure PAUTH is enabled
196ifeq (${ENABLE_PAUTH},0)
197        $(error Error: PAUTH_LR cannot be used without PAUTH (see BRANCH_PROTECTION))
198endif
199
200# Make sure SCTLR2 is enabled
201ifeq (${ENABLE_FEAT_SCTLR2},0)
202        $(error Error: PAUTH_LR cannot be used without ENABLE_FEAT_SCTLR2)
203endif
204
205# FEAT_PAUTH_LR is only supported in aarch64 state
206ifneq (${ARCH},aarch64)
207        $(error ENABLE_FEAT_PAUTH_LR requires AArch64)
208endif
209
210endif # ${ENABLE_FEAT_PAUTH_LR}
211
212ifeq ($(FEATURE_DETECTION),1)
213        $(info FEATURE_DETECTION is an experimental feature)
214endif #(FEATURE_DETECTION)
215
216ifneq ($(ENABLE_SME2_FOR_NS), 0)
217	ifeq (${ENABLE_SME_FOR_NS}, 0)
218                $(warning "ENABLE_SME2_FOR_NS requires ENABLE_SME_FOR_NS also \
219                to be set")
220                $(warning "Forced ENABLE_SME_FOR_NS=1")
221                override ENABLE_SME_FOR_NS	:= 1
222	endif
223endif #(ENABLE_SME2_FOR_NS)
224
225ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
226	ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
227                $(error "ALLOW_RO_XLAT_TABLES requires translation tables \
228                library v2")
229	endif
230endif #(ARM_XLAT_TABLES_LIB_V1)
231
232ifneq (${DECRYPTION_SUPPORT},none)
233	ifeq (${TRUSTED_BOARD_BOOT}, 0)
234                $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT \
235                to be set)
236	endif
237endif #(DECRYPTION_SUPPORT)
238
239# Ensure that no Aarch64-only features are enabled in Aarch32 build
240ifeq (${ARCH},aarch32)
241        ifneq (${ENABLE_LTO},0)
242                $(error "ENABLE_LTO is not supported with ARCH=aarch32")
243        endif
244        ifneq (${EL3_EXCEPTION_HANDLING},0)
245                $(error "EL3_EXCEPTION_HANDLING is not supported outside BL31")
246        endif
247
248        ifeq (${CRASH_REPORTING},1)
249                $(error "CRASH_REPORTING is not supported with ARCH=aarch32")
250        endif
251
252	# SME/SVE only supported on AArch64
253	ifneq (${ENABLE_SME_FOR_NS},0)
254                $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
255	endif
256
257	ifneq (${ENABLE_SVE_FOR_NS},0)
258                $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
259	endif
260
261	ifneq (${ENABLE_SPE_FOR_NS},0)
262                $(error "ENABLE_SPE_FOR_NS cannot be used with ARCH=aarch32")
263	endif
264
265	# BRBE is not supported in AArch32
266	ifneq (${ENABLE_BRBE_FOR_NS},0)
267                $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
268	endif
269
270	# FEAT_RNG_TRAP is not supported in AArch32
271	ifneq (${ENABLE_FEAT_RNG_TRAP},0)
272                $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
273	endif
274
275	ifneq (${ENABLE_FEAT_FPMR},0)
276                $(error "ENABLE_FEAT_FPMR cannot be used with ARCH=aarch32")
277	endif
278
279	ifeq (${ARCH_FEATURE_AVAILABILITY},1)
280                $(error "ARCH_FEATURE_AVAILABILITY cannot be used with ARCH=aarch32")
281	endif
282	# FEAT_MOPS is only supported on AArch64
283	ifneq (${ENABLE_FEAT_MOPS},0)
284                $(error "ENABLE_FEAT_MOPS cannot be used with ARCH=aarch32")
285	endif
286	ifneq (${ENABLE_FEAT_GCIE},0)
287                $(error "ENABLE_FEAT_GCIE cannot be used with ARCH=aarch32")
288	endif
289	ifneq (${ENABLE_FEAT_CPA2},0)
290                $(error "ENABLE_FEAT_CPA2 cannot be used with ARCH=aarch32")
291	endif
292        ifneq (${USE_SPINLOCK_CAS},0)
293                $(error "USE_SPINLOCK_CAS is not supported with ARCH=aarch32")
294        endif
295	ifneq (${PLATFORM_NODE_COUNT},1)
296                $(error "NUMA AWARE PER CPU is not supported with ARCH=aarch32")
297	endif
298	ifneq (${ENABLE_FEAT_MPAM},0)
299                $(error "ENABLE_FEAT_MPAM cannot be used with ARCH=aarch32")
300	endif
301	ifneq (${ENABLE_FEAT_UINJ},0)
302		$(error "ENABLE_FEAT_UINJ cannot be used with ARCH=aarch32")
303	endif
304endif #(ARCH=aarch32)
305
306ifneq (${ENABLE_FEAT_FPMR},0)
307	ifeq (${ENABLE_FEAT_FGT},0)
308                $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_FGT")
309	endif
310	ifeq (${ENABLE_FEAT_HCX},0)
311                $(error "ENABLE_FEAT_FPMR requires ENABLE_FEAT_HCX")
312	endif
313endif #(ENABLE_FEAT_FPMR)
314
315ifneq (${ENABLE_FEAT_CPA2},0)
316	ifeq (${ENABLE_FEAT_SCTLR2},0)
317                $(error "Error: ENABLE_FEAT_CPA2 cannot be used without ENABLE_FEAT_SCTLR2")
318	endif
319endif #${ENABLE_FEAT_CPA2}
320
321ifneq (${ENABLE_SME_FOR_NS},0)
322	ifeq (${ENABLE_SVE_FOR_NS},0)
323                $(error "ENABLE_SME_FOR_NS requires ENABLE_SVE_FOR_NS")
324	endif
325endif #(ENABLE_SME_FOR_NS)
326
327# Secure SME/SVE requires the non-secure component as well
328ifeq (${ENABLE_SME_FOR_SWD},1)
329	ifeq (${ENABLE_SME_FOR_NS},0)
330                $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
331	endif
332	ifeq (${ENABLE_SVE_FOR_SWD},0)
333                $(error "ENABLE_SME_FOR_SWD requires ENABLE_SVE_FOR_SWD")
334	endif
335endif #(ENABLE_SME_FOR_SWD)
336
337# Enabling SVE for SWD requires enabling SVE for NWD due to ENABLE_FEAT
338# mechanism.
339ifeq (${ENABLE_SVE_FOR_SWD},1)
340    ifeq (${ENABLE_SVE_FOR_NS},0)
341        $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
342    endif
343endif
344
345# Enabling FEAT_MOPS requires access to hcrx_el2 registers which is
346# available only when FEAT_HCX is enabled.
347ifneq (${ENABLE_FEAT_MOPS},0)
348    ifeq (${ENABLE_FEAT_HCX},0)
349        $(error "ENABLE_FEAT_MOPS requires ENABLE_FEAT_HCX")
350    endif
351endif
352
353# Enabling SVE for both the worlds typically requires the context
354# management of SVE registers. The only exception being SPMC at S-EL2.
355ifeq (${ENABLE_SVE_FOR_SWD}, 1)
356    ifneq (${ENABLE_SVE_FOR_NS}, 0)
357        ifeq (${CTX_INCLUDE_SVE_REGS}-$(SPMD_SPM_AT_SEL2),0-0)
358            $(warning "ENABLE_SVE_FOR_SWD and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
359        endif
360    endif
361endif
362
363# Enabling SVE in either world while enabling CTX_INCLUDE_FPREGS requires
364# CTX_INCLUDE_SVE_REGS to be enabled due to architectural dependency between FP
365# and SVE registers.
366ifeq (${CTX_INCLUDE_FPREGS}, 1)
367    ifneq (${ENABLE_SVE_FOR_NS},0)
368        ifeq (${CTX_INCLUDE_SVE_REGS},0)
369            # Warning instead of error due to CI dependency on this
370            $(warning "CTX_INCLUDE_FPREGS and ENABLE_SVE_FOR_NS together require CTX_INCLUDE_SVE_REGS")
371            $(warning "Forced ENABLE_SVE_FOR_NS=0")
372            override ENABLE_SVE_FOR_NS	:= 0
373        endif
374    endif
375endif #(CTX_INCLUDE_FPREGS)
376
377# SVE context management is only required if secure world has access to SVE/FP
378# functionality.
379# Enabling CTX_INCLUDE_SVE_REGS requires CTX_INCLUDE_FPREGS to be enabled due
380# to architectural dependency between FP and SVE registers.
381ifeq (${CTX_INCLUDE_SVE_REGS},1)
382    ifeq (${ENABLE_SVE_FOR_SWD},0)
383        $(error "CTX_INCLUDE_SVE_REGS requires ENABLE_SVE_FOR_SWD to also be enabled")
384    endif
385    ifeq (${CTX_INCLUDE_FPREGS},0)
386        $(error "CTX_INCLUDE_SVE_REGS requires CTX_INCLUDE_FPREGS to also be enabled")
387    endif #(CTX_INCLUDE_FPREGS)
388endif #(CTX_INCLUDE_SVE_REGS)
389
390# SME cannot be used with CTX_INCLUDE_FPREGS since SPM does its own context
391# management including FPU registers.
392ifeq (${CTX_INCLUDE_FPREGS},1)
393    ifneq (${ENABLE_SME_FOR_NS},0)
394        $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
395    endif
396endif #(CTX_INCLUDE_FPREGS)
397
398ifeq ($(DRTM_SUPPORT),1)
399        $(info DRTM_SUPPORT is an experimental feature)
400endif
401
402ifeq (${HOB_LIST},1)
403        $(warning HOB_LIST is an experimental feature)
404endif
405
406ifeq (${TRANSFER_LIST},1)
407        $(info TRANSFER_LIST is an experimental feature)
408endif
409
410ifeq ($(PSA_CRYPTO),1)
411        $(info PSA_CRYPTO is an experimental feature)
412endif
413
414ifeq ($(DICE_PROTECTION_ENVIRONMENT),1)
415        $(info DICE_PROTECTION_ENVIRONMENT is an experimental feature)
416endif
417
418ifeq (${LFA_SUPPORT},1)
419        $(warning LFA_SUPPORT is an experimental feature)
420endif #(LFA_SUPPORT)
421
422ifneq (${ENABLE_FEAT_MPAM_PE_BW_CTRL},0)
423        ifeq (${ENABLE_FEAT_MPAM},0)
424                $(error "ENABLE_FEAT_MPAM_PW_BW_CTRL requires ENABLE_FEAT_MPAM")
425        endif
426endif #(ENABLE_FEAT_MPAM_PE_BW_CTRL)
427
428ifneq (${DYNAMIC_WORKAROUND_CVE_2018_3639},0)
429        ifeq (${WORKAROUND_CVE_2018_3639},0)
430                $(error Error: WORKAROUND_CVE_2018_3639 must be 1 if DYNAMIC_WORKAROUND_CVE_2018_3639 is 1)
431        endif
432endif
433
434# Handle all deprecated build options.
435ifeq (${ERROR_DEPRECATED}, 1)
436    ifneq (${NS_TIMER_SWITCH},0)
437        $(error "NS_TIMER_SWITCH breaks Linux preemption model, hence deprecated")
438    endif
439    ifneq (${SPM_MM},0)
440        $(error "SPM_MM build option is deprecated")
441    endif
442endif
443
444ifneq (${ENABLE_FEAT_IDTE3},0)
445        $(info FEAT_IDTE3 is an experimental feature)
446endif #(ENABLE_FEAT_IDTE3)
447