fix(cm): disable SPE/TRBE correctly
SPE and TRBE are unusual features. They have multi-bit enables whose
function is not immediately apparent and disabling them is not
straightforward.
While attempting to figure this out, the disables were made a mess of.
Patch fc7dca72b began changing the owning security state of SPE and
TRBE. This was first used in patch 79c0c7fac0 with calls to
spe_disable() and trbe_disbale(). However, patch 13f4a2525 reverted the
security state ownership, making the spe_disable() and trbe_disable()
redundant and their comments incorrect - the DoS protection is achieved
by the psb/tsb barriers on context switch, introduces separately in
f80887337 and 73d98e375.
Those patches got the behaviour full circle to what it was in fc7dca72b
so the disables can be fully removed for clarity.
However, the original method for disabling these features is not fully
correct - letting the "disabled" state be all zeroes made the features
seem enabled for secure world but they would trap. That is not a problem
while secure world doesn't use them, but could lead to some confusing
debugging in the future. NS and Realm worlds were not affected. This
patch fully establishes the pattern for SPE and TRBE's enablement,
documents it, and implements it such.
The description comments in the features boil down to 2 rules. There is
a third rule possible:
3. To enable TRBE/SPE for world X with a dirty buffer:
* world X owns the buffer
* trapping enabled
This is not listed as it would not work correctly with
SMCCC_ARCH_FEATURE_AVAILABILITY which relies on trapping to be disabled
to report correctly. If that is ever implemented, the SMCCC
implementation should be considered too.
Change-Id: I5588a3d5fc074c2445470954d8c3b172bec77d43
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
diff --git a/include/services/arm_arch_svc.h b/include/services/arm_arch_svc.h
index 1a0ba56..242bf66 100644
--- a/include/services/arm_arch_svc.h
+++ b/include/services/arm_arch_svc.h
@@ -272,7 +272,7 @@
#endif
#if ENABLE_TRBE_FOR_NS
-#define MDCR_FEAT_TRBE MDCR_NSTB(1UL)
+#define MDCR_FEAT_TRBE MDCR_NSTB_EN_BIT
#else
#define MDCR_FEAT_TRBE (0)
#endif
@@ -284,7 +284,7 @@
#endif
#if ENABLE_SPE_FOR_NS
-#define MDCR_FEAT_SPE MDCR_NSPB(1UL)
+#define MDCR_FEAT_SPE MDCR_NSPB_EN_BIT
#else
#define MDCR_FEAT_SPE (0)
#endif
@@ -314,12 +314,12 @@
MDCR_SBRBE(2UL) | \
MDCR_MTPME_BIT | \
MDCR_NSTBE_BIT | \
- MDCR_NSTB(2UL) | \
+ MDCR_NSTB_SS_BIT | \
MDCR_MCCD_BIT | \
MDCR_SCCD_BIT | \
MDCR_SDD_BIT | \
MDCR_SPD32(3UL) | \
- MDCR_NSPB(2UL) | \
+ MDCR_NSPB_SS_BIT | \
MDCR_NSPBE_BIT | \
MDCR_PLAT_IGNORED)
CASSERT((MDCR_EL3_FEATS & MDCR_EL3_IGNORED) == 0, mdcr_feat_is_ignored);