blob: 8e4989aa7be6c41e19393408d721e8b9f02d973a [file] [log] [blame]
Feder Liang55194382021-11-22 16:45:33 +08001#-------------------------------------------------------------------------------
2# Copyright (c) 2022, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8###################### Check compiler for FP vulnerability #####################
9
10# Check compiler with mitigation for the VLLDM instruction security vulnerability or not.
11# For more information, please check https://developer.arm.com/support/arm-security-updates/vlldm-instruction-security-vulnerability.
12if (CONFIG_TFM_FP STREQUAL "hard")
13 # Create test C file.
14 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cvetest.c "int x;")
15 # Compile with mitigation -mfix-cmse-cve-2021-35465.
16 execute_process (
17 COMMAND ${CMAKE_C_COMPILER} -mfix-cmse-cve-2021-35465 -S ${CMAKE_CURRENT_BINARY_DIR}/cvetest.c -o ${CMAKE_CURRENT_BINARY_DIR}/cvetest.s
18 RESULT_VARIABLE ret
19 ERROR_VARIABLE err
20 )
21 file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cvetest.c)
22 # Check result
23 if(NOT ret EQUAL 0)
24 message(FATAL_ERROR "To enable FPU usage in SPE and NSPE both, please use the compiler with '-mfix-cmse-cve-2021-35465' support")
25 else()
26 file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cvetest.s)
27 endif()
28endif()