xtensa: clean up fixups in assembly code
Remove duplicate definitions of EX() and similar TRY/CATCH and SRC/DST macros from assembly sources and put single definition into asm/asmmacro.h Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
This commit is contained in:
@@ -11,16 +11,9 @@
|
||||
* Copyright (C) 2002 Tensilica Inc.
|
||||
*/
|
||||
|
||||
#include <variant/core.h>
|
||||
#include <linux/errno.h>
|
||||
|
||||
/* Load or store instructions that may cause exceptions use the EX macro. */
|
||||
|
||||
#define EX(insn,reg1,reg2,offset,handler) \
|
||||
9: insn reg1, reg2, offset; \
|
||||
.section __ex_table, "a"; \
|
||||
.word 9b, handler; \
|
||||
.previous
|
||||
#include <variant/core.h>
|
||||
#include <asm/asmmacro.h>
|
||||
|
||||
/*
|
||||
* char *__strncpy_user(char *dst, const char *src, size_t len)
|
||||
@@ -75,9 +68,9 @@ __strncpy_user:
|
||||
j .Ldstunaligned
|
||||
|
||||
.Lsrc1mod2: # src address is odd
|
||||
EX(l8ui, a9, a3, 0, fixup_l) # get byte 0
|
||||
EX(11f) l8ui a9, a3, 0 # get byte 0
|
||||
addi a3, a3, 1 # advance src pointer
|
||||
EX(s8i, a9, a11, 0, fixup_s) # store byte 0
|
||||
EX(10f) s8i a9, a11, 0 # store byte 0
|
||||
beqz a9, .Lret # if byte 0 is zero
|
||||
addi a11, a11, 1 # advance dst pointer
|
||||
addi a4, a4, -1 # decrement len
|
||||
@@ -85,16 +78,16 @@ __strncpy_user:
|
||||
bbci.l a3, 1, .Lsrcaligned # if src is now word-aligned
|
||||
|
||||
.Lsrc2mod4: # src address is 2 mod 4
|
||||
EX(l8ui, a9, a3, 0, fixup_l) # get byte 0
|
||||
EX(11f) l8ui a9, a3, 0 # get byte 0
|
||||
/* 1-cycle interlock */
|
||||
EX(s8i, a9, a11, 0, fixup_s) # store byte 0
|
||||
EX(10f) s8i a9, a11, 0 # store byte 0
|
||||
beqz a9, .Lret # if byte 0 is zero
|
||||
addi a11, a11, 1 # advance dst pointer
|
||||
addi a4, a4, -1 # decrement len
|
||||
beqz a4, .Lret # if len is zero
|
||||
EX(l8ui, a9, a3, 1, fixup_l) # get byte 0
|
||||
EX(11f) l8ui a9, a3, 1 # get byte 0
|
||||
addi a3, a3, 2 # advance src pointer
|
||||
EX(s8i, a9, a11, 0, fixup_s) # store byte 0
|
||||
EX(10f) s8i a9, a11, 0 # store byte 0
|
||||
beqz a9, .Lret # if byte 0 is zero
|
||||
addi a11, a11, 1 # advance dst pointer
|
||||
addi a4, a4, -1 # decrement len
|
||||
@@ -117,12 +110,12 @@ __strncpy_user:
|
||||
add a12, a12, a11 # a12 = end of last 4B chunck
|
||||
#endif
|
||||
.Loop1:
|
||||
EX(l32i, a9, a3, 0, fixup_l) # get word from src
|
||||
EX(11f) l32i a9, a3, 0 # get word from src
|
||||
addi a3, a3, 4 # advance src pointer
|
||||
bnone a9, a5, .Lz0 # if byte 0 is zero
|
||||
bnone a9, a6, .Lz1 # if byte 1 is zero
|
||||
bnone a9, a7, .Lz2 # if byte 2 is zero
|
||||
EX(s32i, a9, a11, 0, fixup_s) # store word to dst
|
||||
EX(10f) s32i a9, a11, 0 # store word to dst
|
||||
bnone a9, a8, .Lz3 # if byte 3 is zero
|
||||
addi a11, a11, 4 # advance dst pointer
|
||||
#if !XCHAL_HAVE_LOOPS
|
||||
@@ -132,7 +125,7 @@ __strncpy_user:
|
||||
.Loop1done:
|
||||
bbci.l a4, 1, .L100
|
||||
# copy 2 bytes
|
||||
EX(l16ui, a9, a3, 0, fixup_l)
|
||||
EX(11f) l16ui a9, a3, 0
|
||||
addi a3, a3, 2 # advance src pointer
|
||||
#ifdef __XTENSA_EB__
|
||||
bnone a9, a7, .Lz0 # if byte 2 is zero
|
||||
@@ -141,13 +134,13 @@ __strncpy_user:
|
||||
bnone a9, a5, .Lz0 # if byte 0 is zero
|
||||
bnone a9, a6, .Lz1 # if byte 1 is zero
|
||||
#endif
|
||||
EX(s16i, a9, a11, 0, fixup_s)
|
||||
EX(10f) s16i a9, a11, 0
|
||||
addi a11, a11, 2 # advance dst pointer
|
||||
.L100:
|
||||
bbci.l a4, 0, .Lret
|
||||
EX(l8ui, a9, a3, 0, fixup_l)
|
||||
EX(11f) l8ui a9, a3, 0
|
||||
/* slot */
|
||||
EX(s8i, a9, a11, 0, fixup_s)
|
||||
EX(10f) s8i a9, a11, 0
|
||||
beqz a9, .Lret # if byte is zero
|
||||
addi a11, a11, 1-3 # advance dst ptr 1, but also cancel
|
||||
# the effect of adding 3 in .Lz3 code
|
||||
@@ -161,14 +154,14 @@ __strncpy_user:
|
||||
#ifdef __XTENSA_EB__
|
||||
movi a9, 0
|
||||
#endif /* __XTENSA_EB__ */
|
||||
EX(s8i, a9, a11, 0, fixup_s)
|
||||
EX(10f) s8i a9, a11, 0
|
||||
sub a2, a11, a2 # compute strlen
|
||||
retw
|
||||
.Lz1: # byte 1 is zero
|
||||
#ifdef __XTENSA_EB__
|
||||
extui a9, a9, 16, 16
|
||||
#endif /* __XTENSA_EB__ */
|
||||
EX(s16i, a9, a11, 0, fixup_s)
|
||||
EX(10f) s16i a9, a11, 0
|
||||
addi a11, a11, 1 # advance dst pointer
|
||||
sub a2, a11, a2 # compute strlen
|
||||
retw
|
||||
@@ -176,9 +169,9 @@ __strncpy_user:
|
||||
#ifdef __XTENSA_EB__
|
||||
extui a9, a9, 16, 16
|
||||
#endif /* __XTENSA_EB__ */
|
||||
EX(s16i, a9, a11, 0, fixup_s)
|
||||
EX(10f) s16i a9, a11, 0
|
||||
movi a9, 0
|
||||
EX(s8i, a9, a11, 2, fixup_s)
|
||||
EX(10f) s8i a9, a11, 2
|
||||
addi a11, a11, 2 # advance dst pointer
|
||||
sub a2, a11, a2 # compute strlen
|
||||
retw
|
||||
@@ -196,9 +189,9 @@ __strncpy_user:
|
||||
add a12, a11, a4 # a12 = ending address
|
||||
#endif /* XCHAL_HAVE_LOOPS */
|
||||
.Lnextbyte:
|
||||
EX(l8ui, a9, a3, 0, fixup_l)
|
||||
EX(11f) l8ui a9, a3, 0
|
||||
addi a3, a3, 1
|
||||
EX(s8i, a9, a11, 0, fixup_s)
|
||||
EX(10f) s8i a9, a11, 0
|
||||
beqz a9, .Lunalignedend
|
||||
addi a11, a11, 1
|
||||
#if !XCHAL_HAVE_LOOPS
|
||||
@@ -218,8 +211,7 @@ __strncpy_user:
|
||||
* implementation in memset(). Thus, we differentiate between
|
||||
* load/store fixups. */
|
||||
|
||||
fixup_s:
|
||||
fixup_l:
|
||||
10:
|
||||
11:
|
||||
movi a2, -EFAULT
|
||||
retw
|
||||
|
||||
|
Reference in New Issue
Block a user