Re: [FFmpeg-devel] [PATCH 2/2] aarch64: Add Armv8.5-A BTI support
> +#if (GNU_PROPERTY_AARCH64_BTI != 0) > +.pushsection .note.gnu.property, "a"; > +.balign 8; > +.long 4; > +.long 0x10; > +.long 0x5; > +.asciz "GNU"; > +.long 0xc000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */ > +.long 4; > +.long GNU_PROPERTY_AARCH64_BTI; > +.long 0 > +.popsection The trailing semicolons here are superfluous. They'd be needed if stacking all of it on one single line, but as it's split over multiple lines (which I like), it's not needed, so I'd suggest removing them. Also, I'd prefer to have these directives indented in the same way as the rest of main directives in the file, i.e. with 8 leading spaces. > +#endif > + > .macro function name, export=0, align=2 > .macro endfunc > ELF .size \name, . - \name > @@ -49,6 +78,7 @@ FUNC.endfunc > ELF .type EXTERN_ASM\name, %function > FUNC.func EXTERN_ASM\name > EXTERN_ASM\name: > +AARCH64_VALID_CALL_TARGET > .else I'd also prefer to have this aligned one step deeper, along with the .size/.type/.func above. I can make these hopefully innocent changes before pushing, if that's ok with you. If you want to try out the modifications, my version, ready to be pushed, is available at https://github.com/mstorsjo/FFmpeg/commits/aarch64-bti. Thanks for picking these up, Martin. Your modified version of the change looks fine to push - no issues when tested on our BTI-enabled test environment. Thanks, Jonathan IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] aarch64: Add Armv8.5-A BTI support
On Fri, 12 Nov 2021, Jonathan Wright wrote: Hi, This patch adds 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. Regression tested in in a BTI-enabled environment - no issues. Could someone take a look and merge? diff --git a/libavutil/aarch64/asm.S b/libavutil/aarch64/asm.S index d1fa72b3c6..f78942eb86 100644 --- a/libavutil/aarch64/asm.S +++ b/libavutil/aarch64/asm.S @@ -36,6 +36,35 @@ # define __has_feature(x) 0 #endif +/* Support macros for the Armv8.5-A Branch Target Identification feature which + * requires emitting a .note.gnu.property section with the appropriate + * architecture-dependent feature bits set. + * Read more: "ELF for the Arm® 64-bit Architecture" + */ +#if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1) +# define GNU_PROPERTY_AARCH64_BTI (1 << 0) // Has BTI +# define AARCH64_VALID_CALL_TARGET hint #34 // BTI 'c' +# define AARCH64_VALID_JUMP_TARGET hint #38 // BTI 'j' +#else +# define GNU_PROPERTY_AARCH64_BTI 0 // No BTI +# define AARCH64_VALID_CALL_TARGET +# define AARCH64_VALID_JUMP_TARGET +#endif + +#if (GNU_PROPERTY_AARCH64_BTI != 0) +.pushsection .note.gnu.property, "a"; +.balign 8; +.long 4; +.long 0x10; +.long 0x5; +.asciz "GNU"; +.long 0xc000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */ +.long 4; +.long GNU_PROPERTY_AARCH64_BTI; +.long 0 +.popsection The trailing semicolons here are superfluous. They'd be needed if stacking all of it on one single line, but as it's split over multiple lines (which I like), it's not needed, so I'd suggest removing them. Also, I'd prefer to have these directives indented in the same way as the rest of main directives in the file, i.e. with 8 leading spaces. +#endif + .macro function name, export=0, align=2 .macro endfunc ELF .size \name, . - \name @@ -49,6 +78,7 @@ FUNC.endfunc ELF .type EXTERN_ASM\name, %function FUNC.func EXTERN_ASM\name EXTERN_ASM\name: +AARCH64_VALID_CALL_TARGET .else I'd also prefer to have this aligned one step deeper, along with the .size/.type/.func above. I can make these hopefully innocent changes before pushing, if that's ok with you. If you want to try out the modifications, my version, ready to be pushed, is available at https://github.com/mstorsjo/FFmpeg/commits/aarch64-bti. // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] aarch64: Add Armv8.5-A BTI support
Hi, This patch adds 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. Regression tested in in a BTI-enabled environment - no issues. Could someone take a look and merge? Thanks, Jonathan IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. 0001-aarch64-Add-Armv8.5-A-BTI-support.patch Description: 0001-aarch64-Add-Armv8.5-A-BTI-support.patch ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".