2019-06-04 10:11:33 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
2005-11-01 19:52:23 +00:00
/ *
* linux/ a r c h / a r m / l i b / m e m m o v e . S
*
* Author : Nicolas P i t r e
* Created : Sep 2 8 , 2 0 0 5
* Copyright : ( C) M o n t a V i s t a S o f t w a r e I n c .
* /
# 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 >
2014-11-26 14:36:15 +01:00
# include < a s m / u n w i n d . h >
2005-11-01 19:52:23 +00:00
.text
/ *
* Prototype : void * m e m m o v e ( v o i d * d e s t , c o n s t v o i d * s r c , s i z e _ t n ) ;
*
* Note :
*
* If t h e m e m o r y r e g i o n s d o n ' t o v e r l a p , w e s i m p l y b r a n c h t o m e m c p y w h i c h i s
* normally a b i t f a s t e r . O t h e r w i s e t h e c o p y i s d o n e g o i n g d o w n w a r d s . T h i s
* is a t r a n s p o s i t i o n o f t h e c o d e f r o m c o p y _ t e m p l a t e . S b u t w i t h t h e c o p y
* occurring i n t h e o p p o s i t e d i r e c t i o n .
* /
2020-10-25 23:52:08 +01:00
ENTRY( _ _ m e m m o v e )
2020-11-06 21:46:11 +01:00
WEAK( m e m m o v e )
2014-11-26 14:36:15 +01:00
UNWIND( . f n s t a r t )
2005-11-01 19:52:23 +00:00
subs i p , r0 , r1
cmphi r2 , i p
2020-10-25 23:52:08 +01:00
bls _ _ m e m c p y
2014-11-26 14:36:15 +01:00
UNWIND( . f n e n d )
UNWIND( . f n s t a r t )
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
UNWIND( . s a v e { r0 , r4 , f p r e g , l r } )
stmfd s p ! , { r0 , r4 , U N W I N D ( f p r e g ,) l r }
UNWIND( . s e t f p f p r e g , s p )
UNWIND( m o v f p r e g , s p )
2005-11-01 19:52:23 +00:00
add r1 , r1 , r2
add r0 , r0 , r2
subs r2 , r2 , #4
blt 8 f
ands i p , r0 , #3
PLD( p l d [ r1 , #- 4 ] )
bne 9 f
ands i p , r1 , #3
bne 1 0 f
1 : subs r2 , r2 , #( 28 )
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
stmfd s p ! , { r5 , r6 , r8 , r9 }
2005-11-01 19:52:23 +00:00
blt 5 f
2008-03-31 12:38:31 -04:00
CALGN( a n d s i p , r0 , #31 )
2019-02-18 00:57:38 +01:00
CALGN( s b c s n e r4 , i p , r2 ) @ C is always set here
2005-11-01 19:52:23 +00:00
CALGN( b c s 2 f )
CALGN( a d r r4 , 6 f )
CALGN( s u b s r2 , r2 , i p ) @ C is set here
2008-06-11 12:40:13 -04:00
CALGN( r s b i p , i p , #32 )
2005-11-01 19:52:23 +00:00
CALGN( a d d p c , r4 , i p )
PLD( p l d [ r1 , #- 4 ] )
2 : PLD( s u b s r2 , r2 , #96 )
PLD( p l d [ r1 , #- 32 ] )
PLD( b l t 4 f )
PLD( p l d [ r1 , #- 64 ] )
PLD( p l d [ r1 , #- 96 ] )
3 : PLD( p l d [ r1 , #- 128 ] )
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
4 : ldmdb r1 ! , { r3 , r4 , r5 , r6 , r8 , r9 , i p , l r }
2005-11-01 19:52:23 +00:00
subs r2 , r2 , #32
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
stmdb r0 ! , { r3 , r4 , r5 , r6 , r8 , r9 , i p , l r }
2005-11-01 19:52:23 +00:00
bge 3 b
PLD( c m n r2 , #96 )
PLD( b g e 4 b )
5 : ands i p , r2 , #28
rsb i p , i p , #32
addne p c , p c , i p @ C is always clear here
b 7 f
2010-03-29 10:29:46 +01:00
6 : W( n o p )
2009-07-24 12:32:57 +01:00
W( l d r ) r3 , [ r1 , #- 4 ] !
W( l d r ) r4 , [ r1 , #- 4 ] !
W( l d r ) r5 , [ r1 , #- 4 ] !
W( l d r ) r6 , [ r1 , #- 4 ] !
W( l d r ) r8 , [ r1 , #- 4 ] !
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
W( l d r ) r9 , [ r1 , #- 4 ] !
2009-07-24 12:32:57 +01:00
W( l d r ) l r , [ r1 , #- 4 ] !
2005-11-01 19:52:23 +00:00
add p c , p c , i p
nop
2010-03-29 10:29:46 +01:00
W( n o p )
2009-07-24 12:32:57 +01:00
W( s t r ) r3 , [ r0 , #- 4 ] !
W( s t r ) r4 , [ r0 , #- 4 ] !
W( s t r ) r5 , [ r0 , #- 4 ] !
W( s t r ) r6 , [ r0 , #- 4 ] !
W( s t r ) r8 , [ r0 , #- 4 ] !
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
W( s t r ) r9 , [ r0 , #- 4 ] !
2009-07-24 12:32:57 +01:00
W( s t r ) l r , [ r0 , #- 4 ] !
2005-11-01 19:52:23 +00:00
CALGN( b c s 2 b )
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
7 : ldmfd s p ! , { r5 , r6 , r8 , r9 }
2005-11-01 19:52:23 +00:00
8 : movs r2 , r2 , l s l #31
2019-02-18 00:57:38 +01:00
ldrbne r3 , [ r1 , #- 1 ] !
ldrbcs r4 , [ r1 , #- 1 ] !
ldrbcs i p , [ r1 , #- 1 ]
strbne r3 , [ r0 , #- 1 ] !
strbcs r4 , [ r0 , #- 1 ] !
strbcs i p , [ r0 , #- 1 ]
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
ldmfd s p ! , { r0 , r4 , U N W I N D ( f p r e g ,) p c }
2005-11-01 19:52:23 +00:00
9 : cmp i p , #2
2019-02-18 00:57:38 +01:00
ldrbgt r3 , [ r1 , #- 1 ] !
ldrbge r4 , [ r1 , #- 1 ] !
2005-11-01 19:52:23 +00:00
ldrb l r , [ r1 , #- 1 ] !
2019-02-18 00:57:38 +01:00
strbgt r3 , [ r0 , #- 1 ] !
strbge r4 , [ r0 , #- 1 ] !
2005-11-01 19:52:23 +00:00
subs r2 , r2 , i p
strb l r , [ r0 , #- 1 ] !
blt 8 b
ands i p , r1 , #3
beq 1 b
10 : bic r1 , r1 , #3
cmp i p , #2
ldr r3 , [ r1 , #0 ]
beq 1 7 f
blt 1 8 f
.macro backward_copy_shift push p u l l
subs r2 , r2 , #28
blt 1 4 f
2008-03-31 12:38:31 -04:00
CALGN( a n d s i p , r0 , #31 )
2019-02-18 00:57:38 +01:00
CALGN( s b c s n e r4 , i p , r2 ) @ C is always set here
2005-11-01 19:52:23 +00:00
CALGN( s u b c c r2 , r2 , i p )
CALGN( b c c 1 5 f )
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
11 : stmfd s p ! , { r5 , r6 , r8 - r10 }
2005-11-01 19:52:23 +00:00
PLD( p l d [ r1 , #- 4 ] )
PLD( s u b s r2 , r2 , #96 )
PLD( p l d [ r1 , #- 32 ] )
PLD( b l t 1 3 f )
PLD( p l d [ r1 , #- 64 ] )
PLD( p l d [ r1 , #- 96 ] )
12 : PLD( p l d [ r1 , #- 128 ] )
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
13 : ldmdb r1 ! , { r8 , r9 , r10 , i p }
2014-02-25 08:41:09 +01:00
mov l r , r3 , l s p u s h #\ p u s h
2005-11-01 19:52:23 +00:00
subs r2 , r2 , #32
ldmdb r1 ! , { r3 , r4 , r5 , r6 }
2014-02-25 08:41:09 +01:00
orr l r , l r , i p , l s p u l l #\ p u l l
mov i p , i p , l s p u s h #\ p u s h
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
orr i p , i p , r10 , l s p u l l #\ p u l l
mov r10 , r10 , l s p u s h #\ p u s h
orr r10 , r10 , r9 , l s p u l l #\ p u l l
2014-02-25 08:41:09 +01:00
mov r9 , r9 , l s p u s h #\ p u s h
orr r9 , r9 , r8 , l s p u l l #\ p u l l
mov r8 , r8 , l s p u s h #\ p u s h
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
orr r8 , r8 , r6 , l s p u l l #\ p u l l
2014-02-25 08:41:09 +01:00
mov r6 , r6 , l s p u s h #\ p u s h
orr r6 , r6 , r5 , l s p u l l #\ p u l l
mov r5 , r5 , l s p u s h #\ p u s h
orr r5 , r5 , r4 , l s p u l l #\ p u l l
mov r4 , r4 , l s p u s h #\ p u s h
orr r4 , r4 , r3 , l s p u l l #\ p u l l
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
stmdb r0 ! , { r4 - r6 , r8 - r10 , i p , l r }
2005-11-01 19:52:23 +00:00
bge 1 2 b
PLD( c m n r2 , #96 )
PLD( b g e 1 3 b )
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
ldmfd s p ! , { r5 , r6 , r8 - r10 }
2005-11-01 19:52:23 +00:00
14 : ands i p , r2 , #28
beq 1 6 f
2014-02-25 08:41:09 +01:00
15 : mov l r , r3 , l s p u s h #\ p u s h
2005-11-01 19:52:23 +00:00
ldr r3 , [ r1 , #- 4 ] !
subs i p , i p , #4
2014-02-25 08:41:09 +01:00
orr l r , l r , r3 , l s p u l l #\ p u l l
2005-11-01 19:52:23 +00:00
str l r , [ r0 , #- 4 ] !
bgt 1 5 b
CALGN( c m p r2 , #0 )
CALGN( b g e 1 1 b )
16 : add r1 , r1 , #( \ p u l l / 8 )
b 8 b
.endm
backward_ c o p y _ s h i f t p u s h =8 p u l l =24
17 : backward_ c o p y _ s h i f t p u s h =16 p u l l =16
18 : backward_ c o p y _ s h i f t p u s h =24 p u l l =8
ARM: memmove: use frame pointer as unwind anchor
The memmove routine is a bit unusual in the way it manages the stack
pointer: depending on the execution path through the function, the SP
assumes different values as different subsets of the register file are
preserved and restored again. This is problematic when it comes to EHABI
unwind info, as it is not instruction accurate, and does not allow
tracking the SP value as it changes.
Commit 207a6cb06990c ("ARM: 8224/1: Add unwinding support for memmove
function") addressed this by carving up the function in different chunks
as far as the unwinder is concerned, and keeping a set of unwind
directives for each of them, each corresponding with the state of the
stack pointer during execution of the chunk in question. This not only
duplicates unwind info unnecessarily, but it also complicates unwinding
the stack upon overflow.
Instead, let's do what the compiler does when the SP is updated halfway
through a function, which is to use a frame pointer and emit the
appropriate unwind directives to communicate this to the unwinder.
Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
avoid touching R7 in the body of the function, so that Thumb-2 can use
it as the frame pointer. R11 was not modified in the first place.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
2021-10-04 11:29:11 +02:00
UNWIND( . f n e n d )
2008-08-28 11:22:32 +01:00
ENDPROC( m e m m o v e )
2020-10-25 23:52:08 +01:00
ENDPROC( _ _ m e m m o v e )