Skip to contentSkip to conversation

optee-os: upgrade to upstream 3.11.0

PATCH New Denys Dmytriyenko 1 participant 1 message Dec 17, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 optee-os: upgrade to upstream 3.11.0

As meta-arm has this version in master, but not in dunfell, temporarily overlay corresponding patches locally - could be removed for the next release. Need to alter FILESEXTRAPATHS for bbappend to locate local patches.

Since meta-arm/dunfell has 3.8-specific patches in SRC_URI, let's redefine it completely to match 3.11-specific patch list in meta-arm/master.

Last, but not least, guard all upstream recipe varibales with "ti-soc" override to only affect platforms in meta-ti, but not any other BSPs.

---
 ...-provide-empty-__getauxval-implementation.patch | 62 ++++++++++++++++++++++
 ...lement-support-for-libnames-after-libgcc-.patch | 55 +++++++++++++++++++
 ...mk-make-sure-that-libutils-is-linked-seco.patch | 44 +++++++++++++++
 ...6-allow-setting-sysroot-for-libgcc-lookup.patch | 34 ++++++++++++
 .../0007-allow-setting-sysroot-for-clang.patch     | 29 ++++++++++
 recipes-security/optee/optee-os_%.bbappend         | 15 ++++++
 6 files changed, 239 insertions(+)
 create mode 100644 recipes-security/optee/optee-os/0001-libutils-provide-empty-__getauxval-implementation.patch
 create mode 100644 recipes-security/optee/optee-os/0002-link.mk-implement-support-for-libnames-after-libgcc-.patch
 create mode 100644 recipes-security/optee/optee-os/0003-ta_dev_kit.mk-make-sure-that-libutils-is-linked-seco.patch
 create mode 100644 recipes-security/optee/optee-os/0006-allow-setting-sysroot-for-libgcc-lookup.patch
 create mode 100644 recipes-security/optee/optee-os/0007-allow-setting-sysroot-for-clang.patch
recipes-security/optee/optee-os/0001-libutils-provide-empty-__getauxval-implementation.patch new file +62 -0
new file mode 100644
index 0000000..0120f5c
@@ -0,0 +1,62 @@
+Upstream-Status: Backport
+Signed-off-by: Ross Burton <[email protected]>
+
+From 36e784f621bf5d5be9183beba35f39426277c110 Mon Sep 17 00:00:00 2001
+From: Volodymyr Babchuk <[email protected]>
+Date: Tue, 13 Oct 2020 22:45:39 +0300
+Subject: [PATCH 1/3] libutils: provide empty __getauxval() implementation
+
+Never version of libgcc are built with LSE implementation in mind. To
+determine if LSE is available on platform it calls __getauxval(), so in
+some cases we can get undefined reference to __getauxval() error.
+
+Prominent case is libgcc_eh.a library, which is used by C++ TAs. Exception
+handler depends on atomic operations, so it tries to call
+init_have_lse_atomics() first. This function in turn calls __getauxval(),
+which causes linking error.
+
+In the future we can make __getauxval() to return actual platform
+capabilities.
+
+Signed-off-by: Volodymyr Babchuk <[email protected]>
+Reviewed-by: Jens Wiklander <[email protected]>
+Reviewed-by: Jerome Forissier <[email protected]>
+---
+ lib/libutils/ext/arch/arm/auxval.c | 12 ++++++++++++
+ lib/libutils/ext/arch/arm/sub.mk   |  1 +
+ 2 files changed, 13 insertions(+)
+ create mode 100644 lib/libutils/ext/arch/arm/auxval.c
+
+diff --git a/lib/libutils/ext/arch/arm/auxval.c b/lib/libutils/ext/arch/arm/auxval.c
+new file mode 100644
+index 00000000..98bca850
+--- /dev/null
++++ b/lib/libutils/ext/arch/arm/auxval.c
+@@ -0,0 +1,12 @@
++// SPDX-License-Identifier: BSD-2-Clause
++/*
++ * Copyright (c) 2020, EPAM Systems
++ */
++
++#include <compiler.h>
++
++unsigned long int __getauxval (unsigned long int type);
++unsigned long int __getauxval (unsigned long int type __unused)
++{
++	return 0;
++}
+diff --git a/lib/libutils/ext/arch/arm/sub.mk b/lib/libutils/ext/arch/arm/sub.mk
+index dc5eed67..2e779066 100644
+--- a/lib/libutils/ext/arch/arm/sub.mk
++++ b/lib/libutils/ext/arch/arm/sub.mk
+@@ -3,6 +3,7 @@ srcs-$(CFG_ARM32_$(sm)) += aeabi_unwind.c
+ endif
+ srcs-$(CFG_ARM32_$(sm)) += atomic_a32.S
+ srcs-$(CFG_ARM64_$(sm)) += atomic_a64.S
++srcs-y += auxval.c
+ ifneq ($(sm),ldelf) # TA, core
+ srcs-$(CFG_ARM32_$(sm)) += mcount_a32.S
+ srcs-$(CFG_ARM64_$(sm)) += mcount_a64.S
+-- 
+2.25.1
+
recipes-security/optee/optee-os/0002-link.mk-implement-support-for-libnames-after-libgcc-.patch new file +55 -0

55 lines not on this page · raw message

recipes-security/optee/optee-os/0003-ta_dev_kit.mk-make-sure-that-libutils-is-linked-seco.patch new file +44 -0

44 lines not on this page · raw message

recipes-security/optee/optee-os/0006-allow-setting-sysroot-for-libgcc-lookup.patch new file +34 -0
new file mode 100644
index 0000000..1700539
@@ -0,0 +1,34 @@
+From 0bab935695ebcf0c533b49896ab18ff33d4a47d1 Mon Sep 17 00:00:00 2001
+From: Ross Burton <[email protected]>
+Date: Tue, 26 May 2020 14:38:02 -0500
+Subject: [PATCH] allow setting sysroot for libgcc lookup
+
+Explicitly pass the new variable LIBGCC_LOCATE_CFLAGS variable when searching
+for the compiler libraries as there's no easy way to reliably pass --sysroot
+otherwise.
+
+Upstream-Status: Pending [https://github.com/OP-TEE/optee_os/issues/4188]
+Signed-off-by: Ross Burton <[email protected]>
+---
+ mk/gcc.mk | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/mk/gcc.mk b/mk/gcc.mk
+index adc77a24..81bfa78a 100644
+--- a/mk/gcc.mk
++++ b/mk/gcc.mk
+@@ -13,11 +13,11 @@ nostdinc$(sm)	:= -nostdinc -isystem $(shell $(CC$(sm)) \
+ 			-print-file-name=include 2> /dev/null)
+ 
+ # Get location of libgcc from gcc
+-libgcc$(sm)  	:= $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) \
++libgcc$(sm)  	:= $(shell $(CC$(sm)) $(LIBGCC_LOCATE_CFLAGS) $(CFLAGS$(arch-bits-$(sm))) \
+ 			-print-libgcc-file-name 2> /dev/null)
+-libstdc++$(sm)	:= $(shell $(CXX$(sm)) $(CXXFLAGS$(arch-bits-$(sm))) $(comp-cxxflags$(sm)) \
++libstdc++$(sm)	:= $(shell $(CXX$(sm)) $(LIBGCC_LOCATE_CFLAGS) $(CXXFLAGS$(arch-bits-$(sm))) $(comp-cxxflags$(sm)) \
+ 			-print-file-name=libstdc++.a 2> /dev/null)
+-libgcc_eh$(sm)	:= $(shell $(CXX$(sm)) $(CXXFLAGS$(arch-bits-$(sm))) $(comp-cxxflags$(sm)) \
++libgcc_eh$(sm)	:= $(shell $(CXX$(sm)) $(LIBGCC_LOCATE_CFLAGS) $(CXXFLAGS$(arch-bits-$(sm))) $(comp-cxxflags$(sm)) \
+ 			-print-file-name=libgcc_eh.a 2> /dev/null)
+ 
+ # Define these to something to discover accidental use
recipes-security/optee/optee-os/0007-allow-setting-sysroot-for-clang.patch new file +29 -0
new file mode 100644
index 0000000..5c0d0a5
@@ -0,0 +1,29 @@
+From 3167f2c0dba4db59d61b60a8fe66f969d20aafa9 Mon Sep 17 00:00:00 2001
+From: Brett Warren <[email protected]>
+Date: Wed, 23 Sep 2020 09:27:34 +0100
+Subject: [PATCH] optee: enable clang support
+
+When compiling with clang, the LIBGCC_LOCATE_CFLAG variable used
+to provide a sysroot wasn't included, which results in not locating
+compiler-rt. This is mitigated by including the variable as ammended.
+
+Upstream-Status: Pending
+ChangeId: 8ba69a4b2eb8ebaa047cb266c9aa6c2c3da45701
+Signed-off-by: Brett Warren <[email protected]>
+---
+ mk/clang.mk | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/mk/clang.mk b/mk/clang.mk
+index 0f48c836..47465523 100644
+--- a/mk/clang.mk
++++ b/mk/clang.mk
+@@ -27,7 +27,7 @@ comp-cflags-warns-clang := -Wno-language-extension-token \
+ 
+ # Note, use the compiler runtime library (libclang_rt.builtins.*.a) instead of
+ # libgcc for clang
+-libgcc$(sm)	:= $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) \
++libgcc$(sm)	:= $(shell $(CC$(sm)) $(LIBGCC_LOCATE_CFLAGS) $(CFLAGS$(arch-bits-$(sm))) \
+ 			-rtlib=compiler-rt -print-libgcc-file-name 2> /dev/null)
+ 
+ # Core ASLR relies on the executable being ready to run from its preferred load
recipes-security/optee/optee-os_%.bbappend +15 -0
index 2846d0a..8072490 100644
@@ -1,3 +1,18 @@
+FILESEXTRAPATHS_prepend_ti-soc := "${THISDIR}/${PN}:"
+
+PV_ti-soc = "3.11.0+git${SRCPV}"
+
+SRCREV_ti-soc = "c4def2a8262a03244d9a88461699b9b8e43c6b55"
+
+SRC_URI_ti-soc = " \
+    git://github.com/OP-TEE/optee_os.git \
+    file://0006-allow-setting-sysroot-for-libgcc-lookup.patch \
+    file://0007-allow-setting-sysroot-for-clang.patch \
+    file://0001-libutils-provide-empty-__getauxval-implementation.patch \
+    file://0002-link.mk-implement-support-for-libnames-after-libgcc-.patch \
+    file://0003-ta_dev_kit.mk-make-sure-that-libutils-is-linked-seco.patch \
+"
+
 do_compile_prepend_ti-soc() {
     export TI_SECURE_DEV_PKG=${TI_SECURE_DEV_PKG}
 }
Signature · 1 line
2.7.4