summaryrefslogtreecommitdiffstats
path: root/recipes-security
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-security')
-rw-r--r--recipes-security/optee-imx/optee-client/0001-flags-do-not-override-CFLAGS-from-host.patch17
-rw-r--r--recipes-security/optee-imx/optee-client_3.7.0.imx.bb (renamed from recipes-security/optee-imx/optee-client_3.2.0.imx.bb)18
-rw-r--r--recipes-security/optee-imx/optee-os/0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch36
-rw-r--r--recipes-security/optee-imx/optee-os/0001-scripts-update-scripts-to-use-python3.patch427
-rw-r--r--recipes-security/optee-imx/optee-os_3.7.0.imx.bb (renamed from recipes-security/optee-imx/optee-os_3.2.0.imx.bb)44
-rw-r--r--recipes-security/optee-imx/optee-test_3.2.0.imx.bb58
-rw-r--r--recipes-security/optee-imx/optee-test_3.7.0.imx.bb55
7 files changed, 118 insertions, 537 deletions
diff --git a/recipes-security/optee-imx/optee-client/0001-flags-do-not-override-CFLAGS-from-host.patch b/recipes-security/optee-imx/optee-client/0001-flags-do-not-override-CFLAGS-from-host.patch
index 86c360f2..9c6b1069 100644
--- a/recipes-security/optee-imx/optee-client/0001-flags-do-not-override-CFLAGS-from-host.patch
+++ b/recipes-security/optee-imx/optee-client/0001-flags-do-not-override-CFLAGS-from-host.patch
@@ -1,4 +1,4 @@
1From 6a600c5637c5446ab3d11eb4304a1dd473ec503e Mon Sep 17 00:00:00 2001 1From 591461d6efe51989b4a7f4e875cdf37505eba360 Mon Sep 17 00:00:00 2001
2From: Andrey Zhizhikin <andrey.z@gmail.com> 2From: Andrey Zhizhikin <andrey.z@gmail.com>
3Date: Thu, 4 Jun 2020 19:24:05 +0000 3Date: Thu, 4 Jun 2020 19:24:05 +0000
4Subject: [PATCH] flags: do not override CFLAGS from host 4Subject: [PATCH] flags: do not override CFLAGS from host
@@ -19,11 +19,11 @@ Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com>
19Reviewed-by: Jerome Forissier <jerome@forissier.org> 19Reviewed-by: Jerome Forissier <jerome@forissier.org>
20Reviewed-by: Joakim Bech <joakim.bech@linaro.org> 20Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
21--- 21---
22 flags.mk | 6 +++--- 22 flags.mk | 8 ++++----
23 1 file changed, 3 insertions(+), 3 deletions(-) 23 1 file changed, 4 insertions(+), 4 deletions(-)
24 24
25diff --git a/flags.mk b/flags.mk 25diff --git a/flags.mk b/flags.mk
26index 71f3d18..faabef9 100644 26index c2f0e1c..65192bc 100644
27--- a/flags.mk 27--- a/flags.mk
28+++ b/flags.mk 28+++ b/flags.mk
29@@ -6,7 +6,7 @@ CROSS_COMPILE ?= arm-linux-gnueabihf- 29@@ -6,7 +6,7 @@ CROSS_COMPILE ?= arm-linux-gnueabihf-
@@ -35,10 +35,13 @@ index 71f3d18..faabef9 100644
35 -Werror-implicit-function-declaration -Wextra \ 35 -Werror-implicit-function-declaration -Wextra \
36 -Wfloat-equal -Wformat-nonliteral -Wformat-security \ 36 -Wfloat-equal -Wformat-nonliteral -Wformat-security \
37 -Wformat=2 -Winit-self -Wmissing-declarations \ 37 -Wformat=2 -Winit-self -Wmissing-declarations \
38@@ -15,11 +15,11 @@ CFLAGS := -Wall -Wbad-function-cast -Wcast-align \ 38@@ -16,13 +16,13 @@ CFLAGS := -Wall -Wbad-function-cast -Wcast-align \
39 -Wpointer-arith -Wshadow -Wstrict-prototypes \
40 -Wswitch-default -Wunsafe-loop-optimizations \ 39 -Wswitch-default -Wunsafe-loop-optimizations \
41 -Wwrite-strings -Werror 40 -Wwrite-strings -D_FILE_OFFSET_BITS=64
41 ifeq ($(CFG_WERROR),y)
42-CFLAGS += -Werror
43+override CFLAGS += -Werror
44 endif
42-CFLAGS += -c -fPIC 45-CFLAGS += -c -fPIC
43+override CFLAGS += -c -fPIC 46+override CFLAGS += -c -fPIC
44 47
diff --git a/recipes-security/optee-imx/optee-client_3.2.0.imx.bb b/recipes-security/optee-imx/optee-client_3.7.0.imx.bb
index 19770849..d83f8a9c 100644
--- a/recipes-security/optee-imx/optee-client_3.2.0.imx.bb
+++ b/recipes-security/optee-imx/optee-client_3.7.0.imx.bb
@@ -7,35 +7,35 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=69663ab153298557a59c67a60a743e5b"
7 7
8inherit python3native systemd 8inherit python3native systemd
9 9
10SRCBRANCH = "lf-5.4.y" 10SRCBRANCH = "imx_5.4.24_2.1.0"
11OPTEE_CLIENT_SRC ?= "git://source.codeaurora.org/external/imx/imx-optee-client.git;protocol=https" 11SRC_URI = "git://source.codeaurora.org/external/imx/imx-optee-client.git;protocol=https;branch=${SRCBRANCH}"
12SRC_URI = "${OPTEE_CLIENT_SRC};branch=${SRCBRANCH}"
13 12
14SRCREV = "71a9bef78fff2d5d4db8a2307d3b91e2aa671dc9" 13SRCREV = "bc0ec8ce1e4dc5ae23f4737ef659338b7cd408fe"
15 14
16SRC_URI += "file://tee-supplicant.service \ 15SRC_URI += "file://tee-supplicant.service \
17 file://0001-flags-do-not-override-CFLAGS-from-host.patch \ 16 file://0001-flags-do-not-override-CFLAGS-from-host.patch \
18" 17"
19 18
20S = "${WORKDIR}/git" 19S = "${WORKDIR}/git"
20B = "${WORKDIR}/build"
21SYSTEMD_SERVICE_${PN} = "tee-supplicant.service" 21SYSTEMD_SERVICE_${PN} = "tee-supplicant.service"
22 22
23OPTEE_ARCH ?= "arm32" 23OPTEE_ARCH ?= "arm32"
24OPTEE_ARCH_armv7a = "arm32" 24OPTEE_ARCH_armv7a = "arm32"
25OPTEE_ARCH_aarch64 = "arm64" 25OPTEE_ARCH_aarch64 = "arm64"
26 26
27EXTRA_OEMAKE = "ARCH=${OPTEE_ARCH}" 27EXTRA_OEMAKE = "ARCH=${OPTEE_ARCH} O=${B}"
28 28
29do_install () { 29do_install () {
30 oe_runmake install 30 oe_runmake -C ${S} install
31 31
32 install -D -p -m0644 ${S}/out/export/lib/libteec.so.1.0 ${D}${libdir}/libteec.so.1.0 32 install -D -p -m0644 ${B}/export/usr/lib/libteec.so.1.0 ${D}${libdir}/libteec.so.1.0
33 ln -sf libteec.so.1.0 ${D}${libdir}/libteec.so 33 ln -sf libteec.so.1.0 ${D}${libdir}/libteec.so
34 ln -sf libteec.so.1.0 ${D}${libdir}/libteec.so.1 34 ln -sf libteec.so.1.0 ${D}${libdir}/libteec.so.1
35 35
36 install -D -p -m0755 ${S}/out/export/bin/tee-supplicant ${D}${bindir}/tee-supplicant 36 install -D -p -m0755 ${B}/export/usr/sbin/tee-supplicant ${D}${bindir}/tee-supplicant
37 37
38 cp -a ${S}/out/export/include ${D}/usr/ 38 cp -a ${B}/export/usr/include ${D}/usr/
39 39
40 sed -i -e s:/etc:${sysconfdir}:g -e s:/usr/bin:${bindir}:g ${WORKDIR}/tee-supplicant.service 40 sed -i -e s:/etc:${sysconfdir}:g -e s:/usr/bin:${bindir}:g ${WORKDIR}/tee-supplicant.service
41 install -D -p -m0644 ${WORKDIR}/tee-supplicant.service ${D}${systemd_system_unitdir}/tee-supplicant.service 41 install -D -p -m0644 ${WORKDIR}/tee-supplicant.service ${D}${systemd_system_unitdir}/tee-supplicant.service
diff --git a/recipes-security/optee-imx/optee-os/0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch b/recipes-security/optee-imx/optee-os/0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch
index 509c7fb6..ab42d340 100644
--- a/recipes-security/optee-imx/optee-os/0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch
+++ b/recipes-security/optee-imx/optee-os/0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch
@@ -1,4 +1,4 @@
1From 027a3b9a33fbb23e1d1d7ed6411d4d112d2a55a1 Mon Sep 17 00:00:00 2001 1From 109ed8d9a5351c7bb0fdc0953c7e7fb6cedcad9c Mon Sep 17 00:00:00 2001
2From: Andrey Zhizhikin <andrey.z@gmail.com> 2From: Andrey Zhizhikin <andrey.z@gmail.com>
3Date: Sat, 30 May 2020 22:00:59 +0000 3Date: Sat, 30 May 2020 22:00:59 +0000
4Subject: [PATCH] optee-os: fix gcc10 compilation issue and missing cc-options 4Subject: [PATCH] optee-os: fix gcc10 compilation issue and missing cc-options
@@ -14,17 +14,17 @@ Upstream-Status: Backport [https://github.com/OP-TEE/optee_os/pull/3891]
14 14
15Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com> 15Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com>
16--- 16---
17 core/arch/arm/arm.mk | 21 ++++++++++++++++----- 17 core/arch/arm/arm.mk | 22 +++++++++++++++++-----
18 core/core.mk | 5 +---- 18 core/core.mk | 5 +----
19 mk/cc-option.mk | 9 +++++++++ 19 mk/cc-option.mk | 9 +++++++++
20 mk/gcc.mk | 2 +- 20 mk/gcc.mk | 2 +-
21 ta/mk/ta_dev_kit.mk | 3 +++ 21 ta/mk/ta_dev_kit.mk | 3 +++
22 ta/ta.mk | 1 + 22 ta/ta.mk | 1 +
23 6 files changed, 31 insertions(+), 10 deletions(-) 23 6 files changed, 32 insertions(+), 10 deletions(-)
24 create mode 100644 mk/cc-option.mk 24 create mode 100644 mk/cc-option.mk
25 25
26diff --git a/core/arch/arm/arm.mk b/core/arch/arm/arm.mk 26diff --git a/core/arch/arm/arm.mk b/core/arch/arm/arm.mk
27index aa101be8..4123d85d 100644 27index 5defb327..fffa491a 100644
28--- a/core/arch/arm/arm.mk 28--- a/core/arch/arm/arm.mk
29+++ b/core/arch/arm/arm.mk 29+++ b/core/arch/arm/arm.mk
30@@ -1,3 +1,16 @@ 30@@ -1,3 +1,16 @@
@@ -44,7 +44,7 @@ index aa101be8..4123d85d 100644
44 CFG_LTC_OPTEE_THREAD ?= y 44 CFG_LTC_OPTEE_THREAD ?= y
45 # Size of emulated TrustZone protected SRAM, 448 kB. 45 # Size of emulated TrustZone protected SRAM, 448 kB.
46 # Only applicable when paging is enabled. 46 # Only applicable when paging is enabled.
47@@ -88,7 +101,7 @@ arm32-platform-aflags-no-hard-float ?= 47@@ -106,7 +119,7 @@ arm32-platform-aflags-no-hard-float ?=
48 48
49 arm64-platform-cflags-no-hard-float ?= -mgeneral-regs-only 49 arm64-platform-cflags-no-hard-float ?= -mgeneral-regs-only
50 arm64-platform-cflags-hard-float ?= 50 arm64-platform-cflags-hard-float ?=
@@ -53,7 +53,7 @@ index aa101be8..4123d85d 100644
53 53
54 ifeq ($(DEBUG),1) 54 ifeq ($(DEBUG),1)
55 # For backwards compatibility 55 # For backwards compatibility
56@@ -117,14 +130,12 @@ core-platform-aflags += $(platform-aflags-generic) 56@@ -135,14 +148,12 @@ core-platform-aflags += $(platform-aflags-generic)
57 core-platform-aflags += $(platform-aflags-debug-info) 57 core-platform-aflags += $(platform-aflags-debug-info)
58 58
59 ifeq ($(CFG_ARM64_core),y) 59 ifeq ($(CFG_ARM64_core),y)
@@ -68,16 +68,20 @@ index aa101be8..4123d85d 100644
68 core-platform-cppflags += $(arm32-platform-cppflags) 68 core-platform-cppflags += $(arm32-platform-cppflags)
69 core-platform-cflags += $(arm32-platform-cflags) 69 core-platform-cflags += $(arm32-platform-cflags)
70 core-platform-cflags += $(arm32-platform-cflags-no-hard-float) 70 core-platform-cflags += $(arm32-platform-cflags-no-hard-float)
71@@ -196,5 +207,5 @@ ta-mk-file-export-add-ta_arm64 += CROSS_COMPILE64 ?= $$(CROSS_COMPILE)_nl_ 71@@ -241,8 +252,9 @@ ta-mk-file-export-add-ta_arm64 += COMPILER ?= gcc_nl_
72 ta-mk-file-export-add-ta_arm64 += CROSS_COMPILE_ta_arm64 ?= $$(CROSS_COMPILE64)_nl_ 72 ta-mk-file-export-add-ta_arm64 += COMPILER_ta_arm64 ?= $$(COMPILER)_nl_
73 endif 73 endif
74 74
75-# Set cross compiler prefix for each submodule 75-# Set cross compiler prefix for each submodule
76-$(foreach sm, core $(ta-targets), $(eval CROSS_COMPILE_$(sm) ?= $(CROSS_COMPILE$(arch-bits-$(sm))))) 76-$(foreach sm, core $(ta-targets), $(eval CROSS_COMPILE_$(sm) ?= $(CROSS_COMPILE$(arch-bits-$(sm)))))
77+# Set cross compiler prefix for each TA target 77+# Set cross compiler prefix for each TA target
78+$(foreach sm, $(ta-targets), $(eval CROSS_COMPILE_$(sm) ?= $(CROSS_COMPILE$(arch-bits-$(sm))))) 78+$(foreach sm, $(ta-targets), $(eval CROSS_COMPILE_$(sm) ?= $(CROSS_COMPILE$(arch-bits-$(sm)))))
79+
80
81 arm32-sysreg-txt = core/arch/arm/kernel/arm32_sysreg.txt
82 arm32-sysregs-$(arm32-sysreg-txt)-h := arm32_sysreg.h
79diff --git a/core/core.mk b/core/core.mk 83diff --git a/core/core.mk b/core/core.mk
80index c05815f3..68f45552 100644 84index a51cf847..28c7235c 100644
81--- a/core/core.mk 85--- a/core/core.mk
82+++ b/core/core.mk 86+++ b/core/core.mk
83@@ -8,6 +8,7 @@ arch-dir := core/arch/$(ARCH) 87@@ -8,6 +8,7 @@ arch-dir := core/arch/$(ARCH)
@@ -89,7 +93,7 @@ index c05815f3..68f45552 100644
89 93
90 PLATFORM_$(PLATFORM) := y 94 PLATFORM_$(PLATFORM) := y
91@@ -16,10 +17,6 @@ PLATFORM_FLAVOR_$(PLATFORM_FLAVOR) := y 95@@ -16,10 +17,6 @@ PLATFORM_FLAVOR_$(PLATFORM_FLAVOR) := y
92 $(call cfg-depends-all,CFG_PAGED_USER_TA,CFG_WITH_PAGER CFG_WITH_USER_TA) 96 $(eval $(call cfg-depends-all,CFG_PAGED_USER_TA,CFG_WITH_PAGER CFG_WITH_USER_TA))
93 include core/crypto.mk 97 include core/crypto.mk
94 98
95-# Setup compiler for this sub module 99-# Setup compiler for this sub module
@@ -128,10 +132,10 @@ index 1f2c5990..c53a23b1 100644
128 132
129 # Define these to something to discover accidental use 133 # Define these to something to discover accidental use
130diff --git a/ta/mk/ta_dev_kit.mk b/ta/mk/ta_dev_kit.mk 134diff --git a/ta/mk/ta_dev_kit.mk b/ta/mk/ta_dev_kit.mk
131index fa0bddfe..ae70ef87 100644 135index 04a4f94b..e4b02ea7 100644
132--- a/ta/mk/ta_dev_kit.mk 136--- a/ta/mk/ta_dev_kit.mk
133+++ b/ta/mk/ta_dev_kit.mk 137+++ b/ta/mk/ta_dev_kit.mk
134@@ -78,6 +78,9 @@ clean: 138@@ -92,6 +92,9 @@ clean:
135 @$(cmd-echo-silent) ' CLEAN $(O)' 139 @$(cmd-echo-silent) ' CLEAN $(O)'
136 ${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi 140 ${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi
137 141
@@ -139,16 +143,16 @@ index fa0bddfe..ae70ef87 100644
139+include $(ta-dev-kit-dir$(sm))/mk/cc-option.mk 143+include $(ta-dev-kit-dir$(sm))/mk/cc-option.mk
140+ 144+
141 subdirs = . 145 subdirs = .
142 include $(ta-dev-kit-dir)/mk/subdir.mk 146 include $(ta-dev-kit-dir$(sm))/mk/subdir.mk
143 147
144diff --git a/ta/ta.mk b/ta/ta.mk 148diff --git a/ta/ta.mk b/ta/ta.mk
145index 32353de3..9c64319d 100644 149index dde7be67..ca17054a 100644
146--- a/ta/ta.mk 150--- a/ta/ta.mk
147+++ b/ta/ta.mk 151+++ b/ta/ta.mk
148@@ -98,6 +98,7 @@ $(foreach f, $(libfiles), \ 152@@ -157,6 +157,7 @@ $(foreach f, $(libfiles), \
149 153
150 # Copy .mk files 154 # Copy .mk files
151 ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk mk/cleandirs.mk \ 155 ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk mk/clang.mk mk/cleandirs.mk \
152+ mk/cc-option.mk \ 156+ mk/cc-option.mk \
153 ta/arch/$(ARCH)/link.mk ta/arch/$(ARCH)/link_shlib.mk \ 157 ta/arch/$(ARCH)/link.mk ta/arch/$(ARCH)/link_shlib.mk \
154 ta/mk/ta_dev_kit.mk 158 ta/mk/ta_dev_kit.mk
diff --git a/recipes-security/optee-imx/optee-os/0001-scripts-update-scripts-to-use-python3.patch b/recipes-security/optee-imx/optee-os/0001-scripts-update-scripts-to-use-python3.patch
deleted file mode 100644
index 9621cf6c..00000000
--- a/recipes-security/optee-imx/optee-os/0001-scripts-update-scripts-to-use-python3.patch
+++ /dev/null
@@ -1,427 +0,0 @@
1From 0d4941123b5a88351f5954f6de00892f85ed5abc Mon Sep 17 00:00:00 2001
2From: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
3Date: Mon, 20 Jan 2020 22:32:13 +0000
4Subject: [PATCH] scripts: update scripts to use python3
5
6Python2 is deprecated effective Jan. 2020, and is not available in
7several distributions.
8
9Update scripts here to re-target then onto python version 3.
10
11Upstream-Status: Pending
12
13Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
14---
15 scripts/gen_hashed_bin.py | 282 ++++++++++++++++++++------------------
16 scripts/gen_ld_sects.py | 8 +-
17 scripts/pem_to_pub_c.py | 2 +-
18 scripts/sign.py | 2 +-
19 scripts/symbolize.py | 2 +-
20 scripts/ta_bin_to_c.py | 2 +-
21 scripts/tee_bin_parser.py | 2 +-
22 7 files changed, 157 insertions(+), 143 deletions(-)
23
24diff --git a/scripts/gen_hashed_bin.py b/scripts/gen_hashed_bin.py
25index 32350a47..a76a62cc 100755
26--- a/scripts/gen_hashed_bin.py
27+++ b/scripts/gen_hashed_bin.py
28@@ -1,4 +1,4 @@
29-#!/usr/bin/env python
30+#!/usr/bin/env python3
31 # SPDX-License-Identifier: BSD-2-Clause
32 #
33 # Copyright (c) 2014-2017, Linaro Limited
34@@ -14,163 +14,177 @@ import hashlib
35 arch_id = {'arm32': 0, 'arm64': 1}
36 image_id = {'pager': 0, 'paged': 1}
37
38+
39 def write_header_v1(outf, init_size, args, paged_size):
40- magic = 0x4554504f # 'OPTE'
41- version = 1;
42- outf.write(struct.pack('<IBBHIIIII', \
43- magic, version, arch_id[args.arch], args.flags, init_size, \
44- args.init_load_addr_hi, args.init_load_addr_lo, \
45- args.init_mem_usage, paged_size))
46+ magic = 0x4554504f # 'OPTE'
47+ version = 1
48+ outf.write(struct.pack('<IBBHIIIII',
49+ magic,
50+ version,
51+ arch_id[args.arch],
52+ args.flags,
53+ init_size,
54+ args.init_load_addr_hi,
55+ args.init_load_addr_lo,
56+ args.init_mem_usage,
57+ paged_size))
58+
59
60 def write_header_v2(outf, init_size, args, paged_size):
61- magic = 0x4554504f # 'OPTE'
62- version = 2
63- nb_images = 1 if paged_size == 0 else 2
64- outf.write(struct.pack('<IBBHI', \
65- magic, version, arch_id[args.arch], args.flags, nb_images))
66- outf.write(struct.pack('<IIII', \
67- args.init_load_addr_hi, args.init_load_addr_lo, \
68- image_id['pager'], init_size))
69- if nb_images == 2:
70- outf.write(struct.pack('<IIII', \
71- 0xffffffff, 0xffffffff, image_id['paged'], paged_size))
72+ magic = 0x4554504f # 'OPTE'
73+ version = 2
74+ nb_images = 1 if paged_size == 0 else 2
75+ outf.write(struct.pack('<IBBHI', magic, version,
76+ arch_id[args.arch], args.flags, nb_images))
77+ outf.write(struct.pack('<IIII',
78+ args.init_load_addr_hi, args.init_load_addr_lo,
79+ image_id['pager'], init_size))
80+ if nb_images == 2:
81+ outf.write(
82+ struct.pack(
83+ '<IIII',
84+ 0xffffffff,
85+ 0xffffffff,
86+ image_id['paged'],
87+ paged_size))
88+
89
90 def append_to(outf, start_offs, in_fname, max_bytes=0xffffffff):
91- #print "Appending %s@0x%x 0x%x bytes at position 0x%x" % \
92- #( in_fname, start_offs, max_bytes, int(outf.tell()) )
93- inf = open(in_fname, 'rb');
94- inf.seek(start_offs)
95- while True :
96- nbytes = min(16 * 1024, max_bytes)
97- if nbytes == 0 :
98- break
99- #print "Reading %s %d bytes" % (in_fname, nbytes)
100- buf = inf.read(nbytes)
101- if not buf :
102- break
103- outf.write(buf)
104- max_bytes -= len(buf)
105- inf.close()
106+ inf = open(in_fname, 'rb')
107+ inf.seek(start_offs)
108+ while True:
109+ nbytes = min(16 * 1024, max_bytes)
110+ if nbytes == 0:
111+ break
112+ buf = inf.read(nbytes)
113+ if not buf:
114+ break
115+ outf.write(buf)
116+ max_bytes -= len(buf)
117+ inf.close()
118+
119
120 def append_hashes(outf, in_fname):
121- page_size = 4 * 1024
122-
123- inf = open(in_fname, 'r')
124- while True :
125- page = inf.read(page_size)
126- if len(page) == page_size :
127- #print "Writing hash at position 0x%x" % \
128- #int(outf.tell())
129- outf.write(hashlib.sha256(page).digest())
130- elif len(page) == 0 :
131- break
132- else :
133- print("Error: short read, got " + repr(len(page)))
134- sys.exit(1)
135-
136- inf.close()
137+ page_size = 4 * 1024
138+
139+ inf = open(in_fname, 'rb')
140+ while True:
141+ page = inf.read(page_size)
142+ if len(page) == page_size:
143+ outf.write(hashlib.sha256(page).digest())
144+ elif len(page) == 0:
145+ break
146+ else:
147+ print("Error: short read, got {}".format(len(page)))
148+ sys.exit(1)
149+
150+ inf.close()
151+
152
153 def int_parse(str):
154- return int(str, 0)
155+ return int(str, 0)
156+
157
158 def get_args():
159- parser = argparse.ArgumentParser()
160- parser.add_argument('--arch', required=True, \
161- choices=arch_id.keys(), \
162- help='Architecture')
163+ parser = argparse.ArgumentParser()
164+ parser.add_argument('--arch', required=True,
165+ choices=list(arch_id.keys()),
166+ help='Architecture')
167
168- parser.add_argument('--flags', \
169- type=int, default=0, \
170- help='Flags, currently none defined')
171+ parser.add_argument('--flags',
172+ type=int, default=0,
173+ help='Flags, currently none defined')
174
175- parser.add_argument('--init_size', \
176- required=True, type=int_parse, \
177- help='Size of initialization part of binary')
178+ parser.add_argument('--init_size',
179+ required=True, type=int_parse,
180+ help='Size of initialization part of binary')
181
182- parser.add_argument('--init_load_addr_hi', \
183- type=int_parse, default=0, \
184- help='Upper 32 bits of load address of binary')
185+ parser.add_argument('--init_load_addr_hi',
186+ type=int_parse, default=0,
187+ help='Upper 32 bits of load address of binary')
188
189- parser.add_argument('--init_load_addr_lo', \
190- required=True, type=int_parse, \
191- help='Lower 32 bits of load address of binary')
192+ parser.add_argument('--init_load_addr_lo',
193+ required=True, type=int_parse,
194+ help='Lower 32 bits of load address of binary')
195
196- parser.add_argument('--init_mem_usage', \
197- required=True, type=int_parse, \
198- help='Total amount of used memory when initializing');
199+ parser.add_argument('--init_mem_usage',
200+ required=True, type=int_parse,
201+ help='Total amount of used memory when initializing')
202
203- parser.add_argument('--tee_pager_bin', \
204- required=True, \
205- help='The input tee_pager.bin')
206+ parser.add_argument('--tee_pager_bin',
207+ required=True,
208+ help='The input tee_pager.bin')
209
210- parser.add_argument('--tee_pageable_bin', \
211- required=True, \
212- help='The input tee_pageable.bin')
213+ parser.add_argument('--tee_pageable_bin',
214+ required=True,
215+ help='The input tee_pageable.bin')
216
217- parser.add_argument('--out', \
218- required=False, type=argparse.FileType('wb'), \
219- help='The output tee.bin')
220+ parser.add_argument('--out',
221+ required=False, type=argparse.FileType('wb'),
222+ help='The output tee.bin')
223
224- parser.add_argument('--out_header_v2', \
225- required=False, type=argparse.FileType('wb'), \
226- help='The output tee_header_v2.bin')
227+ parser.add_argument('--out_header_v2',
228+ required=False, type=argparse.FileType('wb'),
229+ help='The output tee_header_v2.bin')
230
231- parser.add_argument('--out_pager_v2', \
232- required=False, type=argparse.FileType('wb'), \
233- help='The output tee_pager_v2.bin')
234+ parser.add_argument('--out_pager_v2',
235+ required=False, type=argparse.FileType('wb'),
236+ help='The output tee_pager_v2.bin')
237
238- parser.add_argument('--out_pageable_v2', \
239- required=False, type=argparse.FileType('wb'), \
240- help='The output tee_pageable_v2.bin')
241+ parser.add_argument('--out_pageable_v2',
242+ required=False, type=argparse.FileType('wb'),
243+ help='The output tee_pageable_v2.bin')
244+
245+ return parser.parse_args()
246
247- return parser.parse_args();
248
249 def main():
250- args = get_args()
251- init_bin_size = args.init_size
252- tee_pager_fname = args.tee_pager_bin
253- tee_pageable_fname = args.tee_pageable_bin
254- pager_input_size = os.path.getsize(tee_pager_fname);
255- paged_input_size = os.path.getsize(tee_pageable_fname);
256- hash_size = paged_input_size / (4 * 1024) * \
257- hashlib.sha256().digest_size
258-
259- if paged_input_size % (4 * 1024) != 0:
260- print("Error: pageable size not a multiple of 4K:" + \
261- repr(paged_input_size))
262- sys.exit(1)
263-
264- init_size = pager_input_size + \
265- min(init_bin_size, paged_input_size) + \
266- hash_size
267- paged_size = paged_input_size - \
268- min(init_bin_size, paged_input_size)
269-
270- if args.out is not None:
271- outf = args.out
272- write_header_v1(outf, init_size, args, paged_size)
273- append_to(outf, 0, tee_pager_fname)
274- append_to(outf, 0, tee_pageable_fname, init_bin_size)
275- append_hashes(outf, tee_pageable_fname)
276- append_to(outf, init_bin_size, tee_pageable_fname)
277- outf.close()
278-
279- if args.out_header_v2 is not None:
280- outf = args.out_header_v2
281- write_header_v2(outf, init_size, args, paged_size)
282- outf.close()
283-
284- if args.out_pager_v2 is not None:
285- outf = args.out_pager_v2
286- append_to(outf, 0, tee_pager_fname)
287- append_to(outf, 0, tee_pageable_fname, init_bin_size)
288- append_hashes(outf, tee_pageable_fname)
289- outf.close()
290-
291- if args.out_pageable_v2 is not None:
292- outf = args.out_pageable_v2
293- append_to(outf, init_bin_size, tee_pageable_fname)
294- outf.close()
295+ args = get_args()
296+ init_bin_size = args.init_size
297+ tee_pager_fname = args.tee_pager_bin
298+ tee_pageable_fname = args.tee_pageable_bin
299+ pager_input_size = os.path.getsize(tee_pager_fname)
300+ paged_input_size = os.path.getsize(tee_pageable_fname)
301+ hash_size = paged_input_size // (4 * 1024) * \
302+ hashlib.sha256().digest_size
303+
304+ if paged_input_size % (4 * 1024) != 0:
305+ print("Error: pageable size not a multiple of 4K: {}".format(
306+ paged_input_size))
307+ sys.exit(1)
308+
309+ init_size = pager_input_size + \
310+ min(init_bin_size, paged_input_size) + \
311+ hash_size
312+ paged_size = paged_input_size - \
313+ min(init_bin_size, paged_input_size)
314+
315+ if args.out is not None:
316+ outf = args.out
317+ write_header_v1(outf, init_size, args, paged_size)
318+ append_to(outf, 0, tee_pager_fname)
319+ append_to(outf, 0, tee_pageable_fname, init_bin_size)
320+ append_hashes(outf, tee_pageable_fname)
321+ append_to(outf, init_bin_size, tee_pageable_fname)
322+ outf.close()
323+
324+ if args.out_header_v2 is not None:
325+ outf = args.out_header_v2
326+ write_header_v2(outf, init_size, args, paged_size)
327+ outf.close()
328+
329+ if args.out_pager_v2 is not None:
330+ outf = args.out_pager_v2
331+ append_to(outf, 0, tee_pager_fname)
332+ append_to(outf, 0, tee_pageable_fname, init_bin_size)
333+ append_hashes(outf, tee_pageable_fname)
334+ outf.close()
335+
336+ if args.out_pageable_v2 is not None:
337+ outf = args.out_pageable_v2
338+ append_to(outf, init_bin_size, tee_pageable_fname)
339+ outf.close()
340+
341
342 if __name__ == "__main__":
343- main()
344+ main()
345diff --git a/scripts/gen_ld_sects.py b/scripts/gen_ld_sects.py
346index c5dc3a7b..2bdbb192 100755
347--- a/scripts/gen_ld_sects.py
348+++ b/scripts/gen_ld_sects.py
349@@ -1,4 +1,4 @@
350-#!/usr/bin/env python
351+#!/usr/bin/env python3
352 # SPDX-License-Identifier: BSD-2-Clause
353 #
354 # Copyright (c) 2017, Linaro Limited
355@@ -8,8 +8,8 @@ import sys
356 import re
357
358 def usage():
359- print "Usage: {0} <section reg exp match> [<skip section>...]".format( \
360- sys.argv[0])
361+ print("Usage: {0} <section reg exp match> [<skip section>...]".format( \
362+ sys.argv[0]))
363 sys.exit (1)
364
365 def main():
366@@ -55,7 +55,7 @@ def main():
367 if sect_name in skip_sections :
368 continue
369
370- print '\t*({0})'.format(sect_name)
371+ print ('\t*({0})'.format(sect_name))
372
373 if __name__ == "__main__":
374 main()
375diff --git a/scripts/pem_to_pub_c.py b/scripts/pem_to_pub_c.py
376index 6b8fa365..0b03d62e 100755
377--- a/scripts/pem_to_pub_c.py
378+++ b/scripts/pem_to_pub_c.py
379@@ -1,4 +1,4 @@
380-#!/usr/bin/env python
381+#!/usr/bin/env python3
382 # SPDX-License-Identifier: BSD-2-Clause
383 #
384 # Copyright (c) 2015, Linaro Limited
385diff --git a/scripts/sign.py b/scripts/sign.py
386index ad47479b..348b40a2 100755
387--- a/scripts/sign.py
388+++ b/scripts/sign.py
389@@ -1,4 +1,4 @@
390-#!/usr/bin/env python
391+#!/usr/bin/env python3
392 #
393 # Copyright (c) 2015, 2017, Linaro Limited
394 #
395diff --git a/scripts/symbolize.py b/scripts/symbolize.py
396index 1eecf758..0e9bd3ed 100755
397--- a/scripts/symbolize.py
398+++ b/scripts/symbolize.py
399@@ -1,4 +1,4 @@
400-#!/usr/bin/env python
401+#!/usr/bin/env python3
402 # SPDX-License-Identifier: BSD-2-Clause
403 #
404 # Copyright (c) 2017, Linaro Limited
405diff --git a/scripts/ta_bin_to_c.py b/scripts/ta_bin_to_c.py
406index cabddbbd..f325fda0 100755
407--- a/scripts/ta_bin_to_c.py
408+++ b/scripts/ta_bin_to_c.py
409@@ -1,4 +1,4 @@
410-#!/usr/bin/env python
411+#!/usr/bin/env python3
412 # SPDX-License-Identifier: BSD-2-Clause
413 #
414 # Copyright (c) 2017, Linaro Limited
415diff --git a/scripts/tee_bin_parser.py b/scripts/tee_bin_parser.py
416index 5f7dd3f0..07da5791 100755
417--- a/scripts/tee_bin_parser.py
418+++ b/scripts/tee_bin_parser.py
419@@ -1,4 +1,4 @@
420-#!/usr/bin/env python
421+#!/usr/bin/env python3
422 # SPDX-License-Identifier: BSD-2-Clause
423 #
424 # Copyright (c) 2016, Linaro Limited
425--
4262.17.1
427
diff --git a/recipes-security/optee-imx/optee-os_3.2.0.imx.bb b/recipes-security/optee-imx/optee-os_3.7.0.imx.bb
index d2c82940..1bef749b 100644
--- a/recipes-security/optee-imx/optee-os_3.2.0.imx.bb
+++ b/recipes-security/optee-imx/optee-os_3.7.0.imx.bb
@@ -1,23 +1,22 @@
1# Copyright (C) 2017-2018 NXP 1# Copyright (C) 2017-2020 NXP
2 2
3SUMMARY = "OPTEE OS" 3SUMMARY = "OPTEE OS"
4DESCRIPTION = "OPTEE OS" 4DESCRIPTION = "OPTEE OS"
5HOMEPAGE = "http://www.optee.org/" 5HOMEPAGE = "http://www.optee.org/"
6LICENSE = "BSD" 6LICENSE = "BSD"
7LIC_FILES_CHKSUM = "file://LICENSE;md5=69663ab153298557a59c67a60a743e5b" 7LIC_FILES_CHKSUM = "file://LICENSE;md5=c1f21c4f72f372ef38a5a4aee55ec173"
8 8
9inherit deploy python3native autotools 9inherit deploy python3native autotools
10DEPENDS = "python3-pycrypto-native u-boot-mkimage-native" 10DEPENDS = "python3-pycrypto-native python3-pyelftools-native u-boot-mkimage-native"
11
12SRCBRANCH = "imx_5.4.24_2.1.0"
11 13
12SRCBRANCH = "lf-5.4.y"
13OPTEE_OS_SRC ?= "git://source.codeaurora.org/external/imx/imx-optee-os.git;protocol=https"
14SRC_URI = "\ 14SRC_URI = "\
15 ${OPTEE_OS_SRC};branch=${SRCBRANCH} \ 15 git://source.codeaurora.org/external/imx/imx-optee-os.git;protocol=https;branch=${SRCBRANCH} \
16 file://0001-scripts-update-scripts-to-use-python3.patch \
17 file://0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch \ 16 file://0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch \
18" 17"
19 18
20SRCREV = "6d99b525af752ecdaabdca6098b2564b2665f2b2" 19SRCREV = "7a49776de59265500f10a247125429fde1555ac1"
21 20
22S = "${WORKDIR}/git" 21S = "${WORKDIR}/git"
23B = "${WORKDIR}/build.${PLATFORM_FLAVOR}" 22B = "${WORKDIR}/build.${PLATFORM_FLAVOR}"
@@ -29,9 +28,13 @@ PLATFORM_FLAVOR_imx6ul7d = "mx6ulevk"
29PLATFORM_FLAVOR_imx6ull14x14evk = "mx6ullevk" 28PLATFORM_FLAVOR_imx6ull14x14evk = "mx6ullevk"
30PLATFORM_FLAVOR_imx6ull9x9evk = "mx6ullevk" 29PLATFORM_FLAVOR_imx6ull9x9evk = "mx6ullevk"
31PLATFORM_FLAVOR_imx6ulz14x14evk = "mx6ulzevk" 30PLATFORM_FLAVOR_imx6ulz14x14evk = "mx6ulzevk"
32PLATFORM_FLAVOR_mx8mm = "mx8mmevk" 31PLATFORM_FLAVOR_mx8mm = "mx8mmevk"
33PLATFORM_FLAVOR_mx8mn = "mx8mnevk" 32PLATFORM_FLAVOR_mx8mn = "mx8mnevk"
34PLATFORM_FLAVOR_mx8qxp = "mx8qxpmek" 33PLATFORM_FLAVOR_mx8qxp = "mx8qxpmek"
34PLATFORM_FLAVOR_mx8mp = "mx8mpevk"
35PLATFORM_FLAVOR_mx8dx = "mx8dxmek"
36PLATFORM_FLAVOR_mx8dxl = "mx8dxlevk"
37PLATFORM_FLAVOR_mx8phantomdxl = "mx8qxpmek"
35 38
36OPTEE_ARCH ?= "arm32" 39OPTEE_ARCH ?= "arm32"
37OPTEE_ARCH_armv7a = "arm32" 40OPTEE_ARCH_armv7a = "arm32"
@@ -42,19 +45,20 @@ OPTEE_ARCH_aarch64 = "arm64"
42# For 64bits, CROSS_COMPILE64 must be set 45# For 64bits, CROSS_COMPILE64 must be set
43# When defining CROSS_COMPILE and CROSS_COMPILE64, we assure that 46# When defining CROSS_COMPILE and CROSS_COMPILE64, we assure that
44# any 32 or 64 bits builds will pass 47# any 32 or 64 bits builds will pass
45EXTRA_OEMAKE = "PLATFORM=imx PLATFORM_FLAVOR=${PLATFORM_FLAVOR} \ 48EXTRA_OEMAKE = " \
46 CROSS_COMPILE=${HOST_PREFIX} \ 49 PLATFORM=imx \
47 CROSS_COMPILE64=${HOST_PREFIX} \ 50 PLATFORM_FLAVOR=${PLATFORM_FLAVOR} \
48 NOWERROR=1 \ 51 CROSS_COMPILE=${HOST_PREFIX} \
49 LDFLAGS= \ 52 CROSS_COMPILE64=${HOST_PREFIX} \
50 O=${B} \ 53 NOWERROR=1 \
51 " 54 LDFLAGS= \
52 55 O=${B} \
56"
53 57
54do_compile () { 58do_compile () {
55 unset LDFLAGS 59 unset LDFLAGS
56 export CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_HOST}" 60 export CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_HOST}"
57 oe_runmake -C ${S} all CFG_TEE_TA_LOG_LEVEL=0 61 oe_runmake -C ${S} all CFG_TEE_TA_LOG_LEVEL=0 CFG_TEE_CORE_LOG_LEVEL=0
58} 62}
59 63
60 64
diff --git a/recipes-security/optee-imx/optee-test_3.2.0.imx.bb b/recipes-security/optee-imx/optee-test_3.2.0.imx.bb
deleted file mode 100644
index c78f9816..00000000
--- a/recipes-security/optee-imx/optee-test_3.2.0.imx.bb
+++ /dev/null
@@ -1,58 +0,0 @@
1# Copyright (C) 2017-2018 NXP
2
3SUMMARY = "OPTEE test"
4HOMEPAGE = "http://www.optee.org/"
5
6LICENSE = "BSD"
7LIC_FILES_CHKSUM = "file://LICENSE.md;md5=daa2bcccc666345ab8940aab1315a4fa"
8
9DEPENDS = "optee-os optee-client python3-pycrypto-native openssl"
10inherit python3native
11
12FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
13
14SRCBRANCH = "lf-5.4.y"
15OPTEE_TEST_SRC ?= "git://source.codeaurora.org/external/imx/imx-optee-test.git;protocol=https"
16
17SRC_URI = "${OPTEE_TEST_SRC};branch=${SRCBRANCH} \
18 file://0003-sock_server-fix-compilation-against-musl-sys-errno.h.patch \
19 file://0004-build-ignore-declaration-after-statement-warnings.patch \
20 file://0005-benchmark_1000-fix-compilation-against-musl-uint.patch \
21 file://0006-regression_8100-use-null-terminated-strings-with-fil.patch \
22 file://0001-use-python3-instead-of-python.patch \
23"
24
25S = "${WORKDIR}/git"
26
27SRCREV = "b7114b828b82f2c0eec124ed424eff1230cc5319"
28
29OPTEE_ARCH ?= "arm32"
30OPTEE_ARCH_armv7a = "arm32"
31OPTEE_ARCH_aarch64 = "arm64"
32
33do_compile () {
34 export TA_DEV_KIT_DIR=${STAGING_INCDIR}/optee/export-user_ta_${OPTEE_ARCH}/
35 export ARCH=${OPTEE_ARCH}
36
37 export OPTEE_CLIENT_EXPORT=${STAGING_DIR_HOST}/usr
38 export CROSS_COMPILE_HOST=${HOST_PREFIX}
39 export CROSS_COMPILE_TA=${HOST_PREFIX}
40 export CROSS_COMPILE=${HOST_PREFIX}
41 export OPTEE_OPENSSL_EXPORT=${STAGING_INCDIR}/
42 oe_runmake V=1 --warn-undefined-variables
43}
44
45do_install () {
46 install -d ${D}/usr/bin
47 install ${S}/out/xtest/xtest ${D}/usr/bin/
48
49 install -d ${D}/lib/optee_armtz
50 find ${S}/out/ta -name '*.ta' | while read name; do
51 install -m 444 $name ${D}/lib/optee_armtz/
52 done
53
54}
55
56FILES_${PN} = "/usr/bin/ /lib*/optee_armtz/"
57
58COMPATIBLE_MACHINE = "(mx6|mx7|mx8)"
diff --git a/recipes-security/optee-imx/optee-test_3.7.0.imx.bb b/recipes-security/optee-imx/optee-test_3.7.0.imx.bb
new file mode 100644
index 00000000..04240ff0
--- /dev/null
+++ b/recipes-security/optee-imx/optee-test_3.7.0.imx.bb
@@ -0,0 +1,55 @@
1# Copyright (C) 2017-2018 NXP
2
3SUMMARY = "OPTEE test"
4HOMEPAGE = "http://www.optee.org/"
5
6LICENSE = "BSD"
7LIC_FILES_CHKSUM = "file://LICENSE.md;md5=daa2bcccc666345ab8940aab1315a4fa"
8
9DEPENDS = "optee-os optee-client python3-pycrypto-native openssl"
10inherit python3native
11
12FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
13
14SRCBRANCH = "imx_5.4.24_2.1.0"
15
16SRC_URI = "git://source.codeaurora.org/external/imx/imx-optee-test.git;protocol=https;branch=${SRCBRANCH} \
17 file://0001-use-python3-instead-of-python.patch \
18"
19
20S = "${WORKDIR}/git"
21B = "${WORKDIR}/build"
22
23SRCREV = "227d6f4c40eaa6f84fe049b9e48c7b27ad7fab08"
24
25OPTEE_ARCH ?= "arm32"
26OPTEE_ARCH_armv7a = "arm32"
27OPTEE_ARCH_aarch64 = "arm64"
28
29TA_DEV_KIT_DIR_arm = "${STAGING_INCDIR}/optee/export-user_ta_arm32/"
30TA_DEV_KIT_DIR_aarch64 = "${STAGING_INCDIR}/optee/export-user_ta_arm64/"
31
32EXTRA_OEMAKE = " \
33 TA_DEV_KIT_DIR=${TA_DEV_KIT_DIR} \
34 ARCH=${OPTEE_ARCH} \
35 OPTEE_CLIENT_EXPORT=${STAGING_DIR_HOST}/usr \
36 CROSS_COMPILE_HOST=${HOST_PREFIX} \
37 CROSS_COMPILE_TA=${HOST_PREFIX} \
38 CROSS_COMPILE=${HOST_PREFIX} \
39 OPTEE_OPENSSL_EXPORT=${STAGING_INCDIR}/ \
40 -C ${S} O=${B} \
41"
42
43do_install () {
44 install -d ${D}/usr/bin
45 install ${B}/xtest/xtest ${D}/usr/bin/
46
47 install -d ${D}/lib/optee_armtz
48 find ${B}/ta -name '*.ta' | while read name; do
49 install -m 444 $name ${D}/lib/optee_armtz/
50 done
51}
52
53FILES_${PN} = "/usr/bin/ /lib*/optee_armtz/"
54
55COMPATIBLE_MACHINE = "(mx6|mx7|mx8)"