Skip to content

Commit 7339fb1

Browse files
linuswRussell King (Oracle)
authored andcommitted
ARM: 9390/2: lib: Annotate loop delay instructions for CFI
When we annotate the loop delay code with SYM_TYPED_FUNC_START() a function prototype signature will be emitted into the object file above each site called from C, and the delay loop code is using "fallthroughs" from the different assembly callbacks. This will not work as the execution flow will run into the prototype signatures. Rewrite the code to use explicit branches to the other code segments and annotate the code using SYM_TYPED_FUNC_START(). Tested on the ARM Versatile which uses the calibrated loop delay. Tested-by: Kees Cook <[email protected]> Reviewed-by: Sami Tolvanen <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]>
1 parent 393999f commit 7339fb1

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

arch/arm/lib/delay-loop.S

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Copyright (C) 1995, 1996 Russell King
66
*/
77
#include <linux/linkage.h>
8+
#include <linux/cfi_types.h>
89
#include <asm/assembler.h>
910
#include <asm/delay.h>
1011

@@ -24,21 +25,26 @@
2425
* HZ <= 1000
2526
*/
2627

27-
ENTRY(__loop_udelay)
28+
SYM_TYPED_FUNC_START(__loop_udelay)
2829
ldr r2, .LC1
2930
mul r0, r2, r0 @ r0 = delay_us * UDELAY_MULT
30-
ENTRY(__loop_const_udelay) @ 0 <= r0 <= 0xfffffaf0
31+
b __loop_const_udelay
32+
SYM_FUNC_END(__loop_udelay)
33+
34+
SYM_TYPED_FUNC_START(__loop_const_udelay) @ 0 <= r0 <= 0xfffffaf0
3135
ldr r2, .LC0
3236
ldr r2, [r2]
3337
umull r1, r0, r2, r0 @ r0-r1 = r0 * loops_per_jiffy
3438
adds r1, r1, #0xffffffff @ rounding up ...
3539
adcs r0, r0, r0 @ and right shift by 31
3640
reteq lr
41+
b __loop_delay
42+
SYM_FUNC_END(__loop_const_udelay)
3743

3844
.align 3
3945

4046
@ Delay routine
41-
ENTRY(__loop_delay)
47+
SYM_TYPED_FUNC_START(__loop_delay)
4248
subs r0, r0, #1
4349
#if 0
4450
retls lr
@@ -58,6 +64,4 @@ ENTRY(__loop_delay)
5864
#endif
5965
bhi __loop_delay
6066
ret lr
61-
ENDPROC(__loop_udelay)
62-
ENDPROC(__loop_const_udelay)
63-
ENDPROC(__loop_delay)
67+
SYM_FUNC_END(__loop_delay)

0 commit comments

Comments
 (0)