arm-trusted-firmware/lib
Petre-Ionut Tudor 60e8f3cfd5 Read-only xlat tables for BL31 memory
This patch introduces a build flag which allows the xlat tables
to be mapped in a read-only region within BL31 memory. It makes it
much harder for someone who has acquired the ability to write to
arbitrary secure memory addresses to gain control of the
translation tables.

The memory attributes of the descriptors describing the tables
themselves are changed to read-only secure data. This change
happens at the end of BL31 runtime setup. Until this point, the
tables have read-write permissions. This gives a window of
opportunity for changes to be made to the tables with the MMU on
(e.g. reclaiming init code). No changes can be made to the tables
with the MMU turned on from this point onwards. This change is also
enabled for sp_min and tspd.

To make all this possible, the base table was moved to .rodata. The
penalty we pay is that now .rodata must be aligned to the size of
the base table (512B alignment). Still, this is better than putting
the base table with the higher level tables in the xlat_table
section, as that would cost us a full 4KB page.

Changing the tables from read-write to read-only cannot be done with
the MMU on, as the break-before-make sequence would invalidate the
descriptor which resolves the level 3 page table where that very
descriptor is located. This would make the translation required for
writing the changes impossible, generating an MMU fault.

The caches are also flushed.

Signed-off-by: Petre-Ionut Tudor <petre-ionut.tudor@arm.com>
Change-Id: Ibe5de307e6dc94c67d6186139ac3973516430466
2020-02-24 16:52:56 +00:00
..
aarch32 Fix Coverity #261967, Infinite loop 2019-08-06 13:06:03 +01:00
aarch64 Read-only xlat tables for BL31 memory 2020-02-24 16:52:56 +00:00
bl_aux_params Introduce lightweight BL platform parameter library 2019-07-18 16:42:40 -07:00
compiler-rt compiler_rt: Import popcountdi2.c and popcountsi2.c files 2020-01-20 11:32:59 +01:00
coreboot Sanitise includes across codebase 2019-01-04 10:43:17 +00:00
cpus Merge "Add Matterhorn CPU lib" into integration 2020-02-21 17:51:10 +00:00
debugfs coverity: debugfs devfip remove comparisons to LONG_MAX 2020-02-04 13:40:30 +00:00
el3_runtime Merge "Coverity: remove unnecessary header file includes" into integration 2020-02-04 17:15:57 +00:00
extensions TF-A: Add support for ARMv8.3-PAuth in BL1 SMC calls and BL2U 2019-10-03 14:43:55 +01:00
fconf fconf: Add mbedtls shared heap as property 2020-02-07 13:51:32 +00:00
libc libc: add memrchr 2019-12-11 08:51:26 +01:00
libfdt libfdt: Downgrade to version 1.4.6-9 2018-10-30 13:42:13 +00:00
locks T589: Fix insufficient ordering guarantees in bakery lock 2020-01-27 09:31:31 -08:00
optee Coverity: remove unnecessary header file includes 2020-02-04 10:23:51 -06:00
pmf Sanitise includes across codebase 2019-01-04 10:43:17 +00:00
psci coverity: fix MISRA violations 2020-02-18 10:47:46 -06:00
romlib FDT wrappers: add functions for read/write bytes 2020-02-03 11:41:27 +00:00
semihosting qemu: Implement qemu_system_off via semihosting. 2020-01-23 10:53:45 +00:00
stack_protector Disable stack protection explicitly 2019-10-20 14:59:09 -04:00
utils coverity: Fix MISRA null pointer violations 2020-02-05 14:53:02 -06:00
xlat_tables Coding guideline suggest not to use unsigned long 2019-11-12 11:14:18 -06:00
xlat_tables_v2 Read-only xlat tables for BL31 memory 2020-02-24 16:52:56 +00:00
zlib Sanitise includes across codebase 2019-01-04 10:43:17 +00:00