.. | .. |
---|
10 | 10 | #ifndef _XTENSA_PROCESSOR_H |
---|
11 | 11 | #define _XTENSA_PROCESSOR_H |
---|
12 | 12 | |
---|
13 | | -#include <variant/core.h> |
---|
| 13 | +#include <asm/core.h> |
---|
14 | 14 | |
---|
15 | 15 | #include <linux/compiler.h> |
---|
| 16 | +#include <linux/stringify.h> |
---|
16 | 17 | #include <asm/ptrace.h> |
---|
17 | 18 | #include <asm/types.h> |
---|
18 | 19 | #include <asm/regs.h> |
---|
.. | .. |
---|
156 | 157 | int align[0] __attribute__ ((aligned(16))); |
---|
157 | 158 | }; |
---|
158 | 159 | |
---|
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 | | - |
---|
167 | 160 | /* This decides where the kernel will search for a free chunk of vm |
---|
168 | 161 | * space during mmap's. |
---|
169 | 162 | */ |
---|
.. | .. |
---|
183 | 176 | |
---|
184 | 177 | /* |
---|
185 | 178 | * 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. |
---|
187 | 181 | * set_thread_state in signal.c depends on it. |
---|
188 | 182 | */ |
---|
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 | \ |
---|
190 | 189 | (1 << PS_CALLINC_SHIFT) | \ |
---|
191 | 190 | (USER_RING << PS_RING_SHIFT) | \ |
---|
192 | 191 | (1 << PS_UM_BIT) | \ |
---|
193 | 192 | (1 << PS_EXCM_BIT)) |
---|
| 193 | +#endif |
---|
194 | 194 | |
---|
195 | 195 | /* Clearing a0 terminates the backtrace. */ |
---|
196 | 196 | #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) |
---|
206 | 210 | |
---|
207 | 211 | /* Forward declaration */ |
---|
208 | 212 | struct task_struct; |
---|
.. | .. |
---|
220 | 224 | |
---|
221 | 225 | /* Special register access. */ |
---|
222 | 226 | |
---|
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 | + }) |
---|
225 | 232 | |
---|
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 | + }) |
---|
232 | 239 | |
---|
233 | 240 | #if XCHAL_HAVE_EXTERN_REGS |
---|
234 | 241 | |
---|