optee/ti-optee-test.git
23 months agoIncrease stack size for GP TTA_Arithmetical TA master ti2019.01 ti2019.01-rc3 ti2019.01-rc4 ti2019.01-rc5 ti2019.02 ti2019.02-rc1 ti2019.02-rc2 ti2019.02-rc3 ti2019.02-rc4 ti2019.03 ti2019.03-rc1 ti2019.03-rc2 ti2019.03-rc3 ti2019.03-rc4 ti2019.04 ti2019.04-rc1 ti2019.04-rc2 ti2019.04-rc3 ti2019.04-rc4 ti2019.04-rc5
Jerome Forissier [Tue, 16 Apr 2019 09:44:51 +0000 (11:44 +0200)]
Increase stack size for GP TTA_Arithmetical TA

On 64-bit platforms with 64-bit user TAs (QEMUv8, HiKey960), gp_8524
crashes with the following dump:

 E/TC:0 0 User TA data-abort at address 0x40003fb0 (translation fault)
 E/TC:0 0  esr 0x92000047  ttbr0 0x200000e19c000   ttbr1 0x00000000   cidr 0x0
 E/TC:0 0  cpu #0          cpsr 0x20000100
 E/TC:0 0  x0  0000000040004ce8 x1  0000000040004ce8
 E/TC:0 0  x2  0000000040004d18 x3  0000000040004da0
 E/TC:0 0  x4  0000000040004cd0 x5  0000000040004ef0
 E/TC:0 0  x6  0000000000000100 x7  000000000e18da80
 E/TC:0 0  x8  0000000000000021 x9  0000000000004c53
 E/TC:0 0  x10 0000000000000041 x11 0000000000000052
 E/TC:0 0  x12 00000000a71c5d59 x13 0000000040004f80
 E/TC:0 0  x14 0000000000000000 x15 0000000000000000
 E/TC:0 0  x16 000000000e138020 x17 0000000000000000
 E/TC:0 0  x18 0000000000000000 x19 000000000e1a2fb0
 E/TC:0 0  x20 0000000000000000 x21 000000000e17e4f0
 E/TC:0 0  x22 00000000000005e0 x23 0000000000000000
 E/TC:0 0  x24 0000000000000000 x25 0000000000000000
 E/TC:0 0  x26 0000000000000000 x27 0000000000000000
 E/TC:0 0  x28 0000000000000000 x29 0000000040004ca0
 E/TC:0 0  x30 0000000040011708 elr 0000000040010100
 E/TC:0 0  sp_el0 0000000040003fb0
 E/TC:0 0 Status of TA 534d4152-5443-4c53-4152-4954484d4554 (0xe18da50) (active)
 E/TC:0 0  arch: aarch64  load address: 0x0000000040005000 ctx-idr: 2
 E/TC:0 0  stack: 0x0000000040004000 4096
 E/TC:0 0  region  0: va 0x0000000040000000 pa 0x000000000e100000 size 0x002000 flags ---R-X
 E/TC:0 0  region  1: va 0x0000000040002000 pa 0x000000000e190000 size 0x001000 flags ---RW-
 E/TC:0 0  region  2: va 0x0000000040004000 pa 0x000000000e335000 size 0x001000 flags rw-RW-
 E/TC:0 0  region  3: va 0x0000000040005000 pa 0x000000000e316000 size 0x014000 flags r-x--- [0] .ta_head .text .rodata .dynsym .rela.dyn .got .rela.got .dynamic .dynstr .hash
 E/TC:0 0  region  4: va 0x0000000040019000 pa 0x000000000e32a000 size 0x00b000 flags rw---- [0] .data .bss
 E/TC:0 0  region  5: va 0x0000000040025000 pa 0x0000000041102d80 size 0x001000 flags rw-RW-
 E/TC:0 0  [0] 534d4152-5443-4c53-4152-4954484d4554 @ 0x0000000040005000 (optee_test/out/ta/GP_TTA_Arithmetical/534d4152-5443-4c53-4152-4954484d4554.elf)
 E/TC:0 0 Call stack:
 E/TC:0 0  0x0000000040010100 mbedtls_mpi_exp_mod at optee_os/lib/libmbedtls/mbedtls/library/bignum.c:1782
 E/TC:0 0  0x0000000040011960 mbedtls_mpi_is_prime_ext at optee_os/lib/libmbedtls/mbedtls/library/bignum.c:2361
 E/TC:0 0  0x0000000040011990 mbedtls_mpi_is_prime at optee_os/lib/libmbedtls/mbedtls/library/bignum.c:2380
 E/TC:0 0  0x000000004000a4ec TEE_BigIntIsProbablePrime at optee_os/lib/libutee/tee_api_arith_mpi.c:771
 E/TC:0 0  0x00000000400070dc CmdTEEBigIntIsProbablePrime at optee_test/ta/GP_TTA_Arithmetical/TTA_Arithmetical.c:1139
 E/TC:0 0  0x0000000040007930 TA_InvokeCommandEntryPoint at optee_test/ta/GP_TTA_Arithmetical/TTA_Arithmetical.c:1425
 E/TC:0 0  0x000000004000ac74 entry_invoke_command at optee_os/lib/libutee/arch/arm/user_ta_entry.c:191
 E/TC:0 0  0x000000004000ad08 __utee_entry at optee_os/lib/libutee/arch/arm/user_ta_entry.c:219
 E/TC:0 0  0x000000000e10d630 ???

The invalid address is just below the stack, which means the stack size is
insufficient. Let's increase it from 2 KiB to 3 KiB.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Joakim Bech <joakim.bech@linaro.org>
23 months agoGP: fix compile errors with calloc()
Jerome Forissier [Mon, 15 Apr 2019 12:31:09 +0000 (14:31 +0200)]
GP: fix compile errors with calloc()

Fixes a few errors when xtest is compiled with GP tests enabled
(CFG_GP_PACKAGE_PATH pointing to the GP Initial Configuration Test
Suite files).

Fixes: e4ec9e4aca08 ("xtest: Explicitly initialize local variables")
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
2 years agoxtest: Explicitly initialize local variables
Etienne Carriere [Thu, 28 Mar 2019 12:30:21 +0000 (13:30 +0100)]
xtest: Explicitly initialize local variables

This change initializes all local variables to prevent build issues
(warnings and/or errors) in OP-TEE test package. This change uses
= { } for non-scalar variables and = 0 for scalar variables when there
is no obvious value. This change falls back to memset() only when
neither = { } nor = 0 is applicable, here pthread_t typed variable
and variable size arrays.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoTAs: explicitly initialize local variables
Etienne Carriere [Thu, 28 Mar 2019 14:24:22 +0000 (15:24 +0100)]
TAs: explicitly initialize local variables

This change initializes all local variables to prevent build issues
(warnings and/or errors) in OP-TEE test package. This change uses
= { } for non-scalar variables and = 0 for scalar variables.

This change also removes some useless header files inclusion.
This change also fixes few bad indentations.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoregression 1008: adjust TA corruption test for CFG_ULIBS_SHARED=y
Jerome Forissier [Thu, 28 Feb 2019 16:27:46 +0000 (17:27 +0100)]
regression 1008: adjust TA corruption test for CFG_ULIBS_SHARED=y

When TAs are linked against shared versions of libutee etc., the
size of the main binary is reduced significantly. This causes test
1008.4 to fail, because the size of the TA drops from ~121 KiB down
to ~9 KiB which is smaller than the offset supplied to
load_corrupt_ta(). Use a smaller offest to fix the issue.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agodocs: Remove current docs and link to the new location
Joakim Bech [Fri, 22 Feb 2019 09:53:09 +0000 (10:53 +0100)]
docs: Remove current docs and link to the new location

All current documentation has been transferred to a new git called
optee_docs [1]. The output from optee_docs will be rendered using Sphinx
and hosted at optee.readthedocs.io [2]. The new documentation git will
also be part of the regular OP-TEE releases. For completeness, it will
also be included in our manifests making up a full OP-TEE developer
setup.

[1] https://github.com/OP-TEE/optee_docs
[2] https://optee.readthedocs.io

Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
2 years agobenchmark_1000: fix compilation against musl (uint)
André Draszik [Thu, 7 Feb 2019 01:31:27 +0000 (01:31 +0000)]
benchmark_1000: fix compilation against musl (uint)

Compiling against musl-libc fails with the following error:

| .../host/xtest/benchmark_1000.c: In function 'show_test_result':
| .../host/xtest/benchmark_1000.c:102:2: error: unknown type name 'uint'; did you mean 'int'?
|   uint i;
|   ^~~~
|   int
| ...host/xtest/benchmark_1000.c:108:16: error: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'unsigned int'} [-Werror=sign-compare]
|   for (i = 0; i < size; i++) {
|                 ^

etc.

Convert to using more standard size_t

Signed-off-by: André Draszik <andre.draszik@jci.com>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2 years agobuild: ignore declaration-after-statement warnings
André Draszik [Thu, 7 Feb 2019 01:29:08 +0000 (01:29 +0000)]
build: ignore declaration-after-statement warnings

| Makefile:37: recipe for target 'xtest' failed
| make: *** [xtest] Error 2
| make: *** Waiting for unfinished jobs....
| arith_taf.c: In function 'get_handle':
| arith_taf.c:56:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
|   int h = handle_get(&hdb, ptr);
|   ^~~
| arith_taf.c: In function 'ta_entry_arith_new_var':
| arith_taf.c:82:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
|   size_t len = TEE_BigIntSizeInU32(params[0].value.a);
|   ^~~~~~
| arith_taf.c: In function 'ta_entry_arith_new_fmm_var':
| arith_taf.c:129:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
|   size_t len = TEE_BigIntFMMSizeInU32(params[0].value.a);
|   ^~~~~~
| arith_taf.c: In function 'ta_entry_arith_free_handle':
| arith_taf.c:150:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
|   void *ptr = put_handle(params[0].value.a & ~HT_MASK);
|   ^~~~
| arith_taf.c: In function 'ta_entry_arith_from_octet_string':
| arith_taf.c:165:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
|   TEE_BigInt *big_int = lookup_handle(HT_BIGINT, params[0].value.a);
|   ^~~~~~~~~~
| arith_taf.c: In function 'ta_entry_arith_from_s32':
| arith_taf.c:181:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
|   TEE_BigInt *big_int = lookup_handle(HT_BIGINT, params[0].value.a);
|   ^~~~~~~~~~

etc.

Signed-off-by: André Draszik <andre.draszik@jci.com>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2 years agofix compilation against musl (inttypes)
André Draszik [Thu, 7 Feb 2019 01:25:19 +0000 (01:25 +0000)]
fix compilation against musl (inttypes)

Compiling against musl-libc fails with the following error:
| arith_taf.c: In function 'lookup_handle':
| arith_taf.c:38:29: error: expected ')' before 'PRIx32'
|    EMSG("Invalid handle 0x%" PRIx32, handle);
|                              ^~~~~~

and similar for PRIx32 PRIu32 PRId32 etc.

Add the needed include to get the definition of those
macros.

Signed-off-by: André Draszik <andre.draszik@jci.com>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2 years agosock_server: fix compilation against musl (sys/errno.h)
André Draszik [Thu, 7 Feb 2019 01:26:53 +0000 (01:26 +0000)]
sock_server: fix compilation against musl (sys/errno.h)

Compiling against musl-libc fails with the following error:

| In file included from .../host/xtest/sock_server.c:24:
| .../usr/include/sys/errno.h:1:2: error: #warning redirecting incorrect #include <sys/errno.h> to <errno.h> [-Werror=cpp]
|  #warning redirecting incorrect #include <sys/errno.h> to <errno.h>
|   ^~~~~~~

Just remove the needless include.

Signed-off-by: André Draszik <andre.draszik@jci.com>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2 years agoxtest: add --stats applet
Jens Wiklander [Thu, 31 Jan 2019 11:25:08 +0000 (12:25 +0100)]
xtest: add --stats applet

Adds the --stats applet to interact with the pseudo TA "stats".

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoregression: 4002: run MAC tests in multiple increments
Jerome Forissier [Wed, 30 Jan 2019 16:50:05 +0000 (17:50 +0100)]
regression: 4002: run MAC tests in multiple increments

The .in_incr field of struct xtest_mac_case is currently used for
a single step, that is, update() is called to process in_incr byte,
then the rest of the input buffer is passed to final().

This commit allows to run the CBC MAC update() several times in chunks
of in_incr bytes, then the remaining bytes in the input buffer
(<= in_incr) are passed to final().

All MAC tests that have a non-zero increment (.in_incr) are now run
twice: first in two steps, then in multiple steps of in_incr size.

This is a test case for [1].

Link: [1] https://github.com/OP-TEE/optee_os/pull/2779
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agota/cryp_taf: correct return value
Oliver Chiang [Thu, 24 Jan 2019 13:15:12 +0000 (13:15 +0000)]
ta/cryp_taf: correct return value

ta_entry_copy_object_attributes() should faithfully returns
TEE_CopyObjectAttributes1()'s value instead of always overwriting it with
TEE_SUCCESS.

Signed-off-by: Oliver Chiang <rockerfeynman@gmail.com>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
2 years agocmake: locate files WRT to project home directory
Volodymyr Babchuk [Mon, 21 Jan 2019 14:26:35 +0000 (16:26 +0200)]
cmake: locate files WRT to project home directory

Build system can't find file_to_c.py and certificate files, because
CMakeLists.txt have an assumption about those files locations. So,
when you try to use separate build directory, relative path in
CMakeLists.txt is not working as expected.

It is better to use CMAKE_CURRENT_SOURCE_DIR instead of assuming that
mentioned files can be reached from the build directory.

Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
2 years agoregression 6000: fix uninitialized local variables
Etienne Carriere [Tue, 22 Jan 2019 12:27:46 +0000 (13:27 +0100)]
regression 6000: fix uninitialized local variables

Reported by GCC 8.2.0 with traces like:

.../build/optee_test/host/xtest/regression_6000.c:495:8: error: ‘count’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  (void)ADBG_EXPECT_BUFFER(c, &data_00[5], 5, out, count);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../build/optee_test/host/xtest/regression_6000.c:465:11: note: ‘count’ was declared here
  uint32_t count;
           ^~~~~
.../build/optee_test/host/xtest/regression_6000.c:192:23: error: ‘obj’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  op.params[0].value.a = obj;
  ~~~~~~~~~~~~~~~~~~~~~^~~~~
.../build/optee_test/host/xtest/regression_6000.c:463:11: note: ‘obj’ was declared here
  uint32_t obj;
           ^~~

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
2 years agoregression 4100: fix uninitialized local variable
Etienne Carriere [Tue, 22 Jan 2019 12:27:37 +0000 (13:27 +0100)]
regression 4100: fix uninitialized local variable

Reported by GCC 8.2.0 with traces like:

.../build/optee_test/host/xtest/regression_4100.c:884:2: error: ‘cres’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  ADBG_EXPECT_COMPARE_SIGNED(c, cres, ==, cmp_res);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../build/optee_test/host/xtest/regression_4100.c:869:10: note: ‘cres’ was declared here
  int32_t cres;
          ^~~~
.../build/optee_test/host/xtest/regression_4100.c:857:2: error: ‘cres’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  ADBG_EXPECT_COMPARE_SIGNED(c, cres, ==, cmp_res);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../build/optee_test/host/xtest/regression_4100.c:835:10: note: ‘cres’ was declared here
  int32_t cres;
          ^~~~

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
2 years agoregression 4000: fix uninitialized local variable
Etienne Carriere [Tue, 22 Jan 2019 12:27:26 +0000 (13:27 +0100)]
regression 4000: fix uninitialized local variable

Reported by GCC 8.2.0 with trace:

.../build/optee_test/host/xtest/regression_4000.c:4090:24: error: ‘ptx_hash_size’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     if (!ADBG_EXPECT_TEEC_SUCCESS(c,
                        ^~~~~~~~~~~~~
.../build/optee_test/host/xtest/regression_4000.c:3658:9: note: ‘ptx_hash_size’ was declared here
  size_t ptx_hash_size;
         ^~~~~~~~~~~~~

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
2 years agoxtest --aes-perf: add -u option to process buffer in several steps
Jerome Forissier [Thu, 8 Mar 2018 09:36:37 +0000 (10:36 +0100)]
xtest --aes-perf: add -u option to process buffer in several steps

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Suggested-by: Tetsuya Yoshizaki <yoshizaki.tetsuya@socionext.com>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoimprove xtest summary message
Markus S. Wamser [Tue, 16 Oct 2018 09:11:48 +0000 (11:11 +0200)]
improve xtest summary message

"0 test cases were skipped" instead of "0 test case was skipped" after successful run

Signed-off-by: Markus S. Wamser <markus.wamser@mixed-mode.de>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2 years agoregression: split 4007 into key types
Jens Wiklander [Fri, 14 Dec 2018 10:41:36 +0000 (11:41 +0100)]
regression: split 4007 into key types

Splits regression case 4007 into
- 4007_symmetric for symmetric keys
- 4007_rsa for RSA keys, which also is complemented with 3072 and 4096 keys
- 4007_dh for Diffie-Hellman keys
- 4007_ecc for ECC keys

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoregression 4011: correct potential overflow
Etienne Carriere [Fri, 21 Dec 2018 14:36:25 +0000 (15:36 +0100)]
regression 4011: correct potential overflow

Fix issues reported by GCC 8.2.0.

build/optee_test/host/xtest/regression_4000.c: In function ‘xtest_tee_test_4011’:
build/optee_test/host/xtest/regression_4000.c:5029:3: error: ‘memmove’ pointer overflow between offset [0, 8] and size [42949672952147483647] accessing array ‘tmp’ with type ‘uint8_t[1024]’ {aka ‘unsigned char[1024]’} [-Werror=array-bounds]
   memmove(tmp + n + i, tmp + m, tmp_size - m);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
build/optee_test/host/xtest/regression_4000.c:4927:10: note: array ‘tmp’ declared here
  uint8_t tmp[1024];
          ^~~
build/optee_test/host/xtest/regression_4000.c:5029:3: error: ‘memmove’ specified size 4294967295 exceeds maximum object size 2147483647 [-Werror=stringop-overflow=]
   memmove(tmp + n + i, tmp + m, tmp_size - m);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Reported-by: Simon Hughes <simon.hughes@arm.com>
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoxtest: prevent unexpected build warning with strncpy
Etienne Carriere [Fri, 21 Dec 2018 14:36:00 +0000 (15:36 +0100)]
xtest: prevent unexpected build warning with strncpy

This change modifies adbg_run.c to prevent a false positive
warning reported by GCC 8.2 on usage of strncpy():

    build/optee_test/host/xtest/adbg/src/adbg_run.c: In function ‘Do_ADBG_AppendToSuite’:
    build/optee_test/host/xtest/adbg/src/adbg_run.c:103:3: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
       strncpy(p, Source_p->SuiteID_p, size);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    build/optee_test/host/xtest/adbg/src/adbg_run.c:88:9: note: length computed here
      size = strlen(Source_p->SuiteID_p);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

From [1]:
  Using strncpy Safely
  In general, it is not possible to avoid string truncation by strncpy
  except by sizing the destination to be at least a byte larger than
  the length of the source string. With that approach, however, using
  strncpy becomes unnecessary and the function can be avoided in favor
  of other APIs such as strcpy or (less preferably) memcpy. Much has
  been written about the problems with strncpy and we recommend to
  avoid it whenever possible. It is, however, worth keeping in mind
  that unlike other standard string-handling functions, strncpy always
  writes exactly as many characters as specified by the third argument;
  if the source string is shorter, the function fills the remaining
  bytes with NULs.

This change prefers using a snprintf() as used in the alternate
instruction block of the strncpy() call.

[1] https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Simon Hughes <simon.hughes@arm.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoregression: 6010: add rename conflict case (with close)
Jerome Forissier [Wed, 19 Dec 2018 08:05:48 +0000 (09:05 +0100)]
regression: 6010: add rename conflict case (with close)

Adds a test case for issue https://github.com/OP-TEE/optee_os/issues/2707.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agota/os_test: remove mpa testbench
Jens Wiklander [Wed, 21 Nov 2018 13:16:04 +0000 (14:16 +0100)]
ta/os_test: remove mpa testbench

Removes the MPA test suite "testbench" built into the os_test TA. The
test suite is made obsolete by the recently added 41xx cases.

Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (Hikey)
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoregression: add 41xx arithmetic tests
Jens Wiklander [Thu, 15 Nov 2018 09:43:29 +0000 (10:43 +0100)]
regression: add 41xx arithmetic tests

Adds a new 41xx series of for arithmetic tests. The test cases in
os_test TA in the tb_*.c and testframework.c files has been converted to
xtest format. The tests are now performed on TEE Internal API instead of
directly on the libmpa interace.

A few cases has been dropped, for instance random divisions. GCD and
FMM cases added.

Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agota/crypt: add arithmetic TAF wrappers
Jens Wiklander [Wed, 14 Nov 2018 23:29:08 +0000 (00:29 +0100)]
ta/crypt: add arithmetic TAF wrappers

Adds TAF wrappers for GP TEE arithmetical API

Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoregression: 4006: add test for RSASSA no ASN.1
Gabor Szekely [Fri, 14 Sep 2018 14:05:06 +0000 (14:05 +0000)]
regression: 4006: add test for RSASSA no ASN.1

This test checks the TEE_ALG_RSASSA_PKCS1_V1_5 extension, that allows to
sign data without including the hash OID in the signature. The test
vector data is copied from one of the already present vectors, with the
hash OID manually removed in the signature.

Link: <https://github.com/OP-TEE/optee_os/pull/2524>

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Gabor Szekely <szvgabor@gmail.com>
2 years agocmake: component rely on C support
Etienne Carriere [Fri, 9 Nov 2018 17:42:49 +0000 (18:42 +0100)]
cmake: component rely on C support

Without specifing optee_client source expects only C source file
support cmake may attempt to look for resources as g++. When
building with environments that do not provide such tools as when
building from native buildroot ofr a qemu target, optee_client
fails to build. This change ensure a minimal C support allows to
build optee_client with cmake.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
2 years agoregression: add case 1020 (lockdep)
Jerome Forissier [Fri, 5 Oct 2018 13:13:44 +0000 (15:13 +0200)]
regression: add case 1020 (lockdep)

Test the "lockdep" algorithm. This simply triggers a special test
pseudo-TA.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoAndroid.mk: add required header files to LOCAL_ADDITIONAL_DEPENDENCIES
Yongqin Liu [Tue, 16 Oct 2018 08:22:07 +0000 (16:22 +0800)]
Android.mk: add required header files to LOCAL_ADDITIONAL_DEPENDENCIES

Using $(LOCAL_PATH)/host/xtest/regression_8100.c as a target is not
allowed by AOSP document "Build System Changes for Android.mk Writers" [1]
("2. The target is a real file, but it's outside the output directories").

Fixes the following build error:
 external/optee_test/Android.mk:71: error: writing to readonly directory: "external/optee_test/host/xtest/regression_8100.c"

Link: [1] https://android.googlesource.com/platform/build/+/4c9399d9889e/Changes.md#phony_targets
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
[jf: edit commit message]
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2 years agoAndroid.mk : Fix compilation for build outside of source
Jassi Brar [Sun, 29 Jul 2018 07:06:38 +0000 (12:36 +0530)]
Android.mk : Fix compilation for build outside of source

Trying to specify Android build location outside of souce directory's
default 'out' using OUT_DIR_COMMON_BASE env variable, results in the
following error
"....
build/core/binary.mk:1480: error: external/optee_test/Android.mk:
xtest: C_INCLUDES must be under the source or output directories:
"
Fix the error by moving host_include/ from LOCAL_C_INCLUDES to LOCAL_CFLAGS

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
Tested-by: Victor Chong <victor.chong@linaro.org> (hikey620)
Acked-by: Victor Chong <victor.chong@linaro.org>
[jf: wrap commit text]
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2 years agoregression_*.c: move ADBG_CASE_DEFINE()
Jens Wiklander [Fri, 29 Jun 2018 13:30:13 +0000 (15:30 +0200)]
regression_*.c: move ADBG_CASE_DEFINE()

Moves all ADBG_CASE_DEFINE() to right after the function implementing
the test case.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoAndroid.mk: make xtest installed in the vendor partition
Yongqin Liu [Thu, 21 Jun 2018 14:09:15 +0000 (22:09 +0800)]
Android.mk: make xtest installed in the vendor partition

and use ta libs in the vendor partition,
so that we could make optee work with Treble enabled builds too

Acked-by: Victor Chong <victor.chong@linaro.org>
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
2 years agoReplace 32-bit libcrypto.a with version compiled for Cortex-A9 (no udiv)
Jerome Forissier [Tue, 31 Jul 2018 09:12:40 +0000 (11:12 +0200)]
Replace 32-bit libcrypto.a with version compiled for Cortex-A9 (no udiv)

Re-build OpenSSL's libcrypto.a without hardware divide (udiv). Fixes the
following crash observed on Cortex-A9 platforms:

 (gdb) r
 Program terminated with signal SIGILL, Illegal instruction.
 #0  0x00054c30 in lh_insert ()
 (gdb) x/i 0x00054c30
    0x54c30 <lh_insert+22>: udiv r3, r3, r2

Build commands:

 git clone https://github.com/openssl/openssl.git
 cd openssl
 git checkout OpenSSL_1_0_2o
 ./Configure linux-generic32 -mcpu=cortex-a9 no-shared \
             --cross-compile-prefix=arm-linux-gnueabihf-
 make build_libcrypto

Reported-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Andrew F. Davis <afd@ti.com>
2 years agoxest: OpenSSL may be provided by the system 3.2.0
Etienne Carriere [Mon, 25 Jun 2018 07:20:04 +0000 (09:20 +0200)]
xest: OpenSSL may be provided by the system

Introduce build directive OPTEE_OPENSSL_EXPORT in GNU makefile
to get OpenSSL from the target rather than using the provided builds
of the library.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoxtest: Makefile: fix OpenSSL dependency on GP test suite support
Etienne Carriere [Thu, 21 Jun 2018 14:09:48 +0000 (16:09 +0200)]
xtest: Makefile: fix OpenSSL dependency on GP test suite support

CFG_GP_PACKAGE_PATH is not expected to store 'y' but a path, if
defined. This change corrects the test on CFG_GP_PACKAGE_PATH regarding
OpenSSL depedency.

Fixes: 43d58a5fce8f ("xtest: Makefile: link against OpenSSL if MBed TLS is enabled in TA")

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
2 years agoregression: 4003: add AES CBC test 3.2.0-rc1
Jerome Forissier [Tue, 12 Jun 2018 08:13:04 +0000 (10:13 +0200)]
regression: 4003: add AES CBC test

Test case for issue https://github.com/OP-TEE/optee_os/issues/2355.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agota: os_test_lib: add aosp support
Victor Chong [Thu, 7 Jun 2018 03:37:00 +0000 (04:37 +0100)]
ta: os_test_lib: add aosp support

Signed-off-by: Victor Chong <victor.chong@linaro.org>
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
2 years agoregression: 4003: use bigger plain text in AES CTR test
Jerome Forissier [Tue, 5 Jun 2018 16:44:42 +0000 (18:44 +0200)]
regression: 4003: use bigger plain text in AES CTR test

The AES CTR test added in the parent commit results in the accelerated
crypto code being called with 3 blocks of data (48 bytes), which revealed
a bug in the 32-bit version of ce_aes_ctr_encrypt() [1].

Add some more data to exercise a similar loop in the 64-bit version of
ce_aes_ctr_encrypt(). The loop deals with 4 blocks of data.

Link: [1] https://github.com/OP-TEE/optee_os/issues/2305
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
2 years agoregression: 4003: add AES CTR test
Jerome Forissier [Tue, 5 Jun 2018 13:02:37 +0000 (15:02 +0200)]
regression: 4003: add AES CTR test

Test case for issue https://github.com/OP-TEE/optee_os/issues/2305.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
2 years agoregression: add case 1019
Jerome Forissier [Thu, 31 May 2018 07:14:54 +0000 (09:14 +0200)]
regression: add case 1019

Test the dynamically linked TA feature if CFG_TA_DYNLINK=y. Android is not
supported at the moment (xtest 1019 will do nothing).

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (QEMU make & cmake)
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoregression_1000.c: remove useless code
Jerome Forissier [Thu, 31 May 2018 06:12:34 +0000 (08:12 +0200)]
regression_1000.c: remove useless code

TEEC_ERROR_TARGET_DEAD is defined in tee_client_api.h so there is no
need to check for its existence.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2 years agoRemove host/lib/armv{7,8}/libcrypto.a
Jerome Forissier [Tue, 5 Jun 2018 10:46:01 +0000 (12:46 +0200)]
Remove host/lib/armv{7,8}/libcrypto.a

The old copies of libcrypto.a are not used anymore. Remove them.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoxtest: use imported OpenSSL
Jerome Forissier [Tue, 5 Jun 2018 08:09:31 +0000 (10:09 +0200)]
xtest: use imported OpenSSL

This commit modifies the xtest Makefiles to deal with the cases where
xtest needs to use OpenSSL:

- When the GlobalPlatform tests are enabled (CFG_GP_PACKAGE_PATH is set),
- When the MbedTLS tests are enabled (CFG_TA_MBEDTLS=y).

For the first case, it is the "make patch" target that takes care of
copying the header files under host/xtest/for_gp/include/openssl.
For the second case however, the copy does not occur and only the -I flag
is added by [1], resulting in the following error:

  cc1: error: for_gp/include: No such file or directory [-Werror=missing-include-dirs]

Address this problem by using the imported copy of OpenSSL.

The CMake and Android builds are not modified.

Fixes: [1] 43d58a5fce8f ("xtest: Makefile: link against OpenSSL if MBed TLS is enabled in TA")
Fixes: https://github.com/OP-TEE/optee_test/issues/285
Reported-by: Igor Opaniuk <igor.opaniuk@linaro.org>
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Tested-by: Igor Opaniuk <igor.opaniuk@linaro.org> (poplar)
2 years agoAdd host/openssl/lib/{arm,aarch64}/libcrypto.a
Jerome Forissier [Tue, 5 Jun 2018 09:09:01 +0000 (11:09 +0200)]
Add host/openssl/lib/{arm,aarch64}/libcrypto.a

Adds 32-bit and 64-bit builds of libcrypto.a (OpenSSL version 1.2.0o).

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoImport OpenSSL 1.2.0o header files into host/openssl/include
Jerome Forissier [Tue, 5 Jun 2018 08:01:18 +0000 (10:01 +0200)]
Import OpenSSL 1.2.0o header files into host/openssl/include

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoMove host/LICENSE to host/xtest/LICENSE
Jerome Forissier [Tue, 5 Jun 2018 09:21:04 +0000 (11:21 +0200)]
Move host/LICENSE to host/xtest/LICENSE

The GPL v2 license covers the xtest code (host/xtest), not the OpenSSL
crypto libraries (host/lib/*). Therefore, move the LICENSE file down into
host/xtest.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoregression: 4006: add test case for 4096-bit RSA
Jerome Forissier [Mon, 26 Mar 2018 16:10:23 +0000 (00:10 +0800)]
regression: 4006: add test case for 4096-bit RSA

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoregression: 4006: add test case for 3072-bit RSA
Jerome Forissier [Fri, 23 Mar 2018 13:24:21 +0000 (21:24 +0800)]
regression: 4006: add test case for 3072-bit RSA

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agocrypto: add test case for seeding RNG pool
Igor Opaniuk [Fri, 25 May 2018 12:14:05 +0000 (15:14 +0300)]
crypto: add test case for seeding RNG pool

Add test case for testing system pTA functionality for seeding RNG pool.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
2 years agoxtest: Makefile: link against OpenSSL if MBed TLS is enabled in TA
Jerome Forissier [Fri, 18 May 2018 14:40:40 +0000 (16:40 +0200)]
xtest: Makefile: link against OpenSSL if MBed TLS is enabled in TA

Commit 950ea1cda6d3 ("regression: add case 8103") introduces a test that
needs OpenSSL to verify a certificate generated by a TA with Mbed TLS. It
updates xtest's CMakeLists.txt to link against OpenSSL when found, but the
regular Makefile is not updated.

This commit adds support for the new test to the non-CMake build by
linking xtest against the OpenSSL static library when CFG_TA_MBEDTLS=y.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
2 years agoregression: add case 8103
Jens Wiklander [Mon, 30 Apr 2018 13:39:22 +0000 (15:39 +0200)]
regression: add case 8103

Adds regression case 8103 which uses the TAF TA_CRYPT_CMD_MBED_SIGN_CERT
to sign a certificate using a CSR. Output is the X.509 certificate and a
certificate chain used to verify the certificate.

Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (HiKey960)
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU)
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agota/crypt: add TA_CRYPT_CMD_MBED_SIGN_CERT
Jens Wiklander [Mon, 30 Apr 2018 07:34:01 +0000 (09:34 +0200)]
ta/crypt: add TA_CRYPT_CMD_MBED_SIGN_CERT

Adds the TAF TA_CRYPT_CMD_MBED_SIGN_CERT which uses mbedTLS to sign a
certificate.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoInitialize openssl if linked with it
Jens Wiklander [Thu, 3 May 2018 19:21:54 +0000 (21:21 +0200)]
Initialize openssl if linked with it

Early when xtest is initializing initialize OpenSSL if xtest is linked
with OpenSSL.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoregression: add case 8102
Jens Wiklander [Mon, 23 Apr 2018 11:00:31 +0000 (13:00 +0200)]
regression: add case 8102

Adds regression case 8102 which uses the TAF
TA_CRYPT_CMD_MBED_CHECK_CERT to verify a certificate chain.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agocert: add some test certificates
Jens Wiklander [Thu, 26 Apr 2018 15:28:53 +0000 (17:28 +0200)]
cert: add some test certificates

Adds some test certificates for the regression 81xx cases.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoAdd scripts/file_to_c.py
Jens Wiklander [Thu, 26 Apr 2018 12:37:02 +0000 (14:37 +0200)]
Add scripts/file_to_c.py

Adds scripts/file_to_c.py which declares an uint8_t array with the
hexadecimal content of a file.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agota/crypt: add TA_CRYPT_CMD_MBED_CHECK_CERT
Jens Wiklander [Fri, 20 Apr 2018 14:25:21 +0000 (16:25 +0200)]
ta/crypt: add TA_CRYPT_CMD_MBED_CHECK_CERT

Adds the TAF TA_CRYPT_CMD_MBED_CHECK_CERT which uses mbedTLS to check a
certificate chain.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoregression: add case 8101
Jens Wiklander [Fri, 20 Apr 2018 09:22:15 +0000 (11:22 +0200)]
regression: add case 8101

Adds regression case 8101 which calls mbedTLS self tests if
available.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agota/crypt: add TA_CRYPT_CMD_MBED_SELF_TESTS
Jens Wiklander [Fri, 20 Apr 2018 09:20:59 +0000 (11:20 +0200)]
ta/crypt: add TA_CRYPT_CMD_MBED_SELF_TESTS

Adds the TAF TA_CRYPT_CMD_MBED_SELF_TESTS which calls mbedTLS self tests if
compiled with CFG_TA_MBEDTLS_SELF_TEST

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agota/crypt: increase stack size
Jens Wiklander [Fri, 20 Apr 2018 09:20:01 +0000 (11:20 +0200)]
ta/crypt: increase stack size

Increases stack size due to anticipated stack usage by mbedTLS.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoxtest storage: check that we can't use object_id from shared memory
Etienne Carriere [Thu, 26 Apr 2018 12:20:35 +0000 (14:20 +0200)]
xtest storage: check that we can't use object_id from shared memory

According to the GP spec V1.1, the object_id in create/open/rename
functions is not allowed to reside in the shared memory.

This change checks that when a TA uses a SHM buffer to carry the
object_id parameter for create/open/rename function do rejects the
request. It is expected that the TA dies on such conditions.

Suggested-by: Zeng Tao <prime.zeng@hisilicon.com>
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
2 years agota: don't include host_include/conf.mk
Jens Wiklander [Fri, 20 Apr 2018 11:03:26 +0000 (13:03 +0200)]
ta: don't include host_include/conf.mk

Don't include host_include/conf.mk when building the TA as many
unrelated variables are propagated.

Relevant variables are already defined by the dev kit.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoos_test: remove global mempool
Jens Wiklander [Thu, 29 Mar 2018 14:20:04 +0000 (16:20 +0200)]
os_test: remove global mempool

Removes global variable mempool.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoos_test: remove mempool dependency
Jens Wiklander [Thu, 29 Mar 2018 14:16:39 +0000 (16:16 +0200)]
os_test: remove mempool dependency

Removes dependency to global variable mempool the testbench suite. The
bignum operations are called with the destination parameter different
from any of the operand parameters, making the memory pool redundant.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoregression: add case 1018
Jens Wiklander [Tue, 20 Mar 2018 04:50:58 +0000 (12:50 +0800)]
regression: add case 1018

Adds regression case 1018 to test memref paramters out of bounds of
supplied shared memory reference.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (HiKey960)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2 years agoregression: add case 1017
Jens Wiklander [Tue, 20 Mar 2018 04:00:00 +0000 (12:00 +0800)]
regression: add case 1017

Adds regression case 1017 to test coalesced memref parameters.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoregression: 4003: add AES CTR test case 3.1.0
Jerome Forissier [Wed, 11 Apr 2018 11:03:26 +0000 (13:03 +0200)]
regression: 4003: add AES CTR test case

Adds a test case for AES CTR with a buffer big enough to trigger the
regression fixed by https://github.com/OP-TEE/optee_os/pull/2243.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoCmake support for xtest only (not TAs) 3.1.0-rc1
Jens Wiklander [Thu, 1 Feb 2018 13:36:23 +0000 (14:36 +0100)]
Cmake support for xtest only (not TAs)

This introduces support for building the host part (what's running in
linux user space) of xtest using CMake. TAs are as before built using TA
dev kit.

Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Igor Opaniuk <igor.opaniuk@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoregression 6000: fix buffer part compared in 6010 test.
Melanie Favre [Mon, 19 Feb 2018 12:35:52 +0000 (13:35 +0100)]
regression 6000: fix buffer part compared in 6010 test.

Second half of output buffer was compared in regression test 6010,
whereas first part was filled. Now compare correct part.

Signed-off-by: Mélanie Favre <melanie.favre@provenrun.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
3 years agoxtest storage: can't use object_id from shared memory
Etienne Carriere [Fri, 16 Feb 2018 15:11:42 +0000 (16:11 +0100)]
xtest storage: can't use object_id from shared memory

According to the GP spec V1.1, the object_id in create/open/rename
functions is not allowed to reside in the shared memory. This change
insures the test TAs use local buffers to store the target file ID.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Suggested-by: Zeng Tao <prime.zeng@hisilicon.com>
Tested-by: Etienne Carriere <etienne.carriere@linaro.org> (Qemu, GP)
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
3 years agoregression: 4003: merge *4003_xts() and *4003_no_xts()
Jerome Forissier [Fri, 16 Feb 2018 08:25:35 +0000 (09:25 +0100)]
regression: 4003: merge *4003_xts() and *4003_no_xts()

AES XTS tests were kept separate from the other cipher tests for
historical reasons. Merge them together.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoregression 1010: fix wrong printf format specifier
Igor Opaniuk [Mon, 12 Feb 2018 10:26:25 +0000 (12:26 +0200)]
regression 1010: fix wrong printf format specifier

Fix wrong format specifier, which causes build errors:
error: format '%d' expects argument of type 'int', but argument 4 has type
'size_t {aka long unsigned int}' [-Werror=format=]
     "Invalid memory access %u with %d bytes memref",

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
3 years agoregression 1010: crash TA with SHM memref passed as parameter
Etienne Carriere [Fri, 9 Feb 2018 12:11:40 +0000 (13:11 +0100)]
regression 1010: crash TA with SHM memref passed as parameter

This adds few test cases in regression test 1010 to check TA crash
when the TA is provided a memref as invocation parameter. These
tests aims at checking the dump of memref parameter state in sane
when core detect TA crash and dumps the TA state for debug purpose.

Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
3 years agoAndroid.mk: workaround missing-field-initializers error
Victor Chong [Fri, 2 Feb 2018 14:55:21 +0000 (14:55 +0000)]
Android.mk: workaround missing-field-initializers error

Without -Wno-missing-field-initializers, GCC 4.9 generates below
errors, so add it to Android.mk. While we're at it, also add
-Wno-format-zero-length to sync with host/xtest/Makefile.

external/optee_test/host/xtest/regression_5000.c:485:40: error: missing field 'session' initializer [-Werror,-Wmissing-field-initializers]
        struct xtest_session connection = { c };
                                              ^

external/optee_test/host/xtest/regression_2000.c:46:22: error: missing field 'paramTypes' initializer [-Werror,-Wmissing-field-initializers]
        TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
                            ^
external/optee_test/host/xtest/xtest_helpers.h:43:40: note: expanded from macro 'TEEC_OPERATION_INITIALIZER'
                                       ^

external/optee_test/host/xtest/regression_2000.c:272:29: error: missing field 'session_id' initializer [-Werror,-Wmissing-field-initializers]
        TEEC_Session session = { 0 };
                                   ^

Signed-off-by: Victor Chong <victor.chong@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
3 years agoxtest 6007: close and re-open object
Jerome Forissier [Fri, 26 Jan 2018 09:39:54 +0000 (10:39 +0100)]
xtest 6007: close and re-open object

Update regression test 6007 to close and re-open the persistent object
after truncation and extension.
Reproducer for issue https://github.com/OP-TEE/optee_os/issues/2094.

Suggested-by: Kevin Peng <kevinp@marvell.com>
[jf: add close/open to test_file_hole(), too]
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
3 years agoMove ta_storage.h to common location
Jens Wiklander [Thu, 1 Feb 2018 13:16:57 +0000 (14:16 +0100)]
Move ta_storage.h to common location

Since ta_storage.h is used by several TAs move it into a common
location.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoregression: 1006: test passing a NULL reference with 0 size
Jerome Forissier [Tue, 30 Jan 2018 13:33:49 +0000 (14:33 +0100)]
regression: 1006: test passing a NULL reference with 0 size

Test case for OP-TEE issue #2105 [1]: passing a NULL memref.buffer is
acceptable as long as memref.size is zero (GP Internal Core API
specification v1.1.2 section 4.9.4).

Link: [1] https://github.com/OP-TEE/optee_os/issues/2105
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (QEMU)
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years ago4003: add aes-ctr corner case 3.0.0 3.0.0-rc1 ti2018.00 ti2018.00-rc1 ti2018.00-rc2 ti2018.00-rc3 ti2018.00-rc4 ti2018.00-rc5 ti2018.01 ti2018.01-rc1 ti2018.01-rc2 ti2018.01-rc3 ti2018.01-rc4 ti2018.02-rc1 ti2018.02-rc2 ti2018.02-rc3
Jens Wiklander [Fri, 19 Jan 2018 08:52:00 +0000 (09:52 +0100)]
4003: add aes-ctr corner case

Adds a AES-CTR corner case to expose a problem in LTC with hardware
accelerated AES encryption.

The fix for the problem is provided in:
https://github.com/OP-TEE/optee_os/pull/2086

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (HiKey960)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoReduce loop count in regression_1012
Jerome Forissier [Thu, 14 Dec 2017 08:53:24 +0000 (09:53 +0100)]
Reduce loop count in regression_1012

Reduce the loop count in xtest 1012 from 1000 to 3 in order to minimize
debug traces. There is no point in using a higher value in this
functional test.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
3 years agoregression 1008: test with corrupt BSTA
Jens Wiklander [Fri, 24 Nov 2017 15:58:07 +0000 (16:58 +0100)]
regression 1008: test with corrupt BSTA

Updates case 1008 to corrupt bootstrap TAs instead.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Victor Chong <victor.chong@linaro.org> (hikey aosp)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoregression 1008: remove load_fake_ta() test
Jens Wiklander [Fri, 24 Nov 2017 13:02:50 +0000 (14:02 +0100)]
regression 1008: remove load_fake_ta() test

Removes the load_fake_ta() test, it's not applicable with bootstrap TAs.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoregression: remove 9xxx test series
Jens Wiklander [Fri, 24 Nov 2017 11:10:38 +0000 (12:10 +0100)]
regression: remove 9xxx test series

Removes the 9xxx test series as there's new internal tests in OP-TEE
testing this instead. Also when TAs are stored in secure storage all the
file these tests depends on will changed in an even more unpredictable
way.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoxtest: add --install-tas argument
Jens Wiklander [Thu, 9 Nov 2017 15:45:51 +0000 (16:45 +0100)]
xtest: add --install-tas argument

Adds --install-tas argument which will install all bootstrap TAs
(/lib/optee_armtz/*.bsta) in the OP-TEE TA database.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoregression: add case 1003 for mutex
Jens Wiklander [Mon, 13 Nov 2017 18:52:03 +0000 (19:52 +0100)]
regression: add case 1003 for mutex

Adds regression case 1003 for read/write mutex testing.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (HiKey960)
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoregression: 4005: add NIST aes-gcm vectors
Jens Wiklander [Mon, 6 Nov 2017 12:16:43 +0000 (13:16 +0100)]
regression: 4005: add NIST aes-gcm vectors

Adds NIST AES-GCM test vectors to regression case 4005 with
CFG_GCM_NIST_VECTORS=y. Only the first test in each group is
used if CFG_GCM_NIST_VECTORS_LIMITED=y.

With CFG_GCM_NIST_VECTORS=y the size of the xtest binary grows with more
than 10 MiB, unless CFG_GCM_NIST_VECTORS_LIMITED=y is given, then only
by ~1 MiB.

Without CFG_GCM_NIST_VECTORS=y, CFG_GCM_NIST_VECTORS_LIMITED has no
effect.

Android not supported.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (HiKey960)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoregression: 4005: improve test coverage
Jens Wiklander [Fri, 10 Nov 2017 10:13:26 +0000 (11:13 +0100)]
regression: 4005: improve test coverage

Improves test coverage:
* in vect3 by feeding one full block and one almost full block
* in vect4 by feeding the first two blocks as complete blocks

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoxtest/Makefile: remove extra '@'
Jerome Forissier [Mon, 13 Nov 2017 07:46:29 +0000 (08:46 +0100)]
xtest/Makefile: remove extra '@'

Due to an extra '@', 'make V=1' won't print the link command for xtest.
Fix that.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoAndroid.mk: change to use OPTEE_BIN instead of BUILD_OPTEE_OS
Yongqin Liu [Wed, 8 Nov 2017 10:47:16 +0000 (18:47 +0800)]
Android.mk: change to use OPTEE_BIN instead of BUILD_OPTEE_OS

To workaround the problem reported as following
when build OP-TEE with AOSP master:

external/optee_test/Android.mk: error: xtest: LOCAL_ADDITIONAL_DEPENDENCIES must only contain paths (not module names)

change to use $(OPTEE_BIN) defined in optee_os/mk/aosp_optee.mk
which is path like:
out/target/product/hikey/optee/arm-plat-hikey/core/tee.bin

as dependency for xtest instead of using the target of BUILD_OPTEE_OS

Reviewed-by: Victor Chong <victor.chong@linaro.org>
Tested by: Victor Chong <victor.chong@linaro.org> (hikey aosp)
Tested-by: Yongqin Liu <yongqin.liu@linaro.org> (hikey aosp master)
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
3 years agoxtest storage: add case 6019 for storage independence
l00176142 [Tue, 7 Nov 2017 17:16:26 +0000 (01:16 +0800)]
xtest storage: add case 6019 for storage independence

The TA's storage should be independent of each other. What ever
TA #2 do should not affect TA #1's stroage.

Signed-off-by: Jianhui Li <airbak.li@hisilicon.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
3 years agoxtest storage: add a test case of creation of already existing object
Etienne Carriere [Fri, 27 Oct 2017 13:58:01 +0000 (15:58 +0200)]
xtest storage: add a test case of creation of already existing object

Regression xtest 6012 already tests creation and recreation of a
persistent object. This change adds a test in 6012 to re-create the
existing object without setting the overwrite attribute. Creation
should fail but the object should not be altered and later open
should succeed.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
3 years agoxtest: deprecated bass_return_code
Etienne Carriere [Thu, 26 Oct 2017 07:49:14 +0000 (09:49 +0200)]
xtest: deprecated bass_return_code

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoxtest: regression 1xxx: at least warn if test pseudo TA not found
Etienne Carriere [Thu, 26 Oct 2017 07:49:04 +0000 (09:49 +0200)]
xtest: regression 1xxx: at least warn if test pseudo TA not found

Following tests depends on pseudo TAs in the TEE core but xtest is
not expected to report an error if the pTAs are not found.

This change adds some verbosity to help one to understand to test
was skipped and restricts allowed error status to item-not-found.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoxtest 1014: minor beautification
Etienne Carriere [Thu, 26 Oct 2017 07:48:55 +0000 (09:48 +0200)]
xtest 1014: minor beautification

Keep a 80char/line alignment.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoAdds AES-GCM performance test in aes-perf
Jens Wiklander [Thu, 19 Oct 2017 11:50:04 +0000 (13:50 +0200)]
Adds AES-GCM performance test in aes-perf

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoxtest:sdp: fix a xtest crash if TEE is built without test pTA 2.6.0 ti2017.05 ti2017.05-rc4 ti2017.06 ti2017.06-rc1 ti2017.06-rc2 ti2017.06-rc3 ti2017.06-rc4
Etienne Carriere [Wed, 18 Oct 2017 09:55:05 +0000 (11:55 +0200)]
xtest:sdp: fix a xtest crash if TEE is built without test pTA

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
3 years agoxtest:sdp: support old ION API if new API fails
Etienne Carriere [Tue, 24 Oct 2017 13:31:34 +0000 (15:31 +0200)]
xtest:sdp: support old ION API if new API fails

Implement the old ION API using ion0_ or ION0_ as prefix.

Routine allocate_ion_buffer() attempts to allocate using the new
API. If the 1st request (query heap types) fails, try the old API.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (HiKey 4.9/4.12)
Tested-by: Etienne Carriere <etienne.carriere@linaro.org> (Qemus 4.9/4.12)
3 years agoxtest/sdp: sync with ION udpates from linux kernel 4.12 2.6.0-rc1
Etienne Carriere [Thu, 24 Aug 2017 12:48:30 +0000 (14:48 +0200)]
xtest/sdp: sync with ION udpates from linux kernel 4.12

Userland should query ION for the ID of the target heap.

Ioctls ION_IOC_FREE and ION_IOC_SHARE are still defined in the uapi
but no more supported by the kernel driver. Ioctl ION_IOC_ALLOC
returns returns a generic dmabuf file descriptor that references
the target buffer.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (HiKey)
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
3 years agoregression: add case 1002
Jens Wiklander [Mon, 16 Oct 2017 13:16:39 +0000 (15:16 +0200)]
regression: add case 1002

Adds regression case 1002 to test passing a memory buffer to a Pseudo
TA.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
3 years agoxtest: add -DTA_DIR to meet different requirement
l00176142 [Mon, 28 Aug 2017 12:03:28 +0000 (20:03 +0800)]
xtest: add -DTA_DIR to meet different requirement

TA_DIR default value is "/lib/optee_armtz", it should be
able to be changed for different requirement.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jianhui Li <airbak.li@hisilicon.com>