diff --git a/docs/components/context-management-library.rst b/docs/components/context-management-library.rst index 56ba2ec1f..266b82a0c 100644 --- a/docs/components/context-management-library.rst +++ b/docs/components/context-management-library.rst @@ -98,14 +98,15 @@ feature set, and thereby save and restore the configuration associated with them 4. **Dynamic discovery of Feature enablement by EL3** -TF-A supports three states for feature enablement at EL3, to make them available +TF-A supports four states for feature enablement at EL3, to make them available for lower exception levels. .. code:: c - #define FEAT_STATE_DISABLED 0 - #define FEAT_STATE_ENABLED 1 - #define FEAT_STATE_CHECK 2 + #define FEAT_STATE_DISABLED 0 + #define FEAT_STATE_ENABLED 1 + #define FEAT_STATE_CHECK 2 + #define FEAT_STATE_CHECK_ASYMMETRIC 3 A pattern is established for feature enablement behavior. Each feature must support the 3 possible values with rigid semantics. @@ -119,7 +120,26 @@ Each feature must support the 3 possible values with rigid semantics. - **FEAT_STATE_CHECK** - same as ``FEAT_STATE_ALWAYS`` except that the feature's existence will be checked at runtime. Default on dynamic platforms (example: FVP). -.. note:: +- **FEAT_STATE_CHECK_ASYMMETRIC** - same as ``FEAT_STATE_CHECK`` except that the feature's + existence is asymmetric across cores, which requires the feature existence is checked + during warmboot path also. Note that only limited number of features can be asymmetric. + + .. note:: + Only limited number of features can be ``FEAT_STATE_CHECK_ASYMMETRIC`` this is due to + the fact that Operating systems are designed for SMP systems. + There are no clear guidelines what kind of mismatch is allowed but following pointers + can help making a decision + + - All mandatory features must be symmetric. + - Any feature that impacts the generation of page tables must be symmetric. + - Any feature access which does not trap to EL3 should be symmetric. + - Features related with profiling, debug and trace could be asymmetric + - Migration of vCPU/tasks between CPUs should not cause an error + + Whenever there is asymmetric feature support is added for a feature TF-A need to add + feature specific code in context management code. + + .. note:: ``FEAT_RAS`` is an exception here, as it impacts the execution of EL3 and it is essential to know its presence at compile time. Refer to ``ENABLE_FEAT`` macro under :ref:`Build Options` section for more details. @@ -498,4 +518,4 @@ Realm worlds. .. |Context Init WarmBoot| image:: ../resources/diagrams/context_init_warmboot.png .. _Trustzone for AArch64: https://developer.arm.com/documentation/102418/0101/TrustZone-in-the-processor/Switching-between-Security-states .. _Security States with RME: https://developer.arm.com/documentation/den0126/0100/Security-states -.. _lib/el3_runtime/(aarch32/aarch64): https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/lib/el3_runtime \ No newline at end of file +.. _lib/el3_runtime/(aarch32/aarch64): https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/lib/el3_runtime diff --git a/include/common/feat_detect.h b/include/common/feat_detect.h index 788dfb31f..b85e1ce99 100644 --- a/include/common/feat_detect.h +++ b/include/common/feat_detect.h @@ -11,8 +11,9 @@ void detect_arch_features(void); /* Macro Definitions */ -#define FEAT_STATE_DISABLED 0 -#define FEAT_STATE_ALWAYS 1 -#define FEAT_STATE_CHECK 2 +#define FEAT_STATE_DISABLED 0 +#define FEAT_STATE_ALWAYS 1 +#define FEAT_STATE_CHECK 2 +#define FEAT_STATE_CHECK_ASYMMETRIC 3 #endif /* FEAT_DETECT_H */ diff --git a/lib/el3_runtime/aarch64/context.S b/lib/el3_runtime/aarch64/context.S index 62895ffac..5e62da9f2 100644 --- a/lib/el3_runtime/aarch64/context.S +++ b/lib/el3_runtime/aarch64/context.S @@ -142,7 +142,7 @@ endfunc fpregs_context_restore * always enable DIT in EL3 */ #if ENABLE_FEAT_DIT -#if ENABLE_FEAT_DIT == 2 +#if ENABLE_FEAT_DIT >= 2 mrs x8, id_aa64pfr0_el1 and x8, x8, #(ID_AA64PFR0_DIT_MASK << ID_AA64PFR0_DIT_SHIFT) cbz x8, 1f @@ -166,8 +166,7 @@ endfunc fpregs_context_restore .macro restore_mpam3_el3 #if ENABLE_FEAT_MPAM -#if ENABLE_FEAT_MPAM == 2 - +#if ENABLE_FEAT_MPAM >= 2 mrs x8, id_aa64pfr0_el1 lsr x8, x8, #(ID_AA64PFR0_MPAM_SHIFT) and x8, x8, #(ID_AA64PFR0_MPAM_MASK)