Skip to content

Commit 61a6b91

Browse files
committed
xtensa: don't use a12 in __xtensa_copy_user in call0 ABI
a12 is callee-saved register in xtensa call0 ABI, so a function must not change it. The main unaligned copy loop of __xtensa_copy_user uses all low-numbered registers, so a register must be spilled to avoid using a12 as a loop counter. Signed-off-by: Max Filippov <[email protected]>
1 parent d191323 commit 61a6b91

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

arch/xtensa/lib/usercopy.S

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@
6060
.text
6161
ENTRY(__xtensa_copy_user)
6262

63-
abi_entry_default
63+
#if !XCHAL_HAVE_LOOPS && defined(__XTENSA_CALL0_ABI__)
64+
#define STACK_SIZE 4
65+
#else
66+
#define STACK_SIZE 0
67+
#endif
68+
abi_entry(STACK_SIZE)
6469
# a2/ dst, a3/ src, a4/ len
6570
mov a5, a2 # copy dst so that a2 is return value
6671
mov a11, a4 # preserve original len for error case
@@ -75,7 +80,7 @@ ENTRY(__xtensa_copy_user)
7580
__ssa8 a3 # set shift amount from byte offset
7681
bnez a4, .Lsrcunaligned
7782
movi a2, 0 # return success for len==0
78-
abi_ret_default
83+
abi_ret(STACK_SIZE)
7984

8085
/*
8186
* Destination is unaligned
@@ -127,7 +132,7 @@ EX(10f) s8i a6, a5, 0
127132
#endif /* !XCHAL_HAVE_LOOPS */
128133
.Lbytecopydone:
129134
movi a2, 0 # return success for len bytes copied
130-
abi_ret_default
135+
abi_ret(STACK_SIZE)
131136

132137
/*
133138
* Destination and source are word-aligned.
@@ -187,7 +192,7 @@ EX(10f) l8ui a6, a3, 0
187192
EX(10f) s8i a6, a5, 0
188193
.L5:
189194
movi a2, 0 # return success for len bytes copied
190-
abi_ret_default
195+
abi_ret(STACK_SIZE)
191196

192197
/*
193198
* Destination is aligned, Source is unaligned
@@ -205,8 +210,14 @@ EX(10f) l32i a6, a3, 0 # load first word
205210
loopnez a7, .Loop2done
206211
#else /* !XCHAL_HAVE_LOOPS */
207212
beqz a7, .Loop2done
213+
#if defined(__XTENSA_CALL0_ABI__)
214+
s32i a10, a1, 0
215+
slli a10, a7, 4
216+
add a10, a10, a3 # a10 = end of last 16B source chunk
217+
#else
208218
slli a12, a7, 4
209219
add a12, a12, a3 # a12 = end of last 16B source chunk
220+
#endif
210221
#endif /* !XCHAL_HAVE_LOOPS */
211222
.Loop2:
212223
EX(10f) l32i a7, a3, 4
@@ -224,7 +235,12 @@ EX(10f) s32i a8, a5, 8
224235
EX(10f) s32i a9, a5, 12
225236
addi a5, a5, 16
226237
#if !XCHAL_HAVE_LOOPS
238+
#if defined(__XTENSA_CALL0_ABI__)
239+
blt a3, a10, .Loop2
240+
l32i a10, a1, 0
241+
#else
227242
blt a3, a12, .Loop2
243+
#endif
228244
#endif /* !XCHAL_HAVE_LOOPS */
229245
.Loop2done:
230246
bbci.l a4, 3, .L12
@@ -264,7 +280,7 @@ EX(10f) l8ui a6, a3, 0
264280
EX(10f) s8i a6, a5, 0
265281
.L15:
266282
movi a2, 0 # return success for len bytes copied
267-
abi_ret_default
283+
abi_ret(STACK_SIZE)
268284

269285
ENDPROC(__xtensa_copy_user)
270286

@@ -281,4 +297,4 @@ ENDPROC(__xtensa_copy_user)
281297
10:
282298
sub a2, a5, a2 /* a2 <-- bytes copied */
283299
sub a2, a11, a2 /* a2 <-- bytes not copied */
284-
abi_ret_default
300+
abi_ret(STACK_SIZE)

0 commit comments

Comments
 (0)