+++ /dev/null
-From b2dd8747125be413f9b8b7fd7e52f457cabd709c Mon Sep 17 00:00:00 2001
-From: Jens Wiklander <jens.wiklander@linaro.org>
-Date: Tue, 5 Feb 2019 13:05:29 +0100
-Subject: [PATCH] Fix alignment of data for mempool_alloc_pool()
-
-Upstream-Status: Submitted
-
-Prior to this patch was _TEE_MathAPI_Init() in
-lib/libutee/tee_api_arith_mpi.c supplying a data buffer which was only 4
-byte aligned while mempool_alloc_pool() requires the alignment of long.
-This will work in 32-bit mode, but could lead to alignment problem in
-64-bit mode. The same problem can happen with
-lib/libutee/tee_api_arith_mpa.c, but so far it has remained hidden.
-
-Incorrect alignment can result in errors like:
-E/TA: assertion '!((vaddr_t)data & (POOL_ALIGN - 1))' failed at lib/libutils/ext/mempool.c:134 in mempool_alloc_pool()
-
-This fix introduces MEMPOOL_ALIGN which specifies required alignment of
-data supplied to mempool_alloc_pool().
-
-Fixes: 062e3d01c039 ("ta: switch to to mbedtls for bignum")
-Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
-Tested-by: Joakim Bech <joakim.bech@linaro.org> (QEMU v8)
-Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
-Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
----
- core/lib/libtomcrypt/src/mpa_desc.c | 2 +-
- core/lib/libtomcrypt/src/mpi_desc.c | 2 +-
- lib/libutee/tee_api_arith_mpa.c | 3 ++-
- lib/libutee/tee_api_arith_mpi.c | 3 +--
- lib/libutils/ext/include/mempool.h | 5 ++++-
- lib/libutils/ext/mempool.c | 9 ++++-----
- 6 files changed, 13 insertions(+), 11 deletions(-)
-
-diff --git a/core/lib/libtomcrypt/src/mpa_desc.c b/core/lib/libtomcrypt/src/mpa_desc.c
-index b407f54..58aa242 100644
---- a/core/lib/libtomcrypt/src/mpa_desc.c
-+++ b/core/lib/libtomcrypt/src/mpa_desc.c
-@@ -40,7 +40,7 @@ static struct mempool *get_mpa_scratch_memory_pool(void)
- #else /* CFG_WITH_PAGER */
- static struct mempool *get_mpa_scratch_memory_pool(void)
- {
-- static uint32_t data[LTC_MEMPOOL_U32_SIZE] __aligned(__alignof__(long));
-+ static uint32_t data[LTC_MEMPOOL_U32_SIZE] __aligned(MEMPOOL_ALIGN);
-
- return mempool_alloc_pool(data, sizeof(data), NULL);
- }
-diff --git a/core/lib/libtomcrypt/src/mpi_desc.c b/core/lib/libtomcrypt/src/mpi_desc.c
-index a43fbb4..67bc3a7 100644
---- a/core/lib/libtomcrypt/src/mpi_desc.c
-+++ b/core/lib/libtomcrypt/src/mpi_desc.c
-@@ -38,7 +38,7 @@ static struct mempool *get_mp_scratch_memory_pool(void)
- #else /* CFG_WITH_PAGER */
- static struct mempool *get_mp_scratch_memory_pool(void)
- {
-- static uint8_t data[MPI_MEMPOOL_SIZE] __aligned(__alignof__(long));
-+ static uint8_t data[MPI_MEMPOOL_SIZE] __aligned(MEMPOOL_ALIGN);
-
- return mempool_alloc_pool(data, sizeof(data), NULL);
- }
-diff --git a/lib/libutee/tee_api_arith_mpa.c b/lib/libutee/tee_api_arith_mpa.c
-index 0f6c7f1..a8ca6aa 100644
---- a/lib/libutee/tee_api_arith_mpa.c
-+++ b/lib/libutee/tee_api_arith_mpa.c
-@@ -19,7 +19,8 @@
-
- static uint32_t mempool_u32[mpa_scratch_mem_size_in_U32(
- MPA_INTERNAL_MEM_POOL_SIZE,
-- CFG_TA_BIGNUM_MAX_BITS)];
-+ CFG_TA_BIGNUM_MAX_BITS)]
-+ __aligned(MEMPOOL_ALIGN);
- static mpa_scratch_mem mempool;
-
- /*************************************************************
-diff --git a/lib/libutee/tee_api_arith_mpi.c b/lib/libutee/tee_api_arith_mpi.c
-index 8e2751b..6b074e1 100644
---- a/lib/libutee/tee_api_arith_mpi.c
-+++ b/lib/libutee/tee_api_arith_mpi.c
-@@ -42,8 +42,7 @@ static void __noreturn mpi_panic(const char *func, int line, int rc)
-
- void _TEE_MathAPI_Init(void)
- {
-- static uint8_t data[MPI_MEMPOOL_SIZE]
-- __aligned(__alignof__(mbedtls_mpi_uint));
-+ static uint8_t data[MPI_MEMPOOL_SIZE] __aligned(MEMPOOL_ALIGN);
-
- mbedtls_mpi_mempool = mempool_alloc_pool(data, sizeof(data), NULL);
- if (!mbedtls_mpi_mempool)
-diff --git a/lib/libutils/ext/include/mempool.h b/lib/libutils/ext/include/mempool.h
-index 62377df..2a60800 100644
---- a/lib/libutils/ext/include/mempool.h
-+++ b/lib/libutils/ext/include/mempool.h
-@@ -19,9 +19,12 @@ struct mempool_item {
-
- struct mempool;
-
-+#define MEMPOOL_ALIGN __alignof__(long)
-+
- /*
- * mempool_alloc_pool() - Allocate a new memory pool
-- * @data: a block of memory to carve out items from
-+ * @data: a block of memory to carve out items from, must
-+ * have an alignment of MEMPOOL_ALIGN.
- * @size: size fo the block of memory
- * @release_mem: function to call when the pool has been emptied,
- * ignored if NULL.
-diff --git a/lib/libutils/ext/mempool.c b/lib/libutils/ext/mempool.c
-index f977699..6d38590 100644
---- a/lib/libutils/ext/mempool.c
-+++ b/lib/libutils/ext/mempool.c
-@@ -53,7 +53,6 @@
- * So the potential fragmentation is mitigated.
- */
-
--#define POOL_ALIGN __alignof__(long)
-
- struct mempool {
- size_t size; /* size of the memory pool, in bytes */
-@@ -130,8 +129,8 @@ mempool_alloc_pool(void *data, size_t size,
- {
- struct mempool *pool = calloc(1, sizeof(*pool));
-
-- COMPILE_TIME_ASSERT(POOL_ALIGN >= __alignof__(struct mempool_item));
-- assert(!((vaddr_t)data & (POOL_ALIGN - 1)));
-+ COMPILE_TIME_ASSERT(MEMPOOL_ALIGN >= __alignof__(struct mempool_item));
-+ assert(!((vaddr_t)data & (MEMPOOL_ALIGN - 1)));
-
- if (pool) {
- pool->size = size;
-@@ -163,13 +162,13 @@ void *mempool_alloc(struct mempool *pool, size_t size)
- pool->last_offset);
- offset = pool->last_offset + last_item->size;
-
-- offset = ROUNDUP(offset, POOL_ALIGN);
-+ offset = ROUNDUP(offset, MEMPOOL_ALIGN);
- if (offset > pool->size)
- goto error;
- }
-
- size = sizeof(struct mempool_item) + size;
-- size = ROUNDUP(size, POOL_ALIGN);
-+ size = ROUNDUP(size, MEMPOOL_ALIGN);
- if (offset + size > pool->size)
- goto error;
-
---
-2.7.4
-
--- /dev/null
+From f94d9558d9eae48e92ce8d651539b6cf69eb4394 Mon Sep 17 00:00:00 2001
+From: Joshua Watt <JPEWhacker@gmail.com>
+Date: Mon, 18 May 2020 20:00:00 -0500
+Subject: [PATCH] arm64: Disable outline-atomics when compiling
+
+Disables the automatic detection of LSE (Large System Extension)
+instructions when compiling AArch64 code. GCC 10 implements this
+detection in libgcc using __getauxval(), which optee doesn't implement.
+This requires that the proper -mcpu is passed to GCC so that the code
+can be correctly compiled to use either LSE or load-store-exclusive.
+
+Fixes linker errors like the following when compiling with GCC 10:
+
+ aarch64-linux-ld.bfd: libgcc.a(lse-init.o):
+ in function `init_have_lse_atomics':
+ lse-init.c:44: undefined reference to `__getauxval'
+ core/arch/arm/kernel/link.mk:38:
+ recipe for target 'build/core/all_objs.o' failed
+
+Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
+Upstream-Status: Submitted [https://github.com/OP-TEE/optee_os/pull/3874]
+---
+ core/arch/arm/arm.mk | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/core/arch/arm/arm.mk b/core/arch/arm/arm.mk
+index a18eda3b..07069c66 100644
+--- a/core/arch/arm/arm.mk
++++ b/core/arch/arm/arm.mk
+@@ -115,7 +115,7 @@ arm32-platform-aflags-no-hard-float ?=
+
+ arm64-platform-cflags-no-hard-float ?= -mgeneral-regs-only
+ arm64-platform-cflags-hard-float ?=
+-arm64-platform-cflags-generic ?= -mstrict-align
++arm64-platform-cflags-generic ?= -mstrict-align $(call cc-option,-mno-outline-atomics,)
+
+ ifeq ($(DEBUG),1)
+ # For backwards compatibility
+--
+2.17.1
+
+++ /dev/null
-From 027a3b9a33fbb23e1d1d7ed6411d4d112d2a55a1 Mon Sep 17 00:00:00 2001
-From: Andrey Zhizhikin <andrey.z@gmail.com>
-Date: Sat, 30 May 2020 22:00:59 +0000
-Subject: [PATCH] optee-os: fix gcc10 compilation issue and missing cc-options
-
-Backport PR 3891 from upstream to imx fork, which addressed compilation
-failure when GCC10 is used.
-
-Additional changes ported fixed cc-options macro, which allows to query
-compiler used if the desired option exists before it could be set. This
-solves also the build issues when GCC9 is used to build this component.
-
-Upstream-Status: Backport [https://github.com/OP-TEE/optee_os/pull/3891]
-
-Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com>
----
- core/arch/arm/arm.mk | 21 ++++++++++++++++-----
- core/core.mk | 5 +----
- mk/cc-option.mk | 9 +++++++++
- mk/gcc.mk | 2 +-
- ta/mk/ta_dev_kit.mk | 3 +++
- ta/ta.mk | 1 +
- 6 files changed, 31 insertions(+), 10 deletions(-)
- create mode 100644 mk/cc-option.mk
-
-diff --git a/core/arch/arm/arm.mk b/core/arch/arm/arm.mk
-index 0a95b1ec..bfcbe896 100644
---- a/core/arch/arm/arm.mk
-+++ b/core/arch/arm/arm.mk
-@@ -1,3 +1,16 @@
-+# Setup compiler for the core module
-+ifeq ($(CFG_ARM64_core),y)
-+arch-bits-core := 64
-+else
-+arch-bits-core := 32
-+endif
-+CROSS_COMPILE_core := $(CROSS_COMPILE$(arch-bits-core))
-+COMPILER_core := $(COMPILER)
-+include mk/$(COMPILER_core).mk
-+
-+# Defines the cc-option macro using the compiler set for the core module
-+include mk/cc-option.mk
-+
- CFG_LTC_OPTEE_THREAD ?= y
- # Size of emulated TrustZone protected SRAM, 448 kB.
- # Only applicable when paging is enabled.
-@@ -95,7 +108,7 @@ arm32-platform-aflags-no-hard-float ?=
-
- arm64-platform-cflags-no-hard-float ?= -mgeneral-regs-only
- arm64-platform-cflags-hard-float ?=
--arm64-platform-cflags-generic ?= -mstrict-align
-+arm64-platform-cflags-generic := -mstrict-align $(call cc-option,-mno-outline-atomics,)
-
- ifeq ($(DEBUG),1)
- # For backwards compatibility
-@@ -124,14 +137,12 @@ core-platform-aflags += $(platform-aflags-generic)
- core-platform-aflags += $(platform-aflags-debug-info)
-
- ifeq ($(CFG_ARM64_core),y)
--arch-bits-core := 64
- core-platform-cppflags += $(arm64-platform-cppflags)
- core-platform-cflags += $(arm64-platform-cflags)
- core-platform-cflags += $(arm64-platform-cflags-generic)
- core-platform-cflags += $(arm64-platform-cflags-no-hard-float)
- core-platform-aflags += $(arm64-platform-aflags)
- else
--arch-bits-core := 32
- core-platform-cppflags += $(arm32-platform-cppflags)
- core-platform-cflags += $(arm32-platform-cflags)
- core-platform-cflags += $(arm32-platform-cflags-no-hard-float)
-@@ -217,8 +228,8 @@ ta-mk-file-export-add-ta_arm64 += CROSS_COMPILE64 ?= $$(CROSS_COMPILE)_nl_
- ta-mk-file-export-add-ta_arm64 += CROSS_COMPILE_ta_arm64 ?= $$(CROSS_COMPILE64)_nl_
- endif
-
--# Set cross compiler prefix for each submodule
--$(foreach sm, core $(ta-targets), $(eval CROSS_COMPILE_$(sm) ?= $(CROSS_COMPILE$(arch-bits-$(sm)))))
-+# Set cross compiler prefix for each TA target
-+$(foreach sm, $(ta-targets), $(eval CROSS_COMPILE_$(sm) ?= $(CROSS_COMPILE$(arch-bits-$(sm)))))
-
- arm32-sysreg-txt = core/arch/arm/kernel/arm32_sysreg.txt
- arm32-sysregs-$(arm32-sysreg-txt)-h := arm32_sysreg.h
-diff --git a/core/core.mk b/core/core.mk
-index 37906792..4eec217a 100644
---- a/core/core.mk
-+++ b/core/core.mk
-@@ -8,6 +8,7 @@ arch-dir := core/arch/$(ARCH)
- platform-dir := $(arch-dir)/plat-$(PLATFORM)
- include $(platform-dir)/conf.mk
- include mk/config.mk
-+# $(ARCH).mk also sets the compiler for the core module
- include core/arch/$(ARCH)/$(ARCH).mk
-
- PLATFORM_$(PLATFORM) := y
-@@ -16,10 +17,6 @@ PLATFORM_FLAVOR_$(PLATFORM_FLAVOR) := y
- $(call cfg-depends-all,CFG_PAGED_USER_TA,CFG_WITH_PAGER CFG_WITH_USER_TA)
- include core/crypto.mk
-
--# Setup compiler for this sub module
--COMPILER_$(sm) ?= $(COMPILER)
--include mk/$(COMPILER_$(sm)).mk
--
- cppflags$(sm) += -D__KERNEL__
-
- cppflags$(sm) += -Icore/include
-diff --git a/mk/cc-option.mk b/mk/cc-option.mk
-new file mode 100644
-index 00000000..4699fbcc
---- /dev/null
-+++ b/mk/cc-option.mk
-@@ -0,0 +1,9 @@
-+_cc-option-supported = $(if $(shell $(CC$(sm)) $(1) -c -x c /dev/null -o /dev/null 2>/dev/null >/dev/null || echo "Not supported"),,1)
-+_cc-opt-cached-var-name = $(subst =,~,$(strip cached-cc-option-$(1)-$(subst $(empty) $(empty),,$(CC$(sm)))))
-+define _cc-option
-+$(eval _var_name := $(call _cc-opt-cached-var-name,$(1)))
-+$(eval $(_var_name) := $(if $(filter $(origin $(_var_name)),undefined),$(call _cc-option-supported,$(1)),$($(_var_name))))
-+$(if $($(_var_name)),$(1),$(2))
-+endef
-+cc-option = $(strip $(call _cc-option,$(1),$(2)))
-+
-diff --git a/mk/gcc.mk b/mk/gcc.mk
-index c516c731..330b200a 100644
---- a/mk/gcc.mk
-+++ b/mk/gcc.mk
-@@ -12,7 +12,7 @@ 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)) $(LIBGCC_LOCATE_CFLAGS) $(CFLAGS$(arch-bits-$(sm))) $(comp-cflags$(sm)) \
-+libgcc$(sm) := $(shell $(CC$(sm)) $(LIBGCC_LOCATE_CFLAGS) $(CFLAGS$(arch-bits-$(sm))) \
- -print-libgcc-file-name 2> /dev/null)
-
- # Define these to something to discover accidental use
-diff --git a/ta/mk/ta_dev_kit.mk b/ta/mk/ta_dev_kit.mk
-index 8473c6df..40e77c3e 100644
---- a/ta/mk/ta_dev_kit.mk
-+++ b/ta/mk/ta_dev_kit.mk
-@@ -86,6 +86,9 @@ clean:
- @$(cmd-echo-silent) ' CLEAN $(O)'
- ${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi
-
-+include $(ta-dev-kit-dir$(sm))/mk/$(COMPILER_$(sm)).mk
-+include $(ta-dev-kit-dir$(sm))/mk/cc-option.mk
-+
- subdirs = .
- include $(ta-dev-kit-dir$(sm))/mk/subdir.mk
-
-diff --git a/ta/ta.mk b/ta/ta.mk
-index 1b7e999d..e0915d18 100644
---- a/ta/ta.mk
-+++ b/ta/ta.mk
-@@ -105,6 +105,7 @@ $(foreach f, $(libfiles), \
-
- # Copy .mk files
- ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk mk/cleandirs.mk \
-+ mk/cc-option.mk \
- ta/arch/$(ARCH)/link.mk ta/arch/$(ARCH)/link_shlib.mk \
- ta/mk/ta_dev_kit.mk
-
---
-2.17.1
-
+++ /dev/null
-diff --git a/scripts/arm32_sysreg.py b/scripts/arm32_sysreg.py
-index bd0c619e..530b0f44 100755
---- a/scripts/arm32_sysreg.py
-+++ b/scripts/arm32_sysreg.py
-@@ -1,4 +1,4 @@
--#!/usr/bin/env python
-+#!/usr/bin/env python3
- # SPDX-License-Identifier: BSD-2-Clause
- #
- # Copyright (c) 2018, Linaro Limited
-diff --git a/scripts/gen_hashed_bin.py b/scripts/gen_hashed_bin.py
-index 67b2b049..619cf26e 100755
---- a/scripts/gen_hashed_bin.py
-+++ b/scripts/gen_hashed_bin.py
-@@ -1,4 +1,4 @@
--#!/usr/bin/env python
-+#!/usr/bin/env python3
- # SPDX-License-Identifier: BSD-2-Clause
- #
- # Copyright (c) 2014-2017, Linaro Limited
-diff --git a/scripts/gen_ld_sects.py b/scripts/gen_ld_sects.py
-index 43e812b5..bc82dd8b 100755
---- a/scripts/gen_ld_sects.py
-+++ b/scripts/gen_ld_sects.py
-@@ -1,4 +1,4 @@
--#!/usr/bin/env python
-+#!/usr/bin/env python3
- # SPDX-License-Identifier: BSD-2-Clause
- #
- # Copyright (c) 2017, Linaro Limited
-diff --git a/scripts/pem_to_pub_c.py b/scripts/pem_to_pub_c.py
-index ddc17c18..69a4355c 100755
---- a/scripts/pem_to_pub_c.py
-+++ b/scripts/pem_to_pub_c.py
-@@ -1,4 +1,4 @@
--#!/usr/bin/env python
-+#!/usr/bin/env python3
- # SPDX-License-Identifier: BSD-2-Clause
- #
- # Copyright (c) 2015, Linaro Limited
-diff --git a/scripts/sign.py b/scripts/sign.py
-index 84fd7714..f6e6b667 100755
---- a/scripts/sign.py
-+++ b/scripts/sign.py
-@@ -1,4 +1,4 @@
--#!/usr/bin/env python
-+#!/usr/bin/env python3
- #
- # Copyright (c) 2015, 2017, Linaro Limited
- #
-diff --git a/scripts/symbolize.py b/scripts/symbolize.py
-index 99a48c70..cbd9884a 100755
---- a/scripts/symbolize.py
-+++ b/scripts/symbolize.py
-@@ -1,4 +1,4 @@
--#!/usr/bin/env python
-+#!/usr/bin/env python3
- # SPDX-License-Identifier: BSD-2-Clause
- #
- # Copyright (c) 2017, Linaro Limited
-diff --git a/scripts/ta_bin_to_c.py b/scripts/ta_bin_to_c.py
-index 1496f816..a01e7f9b 100755
---- a/scripts/ta_bin_to_c.py
-+++ b/scripts/ta_bin_to_c.py
-@@ -1,4 +1,4 @@
--#!/usr/bin/env python
-+#!/usr/bin/env python3
- # SPDX-License-Identifier: BSD-2-Clause
- #
- # Copyright (c) 2017, Linaro Limited
-diff --git a/scripts/tee_bin_parser.py b/scripts/tee_bin_parser.py
-index 8356ad5d..4409074b 100755
---- a/scripts/tee_bin_parser.py
-+++ b/scripts/tee_bin_parser.py
-@@ -1,4 +1,4 @@
--#!/usr/bin/env python
-+#!/usr/bin/env python3
- # SPDX-License-Identifier: BSD-2-Clause
- #
- # Copyright (c) 2016, Linaro Limited
DESCRIPTION = "OPTEE OS"
LICENSE = "BSD"
-LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=69663ab153298557a59c67a60a743e5b"
+LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=c1f21c4f72f372ef38a5a4aee55ec173"
-DEPENDS = "python3-pycrypto-native"
+PV = "3.8+git${SRCPV}"
+
+DEPENDS += "python3-pyelftools-native python3-pycryptodome-native python3-pycryptodomex-native dtc-native"
inherit deploy python3native
-SRCREV = "4e8d2e5307b99a91a0cac3ea3560ecb7d62898d6"
SRC_URI = "git://source.codeaurora.org/external/qoriq/qoriq-components/optee_os;nobranch=1 \
file://0001-allow-setting-sysroot-for-libgcc-lookup.patch \
- file://0001-Fix-alignment-of-data-for-mempool_alloc_pool.patch \
- file://0001-use-python3-instead-of-python.patch \
- file://0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch \
+ file://0001-arm64-Disable-outline-atomics-when-compiling.patch \
"
+SRCREV = "0cb01f7f6aee552ead49990c06f69f73f459cc65"
+
S = "${WORKDIR}/git"
OPTEEMACHINE ?= "${MACHINE}"
OPTEEMACHINE_ls1088ardb-pb = "ls1088ardb"
OPTEEMACHINE_ls1046afrwy = "ls1046ardb"
+OPTEEMACHINE_lx2162aqds = "lx2160aqds"
EXTRA_OEMAKE = "PLATFORM=ls-${OPTEEMACHINE} CFG_ARM64_core=y \
ARCH=arm \
LDFLAGS= \
LIBGCC_LOCATE_CFLAGS=--sysroot=${STAGING_DIR_HOST} \
"
+EXTRA_OEMAKE_append_lx2162aqds = " CFG_EMBED_DTB_SOURCE_FILE=fsl-lx2160a-qds.dts CFG_EMBED_DT=y"
OPTEE_ARCH_armv7a = "arm32"
OPTEE_ARCH_aarch64 = "arm64"