forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 958e46acc8e900e8569dd467c1af9b8d2d019394
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,14 @@
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 */
40
- int preempt_lazy_count; /* 0 => preemptable,
57
+ int preempt_lazy_count; /* 0 => preemptable,
4158 <0 => BUG */
4259 unsigned long local_flags; /* private flags for thread */
4360 #ifdef CONFIG_LIVEPATCH
....@@ -46,6 +63,10 @@
4663 #if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) && defined(CONFIG_PPC32)
4764 struct cpu_accounting_data accounting;
4865 #endif
66
+ unsigned char slb_preload_nr;
67
+ unsigned char slb_preload_tail;
68
+ u32 slb_preload_esid[SLB_PRELOAD_NR];
69
+
4970 /* low level flags - has atomic operations done on it */
5071 unsigned long flags ____cacheline_aligned_in_smp;
5172 };
....@@ -55,8 +76,6 @@
5576 */
5677 #define INIT_THREAD_INFO(tsk) \
5778 { \
58
- .task = &tsk, \
59
- .cpu = 0, \
6079 .preempt_count = INIT_PREEMPT_COUNT, \
6180 .flags = 0, \
6281 }
....@@ -64,16 +83,13 @@
6483 #define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)
6584
6685 /* 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
-
7686 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
87
+
88
+#ifdef CONFIG_PPC_BOOK3S_64
89
+void arch_setup_new_exec(void);
90
+#define arch_setup_new_exec arch_setup_new_exec
91
+#endif
92
+
7793 #endif /* __ASSEMBLY__ */
7894
7995 /*
....@@ -82,7 +98,8 @@
8298 #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
8399 #define TIF_SIGPENDING 1 /* signal pending */
84100 #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
85
-#define TIF_FSCHECK 3 /* Check FS is USER_DS on return */
101
+#define TIF_NOTIFY_SIGNAL 3 /* signal notifications exist */
102
+#define TIF_SYSCALL_EMU 4 /* syscall emulation active */
86103 #define TIF_RESTORE_TM 5 /* need to restore TM FP/VEC/VSX */
87104 #define TIF_PATCH_PENDING 6 /* pending live patching update */
88105 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
....@@ -111,6 +128,7 @@
111128 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
112129 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
113130 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
131
+#define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL)
114132 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
115133 #define _TIF_32BIT (1<<TIF_32BIT)
116134 #define _TIF_RESTORE_TM (1<<TIF_RESTORE_TM)
....@@ -126,15 +144,15 @@
126144 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
127145 #define _TIF_NOHZ (1<<TIF_NOHZ)
128146 #define _TIF_NEED_RESCHED_LAZY (1<<TIF_NEED_RESCHED_LAZY)
129
-#define _TIF_FSCHECK (1<<TIF_FSCHECK)
147
+#define _TIF_SYSCALL_EMU (1<<TIF_SYSCALL_EMU)
130148 #define _TIF_SYSCALL_DOTRACE (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
131149 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
132
- _TIF_NOHZ)
150
+ _TIF_NOHZ | _TIF_SYSCALL_EMU)
133151
134152 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
135153 _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
136154 _TIF_RESTORE_TM | _TIF_PATCH_PENDING | \
137
- _TIF_FSCHECK | _TIF_NEED_RESCHED_LAZY)
155
+ _TIF_NEED_RESCHED_LAZY | _TIF_NOTIFY_SIGNAL)
138156 #define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR)
139157 #define _TIF_NEED_RESCHED_MASK (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)
140158
....@@ -158,10 +176,10 @@
158176 return (ti->local_flags & flags) != 0;
159177 }
160178
161
-#ifdef CONFIG_PPC64
179
+#ifdef CONFIG_COMPAT
162180 #define is_32bit_task() (test_thread_flag(TIF_32BIT))
163181 #else
164
-#define is_32bit_task() (1)
182
+#define is_32bit_task() (IS_ENABLED(CONFIG_PPC32))
165183 #endif
166184
167185 #if defined(CONFIG_PPC64)