blob: 8a1a4e57d4ad5ba76bd6ad0e67c8bdd560db9aab [file] [log] [blame]
Jiafei Pan46367ad2018-03-02 07:23:30 +00001/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Jiafei Pan46367ad2018-03-02 07:23:30 +00007#include <stdint.h>
8
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009#include <arch_helpers.h>
10
Jiafei Pan46367ad2018-03-02 07:23:30 +000011#define RANDOM_CANARY_VALUE ((u_register_t) 3288484550995823360ULL)
12
13u_register_t plat_get_stack_protector_canary(void)
14{
15 /*
16 * Ideally, a random number should be returned instead of the
17 * combination of a timer's value and a compile-time constant. As the
18 * FVP does not have any random number generator, this is better than
19 * nothing but not necessarily really secure.
20 */
21 return RANDOM_CANARY_VALUE ^ read_cntpct_el0();
22}