various minor cleanups

- Remove unused assembly routines "secure_mmu_xxx".
- arm32/plat-stm:
  . move platform stm definitions of CFG_TEE_xxx configs from conf.mk to
    system_config.in
  . emit error in case some configuration variables are not defined
  .Remove deprecated macro _USE_SLAPORT_LIB
- Comment message format

Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org>
CCM Authentication optimization

CCM   is now optimized. Instead of being computed twice,
libtomcrypt code has been optimized so that classical ccm_init, ccm_process,...
can be used incrementally (when the whole stream is not available when
starting the authentication).
CCM way of proceeding is now very closed to GCM authentication.

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

Reviewed-by: Etienne Carriere <etienne.carriere@st.com>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
travis plat-vexpress: adding flavor qemu_virt

Adds plat-vexpress flagvor qemu_virt to Travis CI builds

Reviewed-by: Etienne Carriere <etienne.carriere@st.com>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
thread: check cpsr after fast handler

Asserts that a fast handler hasn't cleared the I, F or A bits
in CPSR.

Reviewed-by: Etienne Carriere <etienne.carriere@st.com>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Optimize mmu handling

Previously there was two complete L1 mmu tables where one was only
used when kernel mapping was active and the other when user mapping
was active too. In addition to that there was several sets of L2 mmu
tables which where unused.

Now there's only one complete L1 mmu table shared by all CPUs. There's
one small L1 mmu table for each thread used to keep user mappings. The
small L1 mmu tables takes each 128 bytes and can spans 32 MiB of
virtual memory.

This change saves memory ~32 KiB, but also prepares for multiprocessing
since each thread has its own user mapping.

Due to the change of mmu table handling many low level assembly and C
functions are changed, and some even removed.

Reviewed-by: Etienne Carriere <etienne.carriere@st.com>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Remove some assembly files

Removes kta_table_unpg_asm.S,
Remove tee_pager_unpg_asm.S
Removes tee_mmu_unpg_asm.S
* Replaces assembly implementation of tee_mmu_switch()
  with a C version
* Replaces calls to tee_mmu_invtlb_asid with
  secure_mmu_unifiedtlbinv_byasid

Reviewed-by: Etienne Carriere <etienne.carriere@st.com>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Rename .bss.prebss.* sections to .nozi.*

Renames .bss.prebss.* sections to .nozi.* to be clear that it's
not a "subsection" of .bss and also make the matching in the link
script easier.

plat-vexpress:
* The .nozi section is moved after the .bss section
* The padding added before .nozi by the linker is recorded to
  make it possible to do something useful with the otherwise
  wasted memory

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)
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (FVP platform)
Fix TEE_BigIntMulMod

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

Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Remove unused chip_services.c

Removes chip_services.c and declaration of enable_secure_wd() in
chip_services.h

Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Jens Wiklander <jens.wiklander@linaro.org>
Update relevant "msr {s,c}prs, reg" instructions

Updates relevant "msr {s,c}prs, reg" instructions to
"msr {s,c}prs_fsxc, reg" to avoid loosing bits when
setting SPSR/CPSR.

Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
plat-vexpress: Set CPSR.A when initializing

Sets CPSR.A when initializing a core. The bit should already be
set by the OP-TEE Dispatcher in ARM Trusted Firmware but in case
it isn't make sure the bit is set.

Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (STM platform)
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (FVP platform)
Fix wrong parameter in GCM authentication

Signed-off-by: Pascal Brand <pascal.brand@st.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (STM platform)
Travis now runs checkpatch.pl

Note that this implies:
- If checkpatch.pl fails, Travis results is now "failed". In such a case,
  it must be checked that
  - checkpatch.pl fails for good reason (GP CamelCase style for ex.)
  - all the compilations steps are fine
- Signing the commit is now mandatory
     git commit -s ...
- When pushing several commits on the same branch (same pull-request),
  checkpatch.pl is run only on the code differences given by the
  the last commit

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org>
Signed-off-by: Pascal Brand <pascal.brand@st.com>
Add support for per-directory/per-library/per-file includes, and per-library CPP flags

The new variables that can be used in sub.mk are:

  1) For includes: incdirs-y, incdirs-lib-y, incdirs-<filename>-y

For example, suppose core/lib/libfoo/sub.mk contains the following:

  # All source files declared in $(srcs-y) in this sub.mk will
  # have -Icore/lib/libfoo/include
  incdirs-y := include

  # All source files for the current library $(libname) will be built
  # with -Icore/lib/libfoo/include/baz (even files that are in other
  # directories)
  incdirs-lib-y := include/baz

  # In addition to the above, bar.c will be compiled with
  # -Icore/lib/libfoo/include/bar
  incdirs-bar.c-y := include/bar

  2) For CPP flags: cppflags-lib-y

For example, to add -DLIBFOO to all the source files that belong to the same
library, add this to any of the sub.mk files:

  cppflags-lib-y := -DLIBFOO

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: Jens Wiklander <jens.wiklander@linaro.org> (QEMU virt platform)
Add dhex_dump() and DHEXDUMP() to format and print data in hexadecimal

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 stable commits to the setup FVP script

Instead of checking out latest on all Gits we have now identified a
couple of commits for all Gits (except optee_os) that could be
considered as stable commits.

Also added a script that cleans all Gits.

Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Joakim Bech <joakim.bech@linaro.org> (FVP)
Minimize LTC with some flags

Sets LTC_NO_TEST for globally.

Lets platform decide with libtomcrypt_with_optimize_size if
LTC_SMALL_CODE and LTC_NO_FAST should be set.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
plat-vexpress: set libtomcrypt_with_optimize_size

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>