@ -13,26 +13,14 @@
# if CTX_INCLUDE_EL2_REGS
.global el2_sysregs_context_save_common
.global el2_sysregs_context_restore_common
# if ENABLE_SPE_FOR_LOWER_ELS
.global el2_sysregs_context_save_spe
.global el2_sysregs_context_restore_spe
# endif / * ENABLE_SPE_FOR_LOWER_ELS * /
# if CTX_INCLUDE_MTE_REGS
.global el2_sysregs_context_save_mte
.global el2_sysregs_context_restore_mte
# endif / * CTX_INCLUDE_MTE_REGS * /
# if ENABLE_MPAM_FOR_LOWER_ELS
.global el2_sysregs_context_save_mpam
.global el2_sysregs_context_restore_mpam
# endif / * ENABLE_MPAM_FOR_LOWER_ELS * /
# if ENABLE_FEAT_ECV
.global el2_sysregs_context_save_ecv
.global el2_sysregs_context_restore_ecv
# endif / * ENABLE_FEAT_ECV * /
# if ENABLE_FEAT_VHE
.global el2_sysregs_context_save_vhe
.global el2_sysregs_context_restore_vhe
# endif / * ENABLE_FEAT_VHE * /
# if RAS_EXTENSION
.global el2_sysregs_context_save_ras
.global el2_sysregs_context_restore_ras
@ -220,20 +208,6 @@ func el2_sysregs_context_restore_common
ret
endfunc el2_sysregs_context_restore_common
# if ENABLE_SPE_FOR_LOWER_ELS
func el2_sysregs_context_save_spe
mrs x13 , PMSCR_EL2
str x13 , [ x0 , # CTX_PMSCR_EL2 ]
ret
endfunc el2_sysregs_context_save_spe
func el2_sysregs_context_restore_spe
ldr x13 , [ x0 , # CTX_PMSCR_EL2 ]
msr PMSCR_EL2 , x13
ret
endfunc el2_sysregs_context_restore_spe
# endif / * ENABLE_SPE_FOR_LOWER_ELS * /
# if CTX_INCLUDE_MTE_REGS
func el2_sysregs_context_save_mte
mrs x9 , TFSR_EL2
@ -248,208 +222,6 @@ func el2_sysregs_context_restore_mte
endfunc el2_sysregs_context_restore_mte
# endif / * CTX_INCLUDE_MTE_REGS * /
# if ENABLE_MPAM_FOR_LOWER_ELS
func el2_sysregs_context_save_mpam
mrs x10 , MPAM2_EL2
str x10 , [ x0 , # CTX_MPAM2_EL2 ]
mrs x10 , MPAMIDR_EL1
/ *
* The context registers that we intend to save would be part of the
* PE ' s system register frame only if MPAMIDR_EL1.HAS_HCR = = 1 .
* /
tbz w10 , # MPAMIDR_EL1_HAS_HCR_SHIFT , 3 f
/ *
* MPAMHCR_EL2 , MPAMVPMV_EL2 and MPAMVPM0_EL2 would be present in the
* system register frame if MPAMIDR_EL1.HAS_HCR = = 1 . Proceed to save
* the context of these registers.
* /
mrs x11 , MPAMHCR_EL2
mrs x12 , MPAMVPM0_EL2
stp x11 , x12 , [ x0 , # CTX_MPAMHCR_EL2 ]
mrs x13 , MPAMVPMV_EL2
str x13 , [ x0 , # CTX_MPAMVPMV_EL2 ]
/ *
* MPAMIDR_EL1.VPMR_MAX has to be probed to obtain the maximum supported
* VPMR value. Proceed to save the context of registers from
* MPAMVPM1_EL2 to MPAMVPM < x > _EL2 where x is VPMR_MAX. From MPAM spec ,
* VPMR_MAX should not be zero if HAS_HCR = = 1 .
* /
ubfx x10 , x10 , # MPAMIDR_EL1_VPMR_MAX_SHIFT , \
# MPAMIDR_EL1_VPMR_MAX_WIDTH
/ *
* Once VPMR_MAX has been identified , calculate the offset relative to
* PC to jump to so that relevant context can be saved. The offset is
* calculated as ( VPMR_POSSIBLE_MAX - VPMR_MAX ) * ( instruction size for
* saving one VPM register ) + ( absolute address of label " 1 " ).
* /
mov w11 , # MPAMIDR_EL1_VPMR_MAX_POSSIBLE
sub w10 , w11 , w10
/ * Calculate the size of one block of MPAMVPM * _EL2 save * /
adr x11 , 1 f
adr x12 , 2 f
sub x12 , x12 , x11
madd x10 , x10 , x12 , x11
br x10
/ *
* The branch above would land properly on one of the blocks following
* label " 1 " . Make sure that the order of save is retained.
* /
1 :
# if ENABLE_BTI
bti j
# endif
mrs x10 , MPAMVPM7_EL2
str x10 , [ x0 , # CTX_MPAMVPM7_EL2 ]
2 :
# if ENABLE_BTI
bti j
# endif
mrs x11 , MPAMVPM6_EL2
str x11 , [ x0 , # CTX_MPAMVPM6_EL2 ]
# if ENABLE_BTI
bti j
# endif
mrs x12 , MPAMVPM5_EL2
str x12 , [ x0 , # CTX_MPAMVPM5_EL2 ]
# if ENABLE_BTI
bti j
# endif
mrs x13 , MPAMVPM4_EL2
str x13 , [ x0 , # CTX_MPAMVPM4_EL2 ]
# if ENABLE_BTI
bti j
# endif
mrs x14 , MPAMVPM3_EL2
str x14 , [ x0 , # CTX_MPAMVPM3_EL2 ]
# if ENABLE_BTI
bti j
# endif
mrs x15 , MPAMVPM2_EL2
str x15 , [ x0 , # CTX_MPAMVPM2_EL2 ]
# if ENABLE_BTI
bti j
# endif
mrs x16 , MPAMVPM1_EL2
str x16 , [ x0 , # CTX_MPAMVPM1_EL2 ]
3 : ret
endfunc el2_sysregs_context_save_mpam
func el2_sysregs_context_restore_mpam
ldr x10 , [ x0 , # CTX_MPAM2_EL2 ]
msr MPAM2_EL2 , x10
mrs x10 , MPAMIDR_EL1
/ *
* The context registers that we intend to restore would be part of the
* PE ' s system register frame only if MPAMIDR_EL1.HAS_HCR = = 1 .
* /
tbz w10 , # MPAMIDR_EL1_HAS_HCR_SHIFT , 3 f
/ *
* MPAMHCR_EL2 , MPAMVPMV_EL2 and MPAMVPM0_EL2 would be present in the
* system register frame if MPAMIDR_EL1.HAS_HCR = = 1 . Proceed to restore
* the context of these registers
* /
ldp x11 , x12 , [ x0 , # CTX_MPAMHCR_EL2 ]
msr MPAMHCR_EL2 , x11
msr MPAMVPM0_EL2 , x12
ldr x13 , [ x0 , # CTX_MPAMVPMV_EL2 ]
msr MPAMVPMV_EL2 , x13
/ *
* MPAMIDR_EL1.VPMR_MAX has to be probed to obtain the maximum supported
* VPMR value. Proceed to restore the context of registers from
* MPAMVPM1_EL2 to MPAMVPM < x > _EL2 where x is VPMR_MAX. from MPAM spec ,
* VPMR_MAX should not be zero if HAS_HCR = = 1 .
* /
ubfx x10 , x10 , # MPAMIDR_EL1_VPMR_MAX_SHIFT , \
# MPAMIDR_EL1_VPMR_MAX_WIDTH
/ *
* Once VPMR_MAX has been identified , calculate the offset relative to
* PC to jump to so that relevant context can be restored. The offset is
* calculated as ( VPMR_POSSIBLE_MAX - VPMR_MAX ) * ( instruction size for
* restoring one VPM register ) + ( absolute address of label " 1 " ).
* /
mov w11 , # MPAMIDR_EL1_VPMR_MAX_POSSIBLE
sub w10 , w11 , w10
/ * Calculate the size of one block of MPAMVPM * _EL2 restore * /
adr x11 , 1 f
adr x12 , 2 f
sub x12 , x12 , x11
madd x10 , x10 , x12 , x11
br x10
/ *
* The branch above would land properly on one of the blocks following
* label " 1 " . Make sure that the order of restore is retained.
* /
1 :
# if ENABLE_BTI
bti j
# endif
ldr x10 , [ x0 , # CTX_MPAMVPM7_EL2 ]
msr MPAMVPM7_EL2 , x10
2 :
# if ENABLE_BTI
bti j
# endif
ldr x11 , [ x0 , # CTX_MPAMVPM6_EL2 ]
msr MPAMVPM6_EL2 , x11
# if ENABLE_BTI
bti j
# endif
ldr x12 , [ x0 , # CTX_MPAMVPM5_EL2 ]
msr MPAMVPM5_EL2 , x12
# if ENABLE_BTI
bti j
# endif
ldr x13 , [ x0 , # CTX_MPAMVPM4_EL2 ]
msr MPAMVPM4_EL2 , x13
# if ENABLE_BTI
bti j
# endif
ldr x14 , [ x0 , # CTX_MPAMVPM3_EL2 ]
msr MPAMVPM3_EL2 , x14
# if ENABLE_BTI
bti j
# endif
ldr x15 , [ x0 , # CTX_MPAMVPM2_EL2 ]
msr MPAMVPM2_EL2 , x15
# if ENABLE_BTI
bti j
# endif
ldr x16 , [ x0 , # CTX_MPAMVPM1_EL2 ]
msr MPAMVPM1_EL2 , x16
3 : ret
endfunc el2_sysregs_context_restore_mpam
# endif / * ENABLE_MPAM_FOR_LOWER_ELS * /
# if ENABLE_FEAT_ECV
func el2_sysregs_context_save_ecv
mrs x11 , CNTPOFF_EL2
@ -464,30 +236,6 @@ func el2_sysregs_context_restore_ecv
endfunc el2_sysregs_context_restore_ecv
# endif / * ENABLE_FEAT_ECV * /
# if ENABLE_FEAT_VHE
func el2_sysregs_context_save_vhe
/ *
* CONTEXTIDR_EL2 register is saved only when FEAT_VHE or
* FEAT_Debugv8p2 ( currently not in TF-A ) is supported.
* /
mrs x9 , contextidr_el2
mrs x10 , ttbr1_el2
stp x9 , x10 , [ x0 , # CTX_CONTEXTIDR_EL2 ]
ret
endfunc el2_sysregs_context_save_vhe
func el2_sysregs_context_restore_vhe
/ *
* CONTEXTIDR_EL2 register is restored only when FEAT_VHE or
* FEAT_Debugv8p2 ( currently not in TF-A ) is supported.
* /
ldp x9 , x10 , [ x0 , # CTX_CONTEXTIDR_EL2 ]
msr contextidr_el2 , x9
msr ttbr1_el2 , x10
ret
endfunc el2_sysregs_context_restore_vhe
# endif / * ENABLE_FEAT_VHE * /
# if RAS_EXTENSION
func el2_sysregs_context_save_ras
/ *