Commit c36ef4b1 authored by Will Deacon's avatar Will Deacon Committed by Russell King

ARM: 7171/1: unwind: add unwind directives to bitops assembly macros

The bitops functions (e.g. _test_and_set_bit) on ARM do not have unwind
annotations and therefore the kernel cannot backtrace out of them on a
fatal error (for example, NULL pointer dereference).

This patch annotates the bitops assembly macros with UNWIND annotations
so that we can produce a meaningful backtrace on error. Callers of the
macros are modified to pass their function name as a macro parameter,
enforcing that the macros are used as standalone function implementations.
Acked-by: default avatarDave Martin <dave.martin@linaro.org>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent c89cefed
#include <asm/unwind.h>
#if __LINUX_ARM_ARCH__ >= 6 #if __LINUX_ARM_ARCH__ >= 6
.macro bitop, instr .macro bitop, name, instr
ENTRY( \name )
UNWIND( .fnstart )
ands ip, r1, #3 ands ip, r1, #3
strneb r1, [ip] @ assert word-aligned strneb r1, [ip] @ assert word-aligned
mov r2, #1 mov r2, #1
...@@ -13,9 +17,13 @@ ...@@ -13,9 +17,13 @@
cmp r0, #0 cmp r0, #0
bne 1b bne 1b
bx lr bx lr
UNWIND( .fnend )
ENDPROC(\name )
.endm .endm
.macro testop, instr, store .macro testop, name, instr, store
ENTRY( \name )
UNWIND( .fnstart )
ands ip, r1, #3 ands ip, r1, #3
strneb r1, [ip] @ assert word-aligned strneb r1, [ip] @ assert word-aligned
mov r2, #1 mov r2, #1
...@@ -34,9 +42,13 @@ ...@@ -34,9 +42,13 @@
cmp r0, #0 cmp r0, #0
movne r0, #1 movne r0, #1
2: bx lr 2: bx lr
UNWIND( .fnend )
ENDPROC(\name )
.endm .endm
#else #else
.macro bitop, instr .macro bitop, name, instr
ENTRY( \name )
UNWIND( .fnstart )
ands ip, r1, #3 ands ip, r1, #3
strneb r1, [ip] @ assert word-aligned strneb r1, [ip] @ assert word-aligned
and r2, r0, #31 and r2, r0, #31
...@@ -49,6 +61,8 @@ ...@@ -49,6 +61,8 @@
str r2, [r1, r0, lsl #2] str r2, [r1, r0, lsl #2]
restore_irqs ip restore_irqs ip
mov pc, lr mov pc, lr
UNWIND( .fnend )
ENDPROC(\name )
.endm .endm
/** /**
...@@ -59,7 +73,9 @@ ...@@ -59,7 +73,9 @@
* Note: we can trivially conditionalise the store instruction * Note: we can trivially conditionalise the store instruction
* to avoid dirtying the data cache. * to avoid dirtying the data cache.
*/ */
.macro testop, instr, store .macro testop, name, instr, store
ENTRY( \name )
UNWIND( .fnstart )
ands ip, r1, #3 ands ip, r1, #3
strneb r1, [ip] @ assert word-aligned strneb r1, [ip] @ assert word-aligned
and r3, r0, #31 and r3, r0, #31
...@@ -73,5 +89,7 @@ ...@@ -73,5 +89,7 @@
moveq r0, #0 moveq r0, #0
restore_irqs ip restore_irqs ip
mov pc, lr mov pc, lr
UNWIND( .fnend )
ENDPROC(\name )
.endm .endm
#endif #endif
...@@ -12,6 +12,4 @@ ...@@ -12,6 +12,4 @@
#include "bitops.h" #include "bitops.h"
.text .text
ENTRY(_change_bit) bitop _change_bit, eor
bitop eor
ENDPROC(_change_bit)
...@@ -12,6 +12,4 @@ ...@@ -12,6 +12,4 @@
#include "bitops.h" #include "bitops.h"
.text .text
ENTRY(_clear_bit) bitop _clear_bit, bic
bitop bic
ENDPROC(_clear_bit)
...@@ -12,6 +12,4 @@ ...@@ -12,6 +12,4 @@
#include "bitops.h" #include "bitops.h"
.text .text
ENTRY(_set_bit) bitop _set_bit, orr
bitop orr
ENDPROC(_set_bit)
...@@ -12,6 +12,4 @@ ...@@ -12,6 +12,4 @@
#include "bitops.h" #include "bitops.h"
.text .text
ENTRY(_test_and_change_bit) testop _test_and_change_bit, eor, str
testop eor, str
ENDPROC(_test_and_change_bit)
...@@ -12,6 +12,4 @@ ...@@ -12,6 +12,4 @@
#include "bitops.h" #include "bitops.h"
.text .text
ENTRY(_test_and_clear_bit) testop _test_and_clear_bit, bicne, strne
testop bicne, strne
ENDPROC(_test_and_clear_bit)
...@@ -12,6 +12,4 @@ ...@@ -12,6 +12,4 @@
#include "bitops.h" #include "bitops.h"
.text .text
ENTRY(_test_and_set_bit) testop _test_and_set_bit, orreq, streq
testop orreq, streq
ENDPROC(_test_and_set_bit)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment