Introduce unified API to zero memory
Introduce zeromem_dczva function on AArch64 that can handle unaligned
addresses and make use of DC ZVA instruction to zero a whole block at a
time. This zeroing takes place directly in the cache to speed it up
without doing external memory access.

Remove the zeromem16 function on AArch64 and replace it with an alias to
zeromem. This zeromem16 function is now deprecated.

Remove the 16-bytes alignment constraint on __BSS_START__ in
firmware-design.md as it is now not mandatory anymore (it used to comply
with zeromem16 requirements).

Change the 16-bytes alignment constraints in SP min's linker script to a
8-bytes alignment constraint as the AArch32 zeromem implementation is now
more efficient on 8-bytes aligned addresses.

Introduce zero_normalmem and zeromem helpers in platform agnostic header
that are implemented this way:
* AArch32:
	* zero_normalmem: zero using usual data access
	* zeromem: alias for zero_normalmem
* AArch64:
	* zero_normalmem: zero normal memory  using DC ZVA instruction
	                  (needs MMU enabled)
	* zeromem: zero using usual data access

Usage guidelines: in most cases, zero_normalmem should be preferred.

There are 2 scenarios where zeromem (or memset) must be used instead:
* Code that must run with MMU disabled (which means all memory is
  considered device memory for data accesses).
* Code that fills device memory with null bytes.

Optionally, the following rule can be applied if performance is
important:
* Code zeroing small areas (few bytes) that are not secrets should use
  memset to take advantage of compiler optimizations.

  Note: Code zeroing security-related critical information should use
  zero_normalmem/zeromem instead of memset to avoid removal by
  compilers' optimizations in some cases or misbehaving versions of GCC.

Fixes ARM-software/tf-issues#408

Change-Id: Iafd9663fc1070413c3e1904e54091cf60effaa82
Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
1 parent bcc2bf0 commit 308d359b260d888f024a2d26c76cd4a50789e432
@Douglas Raillard Douglas Raillard authored on 2 Dec 2016
Showing 19 changed files
View
bl1/bl1.ld.S
View
bl1/bl1_fwu.c
View
bl2/aarch64/bl2_entrypoint.S
View
bl2/bl2.ld.S
View
bl2u/aarch64/bl2u_entrypoint.S
View
bl2u/bl2u.ld.S
View
bl31/bl31.ld.S
View
bl32/sp_min/sp_min.ld.S
View
bl32/tsp/aarch64/tsp_entrypoint.S
View
bl32/tsp/tsp.ld.S
View
common/bl_common.c
View
docs/firmware-design.md
View
include/common/aarch64/el3_common_macros.S
View
include/lib/utils.h
View
lib/aarch32/misc_helpers.S
View
lib/aarch64/misc_helpers.S
View
plat/arm/css/common/css_bl2_setup.c
View
plat/mediatek/mt6795/bl31.ld.S
View
plat/nvidia/tegra/common/drivers/memctrl/memctrl.c