From 43d1d951ddb3b725d372884f314babb6594fcd47 Mon Sep 17 00:00:00 2001 From: Manish Pandey Date: Thu, 18 Jul 2024 15:18:20 +0100 Subject: [PATCH] feat(cpufeat): add new feature state for asymmetric features Introduce a new feature state CHECK_ASYMMETRIC to cater for the features which are asymmetric across cores. This state is useful for platforms which has architectural asymmetric cores (A feature is only present in one type of core e.g. big). This state is similar to FEAT_STATE_CHECK (dynamic detection) except that feature state is also checked on each core during warmboot path and override the context (just for asymmetric features) which was setup by core executing CPU_ON call. Only Non-secure context will be re-checked as secure and realm context is created on same core. Signed-off-by: Manish Pandey Change-Id: Ic78a0b6ca996e0d7881c43da1a6a0c422f528ef3 --- .../components/context-management-library.rst | 32 +++++++++++++++---- include/common/feat_detect.h | 7 ++-- lib/el3_runtime/aarch64/context.S | 5 ++- 3 files changed, 32 insertions(+), 12 deletions(-) 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)