Browse Source

feat(pauth): add/modify helpers to support QARMA3

QARMA3 is a pointer authentication algorithm that generates
the PAC codes.

The is_armv8_3_pauth_present() helper was modified in order to
consider the presence of the QARMA3 algorithm (i.e.: when
ID_AA64ISAR2_EL1.{GPA3, APA3} fields are not 0.

In addition, helper is_feat_pacqarma3_present() was implemented to
explicitly detect the presence of QARMA3 algorithm.

Signed-off-by: Juan Pablo Conde <juanpablo.conde@arm.com>
Change-Id: I68e8fa7f8b7ca50d74ae0a2f5f182236d68f3d7b
pull/1988/head
Juan Pablo Conde 2 years ago
parent
commit
9ff5f754ae
  1. 9
      include/arch/aarch64/arch.h
  2. 21
      include/arch/aarch64/arch_features.h
  3. 1
      include/arch/aarch64/arch_helpers.h

9
include/arch/aarch64/arch.h

@ -261,6 +261,15 @@
#define ID_AA64ISAR1_SB_SUPPORTED ULL(0x1)
#define ID_AA64ISAR1_SB_NOT_SUPPORTED ULL(0x0)
/* ID_AA64ISAR2_EL1 definitions */
#define ID_AA64ISAR2_EL1 S3_0_C0_C6_2
#define ID_AA64ISAR2_GPA3_SHIFT U(8)
#define ID_AA64ISAR2_GPA3_MASK ULL(0xf)
#define ID_AA64ISAR2_APA3_SHIFT U(12)
#define ID_AA64ISAR2_APA3_MASK ULL(0xf)
/* ID_AA64MMFR0_EL1 definitions */
#define ID_AA64MMFR0_EL1_PARANGE_SHIFT U(0)
#define ID_AA64MMFR0_EL1_PARANGE_MASK ULL(0xf)

21
include/arch/aarch64/arch_features.h

@ -35,15 +35,30 @@ static inline bool is_armv8_2_ttcnp_present(void)
ID_AA64MMFR2_EL1_CNP_MASK) != 0U;
}
static inline bool is_feat_pacqarma3_present(void)
{
uint64_t mask_id_aa64isar2 =
(ID_AA64ISAR2_GPA3_MASK << ID_AA64ISAR2_GPA3_SHIFT) |
(ID_AA64ISAR2_APA3_MASK << ID_AA64ISAR2_APA3_SHIFT);
/* If any of the fields is not zero, QARMA3 algorithm is present */
return (read_id_aa64isar2_el1() & mask_id_aa64isar2) != 0U;
}
static inline bool is_armv8_3_pauth_present(void)
{
uint64_t mask = (ID_AA64ISAR1_GPI_MASK << ID_AA64ISAR1_GPI_SHIFT) |
uint64_t mask_id_aa64isar1 =
(ID_AA64ISAR1_GPI_MASK << ID_AA64ISAR1_GPI_SHIFT) |
(ID_AA64ISAR1_GPA_MASK << ID_AA64ISAR1_GPA_SHIFT) |
(ID_AA64ISAR1_API_MASK << ID_AA64ISAR1_API_SHIFT) |
(ID_AA64ISAR1_APA_MASK << ID_AA64ISAR1_APA_SHIFT);
/* If any of the fields is not zero, PAuth is present */
return (read_id_aa64isar1_el1() & mask) != 0U;
/*
* If any of the fields is not zero or QARMA3 is present,
* PAuth is present
*/
return ((read_id_aa64isar1_el1() & mask_id_aa64isar1) != 0U ||
is_feat_pacqarma3_present());
}
static inline bool is_armv8_4_dit_present(void)

1
include/arch/aarch64/arch_helpers.h

@ -250,6 +250,7 @@ DEFINE_SYSREG_RW_FUNCS(par_el1)
DEFINE_SYSREG_READ_FUNC(id_pfr1_el1)
DEFINE_SYSREG_READ_FUNC(id_aa64isar0_el1)
DEFINE_SYSREG_READ_FUNC(id_aa64isar1_el1)
DEFINE_RENAME_SYSREG_READ_FUNC(id_aa64isar2_el1, ID_AA64ISAR2_EL1)
DEFINE_SYSREG_READ_FUNC(id_aa64pfr0_el1)
DEFINE_SYSREG_READ_FUNC(id_aa64pfr1_el1)
DEFINE_SYSREG_READ_FUNC(id_aa64dfr0_el1)

Loading…
Cancel
Save