History

aarch64: Add Armv8.5-A BTI support

Add Branch Target Identifiers (BTIs) to all functions defined in AArch64 assembly files. Most of the BTI landing pads are added automatically by the 'function' macro. BTI support is turned on or off at compile time based on the presence of the __ARM_FEATURE_BTI_DEFAULT feature macro. A binary compiled with BTI support can be executed on an Armv8-A processor without BTI support because the instructions are defined in NOP space.

Jonathan Wright committed 6 years ago

Commit 08b47161 parent 6f04cf53 files · +38 −0Browse files

Unified · Split

3 files
  1. libavcodec/aarch64/fft_neon.S +4 −0
  2. libavcodec/aarch64/h264idct_neon.S +4 −0
  3. libavutil/aarch64/asm.S +30 −0
libavcodec/aarch64/fft_neon.S+4−0
@@ -36,6 +36,7 @@ · 35 unmodified lines
36 36
37 37
38function fft4_neon38function fft4_neon
39 AARCH64_VALID_JUMP_TARGET
39 ld1 {v0.2s,v1.2s,v2.2s,v3.2s}, [x0]40 ld1 {v0.2s,v1.2s,v2.2s,v3.2s}, [x0]
40 41
41 fadd v4.2s, v0.2s, v1.2s // r0+r1,i0+i142 fadd v4.2s, v0.2s, v1.2s // r0+r1,i0+i1
@@ -58,6 +59,7 @@ function fft4_neon · 16 unmodified lines
58endfunc59endfunc
59 60
60function fft8_neon61function fft8_neon
62 AARCH64_VALID_JUMP_TARGET
61 mov x1, x063 mov x1, x0
62 ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #3264 ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32
63 ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0]65 ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0]
@@ -108,6 +110,7 @@ function fft8_neon · 44 unmodified lines
108endfunc110endfunc
109 111
110function fft16_neon112function fft16_neon
113 AARCH64_VALID_JUMP_TARGET
111 mov x1, x0114 mov x1, x0
112 ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32115 ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32
113 ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0], #32116 ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0], #32
@@ -337,6 +340,7 @@ endfunc · 223 unmodified lines
337 340
338.macro def_fft n, n2, n4341.macro def_fft n, n2, n4
339function fft\n\()_neon, align=6342function fft\n\()_neon, align=6
343 AARCH64_VALID_JUMP_TARGET
340 sub sp, sp, #16344 sub sp, sp, #16
341 stp x28, x30, [sp]345 stp x28, x30, [sp]
342 add x28, x0, #\n4*2*8346 add x28, x0, #\n4*2*8
libavcodec/aarch64/h264idct_neon.S+4−0
@@ -24,6 +24,7 @@ · 23 unmodified lines
24 24
25function ff_h264_idct_add_neon, export=125function ff_h264_idct_add_neon, export=1
26.L_ff_h264_idct_add_neon:26.L_ff_h264_idct_add_neon:
27 AARCH64_VALID_CALL_TARGET
27 ld1 {v0.4H, v1.4H, v2.4H, v3.4H}, [x1]28 ld1 {v0.4H, v1.4H, v2.4H, v3.4H}, [x1]
28 sxtw x2, w229 sxtw x2, w2
29 movi v30.8H, #030 movi v30.8H, #0
@@ -79,6 +80,7 @@ endfunc · 49 unmodified lines
79 80
80function ff_h264_idct_dc_add_neon, export=181function ff_h264_idct_dc_add_neon, export=1
81.L_ff_h264_idct_dc_add_neon:82.L_ff_h264_idct_dc_add_neon:
83 AARCH64_VALID_CALL_TARGET
82 sxtw x2, w284 sxtw x2, w2
83 mov w3, #085 mov w3, #0
84 ld1r {v2.8H}, [x1]86 ld1r {v2.8H}, [x1]
@@ -266,6 +268,7 @@ endfunc · 181 unmodified lines
266 268
267function ff_h264_idct8_add_neon, export=1269function ff_h264_idct8_add_neon, export=1
268.L_ff_h264_idct8_add_neon:270.L_ff_h264_idct8_add_neon:
271 AARCH64_VALID_CALL_TARGET
269 movi v19.8H, #0272 movi v19.8H, #0
270 sxtw x2, w2273 sxtw x2, w2
271 ld1 {v24.8H, v25.8H}, [x1]274 ld1 {v24.8H, v25.8H}, [x1]
@@ -330,6 +333,7 @@ endfunc · 58 unmodified lines
330 333
331function ff_h264_idct8_dc_add_neon, export=1334function ff_h264_idct8_dc_add_neon, export=1
332.L_ff_h264_idct8_dc_add_neon:335.L_ff_h264_idct8_dc_add_neon:
336 AARCH64_VALID_CALL_TARGET
333 mov w3, #0337 mov w3, #0
334 sxtw x2, w2338 sxtw x2, w2
335 ld1r {v31.8H}, [x1]339 ld1r {v31.8H}, [x1]
libavutil/aarch64/asm.S+30−0
@@ -36,6 +36,35 @@ · 35 unmodified lines
36# define __has_feature(x) 036# define __has_feature(x) 0
37#endif37#endif
38 38
39/* Support macros for the Armv8.5-A Branch Target Identification feature which
40 * requires emitting a .note.gnu.property section with the appropriate
41 * architecture-dependent feature bits set.
42 * Read more: "ELF for the Arm® 64-bit Architecture"
43 */
44#if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1)
45# define GNU_PROPERTY_AARCH64_BTI (1 << 0) // Has BTI
46# define AARCH64_VALID_CALL_TARGET hint #34 // BTI 'c'
47# define AARCH64_VALID_JUMP_TARGET hint #38 // BTI 'j'
48#else
49# define GNU_PROPERTY_AARCH64_BTI 0 // No BTI
50# define AARCH64_VALID_CALL_TARGET
51# define AARCH64_VALID_JUMP_TARGET
52#endif
53
54#if (GNU_PROPERTY_AARCH64_BTI != 0)
55 .pushsection .note.gnu.property, "a"
56 .balign 8
57 .long 4
58 .long 0x10
59 .long 0x5
60 .asciz "GNU"
61 .long 0xc0000000 /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
62 .long 4
63 .long GNU_PROPERTY_AARCH64_BTI
64 .long 0
65 .popsection
66#endif
67
39.macro function name, export=0, align=268.macro function name, export=0, align=2
40 .macro endfunc69 .macro endfunc
41ELF .size \name, . - \name70ELF .size \name, . - \name
@@ -49,6 +78,7 @@ FUNC .endfunc · 7 unmodified lines
49ELF .type EXTERN_ASM\name, %function78ELF .type EXTERN_ASM\name, %function
50FUNC .func EXTERN_ASM\name79FUNC .func EXTERN_ASM\name
51EXTERN_ASM\name:80EXTERN_ASM\name:
81 AARCH64_VALID_CALL_TARGET
52 .else82 .else
53ELF .type \name, %function83ELF .type \name, %function
54FUNC .func \name84FUNC .func \name

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t