162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *  arch/arm/include/asm/thread_info.h
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci *  Copyright (C) 2002 Russell King.
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci#ifndef __ASM_ARM_THREAD_INFO_H
862306a36Sopenharmony_ci#define __ASM_ARM_THREAD_INFO_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifdef __KERNEL__
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#include <linux/compiler.h>
1362306a36Sopenharmony_ci#include <asm/fpstate.h>
1462306a36Sopenharmony_ci#include <asm/page.h>
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#ifdef CONFIG_KASAN
1762306a36Sopenharmony_ci/*
1862306a36Sopenharmony_ci * KASan uses a lot of extra stack space so the thread size order needs to
1962306a36Sopenharmony_ci * be increased.
2062306a36Sopenharmony_ci */
2162306a36Sopenharmony_ci#define THREAD_SIZE_ORDER	2
2262306a36Sopenharmony_ci#else
2362306a36Sopenharmony_ci#define THREAD_SIZE_ORDER	1
2462306a36Sopenharmony_ci#endif
2562306a36Sopenharmony_ci#define THREAD_SIZE		(PAGE_SIZE << THREAD_SIZE_ORDER)
2662306a36Sopenharmony_ci#define THREAD_START_SP		(THREAD_SIZE - 8)
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#ifdef CONFIG_VMAP_STACK
2962306a36Sopenharmony_ci#define THREAD_ALIGN		(2 * THREAD_SIZE)
3062306a36Sopenharmony_ci#else
3162306a36Sopenharmony_ci#define THREAD_ALIGN		THREAD_SIZE
3262306a36Sopenharmony_ci#endif
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci#define OVERFLOW_STACK_SIZE	SZ_4K
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#ifndef __ASSEMBLY__
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_cistruct task_struct;
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ciDECLARE_PER_CPU(struct task_struct *, __entry_task);
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#include <asm/types.h>
4362306a36Sopenharmony_ci#include <asm/traps.h>
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_cistruct cpu_context_save {
4662306a36Sopenharmony_ci	__u32	r4;
4762306a36Sopenharmony_ci	__u32	r5;
4862306a36Sopenharmony_ci	__u32	r6;
4962306a36Sopenharmony_ci	__u32	r7;
5062306a36Sopenharmony_ci	__u32	r8;
5162306a36Sopenharmony_ci	__u32	r9;
5262306a36Sopenharmony_ci	__u32	sl;
5362306a36Sopenharmony_ci	__u32	fp;
5462306a36Sopenharmony_ci	__u32	sp;
5562306a36Sopenharmony_ci	__u32	pc;
5662306a36Sopenharmony_ci	__u32	extra[2];		/* Xscale 'acc' register, etc */
5762306a36Sopenharmony_ci};
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci/*
6062306a36Sopenharmony_ci * low level task data that entry.S needs immediate access to.
6162306a36Sopenharmony_ci * __switch_to() assumes cpu_context follows immediately after cpu_domain.
6262306a36Sopenharmony_ci */
6362306a36Sopenharmony_cistruct thread_info {
6462306a36Sopenharmony_ci	unsigned long		flags;		/* low level flags */
6562306a36Sopenharmony_ci	int			preempt_count;	/* 0 => preemptable, <0 => bug */
6662306a36Sopenharmony_ci	__u32			cpu;		/* cpu */
6762306a36Sopenharmony_ci	__u32			cpu_domain;	/* cpu domain */
6862306a36Sopenharmony_ci	struct cpu_context_save	cpu_context;	/* cpu context */
6962306a36Sopenharmony_ci	__u32			abi_syscall;	/* ABI type and syscall nr */
7062306a36Sopenharmony_ci	unsigned long		tp_value[2];	/* TLS registers */
7162306a36Sopenharmony_ci	union fp_state		fpstate __attribute__((aligned(8)));
7262306a36Sopenharmony_ci	union vfp_state		vfpstate;
7362306a36Sopenharmony_ci#ifdef CONFIG_ARM_THUMBEE
7462306a36Sopenharmony_ci	unsigned long		thumbee_state;	/* ThumbEE Handler Base register */
7562306a36Sopenharmony_ci#endif
7662306a36Sopenharmony_ci};
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci#define INIT_THREAD_INFO(tsk)						\
7962306a36Sopenharmony_ci{									\
8062306a36Sopenharmony_ci	.flags		= 0,						\
8162306a36Sopenharmony_ci	.preempt_count	= INIT_PREEMPT_COUNT,				\
8262306a36Sopenharmony_ci}
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_cistatic inline struct task_struct *thread_task(struct thread_info* ti)
8562306a36Sopenharmony_ci{
8662306a36Sopenharmony_ci	return (struct task_struct *)ti;
8762306a36Sopenharmony_ci}
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci#define thread_saved_pc(tsk)	\
9062306a36Sopenharmony_ci	((unsigned long)(task_thread_info(tsk)->cpu_context.pc))
9162306a36Sopenharmony_ci#define thread_saved_sp(tsk)	\
9262306a36Sopenharmony_ci	((unsigned long)(task_thread_info(tsk)->cpu_context.sp))
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci#ifndef CONFIG_THUMB2_KERNEL
9562306a36Sopenharmony_ci#define thread_saved_fp(tsk)	\
9662306a36Sopenharmony_ci	((unsigned long)(task_thread_info(tsk)->cpu_context.fp))
9762306a36Sopenharmony_ci#else
9862306a36Sopenharmony_ci#define thread_saved_fp(tsk)	\
9962306a36Sopenharmony_ci	((unsigned long)(task_thread_info(tsk)->cpu_context.r7))
10062306a36Sopenharmony_ci#endif
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ciextern void iwmmxt_task_disable(struct thread_info *);
10362306a36Sopenharmony_ciextern void iwmmxt_task_copy(struct thread_info *, void *);
10462306a36Sopenharmony_ciextern void iwmmxt_task_restore(struct thread_info *, void *);
10562306a36Sopenharmony_ciextern void iwmmxt_task_release(struct thread_info *);
10662306a36Sopenharmony_ciextern void iwmmxt_task_switch(struct thread_info *);
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ciextern int iwmmxt_undef_handler(struct pt_regs *, u32);
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_cistatic inline void register_iwmmxt_undef_handler(void)
11162306a36Sopenharmony_ci{
11262306a36Sopenharmony_ci	static struct undef_hook iwmmxt_undef_hook = {
11362306a36Sopenharmony_ci		.instr_mask	= 0x0c000e00,
11462306a36Sopenharmony_ci		.instr_val	= 0x0c000000,
11562306a36Sopenharmony_ci		.cpsr_mask	= MODE_MASK | PSR_T_BIT,
11662306a36Sopenharmony_ci		.cpsr_val	= USR_MODE,
11762306a36Sopenharmony_ci		.fn		= iwmmxt_undef_handler,
11862306a36Sopenharmony_ci	};
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci	register_undef_hook(&iwmmxt_undef_hook);
12162306a36Sopenharmony_ci}
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ciextern void vfp_sync_hwstate(struct thread_info *);
12462306a36Sopenharmony_ciextern void vfp_flush_hwstate(struct thread_info *);
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_cistruct user_vfp;
12762306a36Sopenharmony_cistruct user_vfp_exc;
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ciextern int vfp_preserve_user_clear_hwstate(struct user_vfp *,
13062306a36Sopenharmony_ci					   struct user_vfp_exc *);
13162306a36Sopenharmony_ciextern int vfp_restore_user_hwstate(struct user_vfp *,
13262306a36Sopenharmony_ci				    struct user_vfp_exc *);
13362306a36Sopenharmony_ci#endif
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci/*
13662306a36Sopenharmony_ci * thread information flags:
13762306a36Sopenharmony_ci *  TIF_USEDFPU		- FPU was used by this task this quantum (SMP)
13862306a36Sopenharmony_ci *  TIF_POLLING_NRFLAG	- true if poll_idle() is polling TIF_NEED_RESCHED
13962306a36Sopenharmony_ci *
14062306a36Sopenharmony_ci * Any bit in the range of 0..15 will cause do_work_pending() to be invoked.
14162306a36Sopenharmony_ci */
14262306a36Sopenharmony_ci#define TIF_SIGPENDING		0	/* signal pending */
14362306a36Sopenharmony_ci#define TIF_NEED_RESCHED	1	/* rescheduling necessary */
14462306a36Sopenharmony_ci#define TIF_NOTIFY_RESUME	2	/* callback before returning to user */
14562306a36Sopenharmony_ci#define TIF_UPROBE		3	/* breakpointed or singlestepping */
14662306a36Sopenharmony_ci#define TIF_NOTIFY_SIGNAL	4	/* signal notifications exist */
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci#define TIF_USING_IWMMXT	17
14962306a36Sopenharmony_ci#define TIF_MEMDIE		18	/* is terminating due to OOM killer */
15062306a36Sopenharmony_ci#define TIF_RESTORE_SIGMASK	19
15162306a36Sopenharmony_ci#define TIF_SYSCALL_TRACE	20	/* syscall trace active */
15262306a36Sopenharmony_ci#define TIF_SYSCALL_AUDIT	21	/* syscall auditing active */
15362306a36Sopenharmony_ci#define TIF_SYSCALL_TRACEPOINT	22	/* syscall tracepoint instrumentation */
15462306a36Sopenharmony_ci#define TIF_SECCOMP		23	/* seccomp syscall filtering active */
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci#define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
15862306a36Sopenharmony_ci#define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
15962306a36Sopenharmony_ci#define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
16062306a36Sopenharmony_ci#define _TIF_UPROBE		(1 << TIF_UPROBE)
16162306a36Sopenharmony_ci#define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
16262306a36Sopenharmony_ci#define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
16362306a36Sopenharmony_ci#define _TIF_SYSCALL_TRACEPOINT	(1 << TIF_SYSCALL_TRACEPOINT)
16462306a36Sopenharmony_ci#define _TIF_SECCOMP		(1 << TIF_SECCOMP)
16562306a36Sopenharmony_ci#define _TIF_NOTIFY_SIGNAL	(1 << TIF_NOTIFY_SIGNAL)
16662306a36Sopenharmony_ci#define _TIF_USING_IWMMXT	(1 << TIF_USING_IWMMXT)
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ci/* Checks for any syscall work in entry-common.S */
16962306a36Sopenharmony_ci#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
17062306a36Sopenharmony_ci			   _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci/*
17362306a36Sopenharmony_ci * Change these and you break ASM code in entry-common.S
17462306a36Sopenharmony_ci */
17562306a36Sopenharmony_ci#define _TIF_WORK_MASK		(_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
17662306a36Sopenharmony_ci				 _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
17762306a36Sopenharmony_ci				 _TIF_NOTIFY_SIGNAL)
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci#endif /* __KERNEL__ */
18062306a36Sopenharmony_ci#endif /* __ASM_ARM_THREAD_INFO_H */
181