Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *  arch/arm/include/asm/thread_info.h
0004  *
0005  *  Copyright (C) 2002 Russell King.
0006  */
0007 #ifndef __ASM_ARM_THREAD_INFO_H
0008 #define __ASM_ARM_THREAD_INFO_H
0009 
0010 #ifdef __KERNEL__
0011 
0012 #include <linux/compiler.h>
0013 #include <asm/fpstate.h>
0014 #include <asm/page.h>
0015 
0016 #ifdef CONFIG_KASAN
0017 /*
0018  * KASan uses a lot of extra stack space so the thread size order needs to
0019  * be increased.
0020  */
0021 #define THREAD_SIZE_ORDER   2
0022 #else
0023 #define THREAD_SIZE_ORDER   1
0024 #endif
0025 #define THREAD_SIZE     (PAGE_SIZE << THREAD_SIZE_ORDER)
0026 #define THREAD_START_SP     (THREAD_SIZE - 8)
0027 
0028 #ifdef CONFIG_VMAP_STACK
0029 #define THREAD_ALIGN        (2 * THREAD_SIZE)
0030 #else
0031 #define THREAD_ALIGN        THREAD_SIZE
0032 #endif
0033 
0034 #define OVERFLOW_STACK_SIZE SZ_4K
0035 
0036 #ifndef __ASSEMBLY__
0037 
0038 struct task_struct;
0039 
0040 DECLARE_PER_CPU(struct task_struct *, __entry_task);
0041 
0042 #include <asm/types.h>
0043 
0044 struct cpu_context_save {
0045     __u32   r4;
0046     __u32   r5;
0047     __u32   r6;
0048     __u32   r7;
0049     __u32   r8;
0050     __u32   r9;
0051     __u32   sl;
0052     __u32   fp;
0053     __u32   sp;
0054     __u32   pc;
0055     __u32   extra[2];       /* Xscale 'acc' register, etc */
0056 };
0057 
0058 /*
0059  * low level task data that entry.S needs immediate access to.
0060  * __switch_to() assumes cpu_context follows immediately after cpu_domain.
0061  */
0062 struct thread_info {
0063     unsigned long       flags;      /* low level flags */
0064     int         preempt_count;  /* 0 => preemptable, <0 => bug */
0065     __u32           cpu;        /* cpu */
0066     __u32           cpu_domain; /* cpu domain */
0067     struct cpu_context_save cpu_context;    /* cpu context */
0068     __u32           abi_syscall;    /* ABI type and syscall nr */
0069     __u8            used_cp[16];    /* thread used copro */
0070     unsigned long       tp_value[2];    /* TLS registers */
0071     union fp_state      fpstate __attribute__((aligned(8)));
0072     union vfp_state     vfpstate;
0073 #ifdef CONFIG_ARM_THUMBEE
0074     unsigned long       thumbee_state;  /* ThumbEE Handler Base register */
0075 #endif
0076 };
0077 
0078 #define INIT_THREAD_INFO(tsk)                       \
0079 {                                   \
0080     .flags      = 0,                        \
0081     .preempt_count  = INIT_PREEMPT_COUNT,               \
0082 }
0083 
0084 static inline struct task_struct *thread_task(struct thread_info* ti)
0085 {
0086     return (struct task_struct *)ti;
0087 }
0088 
0089 #define thread_saved_pc(tsk)    \
0090     ((unsigned long)(task_thread_info(tsk)->cpu_context.pc))
0091 #define thread_saved_sp(tsk)    \
0092     ((unsigned long)(task_thread_info(tsk)->cpu_context.sp))
0093 
0094 #ifndef CONFIG_THUMB2_KERNEL
0095 #define thread_saved_fp(tsk)    \
0096     ((unsigned long)(task_thread_info(tsk)->cpu_context.fp))
0097 #else
0098 #define thread_saved_fp(tsk)    \
0099     ((unsigned long)(task_thread_info(tsk)->cpu_context.r7))
0100 #endif
0101 
0102 extern void iwmmxt_task_disable(struct thread_info *);
0103 extern void iwmmxt_task_copy(struct thread_info *, void *);
0104 extern void iwmmxt_task_restore(struct thread_info *, void *);
0105 extern void iwmmxt_task_release(struct thread_info *);
0106 extern void iwmmxt_task_switch(struct thread_info *);
0107 
0108 extern void vfp_sync_hwstate(struct thread_info *);
0109 extern void vfp_flush_hwstate(struct thread_info *);
0110 
0111 struct user_vfp;
0112 struct user_vfp_exc;
0113 
0114 extern int vfp_preserve_user_clear_hwstate(struct user_vfp *,
0115                        struct user_vfp_exc *);
0116 extern int vfp_restore_user_hwstate(struct user_vfp *,
0117                     struct user_vfp_exc *);
0118 #endif
0119 
0120 /*
0121  * thread information flags:
0122  *  TIF_USEDFPU     - FPU was used by this task this quantum (SMP)
0123  *  TIF_POLLING_NRFLAG  - true if poll_idle() is polling TIF_NEED_RESCHED
0124  *
0125  * Any bit in the range of 0..15 will cause do_work_pending() to be invoked.
0126  */
0127 #define TIF_SIGPENDING      0   /* signal pending */
0128 #define TIF_NEED_RESCHED    1   /* rescheduling necessary */
0129 #define TIF_NOTIFY_RESUME   2   /* callback before returning to user */
0130 #define TIF_UPROBE      3   /* breakpointed or singlestepping */
0131 #define TIF_SYSCALL_TRACE   4   /* syscall trace active */
0132 #define TIF_SYSCALL_AUDIT   5   /* syscall auditing active */
0133 #define TIF_SYSCALL_TRACEPOINT  6   /* syscall tracepoint instrumentation */
0134 #define TIF_SECCOMP     7   /* seccomp syscall filtering active */
0135 #define TIF_NOTIFY_SIGNAL   8   /* signal notifications exist */
0136 
0137 #define TIF_USING_IWMMXT    17
0138 #define TIF_MEMDIE      18  /* is terminating due to OOM killer */
0139 #define TIF_RESTORE_SIGMASK 20
0140 
0141 #define _TIF_SIGPENDING     (1 << TIF_SIGPENDING)
0142 #define _TIF_NEED_RESCHED   (1 << TIF_NEED_RESCHED)
0143 #define _TIF_NOTIFY_RESUME  (1 << TIF_NOTIFY_RESUME)
0144 #define _TIF_UPROBE     (1 << TIF_UPROBE)
0145 #define _TIF_SYSCALL_TRACE  (1 << TIF_SYSCALL_TRACE)
0146 #define _TIF_SYSCALL_AUDIT  (1 << TIF_SYSCALL_AUDIT)
0147 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
0148 #define _TIF_SECCOMP        (1 << TIF_SECCOMP)
0149 #define _TIF_NOTIFY_SIGNAL  (1 << TIF_NOTIFY_SIGNAL)
0150 #define _TIF_USING_IWMMXT   (1 << TIF_USING_IWMMXT)
0151 
0152 /* Checks for any syscall work in entry-common.S */
0153 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
0154                _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
0155 
0156 /*
0157  * Change these and you break ASM code in entry-common.S
0158  */
0159 #define _TIF_WORK_MASK      (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
0160                  _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
0161                  _TIF_NOTIFY_SIGNAL)
0162 
0163 #endif /* __KERNEL__ */
0164 #endif /* __ASM_ARM_THREAD_INFO_H */