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,13 +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,
56
+ <0 => BUG */
57
+ int preempt_lazy_count; /* 0 => preemptable,
3958 <0 => BUG */
4059 unsigned long local_flags; /* private flags for thread */
4160 #ifdef CONFIG_LIVEPATCH
....@@ -44,6 +63,10 @@
4463 #if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) && defined(CONFIG_PPC32)
4564 struct cpu_accounting_data accounting;
4665 #endif
66
+ unsigned char slb_preload_nr;
67
+ unsigned char slb_preload_tail;
68
+ u32 slb_preload_esid[SLB_PRELOAD_NR];
69
+
4770 /* low level flags - has atomic operations done on it */
4871 unsigned long flags ____cacheline_aligned_in_smp;
4972 };
....@@ -53,8 +76,6 @@
5376 */
5477 #define INIT_THREAD_INFO(tsk) \
5578 { \
56
- .task = &tsk, \
57
- .cpu = 0, \
5879 .preempt_count = INIT_PREEMPT_COUNT, \
5980 .flags = 0, \
6081 }
....@@ -62,16 +83,13 @@
6283 #define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)
6384
6485 /* 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
-
7486 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
+
7593 #endif /* __ASSEMBLY__ */
7694
7795 /*
....@@ -80,19 +98,20 @@
8098 #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
8199 #define TIF_SIGPENDING 1 /* signal pending */
82100 #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 */
101
+#define TIF_NOTIFY_SIGNAL 3 /* signal notifications exist */
102
+#define TIF_SYSCALL_EMU 4 /* syscall emulation active */
85103 #define TIF_RESTORE_TM 5 /* need to restore TM FP/VEC/VSX */
86104 #define TIF_PATCH_PENDING 6 /* pending live patching update */
87105 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
88106 #define TIF_SINGLESTEP 8 /* singlestepping active */
89107 #define TIF_NOHZ 9 /* in adaptive nohz mode */
90108 #define TIF_SECCOMP 10 /* secure computing */
91
-#define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
92
-#define TIF_NOERROR 12 /* Force successful syscall return */
109
+
110
+#define TIF_NEED_RESCHED_LAZY 11 /* lazy rescheduling necessary */
111
+#define TIF_SYSCALL_TRACEPOINT 12 /* syscall tracepoint instrumentation */
112
+
93113 #define TIF_NOTIFY_RESUME 13 /* callback before returning to user */
94114 #define TIF_UPROBE 14 /* breakpointed or single-stepping */
95
-#define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
96115 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
97116 for stack store? */
98117 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
....@@ -100,11 +119,16 @@
100119 #define TIF_ELF2ABI 18 /* function descriptors must die! */
101120 #endif
102121 #define TIF_POLLING_NRFLAG 19 /* true if poll_idle() is polling TIF_NEED_RESCHED */
122
+#define TIF_32BIT 20 /* 32 bit binary */
123
+#define TIF_RESTOREALL 21 /* Restore all regs (implies NOERROR) */
124
+#define TIF_NOERROR 22 /* Force successful syscall return */
125
+
103126
104127 /* as above, but as bit values */
105128 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
106129 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
107130 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
131
+#define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL)
108132 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
109133 #define _TIF_32BIT (1<<TIF_32BIT)
110134 #define _TIF_RESTORE_TM (1<<TIF_RESTORE_TM)
....@@ -119,16 +143,18 @@
119143 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
120144 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
121145 #define _TIF_NOHZ (1<<TIF_NOHZ)
122
-#define _TIF_FSCHECK (1<<TIF_FSCHECK)
146
+#define _TIF_NEED_RESCHED_LAZY (1<<TIF_NEED_RESCHED_LAZY)
147
+#define _TIF_SYSCALL_EMU (1<<TIF_SYSCALL_EMU)
123148 #define _TIF_SYSCALL_DOTRACE (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
124149 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
125
- _TIF_NOHZ)
150
+ _TIF_NOHZ | _TIF_SYSCALL_EMU)
126151
127152 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
128153 _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
129154 _TIF_RESTORE_TM | _TIF_PATCH_PENDING | \
130
- _TIF_FSCHECK)
155
+ _TIF_NEED_RESCHED_LAZY | _TIF_NOTIFY_SIGNAL)
131156 #define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR)
157
+#define _TIF_NEED_RESCHED_MASK (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)
132158
133159 /* Bits in local_flags */
134160 /* Don't move TLF_NAPPING without adjusting the code in entry_32.S */
....@@ -150,10 +176,10 @@
150176 return (ti->local_flags & flags) != 0;
151177 }
152178
153
-#ifdef CONFIG_PPC64
179
+#ifdef CONFIG_COMPAT
154180 #define is_32bit_task() (test_thread_flag(TIF_32BIT))
155181 #else
156
-#define is_32bit_task() (1)
182
+#define is_32bit_task() (IS_ENABLED(CONFIG_PPC32))
157183 #endif
158184
159185 #if defined(CONFIG_PPC64)