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

ARM: 8223/1: Add unwinding support for __memzero function

The __memzero function never had unwinding annotations added.
Currently, when accessing invalid pointer by __memzero occurs the
backtrace shown will stop at __memzero 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 __memzero
2. kprobe trapped at any instruction within __memzero
3. interrupted at any instruction within __memzero

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
20cb6abf 296630c9

+12
+12
arch/arm/lib/memzero.S
··· 9 9 */ 10 10 #include <linux/linkage.h> 11 11 #include <asm/assembler.h> 12 + #include <asm/unwind.h> 12 13 13 14 .text 14 15 .align 5 ··· 19 18 * mis-aligned by, and r1 is the number of bytes. If r1 < 4, then we 20 19 * don't bother; we use byte stores instead. 21 20 */ 21 + UNWIND( .fnstart ) 22 22 1: subs r1, r1, #4 @ 1 do we have enough 23 23 blt 5f @ 1 bytes to align with? 24 24 cmp r3, #2 @ 1 ··· 49 47 * use the LR 50 48 */ 51 49 str lr, [sp, #-4]! @ 1 50 + UNWIND( .fnend ) 51 + UNWIND( .fnstart ) 52 + UNWIND( .save {lr} ) 52 53 mov ip, r2 @ 1 53 54 mov lr, r2 @ 1 54 55 ··· 71 66 tst r1, #16 @ 1 16 bytes or more? 72 67 stmneia r0!, {r2, r3, ip, lr} @ 4 73 68 ldr lr, [sp], #4 @ 1 69 + UNWIND( .fnend ) 74 70 75 71 #else 76 72 ··· 81 75 */ 82 76 83 77 stmfd sp!, {r4-r7, lr} 78 + UNWIND( .fnend ) 79 + UNWIND( .fnstart ) 80 + UNWIND( .save {r4-r7, lr} ) 84 81 mov r4, r2 85 82 mov r5, r2 86 83 mov r6, r2 ··· 114 105 tst r1, #16 115 106 stmneia r0!, {r4-r7} 116 107 ldmfd sp!, {r4-r7, lr} 108 + UNWIND( .fnend ) 117 109 118 110 #endif 119 111 112 + UNWIND( .fnstart ) 120 113 4: tst r1, #8 @ 1 8 bytes or more? 121 114 stmneia r0!, {r2, r3} @ 2 122 115 tst r1, #4 @ 1 4 bytes or more? ··· 133 122 tst r1, #1 @ 1 a byte left over 134 123 strneb r2, [r0], #1 @ 1 135 124 ret lr @ 1 125 + UNWIND( .fnend ) 136 126 ENDPROC(__memzero)