Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
6cb7bfeb | 2 | /* thread_info.h: PowerPC low-level thread information |
1da177e4 LT |
3 | * adapted from the i386 version by Paul Mackerras |
4 | * | |
5 | * Copyright (C) 2002 David Howells (dhowells@redhat.com) | |
6 | * - Incorporating suggestions made by Linus Torvalds and Dave Miller | |
7 | */ | |
8 | ||
6cb7bfeb DG |
9 | #ifndef _ASM_POWERPC_THREAD_INFO_H |
10 | #define _ASM_POWERPC_THREAD_INFO_H | |
1da177e4 | 11 | |
ec0c464c CL |
12 | #include <asm/asm-const.h> |
13 | ||
1da177e4 LT |
14 | #ifdef __KERNEL__ |
15 | ||
47613407 | 16 | #define THREAD_SHIFT CONFIG_THREAD_SHIFT |
6cb7bfeb DG |
17 | |
18 | #define THREAD_SIZE (1 << THREAD_SHIFT) | |
19 | ||
1da177e4 | 20 | #ifndef __ASSEMBLY__ |
1da177e4 LT |
21 | #include <linux/cache.h> |
22 | #include <asm/processor.h> | |
23 | #include <asm/page.h> | |
c223c903 | 24 | #include <asm/accounting.h> |
1da177e4 | 25 | |
5434ae74 | 26 | #define SLB_PRELOAD_NR 16U |
1da177e4 LT |
27 | /* |
28 | * low level task data. | |
29 | */ | |
30 | struct thread_info { | |
6cb7bfeb DG |
31 | int preempt_count; /* 0 => preemptable, |
32 | <0 => BUG */ | |
f39224a8 | 33 | unsigned long local_flags; /* private flags for thread */ |
5d31a96e ME |
34 | #ifdef CONFIG_LIVEPATCH |
35 | unsigned long *livepatch_sp; | |
c223c903 CL |
36 | #endif |
37 | #if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) && defined(CONFIG_PPC32) | |
38 | struct cpu_accounting_data accounting; | |
5d31a96e | 39 | #endif |
5434ae74 NP |
40 | unsigned char slb_preload_nr; |
41 | unsigned char slb_preload_tail; | |
42 | u32 slb_preload_esid[SLB_PRELOAD_NR]; | |
43 | ||
1da177e4 LT |
44 | /* low level flags - has atomic operations done on it */ |
45 | unsigned long flags ____cacheline_aligned_in_smp; | |
46 | }; | |
47 | ||
48 | /* | |
49 | * macros/functions for gaining access to the thread information structure | |
1da177e4 LT |
50 | */ |
51 | #define INIT_THREAD_INFO(tsk) \ | |
52 | { \ | |
c99e6efe | 53 | .preempt_count = INIT_PREEMPT_COUNT, \ |
1da177e4 LT |
54 | .flags = 0, \ |
55 | } | |
56 | ||
b69c49b7 | 57 | #define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT) |
328985b2 | 58 | |
1da177e4 | 59 | /* how to get the thread information struct from C */ |
fd70d9f9 | 60 | extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src); |
425d3314 NP |
61 | |
62 | #ifdef CONFIG_PPC_BOOK3S_64 | |
63 | void arch_setup_new_exec(void); | |
64 | #define arch_setup_new_exec arch_setup_new_exec | |
65 | #endif | |
66 | ||
1da177e4 LT |
67 | #endif /* __ASSEMBLY__ */ |
68 | ||
1da177e4 LT |
69 | /* |
70 | * thread information flag bit numbers | |
71 | */ | |
72 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ | |
a583f1b5 SE |
73 | #define TIF_SIGPENDING 1 /* signal pending */ |
74 | #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ | |
3e378680 | 75 | #define TIF_FSCHECK 3 /* Check FS is USER_DS on return */ |
5521eb4b | 76 | #define TIF_SYSCALL_EMU 4 /* syscall emulation active */ |
d31626f7 | 77 | #define TIF_RESTORE_TM 5 /* need to restore TM FP/VEC/VSX */ |
a768f784 | 78 | #define TIF_PATCH_PENDING 6 /* pending live patching update */ |
a583f1b5 SE |
79 | #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ |
80 | #define TIF_SINGLESTEP 8 /* singlestepping active */ | |
22ecbe8d | 81 | #define TIF_NOHZ 9 /* in adaptive nohz mode */ |
a583f1b5 SE |
82 | #define TIF_SECCOMP 10 /* secure computing */ |
83 | #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */ | |
84 | #define TIF_NOERROR 12 /* Force successful syscall return */ | |
7d6d637d | 85 | #define TIF_NOTIFY_RESUME 13 /* callback before returning to user */ |
8b7b80b9 | 86 | #define TIF_UPROBE 14 /* breakpointed or single-stepping */ |
02424d89 | 87 | #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */ |
f0d1128f TC |
88 | #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation |
89 | for stack store? */ | |
22ecbe8d | 90 | #define TIF_MEMDIE 17 /* is terminating due to OOM killer */ |
373c76d6 RR |
91 | #if defined(CONFIG_PPC64) |
92 | #define TIF_ELF2ABI 18 /* function descriptors must die! */ | |
93 | #endif | |
3e378680 | 94 | #define TIF_POLLING_NRFLAG 19 /* true if poll_idle() is polling TIF_NEED_RESCHED */ |
16d7c69c | 95 | #define TIF_32BIT 20 /* 32 bit binary */ |
1da177e4 LT |
96 | |
97 | /* as above, but as bit values */ | |
98 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) | |
1da177e4 LT |
99 | #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) |
100 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) | |
101 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) | |
102 | #define _TIF_32BIT (1<<TIF_32BIT) | |
d31626f7 | 103 | #define _TIF_RESTORE_TM (1<<TIF_RESTORE_TM) |
a768f784 | 104 | #define _TIF_PATCH_PENDING (1<<TIF_PATCH_PENDING) |
1da177e4 LT |
105 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) |
106 | #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) | |
107 | #define _TIF_SECCOMP (1<<TIF_SECCOMP) | |
401d1f02 | 108 | #define _TIF_RESTOREALL (1<<TIF_RESTOREALL) |
401d1f02 | 109 | #define _TIF_NOERROR (1<<TIF_NOERROR) |
7d6d637d | 110 | #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) |
8b7b80b9 | 111 | #define _TIF_UPROBE (1<<TIF_UPROBE) |
02424d89 | 112 | #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT) |
f0d1128f | 113 | #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE) |
22ecbe8d | 114 | #define _TIF_NOHZ (1<<TIF_NOHZ) |
3e378680 | 115 | #define _TIF_FSCHECK (1<<TIF_FSCHECK) |
5521eb4b | 116 | #define _TIF_SYSCALL_EMU (1<<TIF_SYSCALL_EMU) |
10ea8343 | 117 | #define _TIF_SYSCALL_DOTRACE (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ |
22ecbe8d | 118 | _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \ |
5521eb4b | 119 | _TIF_NOHZ | _TIF_SYSCALL_EMU) |
1da177e4 | 120 | |
7d6d637d | 121 | #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ |
d31626f7 | 122 | _TIF_NOTIFY_RESUME | _TIF_UPROBE | \ |
3e378680 ME |
123 | _TIF_RESTORE_TM | _TIF_PATCH_PENDING | \ |
124 | _TIF_FSCHECK) | |
1bd79336 | 125 | #define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR) |
1da177e4 | 126 | |
f39224a8 PM |
127 | /* Bits in local_flags */ |
128 | /* Don't move TLF_NAPPING without adjusting the code in entry_32.S */ | |
129 | #define TLF_NAPPING 0 /* idle thread enabled NAP mode */ | |
a560643e | 130 | #define TLF_SLEEPING 1 /* suspend code enabled SLEEP mode */ |
d6bf29b4 | 131 | #define TLF_LAZY_MMU 3 /* tlb_batch is active */ |
fe1952fc | 132 | #define TLF_RUNLATCH 4 /* Is the runlatch enabled? */ |
f39224a8 PM |
133 | |
134 | #define _TLF_NAPPING (1 << TLF_NAPPING) | |
a560643e | 135 | #define _TLF_SLEEPING (1 << TLF_SLEEPING) |
d6bf29b4 | 136 | #define _TLF_LAZY_MMU (1 << TLF_LAZY_MMU) |
fe1952fc | 137 | #define _TLF_RUNLATCH (1 << TLF_RUNLATCH) |
7a10174e RM |
138 | |
139 | #ifndef __ASSEMBLY__ | |
a465f9b6 | 140 | |
fe1952fc BH |
141 | static inline bool test_thread_local_flags(unsigned int flags) |
142 | { | |
143 | struct thread_info *ti = current_thread_info(); | |
144 | return (ti->local_flags & flags) != 0; | |
145 | } | |
146 | ||
a465f9b6 AB |
147 | #ifdef CONFIG_PPC64 |
148 | #define is_32bit_task() (test_thread_flag(TIF_32BIT)) | |
149 | #else | |
150 | #define is_32bit_task() (1) | |
151 | #endif | |
152 | ||
373c76d6 RR |
153 | #if defined(CONFIG_PPC64) |
154 | #define is_elf2_task() (test_thread_flag(TIF_ELF2ABI)) | |
155 | #else | |
156 | #define is_elf2_task() (0) | |
157 | #endif | |
158 | ||
7a10174e | 159 | #endif /* !__ASSEMBLY__ */ |
f39224a8 | 160 | |
1da177e4 LT |
161 | #endif /* __KERNEL__ */ |
162 | ||
6cb7bfeb | 163 | #endif /* _ASM_POWERPC_THREAD_INFO_H */ |