1/*
2 * Copyright (c) 2017, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <assert_macros.S>
10
11	.globl	update_stack_protector_canary
12
13/* -----------------------------------------------------------------------
14 * void update_stack_protector_canary(void)
15 *
16 * Change the value of the canary used for stack smashing attacks protection.
17 * Note: This must be called when it is safe to call C code, but this cannot be
18 * called by C code. Doing this will make the check fail when the calling
19 * function returns.
20 * -----------------------------------------------------------------------
21 */
22
23func update_stack_protector_canary
24	/* Use x19 as it is callee-saved */
25	mov	x19, x30
26	bl	plat_get_stack_protector_canary
27
28	/* Update the canary with the returned value */
29	adrp	x1,  __stack_chk_guard
30	str	x0, [x1, #:lo12:__stack_chk_guard]
31	ret	x19
32endfunc update_stack_protector_canary
33
34
35