Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 8224/1: Add unwinding support for memmove function

The memmove function never had unwinding annotations added.
Currently, when accessing invalid pointer by memmove occurs the
backtrace shown will stop at memmove or some completely unrelated
function. Add unwinding annotations in hopes of getting a more
useful backtrace in following cases:
1. die on accessing invalid pointer by memmove
2. kprobe trapped at any instruction within memmove
3. interrupted at any instruction within memmove

Signed-off-by: Lin Yongting <linyongting@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Lin Yongting and committed by
Russell King
207a6cb0 20cb6abf

+28
+28
arch/arm/lib/memmove.S
··· 12 12 13 13 #include <linux/linkage.h> 14 14 #include <asm/assembler.h> 15 + #include <asm/unwind.h> 15 16 16 17 .text 17 18 ··· 28 27 */ 29 28 30 29 ENTRY(memmove) 30 + UNWIND( .fnstart ) 31 31 32 32 subs ip, r0, r1 33 33 cmphi r2, ip 34 34 bls memcpy 35 35 36 36 stmfd sp!, {r0, r4, lr} 37 + UNWIND( .fnend ) 38 + 39 + UNWIND( .fnstart ) 40 + UNWIND( .save {r0, r4, lr} ) @ in first stmfd block 37 41 add r1, r1, r2 38 42 add r0, r0, r2 39 43 subs r2, r2, #4 ··· 51 45 52 46 1: subs r2, r2, #(28) 53 47 stmfd sp!, {r5 - r8} 48 + UNWIND( .fnend ) 49 + 50 + UNWIND( .fnstart ) 51 + UNWIND( .save {r0, r4, lr} ) 52 + UNWIND( .save {r5 - r8} ) @ in second stmfd block 54 53 blt 5f 55 54 56 55 CALGN( ands ip, r0, #31 ) ··· 108 97 CALGN( bcs 2b ) 109 98 110 99 7: ldmfd sp!, {r5 - r8} 100 + UNWIND( .fnend ) @ end of second stmfd block 101 + 102 + UNWIND( .fnstart ) 103 + UNWIND( .save {r0, r4, lr} ) @ still in first stmfd block 111 104 112 105 8: movs r2, r2, lsl #31 113 106 ldrneb r3, [r1, #-1]! ··· 139 124 ldr r3, [r1, #0] 140 125 beq 17f 141 126 blt 18f 127 + UNWIND( .fnend ) 142 128 143 129 144 130 .macro backward_copy_shift push pull 145 131 132 + UNWIND( .fnstart ) 133 + UNWIND( .save {r0, r4, lr} ) @ still in first stmfd block 146 134 subs r2, r2, #28 147 135 blt 14f 148 136 ··· 155 137 CALGN( bcc 15f ) 156 138 157 139 11: stmfd sp!, {r5 - r9} 140 + UNWIND( .fnend ) 141 + 142 + UNWIND( .fnstart ) 143 + UNWIND( .save {r0, r4, lr} ) 144 + UNWIND( .save {r5 - r9} ) @ in new second stmfd block 158 145 159 146 PLD( pld [r1, #-4] ) 160 147 PLD( subs r2, r2, #96 ) ··· 194 171 PLD( bge 13b ) 195 172 196 173 ldmfd sp!, {r5 - r9} 174 + UNWIND( .fnend ) @ end of the second stmfd block 175 + 176 + UNWIND( .fnstart ) 177 + UNWIND( .save {r0, r4, lr} ) @ still in first stmfd block 197 178 198 179 14: ands ip, r2, #28 199 180 beq 16f ··· 213 186 214 187 16: add r1, r1, #(\pull / 8) 215 188 b 8b 189 + UNWIND( .fnend ) 216 190 217 191 .endm 218 192