Skip to content

Commit c36ef4b

Browse files
wildea01Russell King
authored andcommitted
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: Dave Martin <[email protected]> Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Russell King <[email protected]>
1 parent c89cefe commit c36ef4b

File tree

7 files changed

+28
-22
lines changed

7 files changed

+28
-22
lines changed

arch/arm/lib/bitops.h

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
#include <asm/unwind.h>
2+
13
#if __LINUX_ARM_ARCH__ >= 6
2-
.macro bitop, instr
4+
.macro bitop, name, instr
5+
ENTRY( \name )
6+
UNWIND( .fnstart )
37
ands ip, r1, #3
48
strneb r1, [ip] @ assert word-aligned
59
mov r2, #1
@@ -13,9 +17,13 @@
1317
cmp r0, #0
1418
bne 1b
1519
bx lr
20+
UNWIND( .fnend )
21+
ENDPROC(\name )
1622
.endm
1723

18-
.macro testop, instr, store
24+
.macro testop, name, instr, store
25+
ENTRY( \name )
26+
UNWIND( .fnstart )
1927
ands ip, r1, #3
2028
strneb r1, [ip] @ assert word-aligned
2129
mov r2, #1
@@ -34,9 +42,13 @@
3442
cmp r0, #0
3543
movne r0, #1
3644
2: bx lr
45+
UNWIND( .fnend )
46+
ENDPROC(\name )
3747
.endm
3848
#else
39-
.macro bitop, instr
49+
.macro bitop, name, instr
50+
ENTRY( \name )
51+
UNWIND( .fnstart )
4052
ands ip, r1, #3
4153
strneb r1, [ip] @ assert word-aligned
4254
and r2, r0, #31
@@ -49,6 +61,8 @@
4961
str r2, [r1, r0, lsl #2]
5062
restore_irqs ip
5163
mov pc, lr
64+
UNWIND( .fnend )
65+
ENDPROC(\name )
5266
.endm
5367

5468
/**
@@ -59,7 +73,9 @@
5973
* Note: we can trivially conditionalise the store instruction
6074
* to avoid dirtying the data cache.
6175
*/
62-
.macro testop, instr, store
76+
.macro testop, name, instr, store
77+
ENTRY( \name )
78+
UNWIND( .fnstart )
6379
ands ip, r1, #3
6480
strneb r1, [ip] @ assert word-aligned
6581
and r3, r0, #31
@@ -73,5 +89,7 @@
7389
moveq r0, #0
7490
restore_irqs ip
7591
mov pc, lr
92+
UNWIND( .fnend )
93+
ENDPROC(\name )
7694
.endm
7795
#endif

arch/arm/lib/changebit.S

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@
1212
#include "bitops.h"
1313
.text
1414

15-
ENTRY(_change_bit)
16-
bitop eor
17-
ENDPROC(_change_bit)
15+
bitop _change_bit, eor

arch/arm/lib/clearbit.S

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@
1212
#include "bitops.h"
1313
.text
1414

15-
ENTRY(_clear_bit)
16-
bitop bic
17-
ENDPROC(_clear_bit)
15+
bitop _clear_bit, bic

arch/arm/lib/setbit.S

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@
1212
#include "bitops.h"
1313
.text
1414

15-
ENTRY(_set_bit)
16-
bitop orr
17-
ENDPROC(_set_bit)
15+
bitop _set_bit, orr

arch/arm/lib/testchangebit.S

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@
1212
#include "bitops.h"
1313
.text
1414

15-
ENTRY(_test_and_change_bit)
16-
testop eor, str
17-
ENDPROC(_test_and_change_bit)
15+
testop _test_and_change_bit, eor, str

arch/arm/lib/testclearbit.S

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@
1212
#include "bitops.h"
1313
.text
1414

15-
ENTRY(_test_and_clear_bit)
16-
testop bicne, strne
17-
ENDPROC(_test_and_clear_bit)
15+
testop _test_and_clear_bit, bicne, strne

arch/arm/lib/testsetbit.S

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@
1212
#include "bitops.h"
1313
.text
1414

15-
ENTRY(_test_and_set_bit)
16-
testop orreq, streq
17-
ENDPROC(_test_and_set_bit)
15+
testop _test_and_set_bit, orreq, streq

0 commit comments

Comments
 (0)