2019-06-03 07:44:50 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
2013-03-21 16:16:43 +00:00
/ *
2021-05-27 16:34:47 +01:00
* Copyright ( C ) 2 0 2 1 A r m L t d .
2013-03-21 16:16:43 +00:00
* /
# include < l i n u x / l i n k a g e . h >
# include < a s m / a s s e m b l e r . h >
/ *
* Find a c h a r a c t e r i n a n a r e a o f m e m o r y .
*
* Parameters :
* x0 - b u f
* x1 - c
* x2 - n
* Returns :
* x0 - a d d r e s s o f f i r s t o c c u r r e n c e o f ' c ' o r 0
* /
2021-05-27 16:34:47 +01:00
# define L ( l a b e l ) . L ## l a b e l
# define R E P 8 _ 0 1 0 x01 0 1 0 1 0 1 0 1 0 1 0 1 0 1
# define R E P 8 _ 7 f 0 x7 f7 f7 f7 f7 f7 f7 f7 f
# define s r c i n x0
# define c h r i n w1
# define c n t i n x2
# define r e s u l t x0
# define w o r d c n t x3
# define r e p01 x4
# define r e p c h r x5
# define c u r _ w o r d x6
# define c u r _ b y t e w6
# define t m p x7
# define t m p2 x8
.p2align 4
nop
arm64: clean up symbol aliasing
Now that we have SYM_FUNC_ALIAS() and SYM_FUNC_ALIAS_WEAK(), use those
to simplify and more consistently define function aliases across
arch/arm64.
Aliases are now defined in terms of a canonical function name. For
position-independent functions I've made the __pi_<func> name the
canonical name, and defined other alises in terms of this.
The SYM_FUNC_{START,END}_PI(func) macros obscure the __pi_<func> name,
and make this hard to seatch for. The SYM_FUNC_START_WEAK_PI() macro
also obscures the fact that the __pi_<func> fymbol is global and the
<func> symbol is weak. For clarity, I have removed these macros and used
SYM_FUNC_{START,END}() directly with the __pi_<func> name.
For example:
SYM_FUNC_START_WEAK_PI(func)
... asm insns ...
SYM_FUNC_END_PI(func)
EXPORT_SYMBOL(func)
... becomes:
SYM_FUNC_START(__pi_func)
... asm insns ...
SYM_FUNC_END(__pi_func)
SYM_FUNC_ALIAS_WEAK(func, __pi_func)
EXPORT_SYMBOL(func)
For clarity, where there are multiple annotations such as
EXPORT_SYMBOL(), I've tried to keep annotations grouped by symbol. For
example, where a function has a name and an alias which are both
exported, this is organised as:
SYM_FUNC_START(func)
... asm insns ...
SYM_FUNC_END(func)
EXPORT_SYMBOL(func)
SYM_FUNC_ALIAS(alias, func)
EXPORT_SYMBOL(alias)
For consistency with the other string functions, I've defined strrchr as
a position-independent function, as it can safely be used as such even
though we have no users today.
As we no longer use SYM_FUNC_{START,END}_ALIAS(), our local copies are
removed. The common versions will be removed by a subsequent patch.
There should be no functional change as a result of this patch.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Mark Brown <broonie@kernel.org>
Cc: Joey Gouly <joey.gouly@arm.com>
Cc: Will Deacon <will@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220216162229.1076788-3-mark.rutland@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
2022-02-16 16:22:27 +00:00
SYM_ F U N C _ S T A R T ( _ _ p i _ m e m c h r )
2021-05-27 16:34:47 +01:00
and c h r i n , c h r i n , #0xff
lsr w o r d c n t , c n t i n , #3
cbz w o r d c n t , L ( b y t e _ l o o p )
mov r e p01 , #R E P 8 _ 0 1
mul r e p c h r , x1 , r e p01
and c n t i n , c n t i n , #7
L( w o r d _ l o o p ) :
ldr c u r _ w o r d , [ s r c i n ] , #8
sub w o r d c n t , w o r d c n t , #1
eor c u r _ w o r d , c u r _ w o r d , r e p c h r
sub t m p , c u r _ w o r d , r e p01
orr t m p2 , c u r _ w o r d , #R E P 8 _ 7 f
bics t m p , t m p , t m p2
b. n e L ( f o u n d _ w o r d )
cbnz w o r d c n t , L ( w o r d _ l o o p )
L( b y t e _ l o o p ) :
cbz c n t i n , L ( n o t _ f o u n d )
ldrb c u r _ b y t e , [ s r c i n ] , #1
sub c n t i n , c n t i n , #1
cmp c u r _ b y t e , c h r i n
b. n e L ( b y t e _ l o o p )
sub s r c i n , s r c i n , #1
ret
L( f o u n d _ w o r d ) :
CPU_ L E ( r e v t m p , t m p )
clz t m p , t m p
sub t m p , t m p , #64
add r e s u l t , s r c i n , t m p , a s r #3
2013-03-21 16:16:43 +00:00
ret
2021-05-27 16:34:47 +01:00
L( n o t _ f o u n d ) :
mov r e s u l t , #0
2013-03-21 16:16:43 +00:00
ret
arm64: clean up symbol aliasing
Now that we have SYM_FUNC_ALIAS() and SYM_FUNC_ALIAS_WEAK(), use those
to simplify and more consistently define function aliases across
arch/arm64.
Aliases are now defined in terms of a canonical function name. For
position-independent functions I've made the __pi_<func> name the
canonical name, and defined other alises in terms of this.
The SYM_FUNC_{START,END}_PI(func) macros obscure the __pi_<func> name,
and make this hard to seatch for. The SYM_FUNC_START_WEAK_PI() macro
also obscures the fact that the __pi_<func> fymbol is global and the
<func> symbol is weak. For clarity, I have removed these macros and used
SYM_FUNC_{START,END}() directly with the __pi_<func> name.
For example:
SYM_FUNC_START_WEAK_PI(func)
... asm insns ...
SYM_FUNC_END_PI(func)
EXPORT_SYMBOL(func)
... becomes:
SYM_FUNC_START(__pi_func)
... asm insns ...
SYM_FUNC_END(__pi_func)
SYM_FUNC_ALIAS_WEAK(func, __pi_func)
EXPORT_SYMBOL(func)
For clarity, where there are multiple annotations such as
EXPORT_SYMBOL(), I've tried to keep annotations grouped by symbol. For
example, where a function has a name and an alias which are both
exported, this is organised as:
SYM_FUNC_START(func)
... asm insns ...
SYM_FUNC_END(func)
EXPORT_SYMBOL(func)
SYM_FUNC_ALIAS(alias, func)
EXPORT_SYMBOL(alias)
For consistency with the other string functions, I've defined strrchr as
a position-independent function, as it can safely be used as such even
though we have no users today.
As we no longer use SYM_FUNC_{START,END}_ALIAS(), our local copies are
removed. The common versions will be removed by a subsequent patch.
There should be no functional change as a result of this patch.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Mark Brown <broonie@kernel.org>
Cc: Joey Gouly <joey.gouly@arm.com>
Cc: Will Deacon <will@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220216162229.1076788-3-mark.rutland@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
2022-02-16 16:22:27 +00:00
SYM_ F U N C _ E N D ( _ _ p i _ m e m c h r )
SYM_ F U N C _ A L I A S _ W E A K ( m e m c h r , _ _ p i _ m e m c h r )
2018-12-07 18:08:21 +00:00
EXPORT_ S Y M B O L _ N O K A S A N ( m e m c h r )