• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <platform_def.h>
11 
12 #include "juno_decl.h"
13 
plat_get_stack_protector_canary(void)14 u_register_t plat_get_stack_protector_canary(void)
15 {
16 	uint64_t entropy;
17 
18 	if (!juno_getentropy(&entropy)) {
19 		ERROR("Not enough entropy to initialize canary value\n");
20 		panic();
21 	}
22 
23 	if (sizeof(entropy) == sizeof(u_register_t)) {
24 		return entropy;
25 	}
26 
27 	return (entropy & 0xffffffffULL) ^ (entropy >> 32);
28 }
29