Skip to content

Commit 86e2e88

Browse files
committed
arm: crypto: add a check for crypto extensions support.
In some configuration the CPU may raise an exception bacause of an unknown instruction if it does not support Crypto Extensions for example in some BCM281X (RPi3B in my case) when running barebox as an EFI Payload, where the EFI stops with a synchronous execption See bellow: Synchronous Exception at 0x0000000037BFF548 SP 0x0000000037F798C0 ELR 0x0000000037BFF548 SPSR 0x20000209 FPSR 0x00000000 ESR 0x02000000 FAR 0x14F64325185430BF ESR : EC 0x00 IL 0x1 ISS 0x00000000 Signed-off-by: Chali Anis <chalianis1@gmail.com>
1 parent c7807f8 commit 86e2e88

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

arch/arm/crypto/sha1-ce-glue.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ static struct digest_algo m = {
8888

8989
static int sha1_ce_mod_init(void)
9090
{
91+
uint64_t isar0;
92+
93+
asm volatile("mrs %0, ID_AA64ISAR0_EL1" : "=r"(isar0));
94+
if (!(isar0 & 0xF00))
95+
return -EOPNOTSUPP;
96+
9197
return digest_algo_register(&m);
9298
}
9399
coredevice_initcall(sha1_ce_mod_init);

arch/arm/crypto/sha2-ce-glue.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ static struct digest_algo sha256 = {
116116

117117
static int sha256_ce_digest_register(void)
118118
{
119+
uint64_t isar0;
120+
121+
asm volatile("mrs %0, ID_AA64ISAR0_EL1" : "=r"(isar0));
122+
if (!(isar0 & 0xF000))
123+
return -EOPNOTSUPP;
124+
119125
return digest_algo_register(&sha256);
120126
}
121127
coredevice_initcall(sha256_ce_digest_register);

0 commit comments

Comments
 (0)