powerpc/book3s64/radix: Rename CPU_FTR_P9_TLBIE_BUG feature flag
[linux-2.6-block.git] / arch / powerpc / include / asm / stackprotector.h
CommitLineData
c3ff2a51
CL
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * GCC stack protector support.
4 *
5 */
6
7#ifndef _ASM_STACKPROTECTOR_H
8#define _ASM_STACKPROTECTOR_H
9
10#include <linux/random.h>
11#include <linux/version.h>
12#include <asm/reg.h>
13#include <asm/current.h>
06ec27ae 14#include <asm/paca.h>
c3ff2a51
CL
15
16/*
17 * Initialize the stackprotector canary value.
18 *
19 * NOTE: this must only be called from functions that never return,
20 * and it must always be inlined.
21 */
22static __always_inline void boot_init_stack_canary(void)
23{
24 unsigned long canary;
25
26 /* Try to get a semi random initial value. */
27 canary = get_random_canary();
28 canary ^= mftb();
29 canary ^= LINUX_VERSION_CODE;
30 canary &= CANARY_MASK;
31
32 current->stack_canary = canary;
06ec27ae
CL
33#ifdef CONFIG_PPC64
34 get_paca()->canary = canary;
35#endif
c3ff2a51
CL
36}
37
38#endif /* _ASM_STACKPROTECTOR_H */