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 <common/debug.h> 9 #include <lib/utils.h> 10 #include <plat/common/plat_trng.h> 11 #include <platform_def.h> 12 plat_get_stack_protector_canary(void)13u_register_t plat_get_stack_protector_canary(void) 14 { 15 uint64_t entropy; 16 17 if (!plat_get_entropy(&entropy)) { 18 ERROR("Not enough entropy to initialize canary value\n"); 19 panic(); 20 } 21 22 if (sizeof(entropy) == sizeof(u_register_t)) { 23 return entropy; 24 } 25 26 return (entropy & 0xffffffffULL) ^ (entropy >> 32); 27 } 28