1 /* 2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <arch_helpers.h> 8 #include <debug.h> 9 #include <utils.h> 10 #include "juno_decl.h" 11 #include "juno_def.h" 12 plat_get_stack_protector_canary(void)13u_register_t plat_get_stack_protector_canary(void) 14 { 15 u_register_t c[TRNG_NBYTES / sizeof(u_register_t)]; 16 u_register_t ret = 0; 17 size_t i; 18 19 if (juno_getentropy(c, sizeof(c)) != 0) { 20 ERROR("Not enough entropy to initialize canary value\n"); 21 panic(); 22 } 23 24 /* 25 * On Juno we get 128-bits of entropy in one round. 26 * Fuse the values together to form the canary. 27 */ 28 for (i = 0; i < ARRAY_SIZE(c); i++) 29 ret ^= c[i]; 30 return ret; 31 } 32