2017-02-28 14:43:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
|
|
|
|
*
|
2017-05-03 09:38:09 +01:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2017-02-28 14:43:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <arch_helpers.h>
|
2018-12-14 00:18:21 +00:00
|
|
|
#include <common/debug.h>
|
|
|
|
#include <lib/utils.h>
|
2020-10-08 00:45:22 +01:00
|
|
|
#include <plat/common/plat_trng.h>
|
2019-01-15 14:19:50 +00:00
|
|
|
#include <platform_def.h>
|
2018-12-14 00:18:21 +00:00
|
|
|
|
2017-02-28 14:43:15 +00:00
|
|
|
u_register_t plat_get_stack_protector_canary(void)
|
|
|
|
{
|
2020-10-08 00:43:50 +01:00
|
|
|
uint64_t entropy;
|
2017-02-28 14:43:15 +00:00
|
|
|
|
2020-10-08 00:45:22 +01:00
|
|
|
if (!plat_get_entropy(&entropy)) {
|
2017-02-28 14:43:15 +00:00
|
|
|
ERROR("Not enough entropy to initialize canary value\n");
|
|
|
|
panic();
|
|
|
|
}
|
|
|
|
|
2020-10-08 00:43:50 +01:00
|
|
|
if (sizeof(entropy) == sizeof(u_register_t)) {
|
|
|
|
return entropy;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (entropy & 0xffffffffULL) ^ (entropy >> 32);
|
2017-02-28 14:43:15 +00:00
|
|
|
}
|