blob: 44a3fb2b579a0a6f641f98f73d5faae40da5c52f [file] [log] [blame]
Soby Mathewb4c6df42022-11-09 11:13:29 +00001#
2# SPDX-License-Identifier: BSD-3-Clause
3# SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4#
5
6#
7# Common config options
8#
9arm_config_option(
10 NAME MAX_CPUS
11 HELP "Maximum number of CPUs supported by RMM"
12 TYPE STRING
13 DEFAULT 16)
14
15#
16# The RMM is mapped with 4K pages, and all RMM APIs use the same granularity.
17#
18arm_config_option(
Mate Toth-Palac0cfbb2023-06-19 16:29:52 +020019 NAME GRANULE_SHIFT
20 HELP "The shift value of granule size. i.e: GRANULE_SIZE == 1 << GRANULE_SHIFT"
Soby Mathewb4c6df42022-11-09 11:13:29 +000021 TYPE STRING
Mate Toth-Palac0cfbb2023-06-19 16:29:52 +020022 DEFAULT 12)
Soby Mathewb4c6df42022-11-09 11:13:29 +000023
AlexeiFedorov7c5001a2022-12-14 13:22:33 +000024#
AlexeiFedorovffef39a2024-10-28 16:35:21 +000025# RMM_MAX_GRANULES. Maximum number of memory granules supported.
AlexeiFedorov7c5001a2022-12-14 13:22:33 +000026#
27arm_config_option(
28 NAME RMM_MAX_GRANULES
AlexeiFedorovffef39a2024-10-28 16:35:21 +000029 HELP "Maximum number of memory granules supported"
30 TYPE STRING
31 DEFAULT 0x0)
32
33#
34# RMM_MAX_COH_GRANULES. Maximum number of coherent device granules supported.
35#
36arm_config_option(
37 NAME RMM_MAX_COH_GRANULES
38 HELP "Maximum number of coherent device granules supported"
39 TYPE STRING
AlexeiFedorov037add62024-10-30 15:53:05 +000040 DEFAULT 1)
AlexeiFedorovffef39a2024-10-28 16:35:21 +000041
42#
43# RMM_MAX_NCOH_GRANULES. Maximum number of non-coherent device granules supported.
44#
45arm_config_option(
46 NAME RMM_MAX_NCOH_GRANULES
47 HELP "Maximum number of non-coherent device granules supported"
AlexeiFedorov7c5001a2022-12-14 13:22:33 +000048 TYPE STRING
AlexeiFedorov037add62024-10-30 15:53:05 +000049 DEFAULT 1)
AlexeiFedorov7c5001a2022-12-14 13:22:33 +000050
Soby Mathewb4c6df42022-11-09 11:13:29 +000051arm_config_option(
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +020052 NAME RMM_NUM_PAGES_PER_STACK
53 HELP "Number of pages to use per CPU stack"
54 TYPE STRING
55 DEFAULT 5
56 ADVANCED)
57
58arm_config_option(
Soby Mathewb4c6df42022-11-09 11:13:29 +000059 NAME RMM_DOCS
60 HELP "RMM Documentation build"
61 TYPE BOOL
62 DEFAULT OFF)
63
64# TODO: Move to lib/arch once MbedTLS compilation is moved to build phase.
65arm_config_option(
66 NAME RMM_FPU_USE_AT_REL2
67 HELP "Enable Advanced SIMD support in RMM"
68 TYPE BOOL
Soby Mathew9b2de242024-02-27 16:08:42 +000069 DEFAULT OFF)
Soby Mathewb4c6df42022-11-09 11:13:29 +000070
71#
AlexeiFedorovea68b552023-10-03 11:11:47 +010072# The number of 4K pages allocated for attestation buffer.
73#
74arm_config_option(
75 NAME RMM_CCA_TOKEN_BUFFER
76 HELP "Number of pages to allocate in Aux granules for Realm CCA token"
77 TYPE STRING
78 DEFAULT 1)
79
Arunachalam Ganapathy33e3bdc2024-04-10 20:55:40 +010080arm_config_option(
Arunachalam Ganapathy56aeccc2024-10-24 15:03:55 +010081 NAME RMM_V1_1
82 HELP "Enable v1.1 features in RMM (experimental)"
Arunachalam Ganapathy33e3bdc2024-04-10 20:55:40 +010083 TYPE BOOL
84 DEFAULT OFF)
85
Soby Mathewe307b0a2024-10-03 12:12:52 +010086arm_config_option(
87 NAME ATTEST_EL3_TOKEN_SIGN
88 HELP "Use EL3 service to sign realm attestation token."
89 TYPE BOOL
90 DEFAULT OFF
91 ADVANCED)
92
AlexeiFedorovea68b552023-10-03 11:11:47 +010093#
Jacob Man Chun Yiuf1b6d042025-02-17 16:47:06 +000094# Enable the Stack protection compiler flag.
95# Having the PAUTH and BTI feature enabled makes the software-based
96# stack frame canary redundant. Enabling the software canary could
97# have a performance degradation. Hence the default is OFF.
98#
99arm_config_option(
100 NAME STACK_PROTECTOR
101 HELP "Enable Stack Protection Compiler Flags"
102 string OFF)
103
104#
Soby Mathewb4c6df42022-11-09 11:13:29 +0000105# Introduce a pseudo-library purely for applying flags to RMM's libraries.
106# This is applied to any targets created after this point.
107#
108
109add_library(rmm-common INTERFACE)
110
111target_compile_definitions(rmm-common
112 INTERFACE "$<$<CONFIG:Debug>:DEBUG>")
113
114if(MAX_CPUS EQUAL 0x0)
115 message(FATAL_ERROR "MAX_CPUS is not initialized")
116endif()
117
118target_compile_definitions(rmm-common
Javier Almansa Sobrinoc4ad5b02022-07-05 19:05:14 +0100119 INTERFACE "MAX_CPUS=${MAX_CPUS}U")
Soby Mathewb4c6df42022-11-09 11:13:29 +0000120
Mate Toth-Palac0cfbb2023-06-19 16:29:52 +0200121if(NOT(GRANULE_SHIFT EQUAL 12))
122 message(FATAL_ERROR "GRANULE_SHIFT is not initialized correctly")
Soby Mathewb4c6df42022-11-09 11:13:29 +0000123endif()
124
125target_compile_definitions(rmm-common
Mate Toth-Palac0cfbb2023-06-19 16:29:52 +0200126 INTERFACE "GRANULE_SHIFT=U(${GRANULE_SHIFT})")
Soby Mathewb4c6df42022-11-09 11:13:29 +0000127
AlexeiFedorov7c5001a2022-12-14 13:22:33 +0000128if (RMM_MAX_GRANULES EQUAL 0x0)
129 message (FATAL_ERROR "RMM_MAX_GRANULES not configured")
130endif()
131
132target_compile_definitions(rmm-common
133 INTERFACE "RMM_MAX_GRANULES=U(${RMM_MAX_GRANULES})")
134
AlexeiFedorov037add62024-10-30 15:53:05 +0000135if (RMM_MAX_COH_GRANULES EQUAL 0x0)
136 message (FATAL_ERROR "RMM_MAX_COH_GRANULES cannot be set to 0")
137endif()
138
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +0200139target_compile_definitions(rmm-common
AlexeiFedorovffef39a2024-10-28 16:35:21 +0000140 INTERFACE "RMM_MAX_COH_GRANULES=U(${RMM_MAX_COH_GRANULES})")
141
142if (RMM_MAX_NCOH_GRANULES EQUAL 0x0)
AlexeiFedorov037add62024-10-30 15:53:05 +0000143 message (FATAL_ERROR "RMM_MAX_NCOH_GRANULES cannot be set to 0")
AlexeiFedorovffef39a2024-10-28 16:35:21 +0000144endif()
145
146target_compile_definitions(rmm-common
147 INTERFACE "RMM_MAX_NCOH_GRANULES=U(${RMM_MAX_NCOH_GRANULES})")
148
149target_compile_definitions(rmm-common
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +0200150 INTERFACE "RMM_NUM_PAGES_PER_STACK=UL(${RMM_NUM_PAGES_PER_STACK})")
151
Jacob Man Chun Yiuf1b6d042025-02-17 16:47:06 +0000152# Set stack protector option.
153if(STACK_PROTECTOR)
154 target_compile_definitions(rmm-common
155 INTERFACE "STACK_PROTECTOR_ENABLED=1")
156 message(STATUS "Stack Protector is Enabled.")
157 add_compile_options(-fstack-protector-strong)
158endif()
159
Arunachalam Ganapathy188d9e62024-04-18 13:42:56 +0100160if(RMM_FPU_USE_AT_REL2 AND RMM_ARCH STREQUAL aarch64)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000161 target_compile_definitions(rmm-common
162 INTERFACE "RMM_FPU_USE_AT_REL2=1")
163endif()
164
AlexeiFedorovea68b552023-10-03 11:11:47 +0100165target_compile_definitions(rmm-common
166 INTERFACE "RMM_CCA_TOKEN_BUFFER=U(${RMM_CCA_TOKEN_BUFFER})")
167
Soby Mathewb4c6df42022-11-09 11:13:29 +0000168#
169# Project name and version
170#
171target_compile_definitions(rmm-common
172 INTERFACE "NAME=\"${PROJECT_NAME}\"")
173
174target_compile_definitions(rmm-common
175 INTERFACE "VERSION=\"${PROJECT_VERSION}\"")
176
177#
178# Get git commit information
179#
Soby Mathewb5a29752024-11-14 14:26:11 +0000180Git_Get_Commit_Info(COMMIT_INFO)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000181
182target_compile_definitions(rmm-common
183 INTERFACE "COMMIT_INFO=\"${COMMIT_INFO}\"")
184
Arunachalam Ganapathy56aeccc2024-10-24 15:03:55 +0100185if(RMM_V1_1)
186 message(WARNING "RMM v1.1 features are experimental")
Arunachalam Ganapathy33e3bdc2024-04-10 20:55:40 +0100187 target_compile_definitions(rmm-common
Arunachalam Ganapathy56aeccc2024-10-24 15:03:55 +0100188 INTERFACE "RMM_V1_1=1")
Arunachalam Ganapathy33e3bdc2024-04-10 20:55:40 +0100189endif()
190
Soby Mathewb4c6df42022-11-09 11:13:29 +0000191link_libraries(rmm-common)