• Douglas Raillard's avatar
    Introduce unified API to zero memory · 308d359b
    Douglas Raillard authored
    
    
    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: default avatarDouglas Raillard <douglas.raillard@arm.com>
    308d359b
utils.h 4.09 KB