/* SPDX-License-Identifier: GPL-2.0 */


#ifndef _ASM_STACKPROTECTOR_H
#define _ASM_STACKPROTECTOR_H 1

#ifdef CONFIG_STACKPROTECTOR

#include <asm/tsc.h>
#include <asm/processor.h>
#include <asm/percpu.h>
#include <asm/desc.h>

#include <linux/sched.h>

DECLARE_PER_CPU_CACHE_HOT(unsigned long, __stack_chk_guard);


static __always_inline void boot_init_stack_canary(void)
{
	unsigned long canary = get_random_canary();

	current->stack_canary = canary;
	this_cpu_write(__stack_chk_guard, canary);
}

static inline void cpu_init_stack_canary(int cpu, struct task_struct *idle)
{
	per_cpu(__stack_chk_guard, cpu) = idle->stack_canary;
}

#else	



static inline void cpu_init_stack_canary(int cpu, struct task_struct *idle)
{ }

#endif	
#endif	
