aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadhukar Pappireddy <madhukar.pappireddy@arm.com>2024-03-26 23:01:05 +0100
committerTrustedFirmware Code Review <review@review.trustedfirmware.org>2024-03-26 23:01:05 +0100
commiteee0ec48b5d02aa3e37e45a4d478c68f65eaa56e (patch)
tree714c215960a866e955fd77e7652c759084143eb6
parentff8e68c071296a302f167f5c1381b5efafa23f6e (diff)
parent1e02ce683208c9b1b7ccb9923cb2353257f45079 (diff)
downloadtrusted-firmware-a-master.tar.gz
Merge changes from topic "mte_fixes" into integrationHEADmasterintegration
* changes: build(changelog): move mte to mte2 refactor(mte): remove mte, mte_perm
-rw-r--r--Makefile4
-rw-r--r--bl31/bl31_traps.c2
-rw-r--r--bl32/tsp/tsp_main.c4
-rw-r--r--changelog.yaml7
-rw-r--r--common/feat_detect.c6
-rw-r--r--docs/components/secure-partition-manager.rst4
-rw-r--r--docs/design/firmware-design.rst8
-rw-r--r--docs/getting_started/build-options.rst12
-rw-r--r--include/arch/aarch32/arch_features.h1
-rw-r--r--include/arch/aarch64/arch_features.h12
-rw-r--r--include/lib/el3_runtime/aarch64/context.h4
-rw-r--r--lib/el3_runtime/aarch64/context_mgmt.c12
-rw-r--r--make_helpers/arch_features.mk26
-rw-r--r--plat/arm/board/fvp/platform.mk1
-rw-r--r--plat/arm/board/tc/platform.mk1
15 files changed, 36 insertions, 68 deletions
diff --git a/Makefile b/Makefile
index 800346ad4f..7058d57d98 100644
--- a/Makefile
+++ b/Makefile
@@ -1221,7 +1221,6 @@ $(eval $(call assert_numerics,\
ENABLE_FEAT_ECV \
ENABLE_FEAT_FGT \
ENABLE_FEAT_HCX \
- ENABLE_FEAT_MTE \
ENABLE_FEAT_MTE2 \
ENABLE_FEAT_PAN \
ENABLE_FEAT_RNG \
@@ -1235,7 +1234,6 @@ $(eval $(call assert_numerics,\
ENABLE_FEAT_S1POE \
ENABLE_FEAT_GCS \
ENABLE_FEAT_VHE \
- ENABLE_FEAT_MTE_PERM \
ENABLE_FEAT_MPAM \
ENABLE_RME \
ENABLE_SPE_FOR_NS \
@@ -1384,9 +1382,7 @@ $(eval $(call add_defines,\
ENABLE_FEAT_S2POE \
ENABLE_FEAT_S1POE \
ENABLE_FEAT_GCS \
- ENABLE_FEAT_MTE \
ENABLE_FEAT_MTE2 \
- ENABLE_FEAT_MTE_PERM \
FEATURE_DETECTION \
TWED_DELAY \
ENABLE_FEAT_TWED \
diff --git a/bl31/bl31_traps.c b/bl31/bl31_traps.c
index f1b1fa6ed3..474b4d52c1 100644
--- a/bl31/bl31_traps.c
+++ b/bl31/bl31_traps.c
@@ -165,7 +165,7 @@ u_register_t create_spsr(u_register_t old_spsr, unsigned int target_el)
/* If FEAT_MTE2 is implemented mask tag faults by setting TCO bit */
new_spsr |= old_spsr & SPSR_TCO_BIT_AARCH64;
- if (read_feat_mte_id_field() >= MTE_IMPLEMENTED_ELX) {
+ if (is_feat_mte2_present()) {
new_spsr |= SPSR_TCO_BIT_AARCH64;
}
diff --git a/bl32/tsp/tsp_main.c b/bl32/tsp/tsp_main.c
index d8031f9b9c..805575a213 100644
--- a/bl32/tsp/tsp_main.c
+++ b/bl32/tsp/tsp_main.c
@@ -239,10 +239,10 @@ smc_args_t *tsp_smc_handler(uint64_t func,
service_arg1 = (uint64_t)(service_args >> 64U);
/*
- * Write a dummy value to an MTE register, to simulate usage in the
+ * Write a dummy value to an MTE2 register, to simulate usage in the
* secure world
*/
- if (is_feat_mte_supported()) {
+ if (is_feat_mte2_supported()) {
write_gcr_el1(0x99);
}
diff --git a/changelog.yaml b/changelog.yaml
index 3875a48c75..b7f281c157 100644
--- a/changelog.yaml
+++ b/changelog.yaml
@@ -116,8 +116,11 @@ subsections:
- title: Memory Partitioning and Monitoring (MPAM) Extension (FEAT_MPAM)
scope: mpam
- - title: Memory Tagging Extension
- scope: mte
+ - title: Memory Tagging Extension2
+ scope: mte2
+
+ deprecated:
+ - mte
- title: Pointer Authentication Extension
scope: pauth
diff --git a/common/feat_detect.c b/common/feat_detect.c
index 7a2f0d7e66..7f0103741d 100644
--- a/common/feat_detect.c
+++ b/common/feat_detect.c
@@ -167,9 +167,7 @@ void detect_arch_features(void)
"TRF", 1, 1);
/* v8.5 features */
- check_feature(ENABLE_FEAT_MTE, read_feat_mte_id_field(), "MTE",
- MTE_IMPLEMENTED_EL0, MTE_IMPLEMENTED_ASY);
- check_feature(ENABLE_FEAT_MTE2, read_feat_mte_id_field(), "MTE2",
+ check_feature(ENABLE_FEAT_MTE2, get_armv8_5_mte_support(), "MTE2",
MTE_IMPLEMENTED_ELX, MTE_IMPLEMENTED_ASY);
check_feature(ENABLE_FEAT_RNG, read_feat_rng_id_field(), "RNG", 1, 1);
read_feat_bti();
@@ -204,8 +202,6 @@ void detect_arch_features(void)
"S2POE", 1, 1);
check_feature(ENABLE_FEAT_S1POE, read_feat_s1poe_id_field(),
"S1POE", 1, 1);
- check_feature(ENABLE_FEAT_MTE_PERM, read_feat_mte_perm_id_field(),
- "MTE_PERM", 1, 1);
check_feature(ENABLE_FEAT_CSV2_3, read_feat_csv2_id_field(),
"CSV2_3", 3, 3);
diff --git a/docs/components/secure-partition-manager.rst b/docs/components/secure-partition-manager.rst
index 4834d3a590..b6f421928e 100644
--- a/docs/components/secure-partition-manager.rst
+++ b/docs/components/secure-partition-manager.rst
@@ -215,7 +215,7 @@ implemented and the SPMC is located at S-EL2:
ARM_ARCH_MINOR=5 \
BRANCH_PROTECTION=1 \
CTX_INCLUDE_PAUTH_REGS=1 \
- ENABLE_FEAT_MTE=1 \
+ ENABLE_FEAT_MTE2=1 \
BL32=<path-to-hafnium-binary> \
BL33=<path-to-bl33-binary> \
SP_LAYOUT_FILE=sp_layout.json \
@@ -233,7 +233,7 @@ implemented, the SPMC is located at S-EL2, and enabling secure boot:
ARM_ARCH_MINOR=5 \
BRANCH_PROTECTION=1 \
CTX_INCLUDE_PAUTH_REGS=1 \
- ENABLE_FEAT_MTE=1 \
+ ENABLE_FEAT_MTE2=1 \
BL32=<path-to-hafnium-binary> \
BL33=<path-to-bl33-binary> \
SP_LAYOUT_FILE=sp_layout.json \
diff --git a/docs/design/firmware-design.rst b/docs/design/firmware-design.rst
index fa06c8e28d..2ba54ea8e5 100644
--- a/docs/design/firmware-design.rst
+++ b/docs/design/firmware-design.rst
@@ -2800,9 +2800,11 @@ Armv8.5-A
- Branch Target Identification feature is selected by ``BRANCH_PROTECTION``
option set to 1. This option defaults to 0.
-- Memory Tagging Extension feature is unconditionally enabled for both worlds.
- To enable MTE at EL0 use ``ENABLE_FEAT_MTE`` is required and to enable MTE at
- ELX ``ENABLE_FEAT_MTE2`` is required.
+- Memory Tagging Extension feature has few variants but not all of them require
+ enablement from EL3 to be used at lower EL. e.g. Memory tagging only at
+ EL0(MTE) does not require EL3 configuration however memory tagging at
+ EL2/EL1 (MTE2) does require EL3 enablement and we need to set this option
+ ``ENABLE_FEAT_MTE2`` to 1. This option defaults to 0.
Armv7-A
~~~~~~~
diff --git a/docs/getting_started/build-options.rst b/docs/getting_started/build-options.rst
index f817da0f86..c18c1552c9 100644
--- a/docs/getting_started/build-options.rst
+++ b/docs/getting_started/build-options.rst
@@ -340,23 +340,11 @@ Common build options
flag can take the values 0 to 2, to align with the ``ENABLE_FEAT``
mechanism. Default value is ``0``.
-- ``ENABLE_FEAT_MTE``: Numeric value to enable Memory Tagging Extension
- if the platform wants to use this feature at EL0 ``ENABLE_FEAT_MTE`` is
- required. This flag can take values 0 to 2, to align with the ``ENABLE_FEAT``
- feature detection mechanism. Default value is ``0``.
-
- ``ENABLE_FEAT_MTE2``: Numeric value to enable Memory Tagging Extension2
if the platform wants to use this feature and MTE2 is enabled at ELX.
This flag can take values 0 to 2, to align with the ``ENABLE_FEAT``
mechanism. Default value is ``0``.
-- ``ENABLE_FEAT_MTE_PERM``: Numeric value to enable support for
- ``FEAT_MTE_PERM``, which introduces Allocation tag access permission to
- memory region attributes. ``FEAT_MTE_PERM`` is a optional architectural
- feature available from v8.9 and upwards. This flag can take the values 0 to
- 2, to align with the ``ENABLE_FEAT`` mechanism. Default value is
- ``0``.
-
- ``ENABLE_FEAT_PAN``: Numeric value to enable the ``FEAT_PAN`` (Privileged
Access Never) extension. ``FEAT_PAN`` adds a bit to PSTATE, generating a
permission fault for any privileged data access from EL1/EL2 to virtual
diff --git a/include/arch/aarch32/arch_features.h b/include/arch/aarch32/arch_features.h
index 734a6b5786..b52e4d062e 100644
--- a/include/arch/aarch32/arch_features.h
+++ b/include/arch/aarch32/arch_features.h
@@ -159,7 +159,6 @@ static inline bool is_feat_tcr2_supported(void) { return false; }
static inline bool is_feat_spe_supported(void) { return false; }
static inline bool is_feat_rng_supported(void) { return false; }
static inline bool is_feat_gcs_supported(void) { return false; }
-static inline bool is_feat_mte_supported(void) { return false; }
static inline bool is_feat_mte2_supported(void) { return false; }
static inline bool is_feat_mpam_supported(void) { return false; }
static inline bool is_feat_hcx_supported(void) { return false; }
diff --git a/include/arch/aarch64/arch_features.h b/include/arch/aarch64/arch_features.h
index de59d456df..7582fc65d4 100644
--- a/include/arch/aarch64/arch_features.h
+++ b/include/arch/aarch64/arch_features.h
@@ -105,6 +105,10 @@ static inline unsigned int get_armv8_5_mte_support(void)
return ((read_id_aa64pfr1_el1() >> ID_AA64PFR1_EL1_MTE_SHIFT) &
ID_AA64PFR1_EL1_MTE_MASK);
}
+static inline unsigned int is_feat_mte2_present(void)
+{
+ return get_armv8_5_mte_support() >= MTE_IMPLEMENTED_ELX;
+}
static inline bool is_feat_ssbs_present(void)
{
@@ -136,18 +140,14 @@ static inline bool is_feat_sebep_present(void)
ID_AA64DFR0_SEBEP_MASK) == SEBEP_IMPLEMENTED;
}
-CREATE_FEATURE_FUNCS(feat_mte, id_aa64pfr1_el1, ID_AA64PFR1_EL1_MTE_SHIFT,
- ENABLE_FEAT_MTE)
-CREATE_FEATURE_FUNCS_VER(feat_mte2, read_feat_mte_id_field, MTE_IMPLEMENTED_ELX,
- ENABLE_FEAT_MTE2)
+CREATE_FEATURE_FUNCS_VER(feat_mte2, get_armv8_5_mte_support, MTE_IMPLEMENTED_ELX,
+ ENABLE_FEAT_MTE2)
CREATE_FEATURE_FUNCS(feat_sel2, id_aa64pfr0_el1, ID_AA64PFR0_SEL2_SHIFT,
ENABLE_FEAT_SEL2)
CREATE_FEATURE_FUNCS(feat_twed, id_aa64mmfr1_el1, ID_AA64MMFR1_EL1_TWED_SHIFT,
ENABLE_FEAT_TWED)
CREATE_FEATURE_FUNCS(feat_fgt, id_aa64mmfr0_el1, ID_AA64MMFR0_EL1_FGT_SHIFT,
ENABLE_FEAT_FGT)
-CREATE_FEATURE_FUNCS(feat_mte_perm, id_aa64pfr2_el1,
- ID_AA64PFR2_EL1_MTEPERM_SHIFT, ENABLE_FEAT_MTE_PERM)
CREATE_FEATURE_FUNCS(feat_ecv, id_aa64mmfr0_el1, ID_AA64MMFR0_EL1_ECV_SHIFT,
ENABLE_FEAT_ECV)
CREATE_FEATURE_FUNCS_VER(feat_ecv_v2, read_feat_ecv_id_field,
diff --git a/include/lib/el3_runtime/aarch64/context.h b/include/lib/el3_runtime/aarch64/context.h
index 44efee50ee..fbaa008f1d 100644
--- a/include/lib/el3_runtime/aarch64/context.h
+++ b/include/lib/el3_runtime/aarch64/context.h
@@ -141,7 +141,7 @@
#define CTX_TIMER_SYSREGS_END CTX_AARCH32_END
#endif /* NS_TIMER_SWITCH */
-#if ENABLE_FEAT_MTE
+#if ENABLE_FEAT_MTE2
#define CTX_TFSRE0_EL1 (CTX_TIMER_SYSREGS_END + U(0x0))
#define CTX_TFSR_EL1 (CTX_TIMER_SYSREGS_END + U(0x8))
#define CTX_RGSR_EL1 (CTX_TIMER_SYSREGS_END + U(0x10))
@@ -151,7 +151,7 @@
#define CTX_MTE_REGS_END (CTX_TIMER_SYSREGS_END + U(0x20))
#else
#define CTX_MTE_REGS_END CTX_TIMER_SYSREGS_END
-#endif /* ENABLE_FEAT_MTE */
+#endif /* ENABLE_FEAT_MTE2 */
/*
* End of system registers.
diff --git a/lib/el3_runtime/aarch64/context_mgmt.c b/lib/el3_runtime/aarch64/context_mgmt.c
index ee94dfd9a0..7a00e4734c 100644
--- a/lib/el3_runtime/aarch64/context_mgmt.c
+++ b/lib/el3_runtime/aarch64/context_mgmt.c
@@ -1277,7 +1277,7 @@ void cm_el2_sysregs_context_save(uint32_t security_state)
el2_sysregs_context_save_common(el2_sysregs_ctx);
el2_sysregs_context_save_gic(el2_sysregs_ctx);
- if (is_feat_mte_supported()) {
+ if (is_feat_mte2_supported()) {
write_el2_ctx_mte(el2_sysregs_ctx, tfsr_el2, read_tfsr_el2());
}
@@ -1363,7 +1363,7 @@ void cm_el2_sysregs_context_restore(uint32_t security_state)
el2_sysregs_context_restore_common(el2_sysregs_ctx);
el2_sysregs_context_restore_gic(el2_sysregs_ctx);
- if (is_feat_mte_supported()) {
+ if (is_feat_mte2_supported()) {
write_tfsr_el2(read_el2_ctx_mte(el2_sysregs_ctx, tfsr_el2));
}
@@ -1508,12 +1508,12 @@ static void el1_sysregs_context_save(el1_sysregs_t *ctx)
write_ctx_reg(ctx, CTX_CNTKCTL_EL1, read_cntkctl_el1());
#endif /* NS_TIMER_SWITCH */
-#if ENABLE_FEAT_MTE
+#if ENABLE_FEAT_MTE2
write_ctx_reg(ctx, CTX_TFSRE0_EL1, read_tfsre0_el1());
write_ctx_reg(ctx, CTX_TFSR_EL1, read_tfsr_el1());
write_ctx_reg(ctx, CTX_RGSR_EL1, read_rgsr_el1());
write_ctx_reg(ctx, CTX_GCR_EL1, read_gcr_el1());
-#endif /* ENABLE_FEAT_MTE */
+#endif /* ENABLE_FEAT_MTE2 */
}
@@ -1563,12 +1563,12 @@ static void el1_sysregs_context_restore(el1_sysregs_t *ctx)
write_cntkctl_el1(read_ctx_reg(ctx, CTX_CNTKCTL_EL1));
#endif /* NS_TIMER_SWITCH */
-#if ENABLE_FEAT_MTE
+#if ENABLE_FEAT_MTE2
write_tfsre0_el1(read_ctx_reg(ctx, CTX_TFSRE0_EL1));
write_tfsr_el1(read_ctx_reg(ctx, CTX_TFSR_EL1));
write_rgsr_el1(read_ctx_reg(ctx, CTX_RGSR_EL1));
write_gcr_el1(read_ctx_reg(ctx, CTX_GCR_EL1));
-#endif /* ENABLE_FEAT_MTE */
+#endif /* ENABLE_FEAT_MTE2 */
}
diff --git a/make_helpers/arch_features.mk b/make_helpers/arch_features.mk
index 643d5508ee..ac4796063a 100644
--- a/make_helpers/arch_features.mk
+++ b/make_helpers/arch_features.mk
@@ -307,27 +307,16 @@ CTX_INCLUDE_NEVE_REGS ?= 0
# registers, by setting SCR_EL3.TRNDR.
ENABLE_FEAT_RNG_TRAP ?= 0
-# Enable Memory Tagging Extension. This must be set to 1 if the platform wants
-# to use this feature in the Secure world and MTE is enabled at ELX.
ifeq ($(CTX_INCLUDE_MTE_REGS),1)
- $(warning CTX_INCLUDE_MTE_REGS option is deprecated use ENABLE_FEAT_MTE, Enabling ENABLE_FEAT_MTE)
- ENABLE_FEAT_MTE ?= 1
+ $(warning CTX_INCLUDE_MTE_REGS option is deprecated, Check ENABLE_FEAT_MTE2 usage)
endif
-ifeq (${ARCH},aarch32)
- ifneq ($(or $(ENABLE_FEAT_MTE),0),0)
- $(error ENABLE_FEAT_MTE is not supported for AArch32)
- endif
+ifeq ($(ENABLE_FEAT_MTE),1)
+ $(warning ENABLE_FEAT_MTE option is deprecated, Check ENABLE_FEAT_MTE2 usage)
endif
-ENABLE_FEAT_MTE ?= 0
-ENABLE_FEAT_MTE2 ?= 0
-
-# Add a error message to indicate incorrect MTE2 selection without MTE enabled.
-ifneq ($(ENABLE_FEAT_MTE2),0)
- ifeq ($(ENABLE_FEAT_MTE),0)
- $(error ENABLE_FEAT_MTE2 is not supported without enabling ENABLE_FEAT_MTE)
- endif
-endif
+# Enable FEAT_MTE2. This must be set to 1 if the platform wants
+# to use this feature and is enabled at ELX.
+ENABLE_FEAT_MTE2 ?= 0
#----
# 8.6
@@ -352,9 +341,6 @@ DISABLE_MTPMU ?= 0
# 8.9
#----
-# Flag to enable NoTagAccess memory region attribute for stage 2 of translation.
-ENABLE_FEAT_MTE_PERM ?= 0
-
# Flag to enable access to Stage 2 Permission Indirection (FEAT_S2PIE).
ENABLE_FEAT_S2PIE ?= 0
diff --git a/plat/arm/board/fvp/platform.mk b/plat/arm/board/fvp/platform.mk
index 19c4d275ac..6b995afd6c 100644
--- a/plat/arm/board/fvp/platform.mk
+++ b/plat/arm/board/fvp/platform.mk
@@ -76,7 +76,6 @@ ENABLE_FEAT_CSV2_2 := 2
ENABLE_FEAT_CSV2_3 := 2
ENABLE_FEAT_DIT := 2
ENABLE_FEAT_PAN := 2
-ENABLE_FEAT_MTE_PERM := 2
ENABLE_FEAT_VHE := 2
CTX_INCLUDE_NEVE_REGS := 2
ENABLE_FEAT_SEL2 := 2
diff --git a/plat/arm/board/tc/platform.mk b/plat/arm/board/tc/platform.mk
index 2f23d80664..b30e40cfa9 100644
--- a/plat/arm/board/tc/platform.mk
+++ b/plat/arm/board/tc/platform.mk
@@ -40,7 +40,6 @@ CTX_INCLUDE_AARCH32_REGS := 0
ifeq (${SPD},spmd)
SPMD_SPM_AT_SEL2 := 1
- ENABLE_FEAT_MTE := 1
CTX_INCLUDE_PAUTH_REGS := 1
endif