blob: ad6adb88d6243ed7e6eeec6ea0b06590561670f3 [file] [log] [blame]
Feder Liang55194382021-11-22 16:45:33 +08001#-------------------------------------------------------------------------------
chesun01ea11c822022-12-15 15:53:05 +08002# Copyright (c) 2022-2023, Arm Limited. All rights reserved.
Feder Liang55194382021-11-22 16:45:33 +08003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
Gabor Toth4d414112021-11-10 17:44:50 +01008########################## FPU and MVE #########################################
9
chesun01ea11c822022-12-15 15:53:05 +080010tfm_invalid_config(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU" AND (CONFIG_TFM_ENABLE_MVE OR CONFIG_TFM_ENABLE_MVE_FP))
11tfm_invalid_config((NOT CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_ID STREQUAL "ARMClang") AND CONFIG_TFM_ENABLE_FP)
Gabor Toth4d414112021-11-10 17:44:50 +010012tfm_invalid_config((NOT CONFIG_TFM_FP_ARCH) AND (CONFIG_TFM_ENABLE_FP OR CONFIG_TFM_ENABLE_MVE_FP))
chesun01a94a9c72023-02-14 16:19:51 +080013tfm_invalid_config((CMAKE_C_COMPILER_ID STREQUAL "ARMClang") AND (NOT CONFIG_TFM_FP_ARCH_ASM) AND CONFIG_TFM_ENABLE_FP)
Gabor Toth4d414112021-11-10 17:44:50 +010014tfm_invalid_config((NOT CONFIG_TFM_ENABLE_FP AND NOT CONFIG_TFM_ENABLE_MVE AND NOT CONFIG_TFM_ENABLE_MVE_FP) AND CONFIG_TFM_LAZY_STACKING)
15tfm_invalid_config((CONFIG_TFM_ENABLE_FP OR CONFIG_TFM_ENABLE_MVE OR CONFIG_TFM_ENABLE_MVE_FP) AND NOT CONFIG_TFM_ENABLE_CP10CP11)
16
Feder Liang55194382021-11-22 16:45:33 +080017###################### Check compiler for FP vulnerability #####################
18
19# Check compiler with mitigation for the VLLDM instruction security vulnerability or not.
20# For more information, please check https://developer.arm.com/support/arm-security-updates/vlldm-instruction-security-vulnerability.
Gabor Toth4d414112021-11-10 17:44:50 +010021if (CONFIG_TFM_FLOAT_ABI STREQUAL "hard")
Feder Liang55194382021-11-22 16:45:33 +080022 # Create test C file.
23 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cvetest.c "int x;")
24 # Compile with mitigation -mfix-cmse-cve-2021-35465.
chesun01ea11c822022-12-15 15:53:05 +080025 if (CMAKE_C_COMPILER_ID STREQUAL "ARMClang")
26 execute_process (
27 COMMAND ${CMAKE_C_COMPILER} --target=${CROSS_COMPILE} ${CMAKE_C_FLAGS} -mcmse -mfix-cmse-cve-2021-35465 -S ${CMAKE_CURRENT_BINARY_DIR}/cvetest.c -o ${CMAKE_CURRENT_BINARY_DIR}/cvetest.s
28 RESULT_VARIABLE ret
29 ERROR_VARIABLE err
30 )
31 else()
32 execute_process (
33 COMMAND ${CMAKE_C_COMPILER} -mfix-cmse-cve-2021-35465 -S ${CMAKE_CURRENT_BINARY_DIR}/cvetest.c -o ${CMAKE_CURRENT_BINARY_DIR}/cvetest.s
34 RESULT_VARIABLE ret
35 ERROR_VARIABLE err
36 )
37 endif()
Feder Liang55194382021-11-22 16:45:33 +080038 file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cvetest.c)
39 # Check result
40 if(NOT ret EQUAL 0)
41 message(FATAL_ERROR "To enable FPU usage in SPE and NSPE both, please use the compiler with '-mfix-cmse-cve-2021-35465' support")
42 else()
43 file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cvetest.s)
44 endif()
45endif()