blob: 75557409916fddee4a160d1f93b3570288274d77 [file] [log] [blame]
Antonio Nino Diaz9c9f92c2019-03-13 13:57:39 +00001/*
2 * Copyright (c) 2019, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <cdefs.h>
8#include <stdint.h>
9
10/*
11 * Instruction pointer authentication key A. The low 64-bit are at [0], and the
12 * high bits at [1].
13 */
14static uint64_t plat_apiakey[2];
15
16/*
17 * This is only a toy implementation to generate a seemingly random 128-bit key
18 * from sp and x30 values.
19 */
20uint64_t *plat_init_apiakey(void)
21{
22 uintptr_t return_addr = (uintptr_t)__builtin_return_address(0U);
23 uintptr_t frame_addr = (uintptr_t)__builtin_frame_address(0U);
24
25 plat_apiakey[0] = (return_addr << 13) ^ frame_addr;
26 plat_apiakey[1] = (frame_addr << 15) ^ return_addr;
27
28 return plat_apiakey;
29}