feat(rmmd): add FEAT_MEC support

This patch provides architectural support for further use of
Memory Encryption Contexts (MEC) by declaring the necessary
registers, bits, masks, helpers and values and modifying the
necessary registers to enable FEAT_MEC.

Signed-off-by: Tushar Khandelwal <tushar.khandelwal@arm.com>
Signed-off-by: Juan Pablo Conde <juanpablo.conde@arm.com>
Change-Id: I670dbfcef46e131dcbf3a0b927467ebf6f438fa4
This commit is contained in:
Tushar Khandelwal 2024-03-15 15:00:29 +00:00 committed by Juan Pablo Conde
parent d153bcf427
commit 7e84f3cf90
8 changed files with 50 additions and 0 deletions

View file

@ -614,6 +614,22 @@ ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
endif
endif
################################################################################
# Verify FEAT_RME, FEAT_SCTLR2 and FEAT_TCR2 are enabled if FEAT_MEC is enabled.
################################################################################
ifneq (${ENABLE_FEAT_MEC},0)
ifeq (${ENABLE_RME},0)
$(error FEAT_RME must be enabled when FEAT_MEC is enabled.)
endif
ifeq (${ENABLE_FEAT_TCR2},0)
$(error FEAT_TCR2 must be enabled when FEAT_MEC is enabled.)
endif
ifeq (${ENABLE_FEAT_SCTLR2},0)
$(error FEAT_SCTLR2 must be enabled when FEAT_MEC is enabled.)
endif
endif
################################################################################
# Make 128-Bit sysreg read/writes availabe when FEAT_D128 is enabled.
################################################################################
@ -1297,6 +1313,7 @@ $(eval $(call assert_numerics,\
ENABLE_FEAT_FPMR \
ENABLE_FEAT_HCX \
ENABLE_FEAT_LS64_ACCDATA \
ENABLE_FEAT_MEC \
ENABLE_FEAT_MOPS \
ENABLE_FEAT_MTE2 \
ENABLE_FEAT_PAN \
@ -1466,6 +1483,7 @@ $(eval $(call add_defines,\
ENABLE_FEAT_CSV2_2 \
ENABLE_FEAT_CSV2_3 \
ENABLE_FEAT_LS64_ACCDATA \
ENABLE_FEAT_MEC \
ENABLE_FEAT_PAN \
ENABLE_FEAT_TCR2 \
ENABLE_FEAT_THE \

View file

@ -1382,6 +1382,12 @@ Common build options
Management Extension. This flag can take the values 0 to 2, to align with
the ``ENABLE_FEAT`` mechanism. Default value is 0.
- ``ENABLE_FEAT_MEC``: Numeric value to enable support for the ARMv9.2 Memory
Encryption Contexts (MEC). This flag can take the values 0 to 2, to align
with the ``ENABLE_FEAT`` mechanism. MEC supports multiple encryption
contexts for Realm security state and only one encryption context for the
rest of the security states. Default value is 0.
- ``RMMD_ENABLE_EL3_TOKEN_SIGN``: Numeric value to enable support for singing
realm attestation token signing requests in EL3. This flag can take the
values 0 and 1. The default value is ``0``. When set to ``1``, this option

View file

@ -410,6 +410,9 @@
#define ID_AA64MMFR3_EL1_D128_MASK ULL(0xf)
#define D128_IMPLEMENTED ULL(0x1)
#define ID_AA64MMFR3_EL1_MEC_SHIFT U(28)
#define ID_AA64MMFR3_EL1_MEC_MASK ULL(0xf)
#define ID_AA64MMFR3_EL1_S2POE_SHIFT U(20)
#define ID_AA64MMFR3_EL1_S2POE_MASK ULL(0xf)
@ -617,6 +620,7 @@
#define SCR_FGTEN2_BIT (UL(1) << 59)
#define SCR_NSE_BIT (ULL(1) << SCR_NSE_SHIFT)
#define SCR_EnFPM_BIT (ULL(1) << 50)
#define SCR_MECEn_BIT (UL(1) << 49)
#define SCR_GPF_BIT (UL(1) << 48)
#define SCR_D128En_BIT (UL(1) << 47)
#define SCR_TWEDEL_SHIFT U(30)

View file

@ -373,6 +373,10 @@ CREATE_FEATURE_FUNCS(feat_rme, id_aa64pfr0_el1, ID_AA64PFR0_FEAT_RME_SHIFT,
CREATE_FEATURE_PRESENT(feat_sb, id_aa64isar1_el1, ID_AA64ISAR1_SB_SHIFT,
ID_AA64ISAR1_SB_MASK, 1U)
/* FEAT_MEC: Memory Encryption Contexts */
CREATE_FEATURE_FUNCS(feat_mec, id_aa64mmfr3_el1, ID_AA64MMFR3_EL1_MEC_SHIFT,
ID_AA64MMFR3_EL1_MEC_MASK, 1U, ENABLE_FEAT_MEC)
/*
* FEAT_CSV2: Cache Speculation Variant 2. This checks bit fields[56-59]
* of id_aa64pfr0_el1 register and can be used to check for below features:

View file

@ -125,6 +125,12 @@
#define SCR_FEAT_RAS (0)
#endif
#if ENABLE_FEAT_MEC
#define SCR_FEAT_MEC SCR_MECEn_BIT
#else
#define SCR_FEAT_MEC (0)
#endif
#ifndef SCR_PLAT_FEATS
#define SCR_PLAT_FEATS (0)
#endif
@ -195,6 +201,7 @@
SCR_IRQ_BIT | \
SCR_NS_BIT | \
SCR_RES1_BITS | \
SCR_FEAT_MEC | \
SCR_PLAT_IGNORED)
CASSERT((SCR_EL3_FEATS & SCR_EL3_IGNORED) == 0, scr_feat_is_ignored);
CASSERT((SCR_EL3_FLIPPED & SCR_EL3_FEATS) == SCR_EL3_FLIPPED, scr_flipped_not_a_feat);

View file

@ -548,6 +548,10 @@ static void setup_context_common(cpu_context_t *ctx, const entry_point_info_t *e
}
#endif /* (IMAGE_BL31 && defined(SPD_spmd) && SPMD_SPM_AT_SEL2) */
if (is_feat_mec_supported()) {
scr_el3 |= SCR_MECEn_BIT;
}
/*
* Populate EL3 state so that we've the right context
* before doing ERET

View file

@ -419,6 +419,9 @@ ENABLE_BRBE_FOR_NS ?= 0
# Flag to enable Floating point exception Mode Register Feature (FEAT_FPMR)
ENABLE_FEAT_FPMR ?= 0
# Flag to enable Memory Encryption Contexts (FEAT_MEC).
ENABLE_FEAT_MEC ?= 0
#----
# 9.3
#----

View file

@ -93,6 +93,10 @@ ENABLE_FEAT_SCTLR2 := 2
ENABLE_FEAT_MTE2 := 2
ENABLE_FEAT_LS64_ACCDATA := 2
ifeq (${ENABLE_RME},1)
ENABLE_FEAT_MEC := 2
endif
# The FVP platform depends on this macro to build with correct GIC driver.
$(eval $(call add_define,FVP_USE_GIC_DRIVER))