18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  arch/arm/include/asm/thread_info.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (C) 2002 Russell King.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci#ifndef __ASM_ARM_THREAD_INFO_H
88c2ecf20Sopenharmony_ci#define __ASM_ARM_THREAD_INFO_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifdef __KERNEL__
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/compiler.h>
138c2ecf20Sopenharmony_ci#include <asm/fpstate.h>
148c2ecf20Sopenharmony_ci#include <asm/page.h>
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#ifdef CONFIG_KASAN
178c2ecf20Sopenharmony_ci/*
188c2ecf20Sopenharmony_ci * KASan uses a lot of extra stack space so the thread size order needs to
198c2ecf20Sopenharmony_ci * be increased.
208c2ecf20Sopenharmony_ci */
218c2ecf20Sopenharmony_ci#define THREAD_SIZE_ORDER	2
228c2ecf20Sopenharmony_ci#else
238c2ecf20Sopenharmony_ci#define THREAD_SIZE_ORDER	1
248c2ecf20Sopenharmony_ci#endif
258c2ecf20Sopenharmony_ci#define THREAD_SIZE		(PAGE_SIZE << THREAD_SIZE_ORDER)
268c2ecf20Sopenharmony_ci#define THREAD_START_SP		(THREAD_SIZE - 8)
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cistruct task_struct;
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#include <asm/types.h>
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_citypedef unsigned long mm_segment_t;
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cistruct cpu_context_save {
378c2ecf20Sopenharmony_ci	__u32	r4;
388c2ecf20Sopenharmony_ci	__u32	r5;
398c2ecf20Sopenharmony_ci	__u32	r6;
408c2ecf20Sopenharmony_ci	__u32	r7;
418c2ecf20Sopenharmony_ci	__u32	r8;
428c2ecf20Sopenharmony_ci	__u32	r9;
438c2ecf20Sopenharmony_ci	__u32	sl;
448c2ecf20Sopenharmony_ci	__u32	fp;
458c2ecf20Sopenharmony_ci	__u32	sp;
468c2ecf20Sopenharmony_ci	__u32	pc;
478c2ecf20Sopenharmony_ci	__u32	extra[2];		/* Xscale 'acc' register, etc */
488c2ecf20Sopenharmony_ci};
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/*
518c2ecf20Sopenharmony_ci * low level task data that entry.S needs immediate access to.
528c2ecf20Sopenharmony_ci * __switch_to() assumes cpu_context follows immediately after cpu_domain.
538c2ecf20Sopenharmony_ci */
548c2ecf20Sopenharmony_cistruct thread_info {
558c2ecf20Sopenharmony_ci	unsigned long		flags;		/* low level flags */
568c2ecf20Sopenharmony_ci	int			preempt_count;	/* 0 => preemptable, <0 => bug */
578c2ecf20Sopenharmony_ci	mm_segment_t		addr_limit;	/* address limit */
588c2ecf20Sopenharmony_ci	struct task_struct	*task;		/* main task structure */
598c2ecf20Sopenharmony_ci	__u32			cpu;		/* cpu */
608c2ecf20Sopenharmony_ci	__u32			cpu_domain;	/* cpu domain */
618c2ecf20Sopenharmony_ci#ifdef CONFIG_STACKPROTECTOR_PER_TASK
628c2ecf20Sopenharmony_ci	unsigned long		stack_canary;
638c2ecf20Sopenharmony_ci#endif
648c2ecf20Sopenharmony_ci	struct cpu_context_save	cpu_context;	/* cpu context */
658c2ecf20Sopenharmony_ci	__u32			syscall;	/* syscall number */
668c2ecf20Sopenharmony_ci	__u8			used_cp[16];	/* thread used copro */
678c2ecf20Sopenharmony_ci	unsigned long		tp_value[2];	/* TLS registers */
688c2ecf20Sopenharmony_ci#ifdef CONFIG_CRUNCH
698c2ecf20Sopenharmony_ci	struct crunch_state	crunchstate;
708c2ecf20Sopenharmony_ci#endif
718c2ecf20Sopenharmony_ci	union fp_state		fpstate __attribute__((aligned(8)));
728c2ecf20Sopenharmony_ci	union vfp_state		vfpstate;
738c2ecf20Sopenharmony_ci#ifdef CONFIG_ARM_THUMBEE
748c2ecf20Sopenharmony_ci	unsigned long		thumbee_state;	/* ThumbEE Handler Base register */
758c2ecf20Sopenharmony_ci#endif
768c2ecf20Sopenharmony_ci};
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#define INIT_THREAD_INFO(tsk)						\
798c2ecf20Sopenharmony_ci{									\
808c2ecf20Sopenharmony_ci	.task		= &tsk,						\
818c2ecf20Sopenharmony_ci	.flags		= 0,						\
828c2ecf20Sopenharmony_ci	.preempt_count	= INIT_PREEMPT_COUNT,				\
838c2ecf20Sopenharmony_ci	.addr_limit	= KERNEL_DS,					\
848c2ecf20Sopenharmony_ci}
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci/*
878c2ecf20Sopenharmony_ci * how to get the thread information struct from C
888c2ecf20Sopenharmony_ci */
898c2ecf20Sopenharmony_cistatic inline struct thread_info *current_thread_info(void) __attribute_const__;
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_cistatic inline struct thread_info *current_thread_info(void)
928c2ecf20Sopenharmony_ci{
938c2ecf20Sopenharmony_ci	return (struct thread_info *)
948c2ecf20Sopenharmony_ci		(current_stack_pointer & ~(THREAD_SIZE - 1));
958c2ecf20Sopenharmony_ci}
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#define thread_saved_pc(tsk)	\
988c2ecf20Sopenharmony_ci	((unsigned long)(task_thread_info(tsk)->cpu_context.pc))
998c2ecf20Sopenharmony_ci#define thread_saved_sp(tsk)	\
1008c2ecf20Sopenharmony_ci	((unsigned long)(task_thread_info(tsk)->cpu_context.sp))
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#ifndef CONFIG_THUMB2_KERNEL
1038c2ecf20Sopenharmony_ci#define thread_saved_fp(tsk)	\
1048c2ecf20Sopenharmony_ci	((unsigned long)(task_thread_info(tsk)->cpu_context.fp))
1058c2ecf20Sopenharmony_ci#else
1068c2ecf20Sopenharmony_ci#define thread_saved_fp(tsk)	\
1078c2ecf20Sopenharmony_ci	((unsigned long)(task_thread_info(tsk)->cpu_context.r7))
1088c2ecf20Sopenharmony_ci#endif
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ciextern void crunch_task_disable(struct thread_info *);
1118c2ecf20Sopenharmony_ciextern void crunch_task_copy(struct thread_info *, void *);
1128c2ecf20Sopenharmony_ciextern void crunch_task_restore(struct thread_info *, void *);
1138c2ecf20Sopenharmony_ciextern void crunch_task_release(struct thread_info *);
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ciextern void iwmmxt_task_disable(struct thread_info *);
1168c2ecf20Sopenharmony_ciextern void iwmmxt_task_copy(struct thread_info *, void *);
1178c2ecf20Sopenharmony_ciextern void iwmmxt_task_restore(struct thread_info *, void *);
1188c2ecf20Sopenharmony_ciextern void iwmmxt_task_release(struct thread_info *);
1198c2ecf20Sopenharmony_ciextern void iwmmxt_task_switch(struct thread_info *);
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ciextern void vfp_sync_hwstate(struct thread_info *);
1228c2ecf20Sopenharmony_ciextern void vfp_flush_hwstate(struct thread_info *);
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_cistruct user_vfp;
1258c2ecf20Sopenharmony_cistruct user_vfp_exc;
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ciextern int vfp_preserve_user_clear_hwstate(struct user_vfp *,
1288c2ecf20Sopenharmony_ci					   struct user_vfp_exc *);
1298c2ecf20Sopenharmony_ciextern int vfp_restore_user_hwstate(struct user_vfp *,
1308c2ecf20Sopenharmony_ci				    struct user_vfp_exc *);
1318c2ecf20Sopenharmony_ci#endif
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci/*
1348c2ecf20Sopenharmony_ci * thread information flags:
1358c2ecf20Sopenharmony_ci *  TIF_USEDFPU		- FPU was used by this task this quantum (SMP)
1368c2ecf20Sopenharmony_ci *  TIF_POLLING_NRFLAG	- true if poll_idle() is polling TIF_NEED_RESCHED
1378c2ecf20Sopenharmony_ci *
1388c2ecf20Sopenharmony_ci * Any bit in the range of 0..15 will cause do_work_pending() to be invoked.
1398c2ecf20Sopenharmony_ci */
1408c2ecf20Sopenharmony_ci#define TIF_SIGPENDING		0	/* signal pending */
1418c2ecf20Sopenharmony_ci#define TIF_NEED_RESCHED	1	/* rescheduling necessary */
1428c2ecf20Sopenharmony_ci#define TIF_NOTIFY_RESUME	2	/* callback before returning to user */
1438c2ecf20Sopenharmony_ci#define TIF_UPROBE		3	/* breakpointed or singlestepping */
1448c2ecf20Sopenharmony_ci#define TIF_NOTIFY_SIGNAL	4	/* signal notifications exist */
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci#define TIF_USING_IWMMXT	17
1478c2ecf20Sopenharmony_ci#define TIF_MEMDIE		18	/* is terminating due to OOM killer */
1488c2ecf20Sopenharmony_ci#define TIF_RESTORE_SIGMASK	19
1498c2ecf20Sopenharmony_ci#define TIF_SYSCALL_TRACE	20	/* syscall trace active */
1508c2ecf20Sopenharmony_ci#define TIF_SYSCALL_AUDIT	21	/* syscall auditing active */
1518c2ecf20Sopenharmony_ci#define TIF_SYSCALL_TRACEPOINT	22	/* syscall tracepoint instrumentation */
1528c2ecf20Sopenharmony_ci#define TIF_SECCOMP		23	/* seccomp syscall filtering active */
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci#define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
1568c2ecf20Sopenharmony_ci#define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
1578c2ecf20Sopenharmony_ci#define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
1588c2ecf20Sopenharmony_ci#define _TIF_UPROBE		(1 << TIF_UPROBE)
1598c2ecf20Sopenharmony_ci#define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
1608c2ecf20Sopenharmony_ci#define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
1618c2ecf20Sopenharmony_ci#define _TIF_SYSCALL_TRACEPOINT	(1 << TIF_SYSCALL_TRACEPOINT)
1628c2ecf20Sopenharmony_ci#define _TIF_SECCOMP		(1 << TIF_SECCOMP)
1638c2ecf20Sopenharmony_ci#define _TIF_NOTIFY_SIGNAL	(1 << TIF_NOTIFY_SIGNAL)
1648c2ecf20Sopenharmony_ci#define _TIF_USING_IWMMXT	(1 << TIF_USING_IWMMXT)
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci/* Checks for any syscall work in entry-common.S */
1678c2ecf20Sopenharmony_ci#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
1688c2ecf20Sopenharmony_ci			   _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci/*
1718c2ecf20Sopenharmony_ci * Change these and you break ASM code in entry-common.S
1728c2ecf20Sopenharmony_ci */
1738c2ecf20Sopenharmony_ci#define _TIF_WORK_MASK		(_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
1748c2ecf20Sopenharmony_ci				 _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
1758c2ecf20Sopenharmony_ci				 _TIF_NOTIFY_SIGNAL)
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */
1788c2ecf20Sopenharmony_ci#endif /* __ASM_ARM_THREAD_INFO_H */
179