blob: 8c51f574cf740dc40ec141da0d10c8bac614eb39 [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{
Andre Przywara927b3992020-10-08 00:43:50 +010016 uint64_t entropy;
dp-armb3263b32017-02-28 14:43:15 +000017
Andre Przywara927b3992020-10-08 00:43:50 +010018 if (!juno_getentropy(&entropy)) {
dp-armb3263b32017-02-28 14:43:15 +000019 ERROR("Not enough entropy to initialize canary value\n");
20 panic();
21 }
22
Andre Przywara927b3992020-10-08 00:43:50 +010023 if (sizeof(entropy) == sizeof(u_register_t)) {
24 return entropy;
25 }
26
27 return (entropy & 0xffffffffULL) ^ (entropy >> 32);
dp-armb3263b32017-02-28 14:43:15 +000028}