blob: 236eb5ba37d2582345d72cb88faa4f9dd904d2b5 [file] [log] [blame]
dp-armb3263b32017-02-28 14:43:15 +00001/*
2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
dp-armb3263b32017-02-28 14:43:15 +00005 */
6
7#include <arch_helpers.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008#include <common/debug.h>
9#include <lib/utils.h>
Antonio Nino Diaza320ecd2019-01-15 14:19:50 +000010#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011
dp-armb3263b32017-02-28 14:43:15 +000012#include "juno_decl.h"
dp-armb3263b32017-02-28 14:43:15 +000013
14u_register_t plat_get_stack_protector_canary(void)
15{
16 u_register_t c[TRNG_NBYTES / sizeof(u_register_t)];
17 u_register_t ret = 0;
18 size_t i;
19
20 if (juno_getentropy(c, sizeof(c)) != 0) {
21 ERROR("Not enough entropy to initialize canary value\n");
22 panic();
23 }
24
25 /*
26 * On Juno we get 128-bits of entropy in one round.
27 * Fuse the values together to form the canary.
28 */
29 for (i = 0; i < ARRAY_SIZE(c); i++)
30 ret ^= c[i];
31 return ret;
32}