hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
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,15 +47,12 @@
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,
39
- <0 => BUG */
40
- int preempt_lazy_count; /* 0 => preemptable,
4156 <0 => BUG */
4257 unsigned long local_flags; /* private flags for thread */
4358 #ifdef CONFIG_LIVEPATCH
....@@ -46,6 +61,10 @@
4661 #if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) && defined(CONFIG_PPC32)
4762 struct cpu_accounting_data accounting;
4863 #endif
64
+ unsigned char slb_preload_nr;
65
+ unsigned char slb_preload_tail;
66
+ u32 slb_preload_esid[SLB_PRELOAD_NR];
67
+
4968 /* low level flags - has atomic operations done on it */
5069 unsigned long flags ____cacheline_aligned_in_smp;
5170 };
....@@ -55,8 +74,6 @@
5574 */
5675 #define INIT_THREAD_INFO(tsk) \
5776 { \
58
- .task = &tsk, \
59
- .cpu = 0, \
6077 .preempt_count = INIT_PREEMPT_COUNT, \
6178 .flags = 0, \
6279 }
....@@ -64,16 +81,13 @@
6481 #define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)
6582
6683 /* how to get the thread information struct from C */
67
-static inline struct thread_info *current_thread_info(void)
68
-{
69
- unsigned long val;
70
-
71
- asm (CURRENT_THREAD_INFO(%0,1) : "=r" (val));
72
-
73
- return (struct thread_info *)val;
74
-}
75
-
7684 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
+
7791 #endif /* __ASSEMBLY__ */
7892
7993 /*
....@@ -82,19 +96,19 @@
8296 #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
8397 #define TIF_SIGPENDING 1 /* signal pending */
8498 #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
85
-#define TIF_FSCHECK 3 /* Check FS is USER_DS on return */
99
+#define TIF_NOTIFY_SIGNAL 3 /* signal notifications exist */
100
+#define TIF_SYSCALL_EMU 4 /* syscall emulation active */
86101 #define TIF_RESTORE_TM 5 /* need to restore TM FP/VEC/VSX */
87102 #define TIF_PATCH_PENDING 6 /* pending live patching update */
88103 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
89104 #define TIF_SINGLESTEP 8 /* singlestepping active */
90105 #define TIF_NOHZ 9 /* in adaptive nohz mode */
91106 #define TIF_SECCOMP 10 /* secure computing */
92
-
93
-#define TIF_NEED_RESCHED_LAZY 11 /* lazy rescheduling necessary */
94
-#define TIF_SYSCALL_TRACEPOINT 12 /* syscall tracepoint instrumentation */
95
-
107
+#define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
108
+#define TIF_NOERROR 12 /* Force successful syscall return */
96109 #define TIF_NOTIFY_RESUME 13 /* callback before returning to user */
97110 #define TIF_UPROBE 14 /* breakpointed or single-stepping */
111
+#define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
98112 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
99113 for stack store? */
100114 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
....@@ -103,14 +117,12 @@
103117 #endif
104118 #define TIF_POLLING_NRFLAG 19 /* true if poll_idle() is polling TIF_NEED_RESCHED */
105119 #define TIF_32BIT 20 /* 32 bit binary */
106
-#define TIF_RESTOREALL 21 /* Restore all regs (implies NOERROR) */
107
-#define TIF_NOERROR 22 /* Force successful syscall return */
108
-
109120
110121 /* as above, but as bit values */
111122 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
112123 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
113124 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
125
+#define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL)
114126 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
115127 #define _TIF_32BIT (1<<TIF_32BIT)
116128 #define _TIF_RESTORE_TM (1<<TIF_RESTORE_TM)
....@@ -125,18 +137,16 @@
125137 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
126138 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
127139 #define _TIF_NOHZ (1<<TIF_NOHZ)
128
-#define _TIF_NEED_RESCHED_LAZY (1<<TIF_NEED_RESCHED_LAZY)
129
-#define _TIF_FSCHECK (1<<TIF_FSCHECK)
140
+#define _TIF_SYSCALL_EMU (1<<TIF_SYSCALL_EMU)
130141 #define _TIF_SYSCALL_DOTRACE (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
131142 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
132
- _TIF_NOHZ)
143
+ _TIF_NOHZ | _TIF_SYSCALL_EMU)
133144
134145 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
135146 _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
136147 _TIF_RESTORE_TM | _TIF_PATCH_PENDING | \
137
- _TIF_FSCHECK | _TIF_NEED_RESCHED_LAZY)
148
+ _TIF_NOTIFY_SIGNAL)
138149 #define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR)
139
-#define _TIF_NEED_RESCHED_MASK (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)
140150
141151 /* Bits in local_flags */
142152 /* Don't move TLF_NAPPING without adjusting the code in entry_32.S */
....@@ -158,10 +168,10 @@
158168 return (ti->local_flags & flags) != 0;
159169 }
160170
161
-#ifdef CONFIG_PPC64
171
+#ifdef CONFIG_COMPAT
162172 #define is_32bit_task() (test_thread_flag(TIF_32BIT))
163173 #else
164
-#define is_32bit_task() (1)
174
+#define is_32bit_task() (IS_ENABLED(CONFIG_PPC32))
165175 #endif
166176
167177 #if defined(CONFIG_PPC64)