Merge changes from topic "jc/AMUv1" into integration

* changes:
  docs(build-options): add build macros for features FGT,AMUv1 and ECV
  fix(amu): fault handling on EL2 context switch
This commit is contained in:
Manish Pandey 2021-12-13 13:52:37 +01:00 committed by TrustedFirmware Code Review
commit a5645148a6
5 changed files with 59 additions and 11 deletions

View file

@ -267,6 +267,16 @@ ifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
ENABLE_FEAT_SB = 1 ENABLE_FEAT_SB = 1
endif endif
# Determine and enable FEAT_FGT to access HDFGRTR_EL2 register for v8.6 and higher versions.
ifeq "8.6" "$(word 1, $(sort 8.6 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
ENABLE_FEAT_FGT = 1
endif
# Determine and enable FEAT_ECV to access CNTPOFF_EL2 register for v8.6 and higher versions.
ifeq "8.6" "$(word 1, $(sort 8.6 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
ENABLE_FEAT_ECV = 1
endif
ifneq ($(findstring armclang,$(notdir $(CC))),) ifneq ($(findstring armclang,$(notdir $(CC))),)
TF_CFLAGS_aarch32 = -target arm-arm-none-eabi $(march32-directive) TF_CFLAGS_aarch32 = -target arm-arm-none-eabi $(march32-directive)
TF_CFLAGS_aarch64 = -target aarch64-arm-none-eabi $(march64-directive) TF_CFLAGS_aarch64 = -target aarch64-arm-none-eabi $(march64-directive)
@ -1041,6 +1051,9 @@ $(eval $(call assert_booleans,\
ENABLE_FEAT_HCX \ ENABLE_FEAT_HCX \
ENABLE_MPMM \ ENABLE_MPMM \
ENABLE_MPMM_FCONF \ ENABLE_MPMM_FCONF \
ENABLE_FEAT_FGT \
ENABLE_FEAT_AMUv1 \
ENABLE_FEAT_ECV \
))) )))
$(eval $(call assert_numerics,\ $(eval $(call assert_numerics,\
@ -1153,6 +1166,9 @@ $(eval $(call add_defines,\
ENABLE_FEAT_HCX \ ENABLE_FEAT_HCX \
ENABLE_MPMM \ ENABLE_MPMM \
ENABLE_MPMM_FCONF \ ENABLE_MPMM_FCONF \
ENABLE_FEAT_FGT \
ENABLE_FEAT_AMUv1 \
ENABLE_FEAT_ECV \
))) )))
ifeq (${SANITIZE_UB},trap) ifeq (${SANITIZE_UB},trap)

View file

@ -246,6 +246,24 @@ Common build options
builds, but this behaviour can be overridden in each platform's Makefile or builds, but this behaviour can be overridden in each platform's Makefile or
in the build command line. in the build command line.
- ``ENABLE_FEAT_AMUv1``: Boolean option to enable access to the HAFGRTR_EL2
(Hypervisor Activity Monitors Fine-Grained Read Trap Register) during EL2
to EL3 context save/restore operations. It is an optional feature available
on v8.4 and onwards and must be set to 1 alongside ``ENABLE_FEAT_FGT``, to
access the HAFGRTR_EL2 register. Defaults to ``0``.
- ``ENABLE_FEAT_ECV``: Boolean option to enable support for the Enhanced Counter
Virtualization feature, allowing for access to the CNTPOFF_EL2 (Counter-timer
Physical Offset register) during EL2 to EL3 context save/restore operations.
Its a mandatory architectural feature in Armv8.6 and defaults to ``1`` for
v8.6 or later CPUs.
- ``ENABLE_FEAT_FGT``: Boolean option to enable support for FGT (Fine Grain Traps)
feature allowing for access to the HDFGRTR_EL2 (Hypervisor Debug Fine-Grained
Read Trap Register) during EL2 to EL3 context save/restore operations.
Its a mandatory architectural feature in Armv8.6 and defaults to ``1`` for
v8.6 or later CPUs.
- ``ENABLE_FEAT_HCX``: This option sets the bit SCR_EL3.HXEn in EL3 to allow - ``ENABLE_FEAT_HCX``: This option sets the bit SCR_EL3.HXEn in EL3 to allow
access to HCRX_EL2 (extended hypervisor control register) from EL2 as well as access to HCRX_EL2 (extended hypervisor control register) from EL2 as well as
adding HCRX_EL2 to the EL2 context save/restore operations. adding HCRX_EL2 to the EL2 context save/restore operations.

View file

@ -207,8 +207,8 @@
#define CTX_MPAMVPMV_EL2 U(0x158) #define CTX_MPAMVPMV_EL2 U(0x158)
// Starting with Armv8.6 // Starting with Armv8.6
#define CTX_HAFGRTR_EL2 U(0x160) #define CTX_HDFGRTR_EL2 U(0x160)
#define CTX_HDFGRTR_EL2 U(0x168) #define CTX_HAFGRTR_EL2 U(0x168)
#define CTX_HDFGWTR_EL2 U(0x170) #define CTX_HDFGWTR_EL2 U(0x170)
#define CTX_HFGITR_EL2 U(0x178) #define CTX_HFGITR_EL2 U(0x178)
#define CTX_HFGRTR_EL2 U(0x180) #define CTX_HFGRTR_EL2 U(0x180)

View file

@ -145,11 +145,14 @@ func el2_sysregs_context_save
stp x11, x12, [x0, #CTX_MPAMVPM7_EL2] stp x11, x12, [x0, #CTX_MPAMVPM7_EL2]
#endif #endif
#if ARM_ARCH_AT_LEAST(8, 6) #if ENABLE_FEAT_FGT
mrs x13, HAFGRTR_EL2 mrs x13, HDFGRTR_EL2
mrs x14, HDFGRTR_EL2 #if ENABLE_FEAT_AMUv1
stp x13, x14, [x0, #CTX_HAFGRTR_EL2] mrs x14, HAFGRTR_EL2
stp x13, x14, [x0, #CTX_HDFGRTR_EL2]
#else
str x13, [x0, #CTX_HDFGRTR_EL2]
#endif
mrs x15, HDFGWTR_EL2 mrs x15, HDFGWTR_EL2
mrs x16, HFGITR_EL2 mrs x16, HFGITR_EL2
stp x15, x16, [x0, #CTX_HDFGWTR_EL2] stp x15, x16, [x0, #CTX_HDFGWTR_EL2]
@ -157,7 +160,9 @@ func el2_sysregs_context_save
mrs x9, HFGRTR_EL2 mrs x9, HFGRTR_EL2
mrs x10, HFGWTR_EL2 mrs x10, HFGWTR_EL2
stp x9, x10, [x0, #CTX_HFGRTR_EL2] stp x9, x10, [x0, #CTX_HFGRTR_EL2]
#endif
#if ENABLE_FEAT_ECV
mrs x11, CNTPOFF_EL2 mrs x11, CNTPOFF_EL2
str x11, [x0, #CTX_CNTPOFF_EL2] str x11, [x0, #CTX_CNTPOFF_EL2]
#endif #endif
@ -319,10 +324,14 @@ func el2_sysregs_context_restore
msr MPAMVPMV_EL2, x12 msr MPAMVPMV_EL2, x12
#endif #endif
#if ARM_ARCH_AT_LEAST(8, 6) #if ENABLE_FEAT_FGT
ldp x13, x14, [x0, #CTX_HAFGRTR_EL2] #if ENABLE_FEAT_AMUv1
msr HAFGRTR_EL2, x13 ldp x13, x14, [x0, #CTX_HDFGRTR_EL2]
msr HDFGRTR_EL2, x14 msr HAFGRTR_EL2, x14
#else
ldr x13, [x0, #CTX_HDFGRTR_EL2]
#endif
msr HDFGRTR_EL2, x13
ldp x15, x16, [x0, #CTX_HDFGWTR_EL2] ldp x15, x16, [x0, #CTX_HDFGWTR_EL2]
msr HDFGWTR_EL2, x15 msr HDFGWTR_EL2, x15
@ -331,7 +340,9 @@ func el2_sysregs_context_restore
ldp x9, x10, [x0, #CTX_HFGRTR_EL2] ldp x9, x10, [x0, #CTX_HFGRTR_EL2]
msr HFGRTR_EL2, x9 msr HFGRTR_EL2, x9
msr HFGWTR_EL2, x10 msr HFGWTR_EL2, x10
#endif
#if ENABLE_FEAT_ECV
ldr x11, [x0, #CTX_CNTPOFF_EL2] ldr x11, [x0, #CTX_CNTPOFF_EL2]
msr CNTPOFF_EL2, x11 msr CNTPOFF_EL2, x11
#endif #endif

View file

@ -136,6 +136,9 @@ ENABLE_PAUTH := 0
# Flag to enable access to the HCRX_EL2 register by setting SCR_EL3.HXEn. # Flag to enable access to the HCRX_EL2 register by setting SCR_EL3.HXEn.
ENABLE_FEAT_HCX := 0 ENABLE_FEAT_HCX := 0
# Flag to enable access to the HAFGRTR_EL2 register
ENABLE_FEAT_AMUv1 := 0
# By default BL31 encryption disabled # By default BL31 encryption disabled
ENCRYPT_BL31 := 0 ENCRYPT_BL31 := 0