hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/xtensa/include/asm/processor.h
....@@ -10,9 +10,10 @@
1010 #ifndef _XTENSA_PROCESSOR_H
1111 #define _XTENSA_PROCESSOR_H
1212
13
-#include <variant/core.h>
13
+#include <asm/core.h>
1414
1515 #include <linux/compiler.h>
16
+#include <linux/stringify.h>
1617 #include <asm/ptrace.h>
1718 #include <asm/types.h>
1819 #include <asm/regs.h>
....@@ -156,14 +157,6 @@
156157 int align[0] __attribute__ ((aligned(16)));
157158 };
158159
159
-
160
-/*
161
- * Default implementation of macro that returns current
162
- * instruction pointer ("program counter").
163
- */
164
-#define current_text_addr() ({ __label__ _l; _l: &&_l;})
165
-
166
-
167160 /* This decides where the kernel will search for a free chunk of vm
168161 * space during mmap's.
169162 */
....@@ -183,26 +176,37 @@
183176
184177 /*
185178 * Do necessary setup to start up a newly executed thread.
186
- * Note: We set-up ps as if we did a call4 to the new pc.
179
+ * Note: When windowed ABI is used for userspace we set-up ps
180
+ * as if we did a call4 to the new pc.
187181 * set_thread_state in signal.c depends on it.
188182 */
189
-#define USER_PS_VALUE ((1 << PS_WOE_BIT) | \
183
+#if IS_ENABLED(CONFIG_USER_ABI_CALL0)
184
+#define USER_PS_VALUE ((USER_RING << PS_RING_SHIFT) | \
185
+ (1 << PS_UM_BIT) | \
186
+ (1 << PS_EXCM_BIT))
187
+#else
188
+#define USER_PS_VALUE (PS_WOE_MASK | \
190189 (1 << PS_CALLINC_SHIFT) | \
191190 (USER_RING << PS_RING_SHIFT) | \
192191 (1 << PS_UM_BIT) | \
193192 (1 << PS_EXCM_BIT))
193
+#endif
194194
195195 /* Clearing a0 terminates the backtrace. */
196196 #define start_thread(regs, new_pc, new_sp) \
197
- memset(regs, 0, sizeof(*regs)); \
198
- regs->pc = new_pc; \
199
- regs->ps = USER_PS_VALUE; \
200
- regs->areg[1] = new_sp; \
201
- regs->areg[0] = 0; \
202
- regs->wmask = 1; \
203
- regs->depc = 0; \
204
- regs->windowbase = 0; \
205
- regs->windowstart = 1;
197
+ do { \
198
+ unsigned long syscall = (regs)->syscall; \
199
+ memset((regs), 0, sizeof(*(regs))); \
200
+ (regs)->pc = (new_pc); \
201
+ (regs)->ps = USER_PS_VALUE; \
202
+ (regs)->areg[1] = (new_sp); \
203
+ (regs)->areg[0] = 0; \
204
+ (regs)->wmask = 1; \
205
+ (regs)->depc = 0; \
206
+ (regs)->windowbase = 0; \
207
+ (regs)->windowstart = 1; \
208
+ (regs)->syscall = syscall; \
209
+ } while (0)
206210
207211 /* Forward declaration */
208212 struct task_struct;
....@@ -220,15 +224,18 @@
220224
221225 /* Special register access. */
222226
223
-#define WSR(v,sr) __asm__ __volatile__ ("wsr %0,"__stringify(sr) :: "a"(v));
224
-#define RSR(v,sr) __asm__ __volatile__ ("rsr %0,"__stringify(sr) : "=a"(v));
227
+#define xtensa_set_sr(x, sr) \
228
+ ({ \
229
+ __asm__ __volatile__ ("wsr %0, "__stringify(sr) :: \
230
+ "a"((unsigned int)(x))); \
231
+ })
225232
226
-#define set_sr(x,sr) ({unsigned int v=(unsigned int)x; WSR(v,sr);})
227
-#define get_sr(sr) ({unsigned int v; RSR(v,sr); v; })
228
-
229
-#ifndef XCHAL_HAVE_EXTERN_REGS
230
-#define XCHAL_HAVE_EXTERN_REGS 0
231
-#endif
233
+#define xtensa_get_sr(sr) \
234
+ ({ \
235
+ unsigned int v; \
236
+ __asm__ __volatile__ ("rsr %0, "__stringify(sr) : "=a"(v)); \
237
+ v; \
238
+ })
232239
233240 #if XCHAL_HAVE_EXTERN_REGS
234241