hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/arch/powerpc/include/asm/thread_info.h
....@@ -10,18 +10,36 @@
1010 #define _ASM_POWERPC_THREAD_INFO_H
1111
1212 #include <asm/asm-const.h>
13
+#include <asm/page.h>
1314
1415 #ifdef __KERNEL__
1516
16
-#define THREAD_SHIFT CONFIG_THREAD_SHIFT
17
+#ifdef CONFIG_KASAN
18
+#define MIN_THREAD_SHIFT (CONFIG_THREAD_SHIFT + 1)
19
+#else
20
+#define MIN_THREAD_SHIFT CONFIG_THREAD_SHIFT
21
+#endif
22
+
23
+#if defined(CONFIG_VMAP_STACK) && MIN_THREAD_SHIFT < PAGE_SHIFT
24
+#define THREAD_SHIFT PAGE_SHIFT
25
+#else
26
+#define THREAD_SHIFT MIN_THREAD_SHIFT
27
+#endif
1728
1829 #define THREAD_SIZE (1 << THREAD_SHIFT)
1930
20
-#ifdef CONFIG_PPC64
21
-#define CURRENT_THREAD_INFO(dest, sp) stringify_in_c(clrrdi dest, sp, THREAD_SHIFT)
31
+/*
32
+ * By aligning VMAP'd stacks to 2 * THREAD_SIZE, we can detect overflow by
33
+ * checking sp & (1 << THREAD_SHIFT), which we can do cheaply in the entry
34
+ * assembly.
35
+ */
36
+#ifdef CONFIG_VMAP_STACK
37
+#define THREAD_ALIGN_SHIFT (THREAD_SHIFT + 1)
2238 #else
23
-#define CURRENT_THREAD_INFO(dest, sp) stringify_in_c(rlwinm dest, sp, 0, 0, 31-THREAD_SHIFT)
39
+#define THREAD_ALIGN_SHIFT THREAD_SHIFT
2440 #endif
41
+
42
+#define THREAD_ALIGN (1 << THREAD_ALIGN_SHIFT)
2543
2644 #ifndef __ASSEMBLY__
2745 #include <linux/cache.h>
....@@ -29,12 +47,11 @@
2947 #include <asm/page.h>
3048 #include <asm/accounting.h>
3149
50
+#define SLB_PRELOAD_NR 16U
3251 /*
3352 * low level task data.
3453 */
3554 struct thread_info {
36
- struct task_struct *task; /* main task structure */
37
- int cpu; /* cpu we're on */
3855 int preempt_count; /* 0 => preemptable,
3956 <0 => BUG */
4057 unsigned long local_flags; /* private flags for thread */
....@@ -44,6 +61,10 @@
4461 #if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) && defined(CONFIG_PPC32)
4562 struct cpu_accounting_data accounting;
4663 #endif
64
+ unsigned char slb_preload_nr;
65
+ unsigned char slb_preload_tail;
66
+ u32 slb_preload_esid[SLB_PRELOAD_NR];
67
+
4768 /* low level flags - has atomic operations done on it */
4869 unsigned long flags ____cacheline_aligned_in_smp;
4970 };
....@@ -53,8 +74,6 @@
5374 */
5475 #define INIT_THREAD_INFO(tsk) \
5576 { \
56
- .task = &tsk, \
57
- .cpu = 0, \
5877 .preempt_count = INIT_PREEMPT_COUNT, \
5978 .flags = 0, \
6079 }
....@@ -62,16 +81,13 @@
6281 #define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)
6382
6483 /* how to get the thread information struct from C */
65
-static inline struct thread_info *current_thread_info(void)
66
-{
67
- unsigned long val;
68
-
69
- asm (CURRENT_THREAD_INFO(%0,1) : "=r" (val));
70
-
71
- return (struct thread_info *)val;
72
-}
73
-
7484 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
85
+
86
+#ifdef CONFIG_PPC_BOOK3S_64
87
+void arch_setup_new_exec(void);
88
+#define arch_setup_new_exec arch_setup_new_exec
89
+#endif
90
+
7591 #endif /* __ASSEMBLY__ */
7692
7793 /*
....@@ -80,8 +96,8 @@
8096 #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
8197 #define TIF_SIGPENDING 1 /* signal pending */
8298 #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
83
-#define TIF_FSCHECK 3 /* Check FS is USER_DS on return */
84
-#define TIF_32BIT 4 /* 32 bit binary */
99
+#define TIF_NOTIFY_SIGNAL 3 /* signal notifications exist */
100
+#define TIF_SYSCALL_EMU 4 /* syscall emulation active */
85101 #define TIF_RESTORE_TM 5 /* need to restore TM FP/VEC/VSX */
86102 #define TIF_PATCH_PENDING 6 /* pending live patching update */
87103 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
....@@ -100,11 +116,13 @@
100116 #define TIF_ELF2ABI 18 /* function descriptors must die! */
101117 #endif
102118 #define TIF_POLLING_NRFLAG 19 /* true if poll_idle() is polling TIF_NEED_RESCHED */
119
+#define TIF_32BIT 20 /* 32 bit binary */
103120
104121 /* as above, but as bit values */
105122 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
106123 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
107124 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
125
+#define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL)
108126 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
109127 #define _TIF_32BIT (1<<TIF_32BIT)
110128 #define _TIF_RESTORE_TM (1<<TIF_RESTORE_TM)
....@@ -119,15 +137,15 @@
119137 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
120138 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
121139 #define _TIF_NOHZ (1<<TIF_NOHZ)
122
-#define _TIF_FSCHECK (1<<TIF_FSCHECK)
140
+#define _TIF_SYSCALL_EMU (1<<TIF_SYSCALL_EMU)
123141 #define _TIF_SYSCALL_DOTRACE (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
124142 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
125
- _TIF_NOHZ)
143
+ _TIF_NOHZ | _TIF_SYSCALL_EMU)
126144
127145 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
128146 _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
129147 _TIF_RESTORE_TM | _TIF_PATCH_PENDING | \
130
- _TIF_FSCHECK)
148
+ _TIF_NOTIFY_SIGNAL)
131149 #define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR)
132150
133151 /* Bits in local_flags */
....@@ -150,10 +168,10 @@
150168 return (ti->local_flags & flags) != 0;
151169 }
152170
153
-#ifdef CONFIG_PPC64
171
+#ifdef CONFIG_COMPAT
154172 #define is_32bit_task() (test_thread_flag(TIF_32BIT))
155173 #else
156
-#define is_32bit_task() (1)
174
+#define is_32bit_task() (IS_ENABLED(CONFIG_PPC32))
157175 #endif
158176
159177 #if defined(CONFIG_PPC64)