From 3ee7d019898854f776f95ed31f4b7ea8c8a73dfe Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Wed, 13 Apr 2022 00:00:12 +0300 Subject: [PATCH] optee-ftpm: Use the latest fTPM sources The recipe right now is using https://github.com/microsoft/MSRSec. However this is the initial reference implementation from Microsoft and things have been moved into https://github.com/microsoft/ms-tpm-20-ref/ (in the directory Samples). Switch to new and currently maintained branch Testing against real hardware (the SynQuacer DeveloperBox and a rockpi4) didn't sound any alarms Signed-off-by: Ilias Apalodimas Signed-off-by: Jon Mason --- .../optee-ftpm/0000-fix-ssl-fallthrough.patch | 23 ---------------- .../0001-add-enum-to-ta-flags.patch | 14 +++++----- .../optee-ftpm/optee-ftpm_git.bb | 26 +++++++------------ 3 files changed, 17 insertions(+), 46 deletions(-) delete mode 100644 meta-arm/recipes-security/optee-ftpm/optee-ftpm/0000-fix-ssl-fallthrough.patch diff --git a/meta-arm/recipes-security/optee-ftpm/optee-ftpm/0000-fix-ssl-fallthrough.patch b/meta-arm/recipes-security/optee-ftpm/optee-ftpm/0000-fix-ssl-fallthrough.patch deleted file mode 100644 index 1e2a4b68..00000000 --- a/meta-arm/recipes-security/optee-ftpm/optee-ftpm/0000-fix-ssl-fallthrough.patch +++ /dev/null @@ -1,23 +0,0 @@ -fix gcc compilation - -just fix compilation under gcc. -Upstream-Status: Submitted [https://github.com/microsoft/MSRSec/pull/35] -Compilation issue already fixed in wolfcrypt and submodule -needs to be updated. I sent PR for for update with the link -above. - -Signed-off-by: Maxim Uvarov - -diff --git a/wolfssl/wolfcrypt/types.h b/wolfssl/wolfcrypt/types.h -index 7b3a953aebda..e156ae5c7909 100755 ---- a/external/wolfssl/wolfssl/wolfcrypt/types.h -+++ b/external/wolfssl/wolfssl/wolfcrypt/types.h -@@ -181,7 +181,7 @@ - /* GCC 7 has new switch() fall-through detection */ - #if defined(__GNUC__) - #if ((__GNUC__ > 7) || ((__GNUC__ == 7) && (__GNUC_MINOR__ >= 1))) -- #define FALL_THROUGH __attribute__ ((fallthrough)); -+ #define FALL_THROUGH __attribute__ ((__fallthrough__)); - #endif - #endif - #ifndef FALL_THROUGH diff --git a/meta-arm/recipes-security/optee-ftpm/optee-ftpm/0001-add-enum-to-ta-flags.patch b/meta-arm/recipes-security/optee-ftpm/optee-ftpm/0001-add-enum-to-ta-flags.patch index bbc11079..94509ddd 100644 --- a/meta-arm/recipes-security/optee-ftpm/optee-ftpm/0001-add-enum-to-ta-flags.patch +++ b/meta-arm/recipes-security/optee-ftpm/optee-ftpm/0001-add-enum-to-ta-flags.patch @@ -12,19 +12,19 @@ Signed-off-by: Maxim Uvarov TAs/optee_ta/fTPM/user_ta_header_defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -diff --git a/TAs/optee_ta/fTPM/user_ta_header_defines.h b/TAs/optee_ta/fTPM/user_ta_header_defines.h -index 6ff62d1..685b54a 100644 ---- a/TAs/optee_ta/fTPM/user_ta_header_defines.h -+++ b/TAs/optee_ta/fTPM/user_ta_header_defines.h +diff --git a/Samples/ARM32-FirmwareTPM/optee_ta/fTPM/user_ta_header_defines.h b/Samples/ARM32-FirmwareTPM/optee_ta/fTPM/user_ta_header_defines.h +index 72ecbf0cf1c7..e83619d55d3c 100644 +--- a/Samples/ARM32-FirmwareTPM/optee_ta/fTPM/user_ta_header_defines.h ++++ b/Samples/ARM32-FirmwareTPM/optee_ta/fTPM/user_ta_header_defines.h @@ -44,7 +44,7 @@ #define TA_UUID TA_FTPM_UUID --#define TA_FLAGS (TA_FLAG_SINGLE_INSTANCE | TA_FLAG_INSTANCE_KEEP_ALIVE ) +-#define TA_FLAGS (TA_FLAG_SINGLE_INSTANCE | TA_FLAG_INSTANCE_KEEP_ALIVE) +#define TA_FLAGS (TA_FLAG_SINGLE_INSTANCE | TA_FLAG_INSTANCE_KEEP_ALIVE | TA_FLAG_DEVICE_ENUM_SUPP) #define TA_STACK_SIZE (64 * 1024) - #define TA_DATA_SIZE (64 * 1024) - + #define TA_DATA_SIZE (32 * 1024) + -- 2.17.1 diff --git a/meta-arm/recipes-security/optee-ftpm/optee-ftpm_git.bb b/meta-arm/recipes-security/optee-ftpm/optee-ftpm_git.bb index 1a54e99f..d282c25a 100644 --- a/meta-arm/recipes-security/optee-ftpm/optee-ftpm_git.bb +++ b/meta-arm/recipes-security/optee-ftpm/optee-ftpm_git.bb @@ -13,23 +13,16 @@ TOOLCHAIN = "gcc" inherit deploy python3native LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=27e94c0280987ab296b0b8dd02ab9fe5" +LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=5a3925ece0806073ae9ebbb08ff6f11e" DEPENDS = "python3-pyelftools-native optee-os-tadevkit python3-cryptography-native " FTPM_UUID="bc50d971-d4c9-42c4-82cb-343fb7f37896" -# SRC_URI = "git://github.com/Microsoft/ms-tpm-20-ref;branch=master" -# Since this is not built as a pseudo TA, we can only use it as a kernel module and not built in. -# The TEE supplicant is also needed to provide access to secure storage. -# Secure storage access required by OP-TEE fTPM TA -# is provided via OP-TEE supplicant that's not available during boot. -# Fix this once we replace this with the MS implementation -SRC_URI = "gitsm://github.com/microsoft/MSRSec;protocol=https;branch=master \ - file://0000-fix-ssl-fallthrough.patch \ +SRC_URI = "gitsm://github.com/Microsoft/ms-tpm-20-ref;branch=master;protocol=https \ file://0001-add-enum-to-ta-flags.patch" -SRCREV = "81abeb9fa968340438b4b0c08aa6685833f0bfa1" +SRCREV = "d638536d0fe01acd5e39ffa1bd100b3da82d92c7" S = "${WORKDIR}/git" @@ -55,21 +48,22 @@ export OPENSSL_MODULES="${STAGING_LIBDIR_NATIVE}/ossl-modules" PARALLEL_MAKE = "" do_compile() { - sed -i 's/-mcpu=$(TA_CPU)//' TAs/optee_ta/fTPM/sub.mk + # The internal ${CC} includes the correct -mcpu option + sed -i 's/-mcpu=$(TA_CPU)//' Samples/ARM32-FirmwareTPM/optee_ta/fTPM/sub.mk # there's also a secure variable storage TA called authvars - cd ${S}/TAs/optee_ta - oe_runmake ftpm + cd ${S}/Samples/ARM32-FirmwareTPM/optee_ta + oe_runmake } do_install () { mkdir -p ${D}/lib/optee_armtz - install -D -p -m 0644 ${S}/TAs/optee_ta/out/fTPM/${FTPM_UUID}.ta ${D}/lib/optee_armtz/ - install -D -p -m 0644 ${S}/TAs/optee_ta/out/fTPM/${FTPM_UUID}.stripped.elf ${D}/lib/optee_armtz/ + install -D -p -m 0644 ${S}/Samples/ARM32-FirmwareTPM/optee_ta/out/fTPM/${FTPM_UUID}.ta ${D}/lib/optee_armtz/ + install -D -p -m 0644 ${S}/Samples/ARM32-FirmwareTPM/optee_ta/out/fTPM/${FTPM_UUID}.stripped.elf ${D}/lib/optee_armtz/ } do_deploy () { install -d ${DEPLOYDIR}/optee - install -D -p -m 0644 ${S}/TAs/optee_ta/out/fTPM/${FTPM_UUID}.stripped.elf ${DEPLOYDIR}/optee/ + install -D -p -m 0644 ${S}/Samples/ARM32-FirmwareTPM/optee_ta/out/fTPM/${FTPM_UUID}.stripped.elf ${DEPLOYDIR}/optee/ } addtask deploy before do_build after do_install