arm-trusted-firmware/lib/psci
Antonio Nino Diaz 3e318e4037 xlat v2: Flush xlat tables after being modified
During cold boot, the initial translation tables are created with data
caches disabled, so all modifications go to memory directly. After the
MMU is enabled and data cache is enabled, any modification to the tables
goes to data cache, and eventually may get flushed to memory.

If CPU0 modifies the tables while CPU1 is off, CPU0 will have the
modified tables in its data cache. When CPU1 is powered on, the MMU is
enabled, then it enables coherency, and then it enables the data cache.
Until this is done, CPU1 isn't in coherency, and the translation tables
it sees can be outdated if CPU0 still has some modified entries in its
data cache.

This can be a problem in some cases. For example, the warm boot code
uses only the tables mapped during cold boot, which don't normally
change. However, if they are modified (and a RO page is made RW, or a XN
page is made executable) the CPU will see the old attributes and crash
when it tries to access it.

This doesn't happen in systems with HW_ASSISTED_COHERENCY or
WARMBOOT_ENABLE_DCACHE_EARLY. In these systems, the data cache is
enabled at the same time as the MMU. As soon as this happens, the CPU is
in coherency.

There was an attempt of a fix in psci_helpers.S, but it didn't solve the
problem. That code has been deleted. The code was introduced in commit
<264410306381> ("Invalidate TLB entries during warm boot").

Now, during a map or unmap operation, the memory associated to each
modified table is flushed. Traversing a table will also flush it's
memory, as there is no way to tell in the current implementation if the
table that has been traversed has also been modified.

Change-Id: I4b520bca27502f1018878061bc5fb82af740bb92
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
2018-08-07 12:47:12 +01:00
..
aarch32 xlat v2: Flush xlat tables after being modified 2018-08-07 12:47:12 +01:00
aarch64 xlat v2: Flush xlat tables after being modified 2018-08-07 12:47:12 +01:00
psci_common.c PSCI: Fix logic error to skip cache flushing 2018-07-26 14:14:06 -05:00
psci_lib.mk mem_protect: Add mem_protect API 2017-09-25 13:32:20 +01:00
psci_main.c psci: Use bool in internal interfaces 2018-08-02 15:08:18 +01:00
psci_mem_protect.c PSCI: Fix MISRA defects in MEM_PROTECT 2018-07-24 09:19:22 +01:00
psci_off.c PSCI: Fix MISRA defects in ON/OFF/SUSPEND/SYSTEM_OFF 2018-07-24 09:19:04 +01:00
psci_on.c PSCI: Fix MISRA defects in ON/OFF/SUSPEND/SYSTEM_OFF 2018-07-24 09:19:04 +01:00
psci_private.h psci: Use bool in internal interfaces 2018-08-02 15:08:18 +01:00
psci_setup.c PSCI: Fix MISRA defects in common and setup code 2018-07-24 09:19:34 +01:00
psci_stat.c PSCI: Fix MISRA defects in stat code 2018-07-24 09:19:26 +01:00
psci_suspend.c PSCI: Fix MISRA defects in ON/OFF/SUSPEND/SYSTEM_OFF 2018-07-24 09:19:04 +01:00
psci_system_off.c PSCI: Fix MISRA defects in ON/OFF/SUSPEND/SYSTEM_OFF 2018-07-24 09:19:04 +01:00