Skip to content

Commit

Permalink
core: arm: add helper functions for checking CE support
Browse files Browse the repository at this point in the history
Add helper functions for checking implementation of SHA1, SHA256,
SHA512, SHA3, SM3, SM4 instructions.

Acked-by: Etienne Carriere <[email protected]>
Reviewed-by: Jerome Forissier <[email protected]>
Acked-by: Jens Wiklander <[email protected]>
Signed-off-by: Igor Opaniuk <[email protected]>
  • Loading branch information
igoropaniuk authored and jforissier committed Feb 27, 2024
1 parent a0635f1 commit f73f678
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions core/arch/arm/include/arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,70 @@ static inline bool feat_crc32_implemented(void)
#endif
}

static inline bool feat_aes_implemented(void)
{
#ifdef ARM32
return read_id_isar5() & ID_ISAR5_AES;
#else
return read_id_aa64isar0_el1() & ID_AA64ISAR0_AES;
#endif
}

static inline bool feat_sha1_implemented(void)
{
#ifdef ARM32
return read_id_isar5() & ID_ISAR5_SHA1;
#else
return read_id_aa64isar0_el1() & ID_AA64ISAR0_SHA1;
#endif
}

static inline bool feat_sha256_implemented(void)
{
#ifdef ARM32
return read_id_isar5() & ID_ISAR5_SHA2;
#else
return read_id_aa64isar0_el1() & ID_AA64ISAR0_SHA2;
#endif
}

static inline bool feat_sha512_implemented(void)
{
#ifdef ARM32
return false;
#else
return ((read_id_aa64isar0_el1() & ID_AA64ISAR0_SHA2) >>
ID_AA64ISAR0_SHA2_SHIFT) == ID_AA64ISAR0_SHA2_FEAT_SHA512;
#endif
}

static inline bool feat_sha3_implemented(void)
{
#ifdef ARM32
return false;
#else
return read_id_aa64isar0_el1() & ID_AA64ISAR0_SHA3;
#endif
}

static inline bool feat_sm3_implemented(void)
{
#ifdef ARM32
return false;
#else
return read_id_aa64isar0_el1() & ID_AA64ISAR0_SM3;
#endif
}

static inline bool feat_sm4_implemented(void)
{
#ifdef ARM32
return false;
#else
return read_id_aa64isar0_el1() & ID_AA64ISAR0_SM4;
#endif
}

static inline bool feat_pauth_is_implemented(void)
{
#ifdef ARM32
Expand Down

0 comments on commit f73f678

Please sign in to comment.