diff --git a/Makefile b/Makefile index b6c8b210cb8f905d0ea783720a6f42c091765d6d..24096e1ef67ed1ba5c84d056601386bcf6afc038 100644 --- a/Makefile +++ b/Makefile @@ -245,6 +245,13 @@ endif # arch-features # Determine if FEAT_RNG is supported ENABLE_FEAT_RNG = $(if $(findstring rng,${arch-features}),1,0) +# Determine if FEAT_SB is supported +ENABLE_FEAT_SB = $(if $(findstring sb,${arch-features}),1,0) + +ifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))" +ENABLE_FEAT_SB = 1 +endif + ifneq ($(findstring armclang,$(notdir $(CC))),) TF_CFLAGS_aarch32 = -target arm-arm-none-eabi $(march32-directive) TF_CFLAGS_aarch64 = -target aarch64-arm-none-eabi $(march64-directive) @@ -945,6 +952,7 @@ $(eval $(call assert_booleans,\ COT_DESC_IN_DTB \ USE_SP804_TIMER \ ENABLE_FEAT_RNG \ + ENABLE_FEAT_SB \ ))) $(eval $(call assert_numerics,\ @@ -1038,6 +1046,7 @@ $(eval $(call add_defines,\ COT_DESC_IN_DTB \ USE_SP804_TIMER \ ENABLE_FEAT_RNG \ + ENABLE_FEAT_SB \ ))) ifeq (${SANITIZE_UB},trap) diff --git a/include/arch/aarch32/asm_macros.S b/include/arch/aarch32/asm_macros.S index f75da0ce62e7724828a275b50500c8c55ae16ee7..483f9fe056c8a249e5e93b9f894b29ee7eed6e6a 100644 --- a/include/arch/aarch32/asm_macros.S +++ b/include/arch/aarch32/asm_macros.S @@ -107,12 +107,12 @@ #else /* - * Macro for mitigating against speculative execution beyond ERET. - * If possible use Speculation Barrier instruction defined in ARMv8.5 + * Macro for mitigating against speculative execution beyond ERET. Uses the + * speculation barrier instruction introduced by FEAT_SB, if it's enabled. */ .macro exception_return eret -#if ARM_ARCH_AT_LEAST(8, 5) +#if ENABLE_FEAT_SB sb #else dsb nsh diff --git a/include/arch/aarch64/asm_macros.S b/include/arch/aarch64/asm_macros.S index cbb9f0be8fa2128a51681c92b75ddb4da6491e3d..464c05be1aa40da966d35016f46475b7fe3aa41f 100644 --- a/include/arch/aarch64/asm_macros.S +++ b/include/arch/aarch64/asm_macros.S @@ -219,12 +219,12 @@ .endm /* - * Macro for mitigating against speculative execution beyond ERET. - * If possible use Speculation Barrier instruction defined in ARMv8.5 + * Macro for mitigating against speculative execution beyond ERET. Uses the + * speculation barrier instruction introduced by FEAT_SB, if it's enabled. */ .macro exception_return eret -#if ARM_ARCH_AT_LEAST(8, 5) +#if ENABLE_FEAT_SB sb #else dsb nsh