diff options
author | takeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp> | 2020-11-02 11:07:33 +0900 |
---|---|---|
committer | takeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp> | 2020-11-02 11:07:33 +0900 |
commit | 1c7d6584a7811b7785ae5c1e378f14b5ba0971cf (patch) | |
tree | cd70a267a5ef105ba32f200aa088e281fbd85747 /bsp/meta-renesas/meta-rcar-gen3/recipes-bsp/optee/optee-os | |
parent | 4204309872da5cb401cbb2729d9e2d4869a87f42 (diff) |
basesystem-jjsandbox/ToshikazuOhiwa/master-jj
recipes
Diffstat (limited to 'bsp/meta-renesas/meta-rcar-gen3/recipes-bsp/optee/optee-os')
2 files changed, 502 insertions, 0 deletions
diff --git a/bsp/meta-renesas/meta-rcar-gen3/recipes-bsp/optee/optee-os/0001-core-define-syscall_t-as-void-void.patch b/bsp/meta-renesas/meta-rcar-gen3/recipes-bsp/optee/optee-os/0001-core-define-syscall_t-as-void-void.patch new file mode 100644 index 00000000..bad7b27c --- /dev/null +++ b/bsp/meta-renesas/meta-rcar-gen3/recipes-bsp/optee/optee-os/0001-core-define-syscall_t-as-void-void.patch @@ -0,0 +1,75 @@ +From f6d17e33e7b95c90a2521cfd37cd5cb511909fc4 Mon Sep 17 00:00:00 2001 +From: Jerome Forissier <jerome.forissier@linaro.org> +Date: Thu, 5 Jul 2018 13:07:52 +0200 +Subject: [PATCH] core: define syscall_t as void (*)(void) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +syscall_t is currently typedef'ed as TEE_Result (*)(void). It is used to +represent a pointer to any system call, in the syscall table for instance. +As such, the exact type behind syscall_t cannot reflect all the syscalls +since they have different prototypes. The current declaration with a +TEE_Result return type was probably chosen because it was a common +characteristic of all syscalls to return a TEE_Result. + +However, this type causes compilation warnings with GCC 8.1: + +core/arch/arm/tee/arch_svc.c:43:36: warning: cast between incompatible function types from ‘void (*)(long unsigned int)’ to ‘TEE_Result (*)(void)’ {aka ‘unsigned int (*)(void)’} [-Wcast-function-type] + #define SYSCALL_ENTRY(_fn) { .fn = (syscall_t)_fn } + ^ +core/arch/arm/tee/arch_svc.c:50:2: note: in expansion of macro ‘SYSCALL_ENTRY’ + SYSCALL_ENTRY(syscall_sys_return), + ^~~~~~~~~~~~~ + +The solution is to use 'void (*)(void)' instead, as explained in the GCC +documentation: + + -Wcast-function-type + + Warn when a function pointer is cast to an incompatible function + pointer. [...] The function type void (*) (void) is special and matches + everything, which can be used to suppress this warning. [...] + +Link: [1] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html +Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> +Acked-by: Jens Wiklander <jens.wiklander@linaro.org> +--- + core/arch/arm/tee/arch_svc.c | 2 +- + core/arch/arm/tee/arch_svc_private.h | 7 +++++-- + 2 files changed, 6 insertions(+), 3 deletions(-) + +diff --git a/core/arch/arm/tee/arch_svc.c b/core/arch/arm/tee/arch_svc.c +index eb142ec..b2dd193 100644 +--- a/core/arch/arm/tee/arch_svc.c ++++ b/core/arch/arm/tee/arch_svc.c +@@ -208,7 +208,7 @@ void __weak tee_svc_handler(struct thread_svc_regs *regs) + } + + if (scn > TEE_SCN_MAX) +- scf = syscall_not_supported; ++ scf = (syscall_t)syscall_not_supported; + else + scf = tee_svc_syscall_table[scn].fn; + +diff --git a/core/arch/arm/tee/arch_svc_private.h b/core/arch/arm/tee/arch_svc_private.h +index c0b3a73..695e733 100644 +--- a/core/arch/arm/tee/arch_svc_private.h ++++ b/core/arch/arm/tee/arch_svc_private.h +@@ -7,8 +7,11 @@ + + #include <tee_api_types.h> + +-/* void argument but in reality it can be any number of arguments */ +-typedef TEE_Result (*syscall_t)(void); ++/* ++ * Generic "pointer to function" type. Actual syscalls take zero or more ++ * arguments and return TEE_Result. ++ */ ++typedef void (*syscall_t)(void); + + /* Helper function for tee_svc_handler() */ + uint32_t tee_svc_do_call(struct thread_svc_regs *regs, syscall_t func); +-- +2.7.4 + diff --git a/bsp/meta-renesas/meta-rcar-gen3/recipes-bsp/optee/optee-os/0001-scripts-update-scripts-to-use-python3.patch b/bsp/meta-renesas/meta-rcar-gen3/recipes-bsp/optee/optee-os/0001-scripts-update-scripts-to-use-python3.patch new file mode 100644 index 00000000..9621cf6c --- /dev/null +++ b/bsp/meta-renesas/meta-rcar-gen3/recipes-bsp/optee/optee-os/0001-scripts-update-scripts-to-use-python3.patch @@ -0,0 +1,427 @@ +From 0d4941123b5a88351f5954f6de00892f85ed5abc Mon Sep 17 00:00:00 2001 +From: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com> +Date: Mon, 20 Jan 2020 22:32:13 +0000 +Subject: [PATCH] scripts: update scripts to use python3 + +Python2 is deprecated effective Jan. 2020, and is not available in +several distributions. + +Update scripts here to re-target then onto python version 3. + +Upstream-Status: Pending + +Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com> +--- + scripts/gen_hashed_bin.py | 282 ++++++++++++++++++++------------------ + scripts/gen_ld_sects.py | 8 +- + scripts/pem_to_pub_c.py | 2 +- + scripts/sign.py | 2 +- + scripts/symbolize.py | 2 +- + scripts/ta_bin_to_c.py | 2 +- + scripts/tee_bin_parser.py | 2 +- + 7 files changed, 157 insertions(+), 143 deletions(-) + +diff --git a/scripts/gen_hashed_bin.py b/scripts/gen_hashed_bin.py +index 32350a47..a76a62cc 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 +@@ -14,163 +14,177 @@ import hashlib + arch_id = {'arm32': 0, 'arm64': 1} + image_id = {'pager': 0, 'paged': 1} + ++ + def write_header_v1(outf, init_size, args, paged_size): +- magic = 0x4554504f # 'OPTE' +- version = 1; +- outf.write(struct.pack('<IBBHIIIII', \ +- magic, version, arch_id[args.arch], args.flags, init_size, \ +- args.init_load_addr_hi, args.init_load_addr_lo, \ +- args.init_mem_usage, paged_size)) ++ magic = 0x4554504f # 'OPTE' ++ version = 1 ++ outf.write(struct.pack('<IBBHIIIII', ++ magic, ++ version, ++ arch_id[args.arch], ++ args.flags, ++ init_size, ++ args.init_load_addr_hi, ++ args.init_load_addr_lo, ++ args.init_mem_usage, ++ paged_size)) ++ + + def write_header_v2(outf, init_size, args, paged_size): +- magic = 0x4554504f # 'OPTE' +- version = 2 +- nb_images = 1 if paged_size == 0 else 2 +- outf.write(struct.pack('<IBBHI', \ +- magic, version, arch_id[args.arch], args.flags, nb_images)) +- outf.write(struct.pack('<IIII', \ +- args.init_load_addr_hi, args.init_load_addr_lo, \ +- image_id['pager'], init_size)) +- if nb_images == 2: +- outf.write(struct.pack('<IIII', \ +- 0xffffffff, 0xffffffff, image_id['paged'], paged_size)) ++ magic = 0x4554504f # 'OPTE' ++ version = 2 ++ nb_images = 1 if paged_size == 0 else 2 ++ outf.write(struct.pack('<IBBHI', magic, version, ++ arch_id[args.arch], args.flags, nb_images)) ++ outf.write(struct.pack('<IIII', ++ args.init_load_addr_hi, args.init_load_addr_lo, ++ image_id['pager'], init_size)) ++ if nb_images == 2: ++ outf.write( ++ struct.pack( ++ '<IIII', ++ 0xffffffff, ++ 0xffffffff, ++ image_id['paged'], ++ paged_size)) ++ + + def append_to(outf, start_offs, in_fname, max_bytes=0xffffffff): +- #print "Appending %s@0x%x 0x%x bytes at position 0x%x" % \ +- #( in_fname, start_offs, max_bytes, int(outf.tell()) ) +- inf = open(in_fname, 'rb'); +- inf.seek(start_offs) +- while True : +- nbytes = min(16 * 1024, max_bytes) +- if nbytes == 0 : +- break +- #print "Reading %s %d bytes" % (in_fname, nbytes) +- buf = inf.read(nbytes) +- if not buf : +- break +- outf.write(buf) +- max_bytes -= len(buf) +- inf.close() ++ inf = open(in_fname, 'rb') ++ inf.seek(start_offs) ++ while True: ++ nbytes = min(16 * 1024, max_bytes) ++ if nbytes == 0: ++ break ++ buf = inf.read(nbytes) ++ if not buf: ++ break ++ outf.write(buf) ++ max_bytes -= len(buf) ++ inf.close() ++ + + def append_hashes(outf, in_fname): +- page_size = 4 * 1024 +- +- inf = open(in_fname, 'r') +- while True : +- page = inf.read(page_size) +- if len(page) == page_size : +- #print "Writing hash at position 0x%x" % \ +- #int(outf.tell()) +- outf.write(hashlib.sha256(page).digest()) +- elif len(page) == 0 : +- break +- else : +- print("Error: short read, got " + repr(len(page))) +- sys.exit(1) +- +- inf.close() ++ page_size = 4 * 1024 ++ ++ inf = open(in_fname, 'rb') ++ while True: ++ page = inf.read(page_size) ++ if len(page) == page_size: ++ outf.write(hashlib.sha256(page).digest()) ++ elif len(page) == 0: ++ break ++ else: ++ print("Error: short read, got {}".format(len(page))) ++ sys.exit(1) ++ ++ inf.close() ++ + + def int_parse(str): +- return int(str, 0) ++ return int(str, 0) ++ + + def get_args(): +- parser = argparse.ArgumentParser() +- parser.add_argument('--arch', required=True, \ +- choices=arch_id.keys(), \ +- help='Architecture') ++ parser = argparse.ArgumentParser() ++ parser.add_argument('--arch', required=True, ++ choices=list(arch_id.keys()), ++ help='Architecture') + +- parser.add_argument('--flags', \ +- type=int, default=0, \ +- help='Flags, currently none defined') ++ parser.add_argument('--flags', ++ type=int, default=0, ++ help='Flags, currently none defined') + +- parser.add_argument('--init_size', \ +- required=True, type=int_parse, \ +- help='Size of initialization part of binary') ++ parser.add_argument('--init_size', ++ required=True, type=int_parse, ++ help='Size of initialization part of binary') + +- parser.add_argument('--init_load_addr_hi', \ +- type=int_parse, default=0, \ +- help='Upper 32 bits of load address of binary') ++ parser.add_argument('--init_load_addr_hi', ++ type=int_parse, default=0, ++ help='Upper 32 bits of load address of binary') + +- parser.add_argument('--init_load_addr_lo', \ +- required=True, type=int_parse, \ +- help='Lower 32 bits of load address of binary') ++ parser.add_argument('--init_load_addr_lo', ++ required=True, type=int_parse, ++ help='Lower 32 bits of load address of binary') + +- parser.add_argument('--init_mem_usage', \ +- required=True, type=int_parse, \ +- help='Total amount of used memory when initializing'); ++ parser.add_argument('--init_mem_usage', ++ required=True, type=int_parse, ++ help='Total amount of used memory when initializing') + +- parser.add_argument('--tee_pager_bin', \ +- required=True, \ +- help='The input tee_pager.bin') ++ parser.add_argument('--tee_pager_bin', ++ required=True, ++ help='The input tee_pager.bin') + +- parser.add_argument('--tee_pageable_bin', \ +- required=True, \ +- help='The input tee_pageable.bin') ++ parser.add_argument('--tee_pageable_bin', ++ required=True, ++ help='The input tee_pageable.bin') + +- parser.add_argument('--out', \ +- required=False, type=argparse.FileType('wb'), \ +- help='The output tee.bin') ++ parser.add_argument('--out', ++ required=False, type=argparse.FileType('wb'), ++ help='The output tee.bin') + +- parser.add_argument('--out_header_v2', \ +- required=False, type=argparse.FileType('wb'), \ +- help='The output tee_header_v2.bin') ++ parser.add_argument('--out_header_v2', ++ required=False, type=argparse.FileType('wb'), ++ help='The output tee_header_v2.bin') + +- parser.add_argument('--out_pager_v2', \ +- required=False, type=argparse.FileType('wb'), \ +- help='The output tee_pager_v2.bin') ++ parser.add_argument('--out_pager_v2', ++ required=False, type=argparse.FileType('wb'), ++ help='The output tee_pager_v2.bin') + +- parser.add_argument('--out_pageable_v2', \ +- required=False, type=argparse.FileType('wb'), \ +- help='The output tee_pageable_v2.bin') ++ parser.add_argument('--out_pageable_v2', ++ required=False, type=argparse.FileType('wb'), ++ help='The output tee_pageable_v2.bin') ++ ++ return parser.parse_args() + +- return parser.parse_args(); + + def main(): +- args = get_args() +- init_bin_size = args.init_size +- tee_pager_fname = args.tee_pager_bin +- tee_pageable_fname = args.tee_pageable_bin +- pager_input_size = os.path.getsize(tee_pager_fname); +- paged_input_size = os.path.getsize(tee_pageable_fname); +- hash_size = paged_input_size / (4 * 1024) * \ +- hashlib.sha256().digest_size +- +- if paged_input_size % (4 * 1024) != 0: +- print("Error: pageable size not a multiple of 4K:" + \ +- repr(paged_input_size)) +- sys.exit(1) +- +- init_size = pager_input_size + \ +- min(init_bin_size, paged_input_size) + \ +- hash_size +- paged_size = paged_input_size - \ +- min(init_bin_size, paged_input_size) +- +- if args.out is not None: +- outf = args.out +- write_header_v1(outf, init_size, args, paged_size) +- append_to(outf, 0, tee_pager_fname) +- append_to(outf, 0, tee_pageable_fname, init_bin_size) +- append_hashes(outf, tee_pageable_fname) +- append_to(outf, init_bin_size, tee_pageable_fname) +- outf.close() +- +- if args.out_header_v2 is not None: +- outf = args.out_header_v2 +- write_header_v2(outf, init_size, args, paged_size) +- outf.close() +- +- if args.out_pager_v2 is not None: +- outf = args.out_pager_v2 +- append_to(outf, 0, tee_pager_fname) +- append_to(outf, 0, tee_pageable_fname, init_bin_size) +- append_hashes(outf, tee_pageable_fname) +- outf.close() +- +- if args.out_pageable_v2 is not None: +- outf = args.out_pageable_v2 +- append_to(outf, init_bin_size, tee_pageable_fname) +- outf.close() ++ args = get_args() ++ init_bin_size = args.init_size ++ tee_pager_fname = args.tee_pager_bin ++ tee_pageable_fname = args.tee_pageable_bin ++ pager_input_size = os.path.getsize(tee_pager_fname) ++ paged_input_size = os.path.getsize(tee_pageable_fname) ++ hash_size = paged_input_size // (4 * 1024) * \ ++ hashlib.sha256().digest_size ++ ++ if paged_input_size % (4 * 1024) != 0: ++ print("Error: pageable size not a multiple of 4K: {}".format( ++ paged_input_size)) ++ sys.exit(1) ++ ++ init_size = pager_input_size + \ ++ min(init_bin_size, paged_input_size) + \ ++ hash_size ++ paged_size = paged_input_size - \ ++ min(init_bin_size, paged_input_size) ++ ++ if args.out is not None: ++ outf = args.out ++ write_header_v1(outf, init_size, args, paged_size) ++ append_to(outf, 0, tee_pager_fname) ++ append_to(outf, 0, tee_pageable_fname, init_bin_size) ++ append_hashes(outf, tee_pageable_fname) ++ append_to(outf, init_bin_size, tee_pageable_fname) ++ outf.close() ++ ++ if args.out_header_v2 is not None: ++ outf = args.out_header_v2 ++ write_header_v2(outf, init_size, args, paged_size) ++ outf.close() ++ ++ if args.out_pager_v2 is not None: ++ outf = args.out_pager_v2 ++ append_to(outf, 0, tee_pager_fname) ++ append_to(outf, 0, tee_pageable_fname, init_bin_size) ++ append_hashes(outf, tee_pageable_fname) ++ outf.close() ++ ++ if args.out_pageable_v2 is not None: ++ outf = args.out_pageable_v2 ++ append_to(outf, init_bin_size, tee_pageable_fname) ++ outf.close() ++ + + if __name__ == "__main__": +- main() ++ main() +diff --git a/scripts/gen_ld_sects.py b/scripts/gen_ld_sects.py +index c5dc3a7b..2bdbb192 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 +@@ -8,8 +8,8 @@ import sys + import re + + def usage(): +- print "Usage: {0} <section reg exp match> [<skip section>...]".format( \ +- sys.argv[0]) ++ print("Usage: {0} <section reg exp match> [<skip section>...]".format( \ ++ sys.argv[0])) + sys.exit (1) + + def main(): +@@ -55,7 +55,7 @@ def main(): + if sect_name in skip_sections : + continue + +- print '\t*({0})'.format(sect_name) ++ print ('\t*({0})'.format(sect_name)) + + if __name__ == "__main__": + main() +diff --git a/scripts/pem_to_pub_c.py b/scripts/pem_to_pub_c.py +index 6b8fa365..0b03d62e 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 ad47479b..348b40a2 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 1eecf758..0e9bd3ed 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 cabddbbd..f325fda0 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 5f7dd3f0..07da5791 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 +-- +2.17.1 + |