Skip to content

Commit 357a640

Browse files
committed
core: arm: kernel: add runtime check for CE
Add runtime check during boot for Crypto Extensions if CFG_CRYPTO_WITH_CE=y. Link: OP-TEE#6631 Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
1 parent 8f63e88 commit 357a640

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

core/arch/arm/kernel/boot.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,29 @@ static void init_vfp_nsec(void)
188188
}
189189
#endif
190190

191+
/*
192+
* Check for supported Crypto Extensions (ARMv8 aarch32/aarch64)
193+
* In case one of instructions is not supported false is returned.
194+
*/
195+
static bool check_cpuid_ce(void)
196+
{
197+
uint32_t isar5 = read_isar5();
198+
199+
if (!(isar5 | ID_ISAR5_AES))
200+
return false;
201+
202+
if (!(isar5 | ID_ISAR5_SHA1))
203+
return false;
204+
205+
if (!(isar5 | ID_ISAR5_SHA2))
206+
return false;
207+
208+
if (!(isar5 | ID_ISAR5_CRC32))
209+
return false;
210+
211+
return true;
212+
}
213+
191214
#if defined(CFG_WITH_VFP)
192215

193216
#ifdef ARM32
@@ -1148,6 +1171,13 @@ static void init_primary(unsigned long pageable_part, unsigned long nsec_entry)
11481171
thread_set_exceptions(THREAD_EXCP_ALL);
11491172
primary_save_cntfrq();
11501173
init_vfp_sec();
1174+
1175+
if (IS_ENABLED(CFG_CRYPTO_WITH_CE) && !check_cpuid_ce()) {
1176+
EMSG("OP-TEE is built with CRYPTO_WITH_CE=y");
1177+
EMSG("But CE instructions are not supported by CPU");
1178+
panic();
1179+
}
1180+
11511181
/*
11521182
* Pager: init_runtime() calls thread_kernel_enable_vfp() so we must
11531183
* set a current thread right now to avoid a chicken-and-egg problem

0 commit comments

Comments
 (0)