xref: /optee_os/mk/config.mk (revision ccbc05e1edcc7d1eae3b230e7a18b1e0e756e429)
1# Default configuration values for OP-TEE core (all platforms).
2#
3# Platform-specific overrides are in core/arch/arm32/plat-*/conf.mk.
4# Some subsystem-specific defaults are not here but rather in */sub.mk.
5#
6# Configuration values may be assigned from multiple sources.
7# From higher to lower priority:
8#
9#   1. Make arguments ('make CFG_FOO=bar...')
10#   2. The file specified by $(CFG_OPTEE_CONFIG) (if defined)
11#   3. The environment ('CFG_FOO=bar make...')
12#   4. The platform-specific configuration file: core/arch/arm32/plat-*/conf.mk
13#   5. This file
14#   6. Subsystem-specific makefiles (*/sub.mk)
15#
16# Actual values used during the build are output to $(out-dir)/conf.mk
17# (CFG_* variables only).
18
19# Cross-compiler prefix and suffix
20CROSS_COMPILE ?= arm-linux-gnueabihf-
21CROSS_COMPILE32 ?= $(CROSS_COMPILE)
22CROSS_COMPILE64 ?= aarch64-linux-gnu-
23COMPILER ?= gcc
24
25# For convenience
26ifdef CFLAGS
27CFLAGS32 ?= $(CFLAGS)
28CFLAGS64 ?= $(CFLAGS)
29endif
30
31# Compiler warning level.
32# Supported values: undefined, 1, 2 and 3. 3 gives more warnings.
33WARNS ?= 3
34
35# Define DEBUG=1 to compile without optimization (forces -O0)
36# DEBUG=1
37
38# If y, enable debug features of the TEE core (assertions and lock checks
39# are enabled, panic and assert messages are more verbose, data and prefetch
40# aborts show a stack dump). When disabled, the NDEBUG directive is defined
41# so assertions are disabled.
42CFG_TEE_CORE_DEBUG ?= y
43
44# Log levels for the TEE core. Defines which core messages are displayed
45# on the secure console. Disabling core log (level set to 0) also disables
46# logs from the TAs.
47# 0: none
48# 1: error
49# 2: error + warning
50# 3: error + warning + debug
51# 4: error + warning + debug + flow
52CFG_TEE_CORE_LOG_LEVEL ?= 1
53
54# TA log level
55# If user-mode library libutils.a is built with CFG_TEE_TA_LOG_LEVEL=0,
56# TA tracing is disabled regardless of the value of CFG_TEE_TA_LOG_LEVEL
57# when the TA is built.
58CFG_TEE_TA_LOG_LEVEL ?= 1
59
60# TA enablement
61# When defined to "y", TA traces are output according to
62# CFG_TEE_TA_LOG_LEVEL. Otherwise, they are not output at all
63CFG_TEE_CORE_TA_TRACE ?= y
64
65# If y, enable the memory leak detection feature in the bget memory allocator.
66# When this feature is enabled, calling mdbg_check(1) will print a list of all
67# the currently allocated buffers and the location of the allocation (file and
68# line number).
69# Note: make sure the log level is high enough for the messages to show up on
70# the secure console! For instance:
71# - To debug user-mode (TA) allocations: build OP-TEE *and* the TA with:
72#   $ make CFG_TEE_TA_MALLOC_DEBUG=y CFG_TEE_TA_LOG_LEVEL=3
73# - To debug TEE core allocations: build OP-TEE with:
74#   $ make CFG_TEE_CORE_MALLOC_DEBUG=y CFG_TEE_CORE_LOG_LEVEL=3
75CFG_TEE_CORE_MALLOC_DEBUG ?= n
76CFG_TEE_TA_MALLOC_DEBUG ?= n
77# Prints an error message and dumps the stack on failed memory allocations
78# using malloc() and friends.
79CFG_CORE_DUMP_OOM ?= $(CFG_TEE_CORE_MALLOC_DEBUG)
80
81# Mask to select which messages are prefixed with long debugging information
82# (severity, core ID, thread ID, component name, function name, line number)
83# based on the message level. If BIT(level) is set, the long prefix is shown.
84# Otherwise a short prefix is used (severity and component name only).
85# Levels: 0=none 1=error 2=info 3=debug 4=flow
86CFG_MSG_LONG_PREFIX_MASK ?= 0x1a
87
88# PRNG configuration
89# If CFG_WITH_SOFTWARE_PRNG is enabled, crypto provider provided
90# software PRNG implementation is used.
91# Otherwise, you need to implement hw_get_random_byte() for your platform
92CFG_WITH_SOFTWARE_PRNG ?= y
93
94# Number of threads
95CFG_NUM_THREADS ?= 2
96
97# API implementation version
98CFG_TEE_API_VERSION ?= GPD-1.1-dev
99
100# Implementation description (implementation-dependent)
101CFG_TEE_IMPL_DESCR ?= OPTEE
102
103# Should OPTEE_SMC_CALL_GET_OS_REVISION return a build identifier to Normal
104# World?
105CFG_OS_REV_REPORTS_GIT_SHA1 ?= y
106
107# Trusted OS implementation version
108TEE_IMPL_VERSION ?= $(shell git describe --always --dirty=-dev 2>/dev/null || echo Unknown)
109ifeq ($(CFG_OS_REV_REPORTS_GIT_SHA1),y)
110TEE_IMPL_GIT_SHA1 := 0x$(shell git rev-parse --short=8 HEAD 2>/dev/null || echo 0)
111else
112TEE_IMPL_GIT_SHA1 := 0x0
113endif
114# The following values are not extracted from the "git describe" output because
115# we might be outside of a Git environment, or the tree may have been cloned
116# with limited depth not including any tag, so there is really no guarantee
117# that TEE_IMPL_VERSION contains the major and minor revision numbers.
118CFG_OPTEE_REVISION_MAJOR ?= 3
119CFG_OPTEE_REVISION_MINOR ?= 5
120
121# Trusted OS implementation manufacturer name
122CFG_TEE_MANUFACTURER ?= LINARO
123
124# Trusted firmware version
125CFG_TEE_FW_IMPL_VERSION ?= FW_IMPL_UNDEF
126
127# Trusted OS implementation manufacturer name
128CFG_TEE_FW_MANUFACTURER ?= FW_MAN_UNDEF
129
130# Rich Execution Environment (REE) file system support: normal world OS
131# provides the actual storage.
132# This is the default FS when enabled (i.e., the one used when
133# TEE_STORAGE_PRIVATE is passed to the trusted storage API)
134CFG_REE_FS ?= y
135
136# RPMB file system support
137CFG_RPMB_FS ?= n
138
139# Device identifier used when CFG_RPMB_FS = y.
140# The exact meaning of this value is platform-dependent. On Linux, the
141# tee-supplicant process will open /dev/mmcblk<id>rpmb
142CFG_RPMB_FS_DEV_ID ?= 0
143
144# Enables RPMB key programming by the TEE, in case the RPMB partition has not
145# been configured yet.
146# !!! Security warning !!!
147# Do *NOT* enable this in product builds, as doing so would allow the TEE to
148# leak the RPMB key.
149# This option is useful in the following situations:
150# - Testing
151# - RPMB key provisioning in a controlled environment (factory setup)
152CFG_RPMB_WRITE_KEY ?= n
153
154# Embed public part of this key in OP-TEE OS
155TA_SIGN_KEY ?= keys/default_ta.pem
156
157# Include lib/libutils/isoc in the build? Most platforms need this, but some
158# may not because they obtain the isoc functions from elsewhere
159CFG_LIBUTILS_WITH_ISOC ?= y
160
161# Enables floating point support for user TAs
162# ARM32: EABI defines both a soft-float ABI and a hard-float ABI,
163#	 hard-float is basically a super set of soft-float. Hard-float
164#	 requires all the support routines provided for soft-float, but the
165#	 compiler may choose to optimize to not use some of them and use
166#	 the floating-point registers instead.
167# ARM64: EABI doesn't define a soft-float ABI, everything is hard-float (or
168#	 nothing with ` -mgeneral-regs-only`)
169# With CFG_TA_FLOAT_SUPPORT enabled TA code is free use floating point types
170CFG_TA_FLOAT_SUPPORT ?= y
171
172# Stack unwinding: print a stack dump to the console on core or TA abort, or
173# when a TA panics.
174# If CFG_UNWIND is enabled, both the kernel and user mode call stacks can be
175# unwound (not paged TAs, however).
176# Note that 32-bit ARM code needs unwind tables for this to work, so enabling
177# this option will increase the size of the 32-bit TEE binary by a few KB.
178# Similarly, TAs have to be compiled with -funwind-tables (default when the
179# option is set) otherwise they can't be unwound.
180# Warning: since the unwind sequence for user-mode (TA) code is implemented in
181# the privileged layer of OP-TEE, enabling this feature will weaken the
182# user/kernel isolation. Therefore it should be disabled in release builds.
183ifeq ($(CFG_TEE_CORE_DEBUG),y)
184CFG_UNWIND ?= y
185endif
186
187# Enable support for dynamically loaded user TAs
188CFG_WITH_USER_TA ?= y
189
190# Choosing the architecture(s) of user-mode libraries (used by TAs)
191#
192# Platforms may define a list of supported architectures for user-mode code
193# by setting $(supported-ta-targets). Valid values are "ta_arm32", "ta_arm64",
194# "ta_arm32 ta_arm64" and "ta_arm64 ta_arm32".
195# $(supported-ta-targets) defaults to "ta_arm32" when the TEE core is 32-bits,
196# and "ta_arm32 ta_arm64" when it is 64-bits (that is, when CFG_ARM64_core=y).
197# The first entry in $(supported-ta-targets) has a special role, see
198# CFG_USER_TA_TARGET_<ta-name> below.
199#
200# CFG_USER_TA_TARGETS may be defined to restrict $(supported-ta-targets) or
201# change the order of the values.
202#
203# The list of TA architectures is ultimately stored in $(ta-targets).
204
205# CFG_USER_TA_TARGET_<ta-name> (for example, CFG_USER_TA_TARGET_avb), if
206# defined, selects the unique TA architecture mode for building the in-tree TA
207# <ta-name>. Can be either ta_arm32 or ta_arm64.
208# By default, in-tree TAs are built using the first architecture specified in
209# $(ta-targets).
210
211# Address Space Layout Randomization for user-mode Trusted Applications
212#
213# When this flag is enabled, the ELF loader will introduce a random offset
214# when mapping the application in user space. ASLR makes the exploitation of
215# memory corruption vulnerabilities more difficult.
216CFG_TA_ASLR ?= n
217
218# How much ASLR may shift the base address (in pages). The base address is
219# randomly shifted by an integer number of pages comprised between these two
220# values. Bigger ranges are more secure because they make the addresses harder
221# to guess at the expense of using more memory for the page tables.
222CFG_TA_ASLR_MIN_OFFSET_PAGES ?= 0
223CFG_TA_ASLR_MAX_OFFSET_PAGES ?= 128
224
225# Load user TAs from the REE filesystem via tee-supplicant
226CFG_REE_FS_TA ?= y
227
228# Pre-authentication of TA binaries loaded from the REE filesystem
229#
230# - If CFG_REE_FS_TA_BUFFERED=y: load TA binary into a temporary buffer in the
231#   "Secure DDR" pool, check the signature, then process the file only if it is
232#   valid.
233# - If disabled: hash the binaries as they are being processed and verify the
234#   signature as a last step.
235CFG_REE_FS_TA_BUFFERED ?= $(CFG_REE_FS_TA)
236$(eval $(call cfg-depends-all,CFG_REE_FS_TA_BUFFERED,CFG_REE_FS_TA))
237
238# Support for loading user TAs from a special section in the TEE binary.
239# Such TAs are available even before tee-supplicant is available (hence their
240# name), but note that many services exported to TAs may need tee-supplicant,
241# so early use is limited to a subset of the TEE Internal Core API (crypto...)
242# To use this feature, set EARLY_TA_PATHS to the paths to one or more TA ELF
243# file(s). For example:
244#   $ make ... \
245#     EARLY_TA_PATHS="path/to/8aaaf200-2450-11e4-abe2-0002a5d5c51b.stripped.elf \
246#                     path/to/cb3e5ba0-adf1-11e0-998b-0002a5d5c51b.stripped.elf"
247# Typical build steps:
248#   $ make ta_dev_kit CFG_EARLY_TA=y # Create the dev kit (user mode libraries,
249#                                    # headers, makefiles), ready to build TAs.
250#                                    # CFG_EARLY_TA=y is optional, it prevents
251#                                    # later library recompilations.
252#   <build some TAs>
253#   $ make EARLY_TA_PATHS=<paths>    # Build OP-TEE and embbed the TA(s)
254#
255# Another option is CFG_IN_TREE_EARLY_TAS which is used to point at
256# in-tree TAs. CFG_IN_TREE_EARLY_TAS is formatted as:
257# <name-of-ta>/<uuid>
258# for instance avb/023f8f1a-292a-432b-8fc4-de8471358067
259ifneq ($(EARLY_TA_PATHS)$(CFG_IN_TREE_EARLY_TAS),)
260$(call force,CFG_EARLY_TA,y)
261else
262CFG_EARLY_TA ?= n
263endif
264ifeq ($(CFG_EARLY_TA),y)
265$(call force,CFG_ZLIB,y)
266endif
267
268# Support for dynamically linked user TAs
269CFG_TA_DYNLINK ?= y
270
271# Enable paging, requires SRAM, can't be enabled by default
272CFG_WITH_PAGER ?= n
273
274# Runtime lock dependency checker: ensures that a proper locking hierarchy is
275# used in the TEE core when acquiring and releasing mutexes. Any violation will
276# cause a panic as soon as the invalid locking condition is detected. If
277# CFG_UNWIND is enabled, the algorithm records the call stacks when locks are
278# taken, and prints them when a potential deadlock is found.
279# Expect a significant performance impact when enabling this.
280CFG_LOCKDEP ?= n
281
282# BestFit algorithm in bget reduces the fragmentation of the heap when running
283# with the pager enabled or lockdep
284CFG_CORE_BGET_BESTFIT ?= $(call cfg-one-enabled, CFG_WITH_PAGER CFG_LOCKDEP)
285
286# Use the pager for user TAs
287CFG_PAGED_USER_TA ?= $(CFG_WITH_PAGER)
288
289# Enable support for detected undefined behavior in C
290# Uses a lot of memory, can't be enabled by default
291CFG_CORE_SANITIZE_UNDEFINED ?= n
292
293# Enable Kernel Address sanitizer, has a huge performance impact, uses a
294# lot of memory and need platform specific adaptations, can't be enabled by
295# default
296CFG_CORE_SANITIZE_KADDRESS ?= n
297
298# Device Tree support
299#
300# When CFG_DT is enabled core embeds the FDT library (libfdt) allowing
301# device tree blob (DTB) parsing from the core.
302#
303# When CFG_DT is enabled, the TEE _start function expects to find
304# the address of a DTB in register X2/R2 provided by the early boot stage
305# or value 0 if boot stage provides no DTB.
306#
307# When CFG_EMBED_DTB is enabled, CFG_EMBED_DTB_SOURCE_FILE shall define the
308# relative path of a DTS file located in core/arch/$(ARCH)/dts.
309# The DTS file is compiled into a DTB file which content is embedded in a
310# read-only section of the core.
311ifneq ($(strip $(CFG_EMBED_DTB_SOURCE_FILE)),)
312CFG_EMBED_DTB ?= y
313endif
314ifeq ($(CFG_EMBED_DTB),y)
315$(call force,CFG_DT,y)
316endif
317CFG_EMBED_DTB ?= n
318CFG_DT ?= n
319
320# Maximum size of the Device Tree Blob, has to be large enough to allow
321# editing of the supplied DTB.
322CFG_DTB_MAX_SIZE ?= 0x10000
323
324# Device Tree Overlay support.
325# This define enables support for an OP-TEE provided DTB overlay.
326# One of two modes is supported in this case:
327# 1. Append OP-TEE nodes to an existing DTB overlay located at CFG_DT_ADDR or
328#    passed in arg2
329# 2. Generate a new DTB overlay at CFG_DT_ADDR
330# A subsequent boot stage must then merge the generated overlay DTB into a main
331# DTB using the standard fdt_overlay_apply() method.
332CFG_EXTERNAL_DTB_OVERLAY ?= n
333
334# Enable core self tests and related pseudo TAs
335CFG_TEE_CORE_EMBED_INTERNAL_TESTS ?= y
336
337# This option enables OP-TEE to respond to SMP boot request: the Rich OS
338# issues this to request OP-TEE to release secondaries cores out of reset,
339# with specific core number and non-secure entry address.
340CFG_BOOT_SECONDARY_REQUEST ?= n
341
342# Default heap size for Core, 64 kB
343CFG_CORE_HEAP_SIZE ?= 65536
344
345# Default size of nexus heap. 16 kB. Used only if CFG_VIRTUALIZATION
346# is enabled
347CFG_CORE_NEX_HEAP_SIZE ?= 16384
348
349# TA profiling.
350# When this option is enabled, OP-TEE can execute Trusted Applications
351# instrumented with GCC's -pg flag and will output profiling information
352# in gmon.out format to /tmp/gmon-<ta_uuid>.out (path is defined in
353# tee-supplicant)
354CFG_TA_GPROF_SUPPORT ?= n
355
356# TA function tracing.
357# When this option is enabled, OP-TEE can execute Trusted Applications
358# instrumented with GCC's -pg flag and will output function tracing
359# information in ftrace.out format to /tmp/ftrace-<ta_uuid>.out (path is
360# defined in tee-supplicant)
361CFG_TA_FTRACE_SUPPORT ?= n
362
363# Enable to compile user TA libraries with profiling (-pg).
364# Depends on CFG_TA_GPROF_SUPPORT or CFG_TA_FTRACE_SUPPORT.
365CFG_ULIBS_MCOUNT ?= n
366
367ifeq ($(CFG_ULIBS_MCOUNT),y)
368ifeq (,$(filter y,$(CFG_TA_GPROF_SUPPORT) $(CFG_TA_FTRACE_SUPPORT)))
369$(error Cannot instrument user libraries if user mode profiling is disabled)
370endif
371endif
372
373# Build libutee, libutils, libmpa/libmbedtls as shared libraries.
374# - Static libraries are still generated when this is enabled, but TAs will use
375# the shared libraries unless explicitly linked with the -static flag.
376# - Shared libraries are made of two files: for example, libutee is
377#   libutee.so and 527f1a47-b92c-4a74-95bd-72f19f4a6f74.ta. The '.so' file
378#   is a totally standard shared object, and should be used to link against.
379#   The '.ta' file is a signed version of the '.so' and should be installed
380#   in the same way as TAs so that they can be found at runtime.
381CFG_ULIBS_SHARED ?= n
382
383ifeq (yy,$(CFG_TA_GPROF_SUPPORT)$(CFG_ULIBS_SHARED))
384# FIXME:
385# TA profiling with gprof does not work well with shared libraries (not limited
386# to CFG_ULIBS_SHARED=y actually), because the total .text size is not known at
387# link time. The symptom is an error trace when the TA starts (and no gprof
388# output is produced):
389#  E/TA: __utee_gprof_init:159 gprof: could not allocate profiling buffer
390# The allocation of the profiling buffer should probably be done at runtime
391# via a new syscall/PTA call instead of having it pre-allocated in .bss by the
392# linker.
393$(error CFG_TA_GPROF_SUPPORT and CFG_ULIBS_SHARED are currently incompatible)
394endif
395
396# CFG_GP_SOCKETS
397# Enable Global Platform Sockets support
398CFG_GP_SOCKETS ?= y
399
400# Enable Secure Data Path support in OP-TEE core (TA may be invoked with
401# invocation parameters referring to specific secure memories).
402CFG_SECURE_DATA_PATH ?= n
403
404# Enable storage for TAs in secure storage, depends on CFG_REE_FS=y
405# TA binaries are stored encrypted in the REE FS and are protected by
406# metadata in secure storage.
407CFG_SECSTOR_TA ?= $(call cfg-all-enabled,CFG_REE_FS CFG_WITH_USER_TA)
408$(eval $(call cfg-depends-all,CFG_SECSTOR_TA,CFG_REE_FS CFG_WITH_USER_TA))
409
410# Enable the pseudo TA that managages TA storage in secure storage
411CFG_SECSTOR_TA_MGMT_PTA ?= $(call cfg-all-enabled,CFG_SECSTOR_TA)
412$(eval $(call cfg-depends-all,CFG_SECSTOR_TA_MGMT_PTA,CFG_SECSTOR_TA))
413
414# Enable the pseudo TA for misc. auxilary services, extending existing
415# GlobalPlatform Core API (for example, re-seeding RNG entropy pool etc.)
416CFG_SYSTEM_PTA ?= y
417
418# Enable the pseudo TA for enumeration of TEE based devices for the normal
419# world OS.
420CFG_DEVICE_ENUM_PTA ?= y
421
422# Define the number of cores per cluster used in calculating core position.
423# The cluster number is shifted by this value and added to the core ID,
424# so its value represents log2(cores/cluster).
425# Default is 2**(2) = 4 cores per cluster.
426CFG_CORE_CLUSTER_SHIFT ?= 2
427
428# Enable support for dynamic shared memory (shared memory anywhere in
429# non-secure memory).
430CFG_CORE_DYN_SHM ?= y
431
432# Enable support for reserved shared memory (shared memory in a carved out
433# memory area).
434CFG_CORE_RESERVED_SHM ?= y
435
436# Enables support for larger physical addresses, that is, it will define
437# paddr_t as a 64-bit type.
438CFG_CORE_LARGE_PHYS_ADDR ?= n
439
440# Define the maximum size, in bits, for big numbers in the Internal Core API
441# Arithmetical functions. This does *not* influence the key size that may be
442# manipulated through the Cryptographic API.
443# Set this to a lower value to reduce the TA memory footprint.
444CFG_TA_BIGNUM_MAX_BITS ?= 2048
445
446# Define the maximum size, in bits, for big numbers in the TEE core (privileged
447# layer).
448# This value is an upper limit for the key size in any cryptographic algorithm
449# implemented by the TEE core.
450# Set this to a lower value to reduce the memory footprint.
451CFG_CORE_BIGNUM_MAX_BITS ?= 4096
452
453# Compiles mbedTLS for TA usage
454CFG_TA_MBEDTLS ?= y
455
456# Compile the TA library mbedTLS with self test functions, the functions
457# need to be called to test anything
458CFG_TA_MBEDTLS_SELF_TEST ?= y
459
460# By default use tomcrypt as the main crypto lib providing an implementation
461# for the API in <crypto/crypto.h>
462# CFG_CRYPTOLIB_NAME is used as libname and
463# CFG_CRYPTOLIB_DIR is used as libdir when compiling the library
464#
465# It's also possible to configure to use mbedtls instead of tomcrypt.
466# Then the variables should be assigned as "CFG_CRYPTOLIB_NAME=mbedtls" and
467# "CFG_CRYPTOLIB_DIR=lib/libmbedtls" respectively.
468CFG_CRYPTOLIB_NAME ?= tomcrypt
469CFG_CRYPTOLIB_DIR ?= core/lib/libtomcrypt
470
471# Enable TEE_ALG_RSASSA_PKCS1_V1_5 algorithm for signing with PKCS#1 v1.5 EMSA
472# without ASN.1 around the hash.
473ifeq ($(CFG_CRYPTOLIB_NAME),tomcrypt)
474CFG_CRYPTO_RSASSA_NA1 ?= y
475CFG_CORE_MBEDTLS_MPI ?= y
476endif
477
478# Enable virtualization support. OP-TEE will not work without compatible
479# hypervisor if this option is enabled.
480CFG_VIRTUALIZATION ?= n
481
482ifeq ($(CFG_VIRTUALIZATION),y)
483$(call force,CFG_CORE_RODATA_NOEXEC,y)
484$(call force,CFG_CORE_RWDATA_NOEXEC,y)
485
486# Default number of virtual guests
487CFG_VIRT_GUEST_COUNT ?= 2
488endif
489
490# Enables backwards compatible derivation of RPMB and SSK keys
491CFG_CORE_HUK_SUBKEY_COMPAT ?= y
492