blob: b3c5060bea7e280d02df80d39434c8be36373062 [file] [log] [blame]
Xinyu Zhanga2fab0e2022-10-24 15:37:46 +08001/*
Sherry Zhangf2a4f912023-09-12 15:38:12 +08002 * Copyright (c) 2022-2024, Arm Limited. All rights reserved.
Chris Brand72ee4c62024-01-08 16:56:55 -08003 * Copyright (c) 2023-2024 Cypress Semiconductor Corporation (an Infineon
Chris Brand80326b72023-03-15 13:07:49 -07004 * company) or an affiliate of Cypress Semiconductor Corporation. All rights
5 * reserved.
Xinyu Zhanga2fab0e2022-10-24 15:37:46 +08006 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 *
9 */
10
11#ifndef __CONFIG_BASE_H__
12#define __CONFIG_BASE_H__
13
Xinyu Zhang77668dd2022-10-24 16:17:37 +080014/* Platform Partition Configs */
15
16/* Size of input buffer in platform service */
David Hu6d1a9b62023-02-22 16:54:04 +080017#ifndef PLATFORM_SERVICE_INPUT_BUFFER_SIZE
Xinyu Zhang77668dd2022-10-24 16:17:37 +080018#define PLATFORM_SERVICE_INPUT_BUFFER_SIZE 64
David Hu6d1a9b62023-02-22 16:54:04 +080019#endif
Xinyu Zhang77668dd2022-10-24 16:17:37 +080020
21/* Size of output buffer in platform service */
David Hu6d1a9b62023-02-22 16:54:04 +080022#ifndef PLATFORM_SERVICE_OUTPUT_BUFFER_SIZE
Xinyu Zhang77668dd2022-10-24 16:17:37 +080023#define PLATFORM_SERVICE_OUTPUT_BUFFER_SIZE 64
David Hu6d1a9b62023-02-22 16:54:04 +080024#endif
Xinyu Zhang77668dd2022-10-24 16:17:37 +080025
26/* The stack size of the Platform Secure Partition */
David Hu6d1a9b62023-02-22 16:54:04 +080027#ifndef PLATFORM_SP_STACK_SIZE
Xinyu Zhang77668dd2022-10-24 16:17:37 +080028#define PLATFORM_SP_STACK_SIZE 0x500
David Hu6d1a9b62023-02-22 16:54:04 +080029#endif
Xinyu Zhang77668dd2022-10-24 16:17:37 +080030
31/* Disable Non-volatile counter module */
David Hu6d1a9b62023-02-22 16:54:04 +080032#ifndef PLATFORM_NV_COUNTER_MODULE_DISABLED
Xinyu Zhang77668dd2022-10-24 16:17:37 +080033#define PLATFORM_NV_COUNTER_MODULE_DISABLED 0
David Hu6d1a9b62023-02-22 16:54:04 +080034#endif
Xinyu Zhang77668dd2022-10-24 16:17:37 +080035
Xinyu Zhangd755b822022-10-25 11:18:09 +080036/* Crypto Partition Configs */
37
38/*
39 * Heap size for the crypto backend
40 * CRYPTO_ENGINE_BUF_SIZE needs to be >8KB for EC signing by attest module.
41 */
David Hu6d1a9b62023-02-22 16:54:04 +080042#ifndef CRYPTO_ENGINE_BUF_SIZE
Xinyu Zhangd755b822022-10-25 11:18:09 +080043#define CRYPTO_ENGINE_BUF_SIZE 0x2080
David Hu6d1a9b62023-02-22 16:54:04 +080044#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080045
46/* The max number of concurrent operations that can be active (allocated) at any time in Crypto */
David Hu6d1a9b62023-02-22 16:54:04 +080047#ifndef CRYPTO_CONC_OPER_NUM
Xinyu Zhangd755b822022-10-25 11:18:09 +080048#define CRYPTO_CONC_OPER_NUM 8
David Hu6d1a9b62023-02-22 16:54:04 +080049#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080050
Jianliang Shen78ca8d42022-11-16 17:33:18 +080051/* Enable PSA Crypto random number generator module */
David Hu6d1a9b62023-02-22 16:54:04 +080052#ifndef CRYPTO_RNG_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080053#define CRYPTO_RNG_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080054#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080055
Jianliang Shen78ca8d42022-11-16 17:33:18 +080056/* Enable PSA Crypto Key module */
David Hu6d1a9b62023-02-22 16:54:04 +080057#ifndef CRYPTO_KEY_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080058#define CRYPTO_KEY_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080059#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080060
Jianliang Shen78ca8d42022-11-16 17:33:18 +080061/* Enable PSA Crypto AEAD module */
David Hu6d1a9b62023-02-22 16:54:04 +080062#ifndef CRYPTO_AEAD_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080063#define CRYPTO_AEAD_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080064#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080065
Jianliang Shen78ca8d42022-11-16 17:33:18 +080066/* Enable PSA Crypto MAC module */
David Hu6d1a9b62023-02-22 16:54:04 +080067#ifndef CRYPTO_MAC_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080068#define CRYPTO_MAC_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080069#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080070
Jianliang Shen78ca8d42022-11-16 17:33:18 +080071/* Enable PSA Crypto Hash module */
David Hu6d1a9b62023-02-22 16:54:04 +080072#ifndef CRYPTO_HASH_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080073#define CRYPTO_HASH_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080074#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080075
Jianliang Shen78ca8d42022-11-16 17:33:18 +080076/* Enable PSA Crypto Cipher module */
David Hu6d1a9b62023-02-22 16:54:04 +080077#ifndef CRYPTO_CIPHER_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080078#define CRYPTO_CIPHER_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080079#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080080
Jianliang Shen78ca8d42022-11-16 17:33:18 +080081/* Enable PSA Crypto asymmetric key signature module */
David Hu6d1a9b62023-02-22 16:54:04 +080082#ifndef CRYPTO_ASYM_SIGN_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080083#define CRYPTO_ASYM_SIGN_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080084#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080085
Jianliang Shen78ca8d42022-11-16 17:33:18 +080086/* Enable PSA Crypto asymmetric key encryption module */
David Hu6d1a9b62023-02-22 16:54:04 +080087#ifndef CRYPTO_ASYM_ENCRYPT_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080088#define CRYPTO_ASYM_ENCRYPT_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080089#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080090
Jianliang Shen78ca8d42022-11-16 17:33:18 +080091/* Enable PSA Crypto key derivation module */
David Hu6d1a9b62023-02-22 16:54:04 +080092#ifndef CRYPTO_KEY_DERIVATION_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080093#define CRYPTO_KEY_DERIVATION_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080094#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080095
96/* Default size of the internal scratch buffer used for PSA FF IOVec allocations */
David Hu6d1a9b62023-02-22 16:54:04 +080097#ifndef CRYPTO_IOVEC_BUFFER_SIZE
Xinyu Zhangd755b822022-10-25 11:18:09 +080098#define CRYPTO_IOVEC_BUFFER_SIZE 5120
David Hu6d1a9b62023-02-22 16:54:04 +080099#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +0800100
101/* Use stored NV seed to provide entropy */
David Hu6d1a9b62023-02-22 16:54:04 +0800102#ifndef CRYPTO_NV_SEED
Xinyu Zhangd755b822022-10-25 11:18:09 +0800103#define CRYPTO_NV_SEED 1
David Hu6d1a9b62023-02-22 16:54:04 +0800104#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +0800105
106/*
107 * Only enable multi-part operations in Hash, MAC, AEAD and symmetric ciphers,
108 * to optimize memory footprint in resource-constrained devices.
109 */
David Hu6d1a9b62023-02-22 16:54:04 +0800110#ifndef CRYPTO_SINGLE_PART_FUNCS_DISABLED
Xinyu Zhangd755b822022-10-25 11:18:09 +0800111#define CRYPTO_SINGLE_PART_FUNCS_DISABLED 0
David Hu6d1a9b62023-02-22 16:54:04 +0800112#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +0800113
114/* The stack size of the Crypto Secure Partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800115#ifndef CRYPTO_STACK_SIZE
Xinyu Zhangd755b822022-10-25 11:18:09 +0800116#define CRYPTO_STACK_SIZE 0x1B00
David Hu6d1a9b62023-02-22 16:54:04 +0800117#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +0800118
Xinyu Zhangff653722022-10-27 14:17:36 +0800119/* FWU Partition Configs */
120
121/* Size of the FWU internal data transfer buffer */
David Hu6d1a9b62023-02-22 16:54:04 +0800122#ifndef TFM_FWU_BUF_SIZE
Xinyu Zhangff653722022-10-27 14:17:36 +0800123#define TFM_FWU_BUF_SIZE PSA_FWU_MAX_WRITE_SIZE
David Hu6d1a9b62023-02-22 16:54:04 +0800124#endif
Xinyu Zhangff653722022-10-27 14:17:36 +0800125
126/* The stack size of the Firmware Update Secure Partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800127#ifndef FWU_STACK_SIZE
Xinyu Zhangff653722022-10-27 14:17:36 +0800128#define FWU_STACK_SIZE 0x600
David Hu6d1a9b62023-02-22 16:54:04 +0800129#endif
Xinyu Zhangff653722022-10-27 14:17:36 +0800130
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800131/* Attest Partition Configs */
132
133/* Include optional claims in initial attestation token */
David Hu6d1a9b62023-02-22 16:54:04 +0800134#ifndef ATTEST_INCLUDE_OPTIONAL_CLAIMS
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800135#define ATTEST_INCLUDE_OPTIONAL_CLAIMS 1
David Hu6d1a9b62023-02-22 16:54:04 +0800136#endif
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800137
138/* Include COSE key-id in initial attestation token */
David Hu6d1a9b62023-02-22 16:54:04 +0800139#ifndef ATTEST_INCLUDE_COSE_KEY_ID
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800140#define ATTEST_INCLUDE_COSE_KEY_ID 0
David Hu6d1a9b62023-02-22 16:54:04 +0800141#endif
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800142
143/* The stack size of the Initial Attestation Secure Partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800144#ifndef ATTEST_STACK_SIZE
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800145#define ATTEST_STACK_SIZE 0x700
David Hu6d1a9b62023-02-22 16:54:04 +0800146#endif
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800147
148/* Set the initial attestation token profile */
David Hu6d1a9b62023-02-22 16:54:04 +0800149#if (!ATTEST_TOKEN_PROFILE_PSA_IOT_1) && \
150 (!ATTEST_TOKEN_PROFILE_PSA_2_0_0) && \
151 (!ATTEST_TOKEN_PROFILE_ARM_CCA)
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800152#define ATTEST_TOKEN_PROFILE_PSA_IOT_1 1
David Hu6d1a9b62023-02-22 16:54:04 +0800153#endif
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800154
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800155/* ITS Partition Configs */
156
157/* Create flash FS if it doesn't exist for Internal Trusted Storage partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800158#ifndef ITS_CREATE_FLASH_LAYOUT
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800159#define ITS_CREATE_FLASH_LAYOUT 1
David Hu6d1a9b62023-02-22 16:54:04 +0800160#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800161
162/* Enable emulated RAM FS for platforms that don't have flash for Internal Trusted Storage partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800163#ifndef ITS_RAM_FS
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800164#define ITS_RAM_FS 0
David Hu6d1a9b62023-02-22 16:54:04 +0800165#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800166
167/* Validate filesystem metadata every time it is read from flash */
David Hu6d1a9b62023-02-22 16:54:04 +0800168#ifndef ITS_VALIDATE_METADATA_FROM_FLASH
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800169#define ITS_VALIDATE_METADATA_FROM_FLASH 1
David Hu6d1a9b62023-02-22 16:54:04 +0800170#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800171
172/* The maximum asset size to be stored in the Internal Trusted Storage */
David Hu6d1a9b62023-02-22 16:54:04 +0800173#ifndef ITS_MAX_ASSET_SIZE
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800174#define ITS_MAX_ASSET_SIZE 512
David Hu6d1a9b62023-02-22 16:54:04 +0800175#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800176
177/*
178 * Size of the ITS internal data transfer buffer
179 * (Default to the max asset size so that all requests can be handled in one iteration.)
180 */
David Hu6d1a9b62023-02-22 16:54:04 +0800181#ifndef ITS_BUF_SIZE
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800182#define ITS_BUF_SIZE ITS_MAX_ASSET_SIZE
David Hu6d1a9b62023-02-22 16:54:04 +0800183#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800184
185/* The maximum number of assets to be stored in the Internal Trusted Storage */
David Hu6d1a9b62023-02-22 16:54:04 +0800186#ifndef ITS_NUM_ASSETS
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800187#define ITS_NUM_ASSETS 10
David Hu6d1a9b62023-02-22 16:54:04 +0800188#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800189
190/* The stack size of the Internal Trusted Storage Secure Partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800191#ifndef ITS_STACK_SIZE
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800192#define ITS_STACK_SIZE 0x720
David Hu6d1a9b62023-02-22 16:54:04 +0800193#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800194
Markus Swarowsky7de096f2023-03-16 10:32:02 +0100195/* The size of the authentication tag used when authentication/encryption of ITS files is enabled */
196#ifndef TFM_ITS_AUTH_TAG_LENGTH
197#define TFM_ITS_AUTH_TAG_LENGTH 16
198#endif
199
Bence Balogh49a0d7d2024-08-13 14:26:20 +0200200/* The size of the key used when authentication/encryption of ITS files is enabled */
201#ifndef TFM_ITS_KEY_LENGTH
202#define TFM_ITS_KEY_LENGTH 16
203#endif
204
Markus Swarowsky7de096f2023-03-16 10:32:02 +0100205/* The size of the nonce used when ITS file encryption is enabled */
206#ifndef TFM_ITS_ENC_NONCE_LENGTH
207#define TFM_ITS_ENC_NONCE_LENGTH 12
208#endif
209
Xinyu Zhang07152702022-10-31 12:35:49 +0800210/* PS Partition Configs */
211
212/* Create flash FS if it doesn't exist for Protected Storage partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800213#ifndef PS_CREATE_FLASH_LAYOUT
Xinyu Zhang07152702022-10-31 12:35:49 +0800214#define PS_CREATE_FLASH_LAYOUT 1
David Hu6d1a9b62023-02-22 16:54:04 +0800215#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800216
217/* Enable emulated RAM FS for platforms that don't have flash for Protected Storage partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800218#ifndef PS_RAM_FS
Xinyu Zhang07152702022-10-31 12:35:49 +0800219#define PS_RAM_FS 0
David Hu6d1a9b62023-02-22 16:54:04 +0800220#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800221
222/* Enable rollback protection for Protected Storage partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800223#ifndef PS_ROLLBACK_PROTECTION
Xinyu Zhang07152702022-10-31 12:35:49 +0800224#define PS_ROLLBACK_PROTECTION 1
David Hu6d1a9b62023-02-22 16:54:04 +0800225#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800226
227/* Validate filesystem metadata every time it is read from flash */
David Hu6d1a9b62023-02-22 16:54:04 +0800228#ifndef PS_VALIDATE_METADATA_FROM_FLASH
Xinyu Zhang07152702022-10-31 12:35:49 +0800229#define PS_VALIDATE_METADATA_FROM_FLASH 1
David Hu6d1a9b62023-02-22 16:54:04 +0800230#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800231
232/* The maximum asset size to be stored in the Protected Storage */
David Hu6d1a9b62023-02-22 16:54:04 +0800233#ifndef PS_MAX_ASSET_SIZE
Xinyu Zhang07152702022-10-31 12:35:49 +0800234#define PS_MAX_ASSET_SIZE 2048
David Hu6d1a9b62023-02-22 16:54:04 +0800235#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800236
237/* The maximum number of assets to be stored in the Protected Storage */
David Hu6d1a9b62023-02-22 16:54:04 +0800238#ifndef PS_NUM_ASSETS
Xinyu Zhang07152702022-10-31 12:35:49 +0800239#define PS_NUM_ASSETS 10
David Hu6d1a9b62023-02-22 16:54:04 +0800240#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800241
242/* The stack size of the Protected Storage Secure Partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800243#ifndef PS_STACK_SIZE
Xinyu Zhang07152702022-10-31 12:35:49 +0800244#define PS_STACK_SIZE 0x700
David Hu6d1a9b62023-02-22 16:54:04 +0800245#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800246
Chris Brand72ee4c62024-01-08 16:56:55 -0800247/* NS Agent Mailbox Partition Configs */
248
Sherry Zhang415d7132023-08-09 16:26:56 +0800249/* The stack size of the NS Agent Mailbox Secure Partition */
250#ifndef NS_AGENT_MAILBOX_STACK_SIZE
251#define NS_AGENT_MAILBOX_STACK_SIZE 0x800
252#endif
253
Chris Brand72ee4c62024-01-08 16:56:55 -0800254/* SPM Configs */
Xinyu Zhangcdbe3622022-10-31 14:34:25 +0800255
Xinyu Zhang9a6d90a2023-03-22 17:32:27 +0800256#ifdef CONFIG_TFM_CONNECTION_POOL_ENABLE
Xinyu Zhangcdbe3622022-10-31 14:34:25 +0800257/* The maximal number of secure services that are connected or requested at the same time */
David Hu6d1a9b62023-02-22 16:54:04 +0800258#ifndef CONFIG_TFM_CONN_HANDLE_MAX_NUM
Chris Brand80326b72023-03-15 13:07:49 -0700259#define CONFIG_TFM_CONN_HANDLE_MAX_NUM 8
David Hu6d1a9b62023-02-22 16:54:04 +0800260#endif
Xinyu Zhang9a6d90a2023-03-22 17:32:27 +0800261#endif
Xinyu Zhangcdbe3622022-10-31 14:34:25 +0800262
Xinyu Zhang44dbfa62022-11-23 14:22:32 +0800263/* Disable the doorbell APIs */
David Hu6d1a9b62023-02-22 16:54:04 +0800264#ifndef CONFIG_TFM_DOORBELL_API
Chris Brand80326b72023-03-15 13:07:49 -0700265#define CONFIG_TFM_DOORBELL_API 0
266#endif
267
268/* Do not run the scheduler after handling a secure interrupt if the NSPE was pre-empted */
269#ifndef CONFIG_TFM_SCHEDULE_WHEN_NS_INTERRUPTED
270#define CONFIG_TFM_SCHEDULE_WHEN_NS_INTERRUPTED 0
David Hu6d1a9b62023-02-22 16:54:04 +0800271#endif
Xinyu Zhangcdbe3622022-10-31 14:34:25 +0800272
Sherry Zhangf2a4f912023-09-12 15:38:12 +0800273/* Mask Non-Secure interrupts when executing in secure state. */
274#ifndef CONFIG_TFM_SECURE_THREAD_MASK_NS_INTERRUPT
275#define CONFIG_TFM_SECURE_THREAD_MASK_NS_INTERRUPT 0
276#endif
277
Andrej Butok302da632023-07-14 12:57:08 +0200278/* Enable OTP/NV_COUNTERS emulation in RAM */
279#ifndef OTP_NV_COUNTERS_RAM_EMULATION
280#define OTP_NV_COUNTERS_RAM_EMULATION 0
281#endif
282
Xinyu Zhanga2fab0e2022-10-24 15:37:46 +0800283#endif /* __CONFIG_BASE_H__ */