Skip to content

Commit 00f178e

Browse files
committed
Merge tag 'xtensa-20211105' of git://github.com/jcmvbkbc/linux-xtensa
Pull xtensa updates from Max Filippov: - add support for xtensa cores without windowed registers option * tag 'xtensa-20211105' of git://github.com/jcmvbkbc/linux-xtensa: xtensa: move section symbols to asm/sections.h xtensa: remove unused variable wmask xtensa: only build windowed register support code when needed xtensa: use register window specific opcodes only when present xtensa: implement call0 ABI support in assembly xtensa: definitions for call0 ABI xtensa: don't use a12 in __xtensa_copy_user in call0 ABI xtensa: don't use a12 in strncpy_user xtensa: use a14 instead of a15 in inline assembly xtensa: move _SimulateUserKernelVectorException out of WindowVectors
2 parents 0b707e5 + bd47cdb commit 00f178e

File tree

21 files changed

+541
-265
lines changed

21 files changed

+541
-265
lines changed

arch/xtensa/boot/boot-elf/bootstrap.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ _bootparam:
4242

4343
.align 4
4444
_SetupMMU:
45+
#if XCHAL_HAVE_WINDOWED
4546
movi a0, 0
4647
wsr a0, windowbase
4748
rsync
4849
movi a0, 1
4950
wsr a0, windowstart
5051
rsync
52+
#endif
5153
movi a0, 0x1F
5254
wsr a0, ps
5355
rsync

arch/xtensa/boot/boot-redboot/bootstrap.S

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <asm/regs.h>
44
#include <asm/asmmacro.h>
55
#include <asm/cacheasm.h>
6+
#include <asm/processor.h>
67
/*
78
* RB-Data: RedBoot data/bss
89
* P: Boot-Parameters
@@ -36,7 +37,7 @@
3637
.globl __start
3738
/* this must be the first byte of the loader! */
3839
__start:
39-
entry sp, 32 # we do not intend to return
40+
abi_entry(32) # we do not intend to return
4041
_call0 _start
4142
__start_a0:
4243
.align 4
@@ -55,17 +56,19 @@ _start:
5556
movi a4, 1
5657
wsr a4, ps
5758
rsync
58-
59+
#if XCHAL_HAVE_WINDOWED
5960
rsr a5, windowbase
6061
ssl a5
6162
sll a4, a4
6263
wsr a4, windowstart
6364
rsync
64-
65-
movi a4, 0x00040000
65+
#endif
66+
movi a4, KERNEL_PS_WOE_MASK
6667
wsr a4, ps
6768
rsync
6869

70+
KABI_C0 mov abi_saved0, abi_arg0
71+
6972
/* copy the loader to its address
7073
* Note: The loader itself is a very small piece, so we assume we
7174
* don't partially overlap. We also assume (even more important)
@@ -168,52 +171,52 @@ _reloc:
168171

169172
movi a3, __image_load
170173
sub a4, a3, a4
171-
add a8, a0, a4
174+
add abi_arg2, a0, a4
172175

173176
# a1 Stack
174177
# a8(a4) Load address of the image
175178

176-
movi a6, _image_start
177-
movi a10, _image_end
178-
movi a7, 0x1000000
179-
sub a11, a10, a6
180-
movi a9, complen
181-
s32i a11, a9, 0
179+
movi abi_arg0, _image_start
180+
movi abi_arg4, _image_end
181+
movi abi_arg1, 0x1000000
182+
sub abi_tmp0, abi_arg4, abi_arg0
183+
movi abi_arg3, complen
184+
s32i abi_tmp0, abi_arg3, 0
182185

183186
movi a0, 0
184187

185-
# a6 destination
186-
# a7 maximum size of destination
187-
# a8 source
188-
# a9 ptr to length
188+
# abi_arg0 destination
189+
# abi_arg1 maximum size of destination
190+
# abi_arg2 source
191+
# abi_arg3 ptr to length
189192

190193
.extern gunzip
191-
movi a4, gunzip
192-
beqz a4, 1f
194+
movi abi_tmp0, gunzip
195+
beqz abi_tmp0, 1f
193196

194-
callx4 a4
197+
abi_callx abi_tmp0
195198

196199
j 2f
197200

198201

199-
# a6 destination start
200-
# a7 maximum size of destination
201-
# a8 source start
202-
# a9 ptr to length
203-
# a10 destination end
202+
# abi_arg0 destination start
203+
# abi_arg1 maximum size of destination
204+
# abi_arg2 source start
205+
# abi_arg3 ptr to length
206+
# abi_arg4 destination end
204207

205208
1:
206-
l32i a9, a8, 0
207-
l32i a11, a8, 4
208-
s32i a9, a6, 0
209-
s32i a11, a6, 4
210-
l32i a9, a8, 8
211-
l32i a11, a8, 12
212-
s32i a9, a6, 8
213-
s32i a11, a6, 12
214-
addi a6, a6, 16
215-
addi a8, a8, 16
216-
blt a6, a10, 1b
209+
l32i abi_tmp0, abi_arg2, 0
210+
l32i abi_tmp1, abi_arg2, 4
211+
s32i abi_tmp0, abi_arg0, 0
212+
s32i abi_tmp1, abi_arg0, 4
213+
l32i abi_tmp0, abi_arg2, 8
214+
l32i abi_tmp1, abi_arg2, 12
215+
s32i abi_tmp0, abi_arg0, 8
216+
s32i abi_tmp1, abi_arg0, 12
217+
addi abi_arg0, abi_arg0, 16
218+
addi abi_arg2, abi_arg2, 16
219+
blt abi_arg0, abi_arg4, 1b
217220

218221

219222
/* jump to the kernel */
@@ -230,6 +233,7 @@ _reloc:
230233

231234
# a2 Boot parameter list
232235

236+
KABI_C0 mov abi_arg0, abi_saved0
233237
movi a0, _image_start
234238
jx a0
235239

arch/xtensa/include/asm/asmmacro.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@
194194
#define XTENSA_STACK_ALIGNMENT 16
195195

196196
#if defined(__XTENSA_WINDOWED_ABI__)
197+
198+
/* Assembly instructions for windowed kernel ABI. */
199+
#define KABI_W
200+
/* Assembly instructions for call0 kernel ABI (will be ignored). */
201+
#define KABI_C0 #
202+
197203
#define XTENSA_FRAME_SIZE_RESERVE 16
198204
#define XTENSA_SPILL_STACK_RESERVE 32
199205

@@ -206,8 +212,34 @@
206212
#define abi_ret(frame_size) retw
207213
#define abi_ret_default retw
208214

215+
/* direct call */
216+
#define abi_call call4
217+
/* indirect call */
218+
#define abi_callx callx4
219+
/* outgoing call argument registers */
220+
#define abi_arg0 a6
221+
#define abi_arg1 a7
222+
#define abi_arg2 a8
223+
#define abi_arg3 a9
224+
#define abi_arg4 a10
225+
#define abi_arg5 a11
226+
/* return value */
227+
#define abi_rv a6
228+
/* registers preserved across call */
229+
#define abi_saved0 a2
230+
#define abi_saved1 a3
231+
232+
/* none of the above */
233+
#define abi_tmp0 a4
234+
#define abi_tmp1 a5
235+
209236
#elif defined(__XTENSA_CALL0_ABI__)
210237

238+
/* Assembly instructions for windowed kernel ABI (will be ignored). */
239+
#define KABI_W #
240+
/* Assembly instructions for call0 kernel ABI. */
241+
#define KABI_C0
242+
211243
#define XTENSA_SPILL_STACK_RESERVE 0
212244

213245
#define abi_entry(frame_size) __abi_entry (frame_size)
@@ -233,10 +265,43 @@
233265

234266
#define abi_ret_default ret
235267

268+
/* direct call */
269+
#define abi_call call0
270+
/* indirect call */
271+
#define abi_callx callx0
272+
/* outgoing call argument registers */
273+
#define abi_arg0 a2
274+
#define abi_arg1 a3
275+
#define abi_arg2 a4
276+
#define abi_arg3 a5
277+
#define abi_arg4 a6
278+
#define abi_arg5 a7
279+
/* return value */
280+
#define abi_rv a2
281+
/* registers preserved across call */
282+
#define abi_saved0 a12
283+
#define abi_saved1 a13
284+
285+
/* none of the above */
286+
#define abi_tmp0 a8
287+
#define abi_tmp1 a9
288+
236289
#else
237290
#error Unsupported Xtensa ABI
238291
#endif
239292

293+
#if defined(USER_SUPPORT_WINDOWED)
294+
/* Assembly instructions for windowed user ABI. */
295+
#define UABI_W
296+
/* Assembly instructions for call0 user ABI (will be ignored). */
297+
#define UABI_C0 #
298+
#else
299+
/* Assembly instructions for windowed user ABI (will be ignored). */
300+
#define UABI_W #
301+
/* Assembly instructions for call0 user ABI. */
302+
#define UABI_C0
303+
#endif
304+
240305
#define __XTENSA_HANDLER .section ".exception.text", "ax"
241306

242307
#endif /* _XTENSA_ASMMACRO_H */

arch/xtensa/include/asm/atomic.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
*
2626
* Locking interrupts looks like this:
2727
*
28-
* rsil a15, TOPLEVEL
28+
* rsil a14, TOPLEVEL
2929
* <code>
30-
* wsr a15, PS
30+
* wsr a14, PS
3131
* rsync
3232
*
33-
* Note that a15 is used here because the register allocation
33+
* Note that a14 is used here because the register allocation
3434
* done by the compiler is not guaranteed and a window overflow
3535
* may not occur between the rsil and wsr instructions. By using
36-
* a15 in the rsil, the machine is guaranteed to be in a state
36+
* a14 in the rsil, the machine is guaranteed to be in a state
3737
* where no register reference will cause an overflow.
3838
*/
3939

@@ -185,15 +185,15 @@ static inline void arch_atomic_##op(int i, atomic_t * v) \
185185
unsigned int vval; \
186186
\
187187
__asm__ __volatile__( \
188-
" rsil a15, "__stringify(TOPLEVEL)"\n" \
188+
" rsil a14, "__stringify(TOPLEVEL)"\n" \
189189
" l32i %[result], %[mem]\n" \
190190
" " #op " %[result], %[result], %[i]\n" \
191191
" s32i %[result], %[mem]\n" \
192-
" wsr a15, ps\n" \
192+
" wsr a14, ps\n" \
193193
" rsync\n" \
194194
: [result] "=&a" (vval), [mem] "+m" (*v) \
195195
: [i] "a" (i) \
196-
: "a15", "memory" \
196+
: "a14", "memory" \
197197
); \
198198
} \
199199

@@ -203,15 +203,15 @@ static inline int arch_atomic_##op##_return(int i, atomic_t * v) \
203203
unsigned int vval; \
204204
\
205205
__asm__ __volatile__( \
206-
" rsil a15,"__stringify(TOPLEVEL)"\n" \
206+
" rsil a14,"__stringify(TOPLEVEL)"\n" \
207207
" l32i %[result], %[mem]\n" \
208208
" " #op " %[result], %[result], %[i]\n" \
209209
" s32i %[result], %[mem]\n" \
210-
" wsr a15, ps\n" \
210+
" wsr a14, ps\n" \
211211
" rsync\n" \
212212
: [result] "=&a" (vval), [mem] "+m" (*v) \
213213
: [i] "a" (i) \
214-
: "a15", "memory" \
214+
: "a14", "memory" \
215215
); \
216216
\
217217
return vval; \
@@ -223,16 +223,16 @@ static inline int arch_atomic_fetch_##op(int i, atomic_t * v) \
223223
unsigned int tmp, vval; \
224224
\
225225
__asm__ __volatile__( \
226-
" rsil a15,"__stringify(TOPLEVEL)"\n" \
226+
" rsil a14,"__stringify(TOPLEVEL)"\n" \
227227
" l32i %[result], %[mem]\n" \
228228
" " #op " %[tmp], %[result], %[i]\n" \
229229
" s32i %[tmp], %[mem]\n" \
230-
" wsr a15, ps\n" \
230+
" wsr a14, ps\n" \
231231
" rsync\n" \
232232
: [result] "=&a" (vval), [tmp] "=&a" (tmp), \
233233
[mem] "+m" (*v) \
234234
: [i] "a" (i) \
235-
: "a15", "memory" \
235+
: "a14", "memory" \
236236
); \
237237
\
238238
return vval; \

arch/xtensa/include/asm/cmpxchg.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ __cmpxchg_u32(volatile int *p, int old, int new)
5252
return new;
5353
#else
5454
__asm__ __volatile__(
55-
" rsil a15, "__stringify(TOPLEVEL)"\n"
55+
" rsil a14, "__stringify(TOPLEVEL)"\n"
5656
" l32i %[old], %[mem]\n"
5757
" bne %[old], %[cmp], 1f\n"
5858
" s32i %[new], %[mem]\n"
5959
"1:\n"
60-
" wsr a15, ps\n"
60+
" wsr a14, ps\n"
6161
" rsync\n"
6262
: [old] "=&a" (old), [mem] "+m" (*p)
6363
: [cmp] "a" (old), [new] "r" (new)
64-
: "a15", "memory");
64+
: "a14", "memory");
6565
return old;
6666
#endif
6767
}
@@ -116,10 +116,10 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr,
116116
/*
117117
* xchg_u32
118118
*
119-
* Note that a15 is used here because the register allocation
119+
* Note that a14 is used here because the register allocation
120120
* done by the compiler is not guaranteed and a window overflow
121121
* may not occur between the rsil and wsr instructions. By using
122-
* a15 in the rsil, the machine is guaranteed to be in a state
122+
* a14 in the rsil, the machine is guaranteed to be in a state
123123
* where no register reference will cause an overflow.
124124
*/
125125

@@ -157,14 +157,14 @@ static inline unsigned long xchg_u32(volatile int * m, unsigned long val)
157157
#else
158158
unsigned long tmp;
159159
__asm__ __volatile__(
160-
" rsil a15, "__stringify(TOPLEVEL)"\n"
160+
" rsil a14, "__stringify(TOPLEVEL)"\n"
161161
" l32i %[tmp], %[mem]\n"
162162
" s32i %[val], %[mem]\n"
163-
" wsr a15, ps\n"
163+
" wsr a14, ps\n"
164164
" rsync\n"
165165
: [tmp] "=&a" (tmp), [mem] "+m" (*m)
166166
: [val] "a" (val)
167-
: "a15", "memory");
167+
: "a14", "memory");
168168
return tmp;
169169
#endif
170170
}

arch/xtensa/include/asm/core.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,15 @@
2626
#define XCHAL_SPANNING_WAY 0
2727
#endif
2828

29+
#if XCHAL_HAVE_WINDOWED
30+
#if defined(CONFIG_USER_ABI_DEFAULT) || defined(CONFIG_USER_ABI_CALL0_PROBE)
31+
/* Whether windowed ABI is supported in userspace. */
32+
#define USER_SUPPORT_WINDOWED
33+
#endif
34+
#if defined(__XTENSA_WINDOWED_ABI__) || defined(USER_SUPPORT_WINDOWED)
35+
/* Whether windowed ABI is supported either in userspace or in the kernel. */
36+
#define SUPPORT_WINDOWED
37+
#endif
38+
#endif
39+
2940
#endif

0 commit comments

Comments
 (0)