uart: add baudrate and clock freqency to uart_init

Adds baudrate and clock frequency as agruments to uart_init().

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
plat-vexpress: add juno flavor

Adds support for ARM Versatile Express V2M-Juno by adding flavor juno.

UART3 (SoC UART1) is used as console uart instead of UART1 (FPGA UART1)
which is used by TSP in ARM Trusted Firmware. UART3 is used for OP-TEE
since that uart is easily accessible on the Juno board, while UART0 and
UART1 only are accessible via headers on the motherboard.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (Juno and FVP)
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Add script for setting up QEMU and OP-TEE

The script will clone and download all needed gits to run OP-TEE
using a QEMU with TrustZone patches.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (Ubuntu 14.01 64-bit)
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (Linux Mint 17 64-bit)
Add crypto provider internal API

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>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (STM platform)
Add support for $(lib-use-ld) and $(lib-ldflags)

When building a static library, set lib-use-ld := y to use $(LD) instead of
$(AR). Link flags may be passed in $(lib-ldflags).

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>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (STM platform)
Add support for $(cflags-lib-y)

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>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (STM platform)
thread: remove THREAD_LOCAL_EXCEPTION_SPS

Removes unused THREAD_LOCAL_EXCEPTION_SPS code.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU virt platform)
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
build: print 'AS' instead of 'CC' when input file is assembly

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>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Update github.md with tag to be added

Signed-off-by: Pascal Brand <pascal.brand@st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Fix sections to map

As highlighted by z08053520@126.com, MMU mapping functions tee_mmu_is_mapped()
and tee_mmu_map_io() wrongly compute the number of sections to check / map.

This patch checks / maps only the relevant sections.

Signed-off-by: Pascal Brand <pascal.brand@st.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: SkyZhang <z08053520@126.com>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (STM platform)
1.Fix user heap corruption by usr_params

Avoids corruption of heap by usr_params, and vice versa, when
stack_size+heap_size is a multiple of 1 MiB. usr_params was
previously unintentionally stored just outside the allocated
stack. If there is not enough padding between stack and heap,
usr_params will overwrite a part of the heap.

2.remove the 1MB limitation of heap_size+stack_size

Signed-off-by: "Rock P. Zhang" <RockPZhang@viatech.com.cn>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (STM platform)
core_tlb_maintenance(TLBINV_BY_ASID) is on

It also contains code style cleanup

Signed-off-by: Pascal Brand <pascal.brand@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> (STM platform)
core/core.mk, mk/config.mk: delete unused definitions

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
core: create conf.h from CFG_* Makefile variables

Simplify the use of makefile configuration variables from C code.
With this patch, one can #include <generated/conf.h> instead of adding
CPP flags definitions to the .mk files.

- CFG_* variables that are set to 'y' are converted to: #define CFG_FOO 1
- Undefined variables, or variables set to 'n' remain undefined in conf.h
- CFG_* variables with any other value are output unchanged

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>
Rename and move TEE_COMPILE_TIME_ASSERT

Renames TEE_COMPILE_TIME_ASSERT to COMPILE_TIME_ASSERT, the
macro is also moved to assert.h to be available anywhere.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@st.com>
Move util.h from core into libutil

Moves util.h from core into libutil to make it available anywhere.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@st.com>
Merge tee_{core,uta}_trace.h into libutil

Merges tee_core_trace.h and tee_uta_trace.h into a common trace.h
in libutil. Since the trace functions now resides libutil they have
to rely on core and libutee to provide functions to print to the
log device.

* Keeps compatible interface from tee_kta_trace.h
* Adds TAMSG() and TAMSG_RAW() to log TA related events
* Removes the TRACE_ALWAYS level

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU virt platform)
Reviewed-by: Etienne Carriere <etienne.carriere@st.com>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (STM platform)
travis: set max log level to 4

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Fix memory leak in tee_svc_cryp_obj_copy()

The following Trusted App would lead to a memory leak in the TEE core:

  TEE_ObjectHandle o1, o2;
  TEE_AllocateTransientObject(TEE_TYPE_RSA_KEYPAIR, 256, &o1);
  TEE_GenerateKey(o1, 256, NULL, 0);
  TEE_AllocateTransientObject(TEE_TYPE_RSA_KEYPAIR, 256, &o2);
  TEE_CopyObjectAttributes(o2, o1);
  TEE_FreeTransientObject(o1);
  TEE_FreeTransientObject(o2);

The leak was introduced by commit ffe040395b13 ("Add crypto provider internal
API").

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>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (STM platform)
Fix buf_overlaps_area security bug

buf_overlaps_area() only returned false in previous implementation that
might lead to a potential security vulnerability and instability in
general since secure and non-secure memory could eventually overlap.

Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
Tested-by: Joakim Bech <joakim.bech@linaro.org> (QEMU)
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (STM platform)
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>