]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - optee/ti-optee-client.git/log
optee/ti-optee-client.git
6 years agotee-supplicant: REE fs open file with O_SYNC flag 2.6.0 2.6.0-rc1 ti2017.05 ti2017.05-rc4 ti2017.06 ti2017.06-rc1 ti2017.06-rc2 ti2017.06-rc3 ti2017.06-rc4
l00176142 [Mon, 16 Oct 2017 09:05:45 +0000 (17:05 +0800)]
tee-supplicant: REE fs open file with O_SYNC flag

CFG_RPMB_FS=y and RPMB_EMU=0(use EMMC RPMB device). Power down when
writing file without the O_SYNC flag, dirf.db was cached by kernel,
some very old (more than two generations) version was in the file
system. If dirf.db and dirfile.db.hash (residing in RPMB) differ by
two versions, it will cause TEE_ERROR_SECURITY, and the file data
will lost.

Add O_SYNC flag in open file to fix this issue.
(fixed by Jens Wiklander)

Signed-off-by: Jianhui Li <airbak.li@hisilicon.com>
Tested-by: Jianhui Li <airbak.li@hisilicon.com> (Hisilicon)
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
6 years agotee_supplicant: add register memory feature
Volodymyr Babchuk [Mon, 6 Mar 2017 19:58:03 +0000 (21:58 +0200)]
tee_supplicant: add register memory feature

If OP-TEE and kernel support registereted shared memory,
then supplicant will use this feature instead of using
shared memory pool.

Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
6 years agotee_client_api: register user memory
Jens Wiklander [Fri, 21 Oct 2016 07:23:24 +0000 (09:23 +0200)]
tee_client_api: register user memory

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Igor Opaniuk <igor.opaniuk@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
6 years agotee-supplicant: move TEEC_LOAD_PATH to Makefile ti2017.05-rc1 ti2017.05-rc2 ti2017.05-rc3
l00176142 [Mon, 28 Aug 2017 11:37:09 +0000 (19:37 +0800)]
tee-supplicant: move TEEC_LOAD_PATH to Makefile

TEEC_LOAD_PATH default value is "/lib", it could be changed by
CFG_TEE_CLIENT_LOAD_PATH in tee_supplicant_android.mk.
As "/lib" could not meet all the scenes, it should be able to be
changed in Makefile for Linux.

* Add -DTEEC_LOAD_PATH in Makefile
* Remove the #ifndef TEEC_LOAD_PATH block in teec_ta_load.c
* Set CFG_TEE_CLIENT_LOAD_PATH ?= /lib in config.mk
  (instead of /system/lib)
* In Android.mk, set CFG_TEE_CLIENT_LOAD_PATH ?= /system/lib
  before config.mk is included

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (QEMU)
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Yongqin Liu yongqin.liu@linaro.org
Tested-by: Yongqin Liu yongqin.liu@linaro.org (Hikey with AOSP master)
Signed-off-by: Jianhui Li <airbak.li@hisilicon.com>
6 years agotee_client_api: support calling libteec from cplusplus
Zeng Tao [Mon, 28 Aug 2017 08:55:25 +0000 (16:55 +0800)]
tee_client_api: support calling libteec from cplusplus

The tee client api has got no restriction for cplusplus program,
simplely add extern "c" in this patch to support this feature.

Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Zeng Tao <prime.zeng@hisilicon.com>
6 years agorpi3: fix unsupported exclusive access issue
Igor Opaniuk [Fri, 14 Jul 2017 14:09:33 +0000 (17:09 +0300)]
rpi3: fix unsupported exclusive access issue

Fix unsupported exclusive issue , which occurs when using gcc builtin
atomic
__sync_fetch_and_add();, which is unfolded into LDXR/STLXR pair
(aarch64).

Currently, __sync_fetch_and_add() is used in bm_timestamp() for updating
head/tail
of timestamp per-cpu ringbuffers.

Fixes: https://github.com/OP-TEE/optee_client/issues/99
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
6 years agolibteec/Makefile: create relative links to shared library instead of absolute ones 2.5.0 2.5.0-rc2 ti2017.03 ti2017.03-rc1 ti2017.03-rc2 ti2017.03-rc3 ti2017.03-rc4 ti2017.04 ti2017.04-rc1 ti2017.04-rc2 ti2017.04-rc3 ti2017.04-rc4
Marc Kleine-Budde [Mon, 12 Jun 2017 15:55:32 +0000 (17:55 +0200)]
libteec/Makefile: create relative links to shared library instead of absolute ones

Absolute paths in link targets are ugly and there is always a risk that
they may be packaged incorrectly. Further the *.so* files are always
expected to reside in the same directory. This patch fixes this problem.

Suggested-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
6 years agoMakefile: preserve links to libraries during make copy_export
Marc Kleine-Budde [Mon, 12 Jun 2017 14:54:50 +0000 (16:54 +0200)]
Makefile: preserve links to libraries during make copy_export

During "make copy_export" and "make install" the shared library is
copied into the LIBDIR. However "cp" is used, thus the links to the
shared library are not preserved. This patch fixes the problem by using
"cp -a" instead.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
6 years agolibteec: benchmark cleanup 2.5.0-rc1
Jerome Forissier [Thu, 1 Jun 2017 12:53:52 +0000 (14:53 +0200)]
libteec: benchmark cleanup

Some cleanup which should also fix a build error on Android:

external/optee_client/libteec/src/tee_client_api.c:556: error: undefined reference to 'bm_timestamp'
external/optee_client/libteec/src/tee_client_api.c:592: error: undefined reference to 'bm_timestamp'
clang.real: error: linker command failed with exit code 1 (use -v to see invocation)

- Move include/linux/teec_benchmark.h up one level, because this file
is not related to the Linux TEE driver
- Make bm_timestamp() a no-op static inline if CFG_TEE_BENCHMARK != y
- Remove conditional compilation in teec_benchmark.c, instead, add the
file to the build only when CFG_TEE_BENCHMARK = y
- Declare benchmark_check_mode() static in teec_benchmark.c, since it
is not used anywhere else

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Igor Opaniuk <igor.opaniuk@linaro.org>
6 years agotee-supplicant: Report error on short buffer when loading TA
Yves Lefloch [Wed, 22 Mar 2017 16:14:07 +0000 (17:14 +0100)]
tee-supplicant: Report error on short buffer when loading TA

Signed-off-by: Yves Lefloch <YvesMarie_Lefloch@sigmadesigns.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
6 years agoFix incorrect share memory size
James Kung [Tue, 16 May 2017 07:27:01 +0000 (15:27 +0800)]
Fix incorrect share memory size

Accroding to TEE Client API Spec section 4.3.8 TEEC_RegisteredMemoryReference,
when handling a TEEC_RegisteredMemoryReference parameter of TEEC_MEMREF_WHOLE
type, the memory region size should read from its parent TEEC_SharedMemory
structure instead of the size described in TEEC_RegisteredMemoryReference
structure.

Signed-off-by: James Kung <kong1191@gmail.com>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Tested-by: Etienne Carriere <etienne.carriere@linaro.org> (QEMUs, GP)
6 years agoStorage: Added CFG_TEE_FS_PARENT_PATH config option
Ruslan Piasetskyi [Thu, 1 Jun 2017 06:36:21 +0000 (09:36 +0300)]
Storage: Added CFG_TEE_FS_PARENT_PATH config option

tee-supplicant needs to create folder which will contain secure files.
In case folder can not be created, tee-supplicant exits.

Sometimes developers have to change this location to another.
For example, Android OS can not use /data folder, because tee-supplicant
is needed for decrypt userdata.img (which is mounted in /data folder).

* Add CFG_TEE_FS_PARENT_PATH config option
* Cleanup secure storage init logic

Signed-off-by: Ruslan Piasetskyi <ruslan.piasetskyi@gmail.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
[jf: fix typo in commit message]
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
6 years agoReplace file permission symbolic values by octal numbers
Jerome Forissier [Tue, 23 May 2017 06:38:07 +0000 (08:38 +0200)]
Replace file permission symbolic values by octal numbers

Octal numbers are prefered over symbolic values for file access modes.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
6 years agoOP-TEE Benchmark
Igor Opaniuk [Wed, 9 Nov 2016 14:06:09 +0000 (14:06 +0000)]
OP-TEE Benchmark

OP-TEE Benchmark feature provides timestamp data for the roundtrip time
from libteec to OP-TEE OS core.

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
6 years agotee-supplicant: FS: remove unused legacy RPC functions
Jerome Forissier [Tue, 30 May 2017 08:17:16 +0000 (10:17 +0200)]
tee-supplicant: FS: remove unused legacy RPC functions

Since commit 129360332591 ("core: FS: remove unused legacy RPC
functions"), OP-TEE OS does not use a number of filesystem-related
commands anymore. Remove them from tee-supplicant.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
6 years agoRemove leftovers of SQL FS
Jerome Forissier [Tue, 30 May 2017 08:22:48 +0000 (10:22 +0200)]
Remove leftovers of SQL FS

Fixes: 403c9a175794 ("Remove SQL-FS")
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
6 years agosupplicant: use public rpc command ids
Etienne Carriere [Tue, 23 May 2017 09:26:13 +0000 (11:26 +0200)]
supplicant: use public rpc command ids

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
6 years agosupplicant: define/describe reserved Ids for supplicant commands
Etienne Carriere [Tue, 23 May 2017 09:25:55 +0000 (11:25 +0200)]
supplicant: define/describe reserved Ids for supplicant commands

Add missing macros OPTEE_MSG_RPC_CMD_SHM_ALLOC/_SHM_FREE/_GPROF.
Move OPTEE_MSG_RPC_CMD_SQL_FS_RESERVED to a better place.
Remove deprecated reference to optee_msg.h.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
6 years agoclient api: fix ULONG_MAX dependency
Etienne Carriere [Mon, 22 May 2017 12:53:48 +0000 (14:53 +0200)]
client api: fix ULONG_MAX dependency

ULONG_MAX depends on limits.h.

Fixes: 9faeb1b6b023 ("tee_client_api: Correct max shared memory size define")
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
6 years agotee_client_api: Correct max shared memory size define
Lukasz Kostyra [Tue, 16 May 2017 09:37:05 +0000 (11:37 +0200)]
tee_client_api: Correct max shared memory size define

Signed-off-by: Lukasz Kostyra <l.kostyra@samsung.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
6 years agotee-supplicant: correct block device path for android
Zhizhou Zhang [Thu, 9 Mar 2017 10:49:27 +0000 (18:49 +0800)]
tee-supplicant: correct block device path for android

ueventd create block devices under /dev/block/.

Signed-off-by: Zhizhou Zhang <zhizhouzhang@asrmicro.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
6 years agoRemove SQL-FS
Jens Wiklander [Wed, 19 Apr 2017 11:38:26 +0000 (13:38 +0200)]
Remove SQL-FS

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agoAndroid.mk: fix CFG_TEE_CLIENT_LOG_FILE checking ti2017.01 ti2017.01-rc1 ti2017.01-rc2 ti2017.01-rc3 ti2017.01-rc4 ti2017.02 ti2017.02-rc1 ti2017.02-rc2 ti2017.02-rc3 ti2017.02-rc4 ti2017.02-rc5 ti2017.02-rc6
Ruslan Piasetskyi [Thu, 23 Mar 2017 18:56:09 +0000 (20:56 +0200)]
Android.mk: fix CFG_TEE_CLIENT_LOG_FILE checking

CFG_TEE_CLIENT_LOG_FILE variable contains the client library log file
path. The correct way to check if the variable is not empty is using
ifneq operator.

Signed-off-by: Ruslan Piasetskyi <ruslan.piasetskyi@gmail.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agoree_fs_new_opendir(): ignore empty directory 2.4.0
Jerome Forissier [Thu, 23 Mar 2017 10:30:08 +0000 (11:30 +0100)]
ree_fs_new_opendir(): ignore empty directory

The behavior of ree_fs_new_opendir() should be the same when a TA
directory does not exist, or when it is empty: return
TEEC_ERROR_ITEM_NOT_FOUND in both cases.

Currently, ree_fs_new_opendir() returns TEE_SUCCESS when the TA
directory exists.  This causes an issue with REE FS, when the data
directory is mounted over NFS. "xtest 6009 6010" fails with
TEE_StartPersistentObjectEnumerator() returning TEE_SUCCESS instead of
TEE_ERROR_ITEM_NOT_FOUND.

This is because test 6009 does not properly clean up. The test creates
persistent objects, closes them, opens them again with the meta accesss
flag and deletes them by calling TEE_CloseAndDeletePersistentObject1().
It turns out that tee-supplicant *does* attempt to remove the directory
but receives error ENOTEMPTY when the filesystem is NFS-mounted. The
reason is that when it removes the file, as a consequence of
syscall_storage_obj_del() calling o->pobj->fops->remove(o->pobj),
tee-supplicant still has an open file descriptor to the object. This
causes the NFS server to keep a hidden file (.nfsXXX) in the directory,
causing the subsequent rmdir() to fail. Then, when
syscall_storage_obj_del() calls tee_obj_close(), the fd is closed and
the .nfsXXX file disappears. We're left with an empty TA directory, and
when TEE_StartPersistentObjectEnumerator() invokes ree_fs_new_opendir()
it ends up with TEE_SUCCESS instead of TEE_ERROR_ITEM_NOT_FOUND.

One option to fix the issue is to fix the directory cleanup sequence,
i.e., make sure that the file descriptor is closed before the file is
unlinked and the directory removed. But we choose to adjust
ree_fs_new_opendir() instead, because it is less intrusive in OP-TEE OS
and also because the secure storage code is being reworked anyway for
other reasons.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agotee_supplicant_android.mk: Add missing configs for sockets ti2017.00 ti2017.00-c4 ti2017.00-rc3 ti2017.00-rc4 ti2017.00-rc5 ti2017.00-rc6
Victor Chong [Wed, 1 Mar 2017 04:58:34 +0000 (04:58 +0000)]
tee_supplicant_android.mk: Add missing configs for sockets

Signed-off-by: Victor Chong <victor.chong@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
7 years agotee-supplicant: fix variable is used unitialized error
Victor Chong [Wed, 1 Mar 2017 04:52:06 +0000 (04:52 +0000)]
tee-supplicant: fix variable is used unitialized error

Fixes build error below:
tee_socket.c:393:7: error: variable 'to' is used uninitialized whenever
'if' condition is false [-Werror,-Wsometimes-uninitialized]

Signed-off-by: Victor Chong <victor.chong@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
7 years agoUse the mode also in open_wrapper
Joakim Bech [Wed, 1 Mar 2017 11:21:34 +0000 (12:21 +0100)]
Use the mode also in open_wrapper

When source code is built with FORTIFY, it will give an error if you're
doing an open syscall without specifing the mode parameter.

Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agotee-supplicant: Add support for TCP/UDP iSocket interface
Jens Wiklander [Tue, 13 Dec 2016 19:47:01 +0000 (20:47 +0100)]
tee-supplicant: Add support for TCP/UDP iSocket interface

Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Tested-by: Etienne Carriere <etienne.carriere@linaro.org> (b2260)
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agotee-supplicant: spawn threads as needed
Jens Wiklander [Tue, 13 Dec 2016 10:20:31 +0000 (11:20 +0100)]
tee-supplicant: spawn threads as needed

* Spawns threads as needed, but only if the kernel supports asynchronous
  supplicant requests.
* Adds mutex protecting RPMB
* Adds mutex protecting SQL_FS

Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agotee-supplicant: support asynchronous supplicant requests
Jens Wiklander [Mon, 12 Dec 2016 11:38:28 +0000 (12:38 +0100)]
tee-supplicant: support asynchronous supplicant requests

Adds support for asynchronous supplicant requests, meaning that the
supplicant can process several requests in parallel or block in a
request for some time. This is not yet taken advantage of.

Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agotee-supplicant: Update TEEC_TEST_LOAD_PATH for Android ti2017.00-rc1 ti2017.00-rc2
Victor Chong [Fri, 3 Feb 2017 12:35:25 +0000 (12:35 +0000)]
tee-supplicant: Update TEEC_TEST_LOAD_PATH for Android

Match TA_TEST_DIR in optee_test/blob/master/host/xtest/xtest_1000.c

Signed-off-by: Victor Chong <victor.chong@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
7 years agoree fs rpc: open with best-effort allowing RO data fs
Andy Green [Tue, 31 Jan 2017 01:35:52 +0000 (09:35 +0800)]
ree fs rpc: open with best-effort allowing RO data fs

The REE handler for open always uses flags O_RDWR at the moment.

This breaks the possibility to use read-only operations on a
read-only mounted filesystem at /data.

Change it to try to open with O_RDWR, if not possible fall back
to O_RDONLY and only fail if that isn't workable either.

If O_RDONLY isn't enough, then the TA should use another means
to get the fs mounted rw for the duration of his write activity.
He will get failures on the write action if not, but that is
fair enough.

Signed-off-by: Andy Green <andy@warmcat.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
7 years agoAdd support for TA profiling (gprof)
Jerome Forissier [Fri, 21 Oct 2016 14:07:32 +0000 (16:07 +0200)]
Add support for TA profiling (gprof)

Enable with: CFG_TA_GPROF_SUPPORT=y.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agoRename optee_msg_fs.h to optee_msg_supplicant.h
Jerome Forissier [Wed, 26 Oct 2016 11:45:45 +0000 (13:45 +0200)]
Rename optee_msg_fs.h to optee_msg_supplicant.h

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agotee-supplicant: disable warnings only for sql_fs.c
Jerome Forissier [Mon, 23 Jan 2017 14:52:17 +0000 (15:52 +0100)]
tee-supplicant: disable warnings only for sql_fs.c

sql_fs.c includes an API header (sqlfs.h in libsqlfs) which generates
warnings when built with our default flags. Silence them only for this
particular file, so that we won't miss potential issues in new code.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agoAdd backward compatibility with older TA UUID format 2.3.0
Jerome Forissier [Wed, 4 Jan 2017 10:39:14 +0000 (11:39 +0100)]
Add backward compatibility with older TA UUID format

Fixes: ce5fefe6cba ("Format UUID strings correctly")
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agoAllow O to be an absolute path
Jerome Forissier [Fri, 25 Nov 2016 14:07:01 +0000 (15:07 +0100)]
Allow O to be an absolute path

Update so that absolute as well as relative paths are accepted by the
Makefile.

Tested with:
  $ export CFG_WITH_SQLFS=y
  $ make
  $ make O=build
  $ make O=/tmp/build
  $ make O=~/build

Note that tilde expansion is supposed to be done by the calling shell.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Suggested-by: Zeng Tao <prime.zeng@hisilicon.com>
Acked-by: Zeng Tao <prime.zeng@hisilicon.com>
7 years agoFormat UUID strings correctly ti2016.06 ti2016.06-rc1 ti2016.06-rc2 ti2016.06-rc3 ti2016.06-rc4
Jens Wiklander [Thu, 8 Dec 2016 15:43:27 +0000 (16:43 +0100)]
Format UUID strings correctly

Prior to this patch although GlobalPlatform specifies that TAs and such
are identified with UUIDs, we don't format them quite right when turning
them into strings. Per https://www.ietf.org/rfc/rfc4122.txt, there
should be another hyphen after the first two bytes of clockSeqAndNode.

Unfortunately, fixing this breaks compatibility between how TAs are
built, and when the OS loads them.

With this patch UUID string are formated with the additional hyphen as
for instance: f81d4fae-7dec-11d0-a765-00a0c91e6bf6

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Fixes: https://github.com/OP-TEE/optee_os/issues/857
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agoEncode UUID big endian
Jens Wiklander [Thu, 8 Dec 2016 14:14:16 +0000 (15:14 +0100)]
Encode UUID big endian

When encoding a UUID as a sequence of bytes, the spec
(https://www.ietf.org/rfc/rfc4122.txt) says that the u32, and two u16s
should be represented big endian.

Before this patch OPTEE always treated them natively. With this patch
UUIDs are always converted to/from big endian when communicating with
the kernel.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Fixes: https://github.com/OP-TEE/optee_os/issues/858
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agotee-supplicant: add missing unistd.h in tee_fs.h
Zoltan Kuscsik [Fri, 2 Dec 2016 11:52:38 +0000 (12:52 +0100)]
tee-supplicant: add missing unistd.h  in tee_fs.h

R_OK, W_OK are defined by uninstd.h. This change ensures
the project can be compiled with Android Bionic

Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
[Rebase on top of master]
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
7 years agoREADME: Replace toolchain URL with reference to toolchain.mk
Victor Chong [Tue, 6 Dec 2016 05:47:19 +0000 (05:47 +0000)]
README: Replace toolchain URL with reference to toolchain.mk

This is to avoid hard coding toolchain URL which tends to change and
require constant updates.

Signed-off-by: Victor Chong <victor.chong@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
7 years agoUpdate clean rules
Jerome Forissier [Mon, 28 Nov 2016 09:27:56 +0000 (10:27 +0100)]
Update clean rules

Do not use rm -rf, it's unsafe. Instead, remove only the files created
by the build and the output directories if they're empty. This allows
to specify the source directory as an output location:

  $ make O=.
  $ make O=. clean

Without this fix the clean step would remove the source files too.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
7 years agoIntroduce BINDIR, LIBDIR, INCLUDEDIR and DESTDIR
Jerome Forissier [Wed, 23 Nov 2016 14:12:17 +0000 (15:12 +0100)]
Introduce BINDIR, LIBDIR, INCLUDEDIR and DESTDIR

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Tested-by: Joakim Bech <joakim.bech@linaro.org> (RPi3)
7 years agolibteec: sync tee.h with the linux kernel header file
Etienne Carriere [Tue, 8 Nov 2016 10:47:13 +0000 (11:47 +0100)]
libteec: sync tee.h with the linux kernel header file

This changes is about cleanup. No functional change.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agolibteec extension: TEEC_RegisterSharedMemoryFileDescriptor()
Etienne Carriere [Tue, 8 Nov 2016 10:46:44 +0000 (11:46 +0100)]
libteec extension: TEEC_RegisterSharedMemoryFileDescriptor()

Create a shared memory object in system out of a file descriptor.
libteec relays the request to the tee driver and returns a shared
memory structure referring to the shared memory object.

Driver provides a file descriptor for the newly created tee_shm object.
TEE Client API library closes this fd when the shared memory object
is released from API TEEC_ReleaseSharedMemory().

None of the APIs TEEC_RegisterSharedMemoryFromFileDescriptor() and
TEEC_ReleaseSharedMemory() do close the initial file descriptor that
gets registered. It remains the responsibility of the called to
handle its file descriptor.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agoAdd new RPC FS functions with useful error codes
Jens Wiklander [Fri, 9 Sep 2016 08:41:15 +0000 (10:41 +0200)]
Add new RPC FS functions with useful error codes

As the interface is changed to use proper error codes, the way
parameters are passed is also updated.

Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (HiKey)
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agobuild: print 'LINK' rather than 'LD' when $(LD) is not used directly 2.2.0
Jerome Forissier [Mon, 18 Jul 2016 16:09:43 +0000 (18:09 +0200)]
build: print 'LINK' rather than 'LD' when $(LD) is not used directly

When $(CC) is called to link object files, it makes little sense to
print 'LD <executable>'. Reserve this for when $(LD) is called
directly. Using 'CC <executable>' on the other hand would make it hard
to distinguish compile from link steps. So, print 'LINK <executable>'
instead. This is similar to what the Linux kernel build system does.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
7 years agoTravis: unset CC
Jerome Forissier [Mon, 18 Jul 2016 15:38:00 +0000 (17:38 +0200)]
Travis: unset CC

The CC environment variable must not be set, otherwise our Makefiles
will use it instead of $(CROSS_COMPILE)gcc.
What it means is: we have been compiling for x86_64 until now.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
7 years agotee-supplicant: link with -lpthread
Jerome Forissier [Mon, 18 Jul 2016 14:51:32 +0000 (16:51 +0200)]
tee-supplicant: link with -lpthread

tee-supplicant uses pthread functions so it should link with -lpthread
(except for Android which provides the pthread functions a part of the
C library).

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
7 years agoTravis: build with CFG_SQL_FS=y
Jerome Forissier [Mon, 18 Jul 2016 13:03:29 +0000 (15:03 +0200)]
Travis: build with CFG_SQL_FS=y

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
7 years agoAdd Android build for SQL FS
Jerome Forissier [Tue, 10 May 2016 08:30:31 +0000 (10:30 +0200)]
Add Android build for SQL FS

Compile-tested with:
  $ ../toolchains/android-ndk-r10e/ndk-build -j NDK_PROJECT_PATH=. \
    APP_BUILD_SCRIPT=Android.mk APP_ABI=arm64-v8a CFG_SQL_FS=y

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
7 years agotee-supplicant: implement SQL FS file operations
Jerome Forissier [Tue, 3 May 2016 15:30:43 +0000 (17:30 +0200)]
tee-supplicant: implement SQL FS file operations

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
7 years agotee-supplicant: add missing flags in conversion function
Jerome Forissier [Wed, 4 May 2016 08:00:01 +0000 (10:00 +0200)]
tee-supplicant: add missing flags in conversion function

Adding TEE_FS_O_TRUNC and TEE_FS_S_IXUSR.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
7 years agotee-supplicant: move file operations and flags to their own header
Jerome Forissier [Tue, 3 May 2016 11:48:05 +0000 (13:48 +0200)]
tee-supplicant: move file operations and flags to their own header

The flags and conversion functions will be re-used by the SQL
filesystem, so move them to a common header: tee_fs.h.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
7 years agolibsqlfs: fix sqlfs_proc_read()
Jerome Forissier [Fri, 13 May 2016 12:50:39 +0000 (14:50 +0200)]
libsqlfs: fix sqlfs_proc_read()

sqlfs_proc_read() should return 0 when reading an empty file or past
EOF. Upstream: https://github.com/guardianproject/libsqlfs/pull/10.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
7 years agoImport libsqlfs
Jerome Forissier [Tue, 3 May 2016 09:03:25 +0000 (11:03 +0200)]
Import libsqlfs

Import libsqlfs from //github.com/guardianproject/libsqlfs.git commit
effc5bc58161 ("Fix parallel build errors...").

From http://www.nongnu.org/libsqlfs/:
"The libsqlfs library implements a POSIX style file system on top of an
SQLite database. It allows applications to have access to a full
read/write file system in a single file, complete with its own file
hierarchy and name space. [...] This brings the benefits of a real
database, such as transactions and concurrency control"

Note that libsqlfs is distributed under the GNU LGPL version 2 or later,
which has its own implications on how the library may be used in this
project. In short: do not link statically and do not break the
interface.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
7 years agoImport SQLite
Jerome Forissier [Tue, 3 May 2016 07:52:26 +0000 (09:52 +0200)]
Import SQLite

Import https://www.sqlite.org/2016/sqlite-amalgamation-3110100.zip.
This is the first of a series of commits enabling support for a
filesystem based on a SQLite database. Hence, this code is enabled
with CFG_SQL_FS=y.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
7 years agoAdd the missed login method
prime-zeng [Thu, 11 Aug 2016 03:57:26 +0000 (11:57 +0800)]
Add the missed login method

Reviewed-by: David Brown <david.brown@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Zeng Tao <prime.zeng@huawei.com>
7 years agoRemove the connection_method limit
prime-zeng [Thu, 11 Aug 2016 03:28:31 +0000 (11:28 +0800)]
Remove the connection_method limit

Since we have to add support for login method other than TEE_LOGIN_PUBLIC
in the future, remove the limit now.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: David Brown <david.brown@linaro.org>
Signed-off-by: Zeng Tao <prime.zeng@huawei.com>
7 years agoUse "make V=1" for verbose build 20160825-for-lmg
Jerome Forissier [Wed, 17 Aug 2016 07:04:37 +0000 (09:04 +0200)]
Use "make V=1" for verbose build

Replace 'VERBOSE_BUILD' with 'V' for simplicity and consistency with
other projects.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
7 years agoTry loading TAs from another writable path
David Brown [Tue, 2 Aug 2016 17:51:32 +0000 (11:51 -0600)]
Try loading TAs from another writable path

To allow testing of corrupt TA loading on systems where the TA
directory is read-only, try loading TAs first from an alternate
`TEEC_TEST_LOAD_PATH` before the regular path.  This allows the test
to override the TA with one for testing purposes.

Although useful for testing, this should not be enabled for a
production system, since it facilitates replacing a TA with a corrupt
image.  CFG_TA_TEST_PATH can be turned off in the `config.mk`.

Signed-off-by: David Brown <david.brown@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
7 years agoAdjust error codes for TEEC_OpenSession() and TEEC_InvokeCommand()
Jerome Forissier [Wed, 27 Jul 2016 13:43:00 +0000 (15:43 +0200)]
Adjust error codes for TEEC_OpenSession() and TEEC_InvokeCommand()

When the ioctl() call inside TEEC_OpenSession() or TEEC_InvokeCommand()
fails, TEEC_ERROR_BAD_STATE is returned. Update the error path to
return more descriptive codes:
- TEEC_ERROR_OUT_OF_MEMORY if ioctl() has set errno to ENOMEM (with the
current driver, this can occur when the driver's private memory pool is
full).
- TEEC_ERROR_GENERIC otherwise.

This commit also removes <err.h> which is not needed and may cause a
compile warning ("declaration of â€˜err’ shadows a global declaration").

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: David Brown <david.brown@linaro.org>
7 years agoCheck flags before allocating shared memory. 2.1.0
Kris [Sun, 5 Jun 2016 21:17:58 +0000 (23:17 +0200)]
Check flags before allocating shared memory.

In TEEC_AllocateSharedMemory check if TEEC_MEM_INPUT, TEEC_MEM_OUTPUT
or both values are set in shm->flags before allocating shared memory.

Signed-off-by: Krzysztof Kwiatkowski <kris@amongbytes.com>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Joakim Bech <joakim.bech@linaro.org> (QEMU)
8 years agoFix compiler missing-field-initializers warnings
Zoltan Kuscsik [Fri, 1 Apr 2016 11:50:56 +0000 (13:50 +0200)]
Fix compiler missing-field-initializers warnings

Tested on AOSP 5.0

Signed-off-by: Zoltan Kuscsik <zoltan.kuscsik@linaro.org>
Change-Id: I0817e4b7c772a25c0d7fe89e2e5c8bd891696fa7
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Zoltan Kuscsik <zoltan.kuscsik@linaro.org>
8 years agoFix return-type warnings with CLang
Zoltan Kuscsik [Fri, 1 Apr 2016 11:52:25 +0000 (13:52 +0200)]
Fix return-type warnings with CLang

Signed-off-by: Zoltan Kuscsik <zoltan.kuscsik@linaro.org>
Change-Id: I322603a6857e27ebd4cc63abe0f00a1a3e7e6471
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Zoltan Kuscsik <zoltan.kuscsik@linaro.org>
8 years agoAndroid: fix makefile compatibility
Zoltan Kuscsik [Thu, 31 Mar 2016 12:17:51 +0000 (14:17 +0200)]
Android: fix makefile compatibility

Android always adds the gen/SHARED_LIBRARIES folder
from the product output folder to the include dirs, however,
this directory may be non-existing.

The target binary name tee-supplicant conflicts
with the source subfolder name tee-supplicant.

Android stores the build object files in a temporary
directory structure matching the tree structure of
the source folders.

Signed-off-by: Zoltan Kuscsik <zoltan.kuscsik@linaro.org>
Change-Id: I9b24e61ccd757dedbfd4584ffa6fc9c09daeaccd
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Zoltan Kuscsik <zoltan.kuscsik@linaro.org>
8 years agoAndroid: export public include dir
Zoltan Kuscsik [Thu, 31 Mar 2016 11:54:39 +0000 (13:54 +0200)]
Android: export public include dir

We make sure that applications linking to libteec
are always pointed to the right include dir.
This is achieved by using:

LOCAL_EXPORT_C_INCLUDE_DIRS

Change-Id: I8170ed008da81bcbecbe7a00533932ca79ace8f1
Signed-off-by: Zoltan Kuscsik <zoltan.kuscsik@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Zoltan Kuscsik <zoltan.kuscsik@linaro.org>
8 years agoAndroid.mk cleanup
Zoltan Kuscsik [Thu, 31 Mar 2016 11:52:37 +0000 (13:52 +0200)]
Android.mk cleanup

Change-Id: Ic5d86d39a7858b5da672f4108e01cc96239a6654

Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Zoltan Kuscsik <zoltan.kuscsik@linaro.org>
Signed-off-by: Zoltan Kuscsik <zoltan.kuscsik@linaro.org>
8 years agoUse Android way for detecting Android builds
Zoltan Kuscsik [Thu, 31 Mar 2016 11:44:38 +0000 (13:44 +0200)]
Use Android way for detecting Android builds

AOSP build system defines the __ANDROID__
constant. No need for another one.

Change-Id: I2ff302e902386d1894441f4a4fa3bc5304320e05
Signed-off-by: Zoltan Kuscsik <zoltan.kuscsik@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Zoltan Kuscsik <zoltan.kuscsik@linaro.org>
8 years agoSupport OP-TEE in generic TEE subsystem 2.0.0
Jens Wiklander [Thu, 26 Mar 2015 09:57:50 +0000 (10:57 +0100)]
Support OP-TEE in generic TEE subsystem

Replaces support for for the old OP-TEE driver with support for OP-TEE
in the generic TEE subsystem.

Uses id instead of fd to identify shared memory objects to let
tee-supplicant manage allocation and freeing of its memory shared with
secure world.

This change depends on corresponding abi change in the kernel.

Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
8 years agotee-supplicant: add TEE_RPC_LOAD_TA2
Jens Wiklander [Fri, 25 Dec 2015 17:06:43 +0000 (18:06 +0100)]
tee-supplicant: add TEE_RPC_LOAD_TA2

Adds new RPC function TEE_RPC_LOAD_TA2 which doesn't allocate a buffer
for the TA to load, instead secure world is responsible to allocate the
buffer when doing this RPC.

Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (HiKey)
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
8 years agoRPMB: fix read_cid() and data access with a real eMMC device
Jerome Forissier [Fri, 29 Jan 2016 16:36:26 +0000 (17:36 +0100)]
RPMB: fix read_cid() and data access with a real eMMC device

Prior to this commit, the RPMB code was tested in emulation mode only
(RPMB_EMU=1). This fixes a couple of issues found when testing with a
real eMMC device on a HiKey board. The eMMC is a Hardkernel 8GB module
plugged into the microSD port. Kernel is from Linaro's 96boards
repository [1], slightly modified so that the RPMB can be used on the
microSD connector (MMC_CAP_CMD23 is added to the capability flags of
the second MMC controller).

[1] https://github.com/96boards/linux branch hikey commit 54e6524885a9
("Merge pull request #178 from xin3liang/hikey-3.18-720p-boot-issue").

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
8 years agoRPMB: add HMAC to emulation mode
Jerome Forissier [Thu, 14 Jan 2016 10:32:04 +0000 (11:32 +0100)]
RPMB: add HMAC to emulation mode

Verify and generate HMAC values as required by the eMMC spec.
The HMAC SHA-256 implementation is from http://www.ouah.org/ogay/hmac/
which states "The code is distribued under the BSD license".
The code is also available from https://github.com/ogay/hmac.
I have kept only the SHA-256 variant and removed the loop unrolling
option.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
8 years agoReplay Protected Memory Block (RPMB) support
Jerome Forissier [Tue, 8 Dec 2015 17:06:43 +0000 (18:06 +0100)]
Replay Protected Memory Block (RPMB) support

This commit adds support for the TEE_RPC_RPMB command, used by OP-TEE
to access the RPMB partition of an eMMC device (/dev/mmcblkXrpmb).
This is independent from the regular filesystem access (TEE_RPC_FS),
so the TEE can use either RPMB or the regular FS (or both) to implement
persistent storage.

RPMB operations are:
 - Get device information (partition size, reliable write count)
 - Read write counter
 - Read and write data
 - Program authentication key

The code relies on the ioctl() interface to implement the required
functions. In addition, an emulation layer is provided so that the RPMB
feature may be tested even if an actual eMMC chip is not available, or
if the kernel does not support it. Emulated mode is currently the
default. It can be disabled in the tee-supplicant Makefile
(-DRPMB_EMU=1).

The eMMC emulation layer does not yet perform any authentication, i.e.,
it will not check the MAC contained in the requests, and it will not
sign the responses with a MAC either. This feature will be added later.

Tested on HiKey using the extended xtest suite (including tests 6001 to
6011) and eMMC emulation only.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
8 years agoFix trace 1.1.0
Pascal Brand [Thu, 17 Dec 2015 09:57:57 +0000 (10:57 +0100)]
Fix trace

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Pascal Brand <pascal.brand@st.com>
8 years agoAdd mutex to protect global variable shared_memory_list
Pascal Brand [Mon, 14 Dec 2015 15:01:16 +0000 (16:01 +0100)]
Add mutex to protect global variable shared_memory_list

Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Pascal Brand <pascal.brand@st.com>
8 years agoFixes incorrectly built library and binary
Joakim Bech [Fri, 6 Nov 2015 12:54:22 +0000 (13:54 +0100)]
Fixes incorrectly built library and binary

The previous patch made it possible to override the CC variable.
However, when you don't assign anything at all, there will still be a
value assigned by the implicit variables and hence both libtee.so and
tee-supplicant will be built using the host compiler instead of the
(ARM) cross compiler and as a result of that other builds like xtest etc
will fail. We fix this by adding the argument "--no-builtin-variables"
when calling the individual makefile(s).

Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
8 years agoMake CC configurable via the environment.
Sumit Garg [Wed, 4 Nov 2015 13:13:06 +0000 (08:13 -0500)]
Make CC configurable via the environment.

Trying to build optee_client with yocto. Required to
override CC with CC set by yocto environment.

Signed-off-by: Sumit Garg <b49020@freescale.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
8 years agoUpdate .gitignore
Jerome Forissier [Wed, 28 Oct 2015 14:10:55 +0000 (15:10 +0100)]
Update .gitignore

Add the output directories created by the Android build.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
8 years agoAndroid.mk: s/tee_supplicant/tee-supplicant/
Jerome Forissier [Tue, 27 Oct 2015 14:26:23 +0000 (15:26 +0100)]
Android.mk: s/tee_supplicant/tee-supplicant/

Fixes the name of the TEE supplicant binary in Android builds. Indeed,
the current driver expects current->comm to be "tee-supplicant", any
other name results in the process failing to start.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
8 years agoRestructure struct type to support 32-bit CA running with 64-bit linux kernel
Aijun Sun [Wed, 5 Aug 2015 06:22:00 +0000 (14:22 +0800)]
Restructure struct type to support 32-bit CA running with 64-bit linux kernel

The changes of data structure in this commit is to be aligned with the changes
in OP-TEE linux kernel driver.

This commit includes:
- Add padding member in struct
- Call pthread_mutex_init to initialize mutex

Signed-off-by: Aijun Sun <aijun.sun@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (HiKey)
Tested-by: Aijun Sun <aijun.sun@linaro.org> (FVP platform: 32/64-bit xtest)
Tested-by: Aijun Sun <aijun.sun@linaro.org> (Qemu platform)
8 years agoChanging from old STM CLA to the new DCO 1.0.0 1.0.0-rc1 1.0.0-rc2 1.0.1
Joakim Bech [Thu, 24 Sep 2015 21:46:04 +0000 (14:46 -0700)]
Changing from old STM CLA to the new DCO

Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
8 years agoStorage: Added create hard-link operation
SY Chiu [Tue, 7 Jul 2015 09:12:03 +0000 (17:12 +0800)]
Storage: Added create hard-link operation

To support atmoic rename operation in OP-TEE, we need to
add a create hard-link operation in tee-supplicant.

Signed-off-by: SY Chiu <sy.chiu@linaro.org>
Tested-by: SY Chiu <sy.chiu@linaro.org> (QEMU)
Reviewed-by: Pascal Brand pascal.brand@linaro.org
8 years agoRemove unused ROOTFS installation
Pascal Brand [Wed, 8 Jul 2015 08:42:53 +0000 (10:42 +0200)]
Remove unused ROOTFS installation

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Pascal Brand <pascal.brand@st.com>
8 years agoDrop TEE_RPC_FREE_TA_WTH_FD, let it be TEE_RPC_FREE_TA 0.3.0
Jerome Forissier [Wed, 20 May 2015 13:22:48 +0000 (15:22 +0200)]
Drop TEE_RPC_FREE_TA_WTH_FD, let it be TEE_RPC_FREE_TA

We don't need two versions of the command. Keep the one with the fd
parameter.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
8 years agoCheck for errors when using incomplete filename
Joakim Bech [Mon, 27 Apr 2015 14:20:51 +0000 (16:20 +0200)]
Check for errors when using incomplete filename

Do error checking when an incomplete filename was returned from the
function tfs_get_absolute_filename(...).

Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
Tested-by: Joakim Bech <joakim.bech@linaro.org> (QEMU)
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
8 years agotee_supp_fs.c readability cleanup
Joakim Bech [Fri, 24 Apr 2015 12:10:41 +0000 (14:10 +0200)]
tee_supp_fs.c readability cleanup

- Shortened the prefix of static functions from "tee_supp_fs" to
  "tee_fs" to make things more readable.
- Using a variable for filename, directory name etc instead of using
  (char *)(fsrpc + 1) everywhere.
- Renamed the function called tee_supp_fs_create_fname(...) to
  tee_fs_get_absolute_filename(...) to better reflect what it actually
  does.

Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
Tested-by: Joakim Bech <joakim.bech@linaro.org> (QEMU)
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
8 years agoFixes eventual buffer overrun in tee-supplicant
Joakim Bech [Fri, 24 Apr 2015 11:25:51 +0000 (13:25 +0200)]
Fixes eventual buffer overrun in tee-supplicant

In the function tee_supp_fs_create_fname(...) you could overwrite the
out buffer. Now we take into account how much data the string
TEE_FS_PATH takes. To support this we let the caller tell the size of
the out buffer it provides instead of assuming that the parameter "out"
always has the size PATH_MAX.

Also did some minor clarifications in the tee_supp_fs_rename(...)
function to make it more understandable.

Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
Tested-by: Joakim Bech <joakim.bech@linaro.org> (QEMU)
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
9 years agodma_buf support
Pascal Brand [Fri, 6 Mar 2015 10:16:31 +0000 (11:16 +0100)]
dma_buf support

Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (STM platform)
Tested-by: Pascal Brand <pascal.brand@linaro.org> (QEMU platform)
Signed-off-by: Pascal Brand <pascal.brand@st.com>
9 years agoGP Internal Core API v1.1 : add defines
Cedric Chaumont [Mon, 16 Mar 2015 08:25:59 +0000 (09:25 +0100)]
GP Internal Core API v1.1 : add defines

Signed-off-by: Cedric Chaumont <cedric.chaumont@st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (QEMU)
Tested-by: Cedric Chaumont <cedric.chaumont@linaro.org> (STM Cannes)
Tested-by: Cedric Chaumont <cedric.chaumont@linaro.org> (FVP)
9 years agoAlign TEEC_FinalizeContext with GP specifications
Pascal Brand [Fri, 13 Mar 2015 12:55:35 +0000 (13:55 +0100)]
Align TEEC_FinalizeContext with GP specifications

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (QEMU platform)
Signed-off-by: Pascal Brand <pascal.brand@st.com>
9 years agoUpdate nbr_bf when freeing the TA
Pascal Brand [Tue, 24 Feb 2015 16:14:35 +0000 (17:14 +0100)]
Update nbr_bf when freeing the TA

Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (QEMU)
Signed-off-by: Pascal Brand <pascal.brand@st.com>
9 years agoKill supplicant in case of fatal error while reading
Pascal Brand [Tue, 24 Feb 2015 16:03:24 +0000 (17:03 +0100)]
Kill supplicant in case of fatal error while reading

Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Pascal Brand <pascal.brand@st.com>
9 years agoAdding missing mutex_lock()
Pascal Brand [Tue, 24 Feb 2015 15:55:14 +0000 (16:55 +0100)]
Adding missing mutex_lock()

Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Pascal Brand <pascal.brand@st.com>
9 years agoRemove dependency on optee_linuxdriver/include/tee_ioc.h
Pascal Brand [Mon, 23 Feb 2015 13:41:52 +0000 (14:41 +0100)]
Remove dependency on optee_linuxdriver/include/tee_ioc.h

Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (QEMU)
Signed-off-by: Pascal Brand <pascal.brand@st.com>
9 years agoUpdated related Linux Driver Refactoring 0.2.0
Cedric Chaumont [Fri, 3 Oct 2014 14:41:39 +0000 (16:41 +0200)]
Updated related Linux Driver Refactoring

Update of the client part, related to the Linux Driver
Refactoring at https://github.com/OP-TEE/optee_linuxdriver/pull/17

Fix #16

Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (STM platform)
Tested-by: Pascal Brand <pascal.brand@linaro.org> (QEMU)
Tested-by: Cedric Chaumont <cedric.chaumont@linaro.org> (FVP)
Tested-by: Cedric Chaumont <cedric.chaumont@linaro.org> (Juno)
Signed-off-by: Cedric Chaumont <cedric.chaumont@st.com>
9 years agoAdd Android.mk 0.1.0
sunny [Fri, 12 Dec 2014 08:09:45 +0000 (16:09 +0800)]
Add Android.mk

1.add the Android.mk to support android system build;
2.add config options CFG_TEE_CLIENT_LOG_FILE/CFG_TEE_SUPP_LOG_FILE/
  CFG_TEE_CLIENT_LOAD_PATH to common config.mk.

Signed-off-by: sunny <sunny@allwinnertech.com>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Tested-by: sunny <sunny@allwinnertech.com> (Allwinner A80 platform)
9 years agoTravis: use default arm-linux-gnueabihf- compiler
Jerome Forissier [Thu, 27 Nov 2014 09:42:38 +0000 (10:42 +0100)]
Travis: use default arm-linux-gnueabihf- compiler

The download of the Linaro compiler as well as the installation of
its dependencies (including some 32-bit libraries) is replaced by
the installation of the default gcc-arm-linux-gnueabihf package.

This speeds up the build significantly.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
9 years agoFixes on trace levels
Pascal Brand [Wed, 19 Nov 2014 14:54:57 +0000 (15:54 +0100)]
Fixes on trace levels

Signed-off-by: Pascal Brand <pascal.brand@st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (STM platform)
9 years agoAlign trace levels to the ones of optee_os
Pascal Brand [Tue, 18 Nov 2014 07:53:37 +0000 (08:53 +0100)]
Align trace levels to the ones of optee_os

Signed-off-by: Pascal Brand <pascal.brand@st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>