optee-ftpm: Use the latest fTPM sources

Message ID 20220412210012.3265592-1-ilias.apalodimas@linaro.org
State New
Headers show
Series optee-ftpm: Use the latest fTPM sources | expand

Commit Message

Ilias Apalodimas April 12, 2022, 9 p.m. UTC
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 <ilias.apalodimas@linaro.org>
---
 .../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

Comments

Jon Mason April 13, 2022, 8:30 p.m. UTC | #1
On Wed, 13 Apr 2022 00:00:12 +0300, Ilias Apalodimas wrote:
> 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

Applied, thanks!

[1/1] optee-ftpm: Use the latest fTPM sources
      commit: 3ee7d019898854f776f95ed31f4b7ea8c8a73dfe

Best regards,

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 1e2a4b681563..000000000000
--- 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 <maxim.uvarov@linaro.org>
-
-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 bbc11079ac1b..94509ddd1eff 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 <maxim.uvarov@linaro.org>
  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 1a54e99fcc85..0b485f3fa5eb 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