diff options
author | Antonio Nino Diaz <antonio.ninodiaz@arm.com> | 2019-01-31 11:01:10 +0000 |
---|---|---|
committer | Antonio Nino Diaz <antonio.ninodiaz@arm.com> | 2019-02-27 11:58:09 +0000 |
commit | ff6844c3de9b34a09f358a3204264059834e2b1d (patch) | |
tree | 86c7a07f933f0d03247b740f237af4736417af61 /plat | |
parent | b86048c40cb7d9ccd7aeac1681945676a6dc36ff (diff) | |
download | arm-trusted-firmware-ff6844c3de9b34a09f358a3204264059834e2b1d.tar.gz |
plat/arm: Implement ARMv8.3-PAuth interfaces
This feature is only supported on FVP.
Change-Id: I4e265610211d92a84bd2773c34acfbe02a1a1826
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
Diffstat (limited to 'plat')
-rw-r--r-- | plat/arm/common/aarch64/arm_pauth.c | 32 | ||||
-rw-r--r-- | plat/arm/common/arm_common.mk | 5 |
2 files changed, 37 insertions, 0 deletions
diff --git a/plat/arm/common/aarch64/arm_pauth.c b/plat/arm/common/aarch64/arm_pauth.c new file mode 100644 index 000000000..c8471190a --- /dev/null +++ b/plat/arm/common/aarch64/arm_pauth.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <cdefs.h> +#include <stdint.h> + +/* + * Instruction pointer authentication key A. The low 64-bit are at [0], and the + * high bits at [1]. They are run-time constants so they are placed in the + * rodata section. They are written before MMU is turned on and the permissions + * are effective. + */ +uint64_t plat_apiakey[2] __section("rodata.apiakey"); + +/* + * This is only a toy implementation to generate a seemingly random 128-bit key + * from sp and x30 values. A production system must re-implement this function + * to generate keys from a reliable randomness source. + */ +uint64_t *plat_init_apiakey(void) +{ + uintptr_t return_addr = (uintptr_t)__builtin_return_address(0U); + uintptr_t frame_addr = (uintptr_t)__builtin_frame_address(0U); + + plat_apiakey[0] = (return_addr << 13) ^ frame_addr; + plat_apiakey[1] = (frame_addr << 15) ^ return_addr; + + return plat_apiakey; +} diff --git a/plat/arm/common/arm_common.mk b/plat/arm/common/arm_common.mk index f18a9af69..5e890ed17 100644 --- a/plat/arm/common/arm_common.mk +++ b/plat/arm/common/arm_common.mk @@ -236,6 +236,11 @@ BL31_SOURCES += lib/extensions/ras/std_err_record.c \ lib/extensions/ras/ras_common.c endif +# Pointer Authentication sources +ifeq (${ENABLE_PAUTH}, 1) +PLAT_BL_COMMON_SOURCES += plat/arm/common/aarch64/arm_pauth.c +endif + # SPM uses libfdt in Arm platforms ifeq (${SPM_MM},0) ifeq (${ENABLE_SPM},1) |