Merge "feat(rng-trap): add EL3 support for FEAT_RNG_TRAP" into integration

This commit is contained in:
Bipin Ravi 2022-08-18 22:24:41 +02:00 committed by TrustedFirmware Code Review
commit 3a41658864
8 changed files with 54 additions and 2 deletions

View file

@ -794,11 +794,15 @@ ifeq (${ARCH},aarch32)
$(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
endif
# BRBE is not supported in Aarch32
# BRBE is not supported in AArch32
ifeq (${ENABLE_BRBE_FOR_NS},1)
$(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
endif
# FEAT_RNG_TRAP is not supported in AArch32
ifeq (${ENABLE_FEAT_RNG_TRAP},1)
$(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
endif
endif
# Ensure ENABLE_RME is not used with SME
@ -1079,6 +1083,7 @@ $(eval $(call assert_numerics,\
ENABLE_FEAT_HCX \
ENABLE_FEAT_PAN \
ENABLE_FEAT_RNG \
ENABLE_FEAT_RNG_TRAP \
ENABLE_FEAT_SB \
ENABLE_FEAT_SEL2 \
ENABLE_FEAT_VHE \
@ -1190,6 +1195,7 @@ $(eval $(call add_defines,\
COT_DESC_IN_DTB \
USE_SP804_TIMER \
ENABLE_FEAT_RNG \
ENABLE_FEAT_RNG_TRAP \
ENABLE_FEAT_SB \
ENABLE_FEAT_DIT \
NR_OF_FW_BANKS \

View file

@ -125,6 +125,9 @@ subsections:
- title: Extended Cache Index (FEAT_CCIDX)
scope: ccidx
- title: Trapping support for RNDR/RNDRRS (FEAT_RNG_TRAP)
scope: rng-trap
- title: Platforms
subsections:

View file

@ -254,6 +254,16 @@ static void read_feat_trbe(void)
#endif
}
/******************************************************************
* Feature : FEAT_RNG_TRAP (Trapping support for RNDR/RNDRRS)
*****************************************************************/
static void read_feat_rng_trap(void)
{
#if (ENABLE_FEAT_RNG_TRAP == FEAT_STATE_1)
feat_detect_panic(is_feat_rng_trap_present(), "RNG_TRAP");
#endif
}
/***********************************************************************************
* TF-A supports many Arm architectural features starting from arch version
* (8.0 till 8.7+). These features are mostly enabled through build flags. This
@ -304,6 +314,7 @@ void detect_arch_features(void)
read_feat_mte();
read_feat_rng();
read_feat_bti();
read_feat_rng_trap();
/* v8.6 features */
read_feat_amuv1p1();

View file

@ -313,7 +313,13 @@ Common build options
- ``ENABLE_FEAT_RNG``: Numeric value to enable the ``FEAT_RNG`` extension.
``FEAT_RNG`` is an optional feature available on Arm v8.5 onwards. This
flag can take the values 0 to 2, to align with the ``FEATURE_DETECTION``
mechanism. Default is ``0``.
mechanism. Default value is ``0``.
- ``ENABLE_FEAT_RNG_TRAP``: Numeric value to enable the ``FEAT_RNG_TRAP``
extension. This feature is only supported in AArch64 state. This flag can
take values 0 to 2, to align with the ``FEATURE_DETECTION`` mechanism.
Default value is ``0``. ``FEAT_RNG_TRAP`` is an optional feature from
Armv8.5 onwards.
- ``ENABLE_FEAT_SB``: Numeric value to enable the ``FEAT_SB`` (Speculation
Barrier) extension allowing access to ``sb`` instruction. ``FEAT_SB`` is an

View file

@ -353,6 +353,12 @@
#define ID_AA64PFR1_EL1_MTE_SHIFT U(8)
#define ID_AA64PFR1_EL1_MTE_MASK ULL(0xf)
#define ID_AA64PFR1_EL1_RNDR_TRAP_SHIFT U(28)
#define ID_AA64PFR1_EL1_RNDR_TRAP_MASK U(0xf)
#define ID_AA64PFR1_EL1_RNG_TRAP_SUPPORTED ULL(0x1)
#define ID_AA64PFR1_EL1_RNG_TRAP_NOT_SUPPORTED ULL(0x0)
/* Memory Tagging Extension is not implemented */
#define MTE_UNIMPLEMENTED U(0)
/* FEAT_MTE: MTE instructions accessible at EL0 are implemented */
@ -485,6 +491,7 @@
#define SCR_GPF_BIT (UL(1) << 48)
#define SCR_TWEDEL_SHIFT U(30)
#define SCR_TWEDEL_MASK ULL(0xf)
#define SCR_TRNDR_BIT (UL(1) << 40)
#define SCR_HXEn_BIT (UL(1) << 38)
#define SCR_ENTP2_SHIFT U(41)
#define SCR_ENTP2_BIT (UL(1) << SCR_ENTP2_SHIFT)

View file

@ -129,6 +129,13 @@ static inline bool is_feat_hcx_present(void)
ID_AA64MMFR1_EL1_HCX_MASK) == ID_AA64MMFR1_EL1_HCX_SUPPORTED);
}
static inline bool is_feat_rng_trap_present(void)
{
return (((read_id_aa64pfr1_el1() >> ID_AA64PFR1_EL1_RNDR_TRAP_SHIFT) &
ID_AA64PFR1_EL1_RNDR_TRAP_MASK)
== ID_AA64PFR1_EL1_RNG_TRAP_SUPPORTED);
}
static inline unsigned int get_armv9_2_feat_rme_support(void)
{
/*

View file

@ -299,6 +299,14 @@ static void setup_context_common(cpu_context_t *ctx, const entry_point_info_t *e
scr_el3 |= SCR_HXEn_BIT;
#endif
/*
* If FEAT_RNG_TRAP is enabled, all reads of the RNDR and RNDRRS
* registers are trapped to EL3.
*/
#if ENABLE_FEAT_RNG_TRAP
scr_el3 |= SCR_TRNDR_BIT;
#endif
#if RAS_TRAP_LOWER_EL_ERR_ACCESS
/*
* SCR_EL3.TERR: Trap Error record accesses. Accesses to the RAS ERR

View file

@ -160,6 +160,10 @@ ENABLE_FEAT_PAN := 0
# Flag to enable access to the Random Number Generator registers
ENABLE_FEAT_RNG := 0
# Flag to enable support for EL3 trapping of reads of the RNDR and RNDRRS
# registers, by setting SCR_EL3.TRNDR.
ENABLE_FEAT_RNG_TRAP := 0
# Flag to enable Speculation Barrier Instruction
ENABLE_FEAT_SB := 0