juno_stack_protector.c 572 Bytes
Newer Older
1
2
3
/*
 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
7
 */

#include <arch_helpers.h>
8
9
#include <common/debug.h>
#include <lib/utils.h>
10
#include <plat/common/plat_trng.h>
11
#include <platform_def.h>
12

13
14
u_register_t plat_get_stack_protector_canary(void)
{
15
	uint64_t entropy;
16

17
	if (!plat_get_entropy(&entropy)) {
18
19
20
21
		ERROR("Not enough entropy to initialize canary value\n");
		panic();
	}

22
23
24
25
26
	if (sizeof(entropy) == sizeof(u_register_t)) {
		return entropy;
	}

	return (entropy & 0xffffffffULL) ^ (entropy >> 32);
27
}