Julian Hall | caa4af8 | 2021-05-19 12:02:36 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | cmake_minimum_required(VERSION 3.16) |
| 8 | include(../../deployment.cmake REQUIRED) |
| 9 | |
| 10 | #------------------------------------------------------------------------------- |
| 11 | # The CMakeLists.txt for building the attestation deployment for opteesp |
| 12 | # |
| 13 | # Builds the attestation service provider for running in an SEL0 secure partition |
| 14 | # hosted by OPTEE in the role of SPM. |
| 15 | #------------------------------------------------------------------------------- |
| 16 | include(${TS_ROOT}/environments/opteesp/env.cmake) |
| 17 | project(trusted-services LANGUAGES C ASM) |
| 18 | add_executable(attestation) |
| 19 | target_include_directories(attestation PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
| 20 | set(SP_UUID "a1baf155-8876-4695-8f7c-54955e8db974") |
| 21 | |
| 22 | |
| 23 | # Include SP DEV KIT interface |
| 24 | set(SP_DEV_KIT_INC_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 25 | list(APPEND CMAKE_MODULE_PATH "${TS_ROOT}/external/Spdevkit") |
| 26 | find_package(Spdevkit REQUIRED) |
| 27 | sp_dev_kit_configure_linking(TARGET attestation DEFINES ARM64=1) |
| 28 | target_link_libraries(attestation PRIVATE ${SP_DEV_KIT_LIBRARIES}) |
| 29 | |
| 30 | #------------------------------------------------------------------------------- |
| 31 | # Default deployment specific configuration |
| 32 | # |
| 33 | #------------------------------------------------------------------------------- |
| 34 | set(TS_NO_FLOAT_HW ON) |
| 35 | |
| 36 | #------------------------------------------------------------------------------- |
| 37 | # Components that are specific to deployment in the opteesp environment. |
| 38 | # |
| 39 | #------------------------------------------------------------------------------- |
| 40 | add_components(TARGET "attestation" |
| 41 | BASE_DIR ${TS_ROOT} |
| 42 | COMPONENTS |
| 43 | "components/common/tlv" |
| 44 | "components/common/endian" |
| 45 | "components/config/ramstore" |
| 46 | "components/config/loader/sp" |
| 47 | "components/messaging/ffa/libsp" |
| 48 | "components/rpc/ffarpc/endpoint" |
| 49 | "components/rpc/ffarpc/caller/sp" |
| 50 | "components/rpc/common/caller" |
| 51 | "components/rpc/common/interface" |
| 52 | "components/service/common/include" |
| 53 | "components/service/common/provider" |
| 54 | "components/service/attestation/include" |
| 55 | "components/service/attestation/claims" |
| 56 | "components/service/attestation/claims/sources/boot_seed_generator" |
| 57 | "components/service/attestation/claims/sources/null_lifecycle" |
| 58 | "components/service/attestation/claims/sources/instance_id" |
Julian Hall | b7db580 | 2021-07-26 16:20:40 +0100 | [diff] [blame] | 59 | "components/service/attestation/claims/sources/implementation_id" |
Julian Hall | caa4af8 | 2021-05-19 12:02:36 +0100 | [diff] [blame] | 60 | "components/service/attestation/claims/sources/event_log" |
| 61 | "components/service/attestation/claims/sources/event_log/mock" |
Julian Hall | 644b57a | 2021-06-30 08:45:19 +0100 | [diff] [blame] | 62 | "components/service/attestation/reporter/local" |
| 63 | "components/service/attestation/reporter/eat" |
| 64 | "components/service/attestation/key_mngr/local" |
Julian Hall | caa4af8 | 2021-05-19 12:02:36 +0100 | [diff] [blame] | 65 | "components/service/attestation/provider" |
| 66 | "components/service/attestation/provider/serializer/packed-c" |
| 67 | "protocols/rpc/common/packed-c" |
| 68 | "environments/opteesp" |
| 69 | ) |
| 70 | |
| 71 | target_sources(attestation PRIVATE |
| 72 | attestation_sp.c |
| 73 | ) |
| 74 | |
| 75 | #------------------------------------------------------------------------------- |
| 76 | # Use the selected platform to provide drivers needed by the deployment |
| 77 | # |
| 78 | #------------------------------------------------------------------------------- |
| 79 | add_platform(TARGET "attestation") |
| 80 | |
| 81 | #------------------------------------------------------------------------------- |
| 82 | # Components used from external projects |
| 83 | # |
| 84 | #------------------------------------------------------------------------------- |
| 85 | |
| 86 | # Temporary dependency on mbedcrypto |
| 87 | set(MBEDTLS_USER_CONFIG_FILE |
| 88 | "${TS_ROOT}/components/service/crypto/client/cpp/config_mbedtls_user.h" |
| 89 | CACHE STRING "Configuration file for mbedcrypto") |
Andrew Beggs | 97a00d4 | 2021-06-15 15:45:46 +0000 | [diff] [blame] | 90 | list(APPEND MBEDTLS_EXTRA_INCLUDES ${SP_DEV_KIT_INCLUDE_DIR}) |
Julian Hall | caa4af8 | 2021-05-19 12:02:36 +0100 | [diff] [blame] | 91 | |
| 92 | # Mbed TLS provides libmbedcrypto |
| 93 | include(../../../external/MbedTLS/MbedTLS.cmake) |
| 94 | target_link_libraries(attestation PRIVATE mbedcrypto) |
| 95 | |
| 96 | # Qcbor |
Andrew Beggs | 97a00d4 | 2021-06-15 15:45:46 +0000 | [diff] [blame] | 97 | set (QCBOR_EXTERNAL_INCLUDE_PATHS ${SP_DEV_KIT_INCLUDE_DIR}) |
Julian Hall | caa4af8 | 2021-05-19 12:02:36 +0100 | [diff] [blame] | 98 | include(${TS_ROOT}/external/qcbor/qcbor.cmake) |
| 99 | target_link_libraries(attestation PRIVATE qcbor) |
| 100 | |
| 101 | # t_cose |
Andrew Beggs | 97a00d4 | 2021-06-15 15:45:46 +0000 | [diff] [blame] | 102 | set (TCOSE_EXTERNAL_INCLUDE_PATHS ${SP_DEV_KIT_INCLUDE_DIR}) |
Julian Hall | caa4af8 | 2021-05-19 12:02:36 +0100 | [diff] [blame] | 103 | include(${TS_ROOT}/external/t_cose/t_cose.cmake) |
| 104 | target_link_libraries(attestation PRIVATE t_cose) |
| 105 | |
| 106 | if(CMAKE_CROSSCOMPILING) |
| 107 | target_link_libraries(attestation PRIVATE stdc++ gcc m) |
| 108 | endif() |
| 109 | |
| 110 | ################################################################# |
| 111 | |
| 112 | target_compile_definitions(attestation PRIVATE |
| 113 | ARM64=1 |
| 114 | ) |
| 115 | |
| 116 | target_include_directories(attestation PRIVATE |
| 117 | ${TS_ROOT} |
| 118 | ${TS_ROOT}/components |
| 119 | ${TS_ROOT}/deployments/attestation/opteesp |
| 120 | ) |
| 121 | |
| 122 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
| 123 | target_compile_options(attestation PRIVATE |
| 124 | -fdiagnostics-show-option |
Julian Hall | caa4af8 | 2021-05-19 12:02:36 +0100 | [diff] [blame] | 125 | -gdwarf-2 |
| 126 | -mstrict-align |
| 127 | -O0 |
Andrew Beggs | 97a00d4 | 2021-06-15 15:45:46 +0000 | [diff] [blame] | 128 | -std=c99 |
Julian Hall | caa4af8 | 2021-05-19 12:02:36 +0100 | [diff] [blame] | 129 | ) |
| 130 | |
| 131 | # Options for GCC that control linking |
| 132 | target_link_options(attestation PRIVATE |
Julian Hall | caa4af8 | 2021-05-19 12:02:36 +0100 | [diff] [blame] | 133 | -zmax-page-size=4096 |
| 134 | ) |
| 135 | # Options directly for LD, these are not understood by GCC |
| 136 | target_link_options(attestation PRIVATE |
| 137 | -Wl,--as-needed |
| 138 | -Wl,--sort-section=alignment |
| 139 | # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list |
| 140 | ) |
| 141 | endif() |
| 142 | |
| 143 | compiler_generate_stripped_elf(TARGET attestation NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF) |
| 144 | |
| 145 | ######################################## install |
| 146 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 147 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 148 | endif() |
| 149 | #TODO: api headers |
| 150 | |
| 151 | install(TARGETS attestation |
| 152 | PUBLIC_HEADER DESTINATION ${TS_ENV}/include |
| 153 | RUNTIME DESTINATION ${TS_ENV}/bin |
| 154 | ) |
| 155 | install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin) |
| 156 | |
| 157 | get_property(_PROTO_FILES TARGET attestation PROPERTY PROTOBUF_FILES) |
| 158 | install(FILES ${_PROTO_FILES} DESTINATION ${TS_ENV}/lib/protobuf) |
| 159 | |
| 160 | |
| 161 | set(EXPORT_SP_NAME "attestation") |
| 162 | set(EXPORT_SP_UUID ${SP_UUID}) |
| 163 | include(${TS_ROOT}/environments/opteesp/ExportSp.cmake) |