@ -279,10 +279,54 @@
# define CTX_CVE_2018_3639_DISABLE U(0)
# define CTX_CVE_2018_3639_END U(0x10) /* Align to the next 16 byte boundary */
/*******************************************************************************
* Registers related to ERRATA_SPECULATIVE_AT
*
* This is essential as with EL1 and EL2 context registers being decoupled ,
* both will not be present for a given build configuration .
* As ERRATA_SPECULATIVE_AT errata requires SCTLR_EL1 and TCR_EL1 registers
* independent of the above logic , we need explicit context entries to be
* reserved for these registers .
*
* NOTE : Based on this we end up with following different configurations depending
* on the presence of errata and inclusion of EL1 or EL2 context .
*
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* | ERRATA_SPECULATIVE_AT | EL1 context | Memory allocation ( Sctlr_el1 , Tcr_el1 ) |
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* | 0 | 0 | None |
* | 0 | 1 | EL1 C - Context structure |
* | 1 | 0 | Errata Context Offset Entries |
* | 1 | 1 | Errata Context Offset Entries |
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*
* In the above table , when ERRATA_SPECULATIVE_AT = 1 , EL1_Context = 0 , it implies
* there is only EL2 context and memory for SCTLR_EL1 and TCR_EL1 registers is
* reserved explicitly under ERRATA_SPECULATIVE_AT build flag here .
*
* In situations when EL1_Context = 1 and ERRATA_SPECULATIVE_AT = 1 , since SCTLR_EL1
* and TCR_EL1 registers will be modified under errata and it happens at the
* early in the codeflow prior to el1 context ( save and restore operations ) ,
* context memory still will be reserved under the errata logic here explicitly .
* These registers will not be part of EL1 context save & restore routines .
*
* Only when ERRATA_SPECULATIVE_AT = 0 , EL1_Context = 1 , for this combination ,
* SCTLR_EL1 and TCR_EL1 will be part of EL1 context structure ( context_el1 . h )
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# define CTX_ERRATA_SPEC_AT_OFFSET (CTX_CVE_2018_3639_OFFSET + CTX_CVE_2018_3639_END)
# if ERRATA_SPECULATIVE_AT
# define CTX_ERRATA_SPEC_AT_SCTLR_EL1 U(0x0)
# define CTX_ERRATA_SPEC_AT_TCR_EL1 U(0x8)
# define CTX_ERRATA_SPEC_AT_END U(0x10) /* Align to the next 16 byte boundary */
# else
# define CTX_ERRATA_SPEC_AT_END U(0x0)
# endif /* ERRATA_SPECULATIVE_AT */
/*******************************************************************************
* Registers related to ARMv8 .3 - PAuth .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# define CTX_PAUTH_REGS_OFFSET (CTX_CVE_2018_3639_OFFSET + CTX_CVE_2018_3639_END)
# define CTX_PAUTH_REGS_OFFSET (CTX_ERRATA_SPEC_AT_OFFSET + CTX_ERRATA_SPEC_AT _END)
# if CTX_INCLUDE_PAUTH_REGS
# define CTX_PACIAKEY_LO U(0x0)
# define CTX_PACIAKEY_HI U(0x8)
@ -332,6 +376,10 @@
# endif
# define CTX_EL3STATE_ALL (CTX_EL3STATE_END >> DWORD_SHIFT)
# define CTX_CVE_2018_3639_ALL (CTX_CVE_2018_3639_END >> DWORD_SHIFT)
# if ERRATA_SPECULATIVE_AT
# define CTX_ERRATA_SPEC_AT_ALL (CTX_ERRATA_SPEC_AT_END >> DWORD_SHIFT)
# endif
# if CTX_INCLUDE_PAUTH_REGS
# define CTX_PAUTH_REGS_ALL (CTX_PAUTH_REGS_END >> DWORD_SHIFT)
# endif
@ -369,6 +417,11 @@ DEFINE_REG_STRUCT(el3_state, CTX_EL3STATE_ALL);
/* Function pointer used by CVE-2018-3639 dynamic mitigation */
DEFINE_REG_STRUCT ( cve_2018_3639 , CTX_CVE_2018_3639_ALL ) ;
/* Registers associated to Errata_Speculative */
# if ERRATA_SPECULATIVE_AT
DEFINE_REG_STRUCT ( errata_speculative_at , CTX_ERRATA_SPEC_AT_ALL ) ;
# endif
/* Registers associated to ARMv8.3-PAuth */
# if CTX_INCLUDE_PAUTH_REGS
DEFINE_REG_STRUCT ( pauth , CTX_PAUTH_REGS_ALL ) ;
@ -400,6 +453,10 @@ typedef struct cpu_context {
# endif
cve_2018_3639_t cve_2018_3639_ctx ;
# if ERRATA_SPECULATIVE_AT
errata_speculative_at_t errata_speculative_at_ctx ;
# endif
# if CTX_INCLUDE_PAUTH_REGS
pauth_t pauth_ctx ;
# endif
@ -433,6 +490,11 @@ extern per_world_context_t per_world_context[CPU_DATA_CONTEXT_NUM];
# endif
# define get_gpregs_ctx(h) (&((cpu_context_t *) h)->gpregs_ctx)
# define get_cve_2018_3639_ctx(h) (&((cpu_context_t *) h)->cve_2018_3639_ctx)
# if ERRATA_SPECULATIVE_AT
# define get_errata_speculative_at_ctx(h) (&((cpu_context_t *) h)->errata_speculative_at_ctx)
# endif
# if CTX_INCLUDE_PAUTH_REGS
# define get_pauth_ctx(h) (&((cpu_context_t *) h)->pauth_ctx)
# endif
@ -459,6 +521,11 @@ CASSERT(CTX_FPREGS_OFFSET == __builtin_offsetof(cpu_context_t, fpregs_ctx),
CASSERT ( CTX_CVE_2018_3639_OFFSET = = __builtin_offsetof ( cpu_context_t , cve_2018_3639_ctx ) ,
assert_core_context_cve_2018_3639_offset_mismatch ) ;
# if ERRATA_SPECULATIVE_AT
CASSERT ( CTX_ERRATA_SPEC_AT_OFFSET = = __builtin_offsetof ( cpu_context_t , errata_speculative_at_ctx ) ,
assert_core_context_errata_speculative_at_offset_mismatch ) ;
# endif
# if CTX_INCLUDE_PAUTH_REGS
CASSERT ( CTX_PAUTH_REGS_OFFSET = = __builtin_offsetof ( cpu_context_t , pauth_ctx ) ,
assert_core_context_pauth_offset_mismatch ) ;