Re: [PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2019-05-30 Thread Sam Tebbs
The fix has been committed as r271780. Apologies for the failure everyone.

Sam

On 29/05/2019 15:22, Sam Tebbs wrote:
> Thanks for finding this Christoph, I had this failure a while ago but it
> stopped happening so I thought all was good. I have a fix ready.
>
> Sam
>
> On 29/05/2019 12:22, Christophe Lyon wrote:
>> On Wed, 29 May 2019 at 11:23, Sam Tebbs  wrote:
>>> The libgcc changes have been acknowledged off-list. Committed as r271735.
>>>
>> After this commit, I'm seeing errors while building libstdc++:
>> 0x11c29f3 aarch64_return_address_signing_enabled()
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/config/aarch64/aarch64.c:4865
>> 0x11c2a08 aarch64_post_cfi_startproc(_IO_FILE*, tree_node*)
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/config/aarch64/aarch64.c:15373
>> 0xa27098 dwarf2out_do_cfi_startproc
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/dwarf2out.c:972
>> 0xa43d6e dwarf2out_begin_prologue(unsigned int, unsigned int, char const*)
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/dwarf2out.c:1106
>> 0xae05d5 final_start_function_1
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/final.c:1735
>> 0xae0c2f final_start_function(rtx_insn*, _IO_FILE*, int)
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/final.c:1818
>> 0x11c4442 aarch64_output_mi_thunk
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/config/aarch64/aarch64.c:6085
>> 0x9cfa4f cgraph_node::expand_thunk(bool, bool)
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:1831
>> 0x9d0dba cgraph_node::assemble_thunks_and_aliases()
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2122
>> 0x9d0d89 cgraph_node::assemble_thunks_and_aliases()
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2140
>> 0x9d1068 cgraph_node::expand()
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2259
>> 0x9d23ec expand_all_functions
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2332
>> 0x9d23ec symbol_table::compile()
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2683
>> 0x9d5020 symbol_table::compile()
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2595
>> 0x9d5020 symbol_table::finalize_compilation_unit()
>>   
>> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2861
>> Please submit a full bug report,
>> with preprocessed source if appropriate.
>> Please include the complete backtrace with any bug report.
>> See  for instructions.
>> make[5]: *** [Makefile:900: strstream.lo] Error 1
>>
>> in aarch64-none-linux-gnu/libstdc++-v3/src/c++98
>>
>> (same for aarch64[_be]-elf)
>>
>> Christophe
>>
>>> On 01/03/2019 14:12, Sam Tebbs wrote:
 On 31/01/2019 14:54, Sam Tebbs wrote:
> 
>> ping 3. The preceding two patches were committed a while ago but require
>> the minor libgcc changes in this patch, which are the only parts left to
>> be reviewed.
> ping 4
 Attached is a rebased patch made to work on top of Sudi Das' BTI patch
 (by renaming UNSPEC_PACISP to UNSPEC_PACIASP and UNSPEC_PACIBSP in
 aarch64-bti-insert.c). The updated changelog is below.

 Are the libgcc changes OK for trunk?

 gcc/
 2019-03-01  Sam Tebbs

 * config/aarch64/aarch64-builtins.c (aarch64_builtins): Add
 AARCH64_PAUTH_BUILTIN_AUTIB1716 and 
 AARCH64_PAUTH_BUILTIN_PACIB1716.
 * config/aarch64/aarch64-builtins.c 
 (aarch64_init_pauth_hint_builtins):
 Add autib1716 and pacib1716 initialisation.
 * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add 
 checks
 for autib1716 and pacib1716.
 * config/aarch64/aarch64-protos.h (aarch64_key_type,
 aarch64_post_cfi_startproc): Define.
 * config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define 
 extern.
 * config/aarch64/aarch64.c 
 (aarch64_handle_standard_branch_protection,
 aarch64_handle_pac_ret_protection): Set default sign key to A.
 * config/aarch64/aarch64.c (aarch64_expand_epilogue,
 aarch64_expand_prologue): Add check for b-key.
 * config/aarch64/aarch64.c (aarch64_ra_sign_key,
 aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define.
 * config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define.
 * config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key".
 * config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716,
 UNSPEC_AUTIB1716, UNSPEC

Re: [PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2019-05-29 Thread Sam Tebbs
Thanks for finding this Christoph, I had this failure a while ago but it 
stopped happening so I thought all was good. I have a fix ready.

Sam

On 29/05/2019 12:22, Christophe Lyon wrote:
> On Wed, 29 May 2019 at 11:23, Sam Tebbs  wrote:
>> The libgcc changes have been acknowledged off-list. Committed as r271735.
>>
> After this commit, I'm seeing errors while building libstdc++:
> 0x11c29f3 aarch64_return_address_signing_enabled()
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/config/aarch64/aarch64.c:4865
> 0x11c2a08 aarch64_post_cfi_startproc(_IO_FILE*, tree_node*)
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/config/aarch64/aarch64.c:15373
> 0xa27098 dwarf2out_do_cfi_startproc
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/dwarf2out.c:972
> 0xa43d6e dwarf2out_begin_prologue(unsigned int, unsigned int, char const*)
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/dwarf2out.c:1106
> 0xae05d5 final_start_function_1
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/final.c:1735
> 0xae0c2f final_start_function(rtx_insn*, _IO_FILE*, int)
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/final.c:1818
> 0x11c4442 aarch64_output_mi_thunk
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/config/aarch64/aarch64.c:6085
> 0x9cfa4f cgraph_node::expand_thunk(bool, bool)
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:1831
> 0x9d0dba cgraph_node::assemble_thunks_and_aliases()
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2122
> 0x9d0d89 cgraph_node::assemble_thunks_and_aliases()
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2140
> 0x9d1068 cgraph_node::expand()
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2259
> 0x9d23ec expand_all_functions
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2332
> 0x9d23ec symbol_table::compile()
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2683
> 0x9d5020 symbol_table::compile()
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2595
> 0x9d5020 symbol_table::finalize_compilation_unit()
>  
> /tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2861
> Please submit a full bug report,
> with preprocessed source if appropriate.
> Please include the complete backtrace with any bug report.
> See  for instructions.
> make[5]: *** [Makefile:900: strstream.lo] Error 1
>
> in aarch64-none-linux-gnu/libstdc++-v3/src/c++98
>
> (same for aarch64[_be]-elf)
>
> Christophe
>
>> On 01/03/2019 14:12, Sam Tebbs wrote:
>>> On 31/01/2019 14:54, Sam Tebbs wrote:
 
> ping 3. The preceding two patches were committed a while ago but require
> the minor libgcc changes in this patch, which are the only parts left to
> be reviewed.
 ping 4
>>> Attached is a rebased patch made to work on top of Sudi Das' BTI patch
>>> (by renaming UNSPEC_PACISP to UNSPEC_PACIASP and UNSPEC_PACIBSP in
>>> aarch64-bti-insert.c). The updated changelog is below.
>>>
>>> Are the libgcc changes OK for trunk?
>>>
>>> gcc/
>>> 2019-03-01  Sam Tebbs
>>>
>>>* config/aarch64/aarch64-builtins.c (aarch64_builtins): Add
>>>AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716.
>>>* config/aarch64/aarch64-builtins.c 
>>> (aarch64_init_pauth_hint_builtins):
>>>Add autib1716 and pacib1716 initialisation.
>>>* config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add 
>>> checks
>>>for autib1716 and pacib1716.
>>>* config/aarch64/aarch64-protos.h (aarch64_key_type,
>>>aarch64_post_cfi_startproc): Define.
>>>* config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define 
>>> extern.
>>>* config/aarch64/aarch64.c 
>>> (aarch64_handle_standard_branch_protection,
>>>aarch64_handle_pac_ret_protection): Set default sign key to A.
>>>* config/aarch64/aarch64.c (aarch64_expand_epilogue,
>>>aarch64_expand_prologue): Add check for b-key.
>>>* config/aarch64/aarch64.c (aarch64_ra_sign_key,
>>>aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define.
>>>* config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define.
>>>* config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key".
>>>* config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716,
>>>UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716,
>>>UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>>* config/aarch64/aarch64.md (do_return): Add check for b-key.
>>>* config/aarch64/aarch64.md (sp): Replace
>>>pauth_hint_num_a with paut

Re: [PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2019-05-29 Thread Christophe Lyon
On Wed, 29 May 2019 at 11:23, Sam Tebbs  wrote:
>
> The libgcc changes have been acknowledged off-list. Committed as r271735.
>

After this commit, I'm seeing errors while building libstdc++:
0x11c29f3 aarch64_return_address_signing_enabled()

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/config/aarch64/aarch64.c:4865
0x11c2a08 aarch64_post_cfi_startproc(_IO_FILE*, tree_node*)

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/config/aarch64/aarch64.c:15373
0xa27098 dwarf2out_do_cfi_startproc

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/dwarf2out.c:972
0xa43d6e dwarf2out_begin_prologue(unsigned int, unsigned int, char const*)

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/dwarf2out.c:1106
0xae05d5 final_start_function_1

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/final.c:1735
0xae0c2f final_start_function(rtx_insn*, _IO_FILE*, int)

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/final.c:1818
0x11c4442 aarch64_output_mi_thunk

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/config/aarch64/aarch64.c:6085
0x9cfa4f cgraph_node::expand_thunk(bool, bool)

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:1831
0x9d0dba cgraph_node::assemble_thunks_and_aliases()

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2122
0x9d0d89 cgraph_node::assemble_thunks_and_aliases()

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2140
0x9d1068 cgraph_node::expand()

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2259
0x9d23ec expand_all_functions

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2332
0x9d23ec symbol_table::compile()

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2683
0x9d5020 symbol_table::compile()

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2595
0x9d5020 symbol_table::finalize_compilation_unit()

/tmp/8467855_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cgraphunit.c:2861
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
make[5]: *** [Makefile:900: strstream.lo] Error 1

in aarch64-none-linux-gnu/libstdc++-v3/src/c++98

(same for aarch64[_be]-elf)

Christophe

> On 01/03/2019 14:12, Sam Tebbs wrote:
> > On 31/01/2019 14:54, Sam Tebbs wrote:
> >> 
> >>> ping 3. The preceding two patches were committed a while ago but require
> >>> the minor libgcc changes in this patch, which are the only parts left to
> >>> be reviewed.
> >> ping 4
> > Attached is a rebased patch made to work on top of Sudi Das' BTI patch
> > (by renaming UNSPEC_PACISP to UNSPEC_PACIASP and UNSPEC_PACIBSP in
> > aarch64-bti-insert.c). The updated changelog is below.
> >
> > Are the libgcc changes OK for trunk?
> >
> > gcc/
> > 2019-03-01  Sam Tebbs
> >
> >   * config/aarch64/aarch64-builtins.c (aarch64_builtins): Add
> >   AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716.
> >   * config/aarch64/aarch64-builtins.c 
> > (aarch64_init_pauth_hint_builtins):
> >   Add autib1716 and pacib1716 initialisation.
> >   * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add 
> > checks
> >   for autib1716 and pacib1716.
> >   * config/aarch64/aarch64-protos.h (aarch64_key_type,
> >   aarch64_post_cfi_startproc): Define.
> >   * config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define 
> > extern.
> >   * config/aarch64/aarch64.c (aarch64_handle_standard_branch_protection,
> >   aarch64_handle_pac_ret_protection): Set default sign key to A.
> >   * config/aarch64/aarch64.c (aarch64_expand_epilogue,
> >   aarch64_expand_prologue): Add check for b-key.
> >   * config/aarch64/aarch64.c (aarch64_ra_sign_key,
> >   aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define.
> >   * config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define.
> >   * config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key".
> >   * config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716,
> >   UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716,
> >   UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP.
> >   * config/aarch64/aarch64.md (do_return): Add check for b-key.
> >   * config/aarch64/aarch64.md (sp): Replace
> >   pauth_hint_num_a with pauth_hint_num.
> >   * config/aarch64/aarch64.md (1716): Replace
> >   pauth_hint_num_a with pauth_hint_num.
> >   * config/aarch64/aarch64.opt (msign-return-address=): Deprecate.
> >   * config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP,
> >   UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
> >   * config/aarch

Re: [PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2019-05-29 Thread Sam Tebbs
The libgcc changes have been acknowledged off-list. Committed as r271735.

On 01/03/2019 14:12, Sam Tebbs wrote:
> On 31/01/2019 14:54, Sam Tebbs wrote:
>> 
>>> ping 3. The preceding two patches were committed a while ago but require
>>> the minor libgcc changes in this patch, which are the only parts left to
>>> be reviewed.
>> ping 4
> Attached is a rebased patch made to work on top of Sudi Das' BTI patch
> (by renaming UNSPEC_PACISP to UNSPEC_PACIASP and UNSPEC_PACIBSP in
> aarch64-bti-insert.c). The updated changelog is below.
>
> Are the libgcc changes OK for trunk?
>
> gcc/
> 2019-03-01  Sam Tebbs
>
>   * config/aarch64/aarch64-builtins.c (aarch64_builtins): Add
>   AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716.
>   * config/aarch64/aarch64-builtins.c (aarch64_init_pauth_hint_builtins):
>   Add autib1716 and pacib1716 initialisation.
>   * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add checks
>   for autib1716 and pacib1716.
>   * config/aarch64/aarch64-protos.h (aarch64_key_type,
>   aarch64_post_cfi_startproc): Define.
>   * config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define extern.
>   * config/aarch64/aarch64.c (aarch64_handle_standard_branch_protection,
>   aarch64_handle_pac_ret_protection): Set default sign key to A.
>   * config/aarch64/aarch64.c (aarch64_expand_epilogue,
>   aarch64_expand_prologue): Add check for b-key.
>   * config/aarch64/aarch64.c (aarch64_ra_sign_key,
>   aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define.
>   * config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define.
>   * config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key".
>   * config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716,
>   UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716,
>   UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>   * config/aarch64/aarch64.md (do_return): Add check for b-key.
>   * config/aarch64/aarch64.md (sp): Replace
>   pauth_hint_num_a with pauth_hint_num.
>   * config/aarch64/aarch64.md (1716): Replace
>   pauth_hint_num_a with pauth_hint_num.
>   * config/aarch64/aarch64.opt (msign-return-address=): Deprecate.
>   * config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP,
>   UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>   * config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716,
>   UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716.
>   * config/aarch64/iterators.md (pauth_mnem_prefix): Add UNSPEC_AUTIA1716,
>   UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_AUTIASP,
>   UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>   * config/aarch64/iterators.md (pauth_hint_num_a): Replace
>   UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and
>   UNSPEC_AUTIA1716 respectively.
>   * config/aarch64/iterators.md (pauth_hint_num_a): Rename to 
> pauth_hint_num
>   and add UNSPEC_PACIBSP, UNSPEC_AUTIBSP, UNSPEC_PACIB1716, 
> UNSPEC_AUTIB1716.
>   * doc/invoke.texi (-mbranch-protection): Add b-key type.
>   * config/aarch64/aarch64-bti-insert.c (aarch64_pac_insn_p): Rename
>   UNSPEC_PACISP to UNSPEC_PACIASP and UNSPEC_PACIBSP.
>
> gcc/testsuite
> 2019-03-01  Sam Tebbs
>
>   * gcc.target/aarch64/return_address_sign_b_1.c: New file.
>   * gcc.target/aarch64/return_address_sign_b_2.c: New file.
>   * gcc.target/aarch64/return_address_sign_b_3.c: New file.
>   * gcc.target/aarch64/return_address_sign_b_exception.c: New file.
>   * gcc.target/aarch64/return_address_sign_ab_exception.c: New file.
>   * gcc.target/aarch64/return_address_sign_builtin.c: New file
>
> libgcc/
> 2019-03-01  Sam Tebbs
>
>   * config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): New
>   function.
>   * config/aarch64/aarch64-unwind.h (aarch64_post_extract_frame_addr,
>   aarch64_post_frob_eh_handler_addr): Add check for b-key.
>   * config/aarch64/aarch64-unwind-h (aarch64_post_extract_frame_addr,
>   aarch64_post_frob_eh_handler_addr, aarch64_post_frob_update_context):
>   Rename RA_A_SIGNED_BIT to RA_SIGNED_BIT.
>   * unwind-dw2-fde.c (get_cie_encoding): Add check for 'B' in augmentation
>   string.
>   * unwind-dw2.c (extract_cie_info): Add check for 'B' in augmentation
>   string.
>   (RA_A_SIGNED_BIT): Rename to RA_SIGNED_BIT.
>


Re: [PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2019-03-01 Thread Sam Tebbs

On 31/01/2019 14:54, Sam Tebbs wrote:
> 
>> ping 3. The preceding two patches were committed a while ago but require
>> the minor libgcc changes in this patch, which are the only parts left to
>> be reviewed.
> ping 4

Attached is a rebased patch made to work on top of Sudi Das' BTI patch 
(by renaming UNSPEC_PACISP to UNSPEC_PACIASP and UNSPEC_PACIBSP in 
aarch64-bti-insert.c). The updated changelog is below.

Are the libgcc changes OK for trunk?

gcc/
2019-03-01  Sam Tebbs

* config/aarch64/aarch64-builtins.c (aarch64_builtins): Add
AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716.
* config/aarch64/aarch64-builtins.c (aarch64_init_pauth_hint_builtins):
Add autib1716 and pacib1716 initialisation.
* config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add checks
for autib1716 and pacib1716.
* config/aarch64/aarch64-protos.h (aarch64_key_type,
aarch64_post_cfi_startproc): Define.
* config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define extern.
* config/aarch64/aarch64.c (aarch64_handle_standard_branch_protection,
aarch64_handle_pac_ret_protection): Set default sign key to A.
* config/aarch64/aarch64.c (aarch64_expand_epilogue,
aarch64_expand_prologue): Add check for b-key.
* config/aarch64/aarch64.c (aarch64_ra_sign_key,
aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define.
* config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define.
* config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key".
* config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716,
UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716,
UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP.
* config/aarch64/aarch64.md (do_return): Add check for b-key.
* config/aarch64/aarch64.md (sp): Replace
pauth_hint_num_a with pauth_hint_num.
* config/aarch64/aarch64.md (1716): Replace
pauth_hint_num_a with pauth_hint_num.
* config/aarch64/aarch64.opt (msign-return-address=): Deprecate.
* config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP,
UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
* config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716,
UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716.
* config/aarch64/iterators.md (pauth_mnem_prefix): Add UNSPEC_AUTIA1716,
UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_AUTIASP,
UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
* config/aarch64/iterators.md (pauth_hint_num_a): Replace
UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and
UNSPEC_AUTIA1716 respectively.
* config/aarch64/iterators.md (pauth_hint_num_a): Rename to 
pauth_hint_num
and add UNSPEC_PACIBSP, UNSPEC_AUTIBSP, UNSPEC_PACIB1716, 
UNSPEC_AUTIB1716.
* doc/invoke.texi (-mbranch-protection): Add b-key type.
* config/aarch64/aarch64-bti-insert.c (aarch64_pac_insn_p): Rename
UNSPEC_PACISP to UNSPEC_PACIASP and UNSPEC_PACIBSP.

gcc/testsuite
2019-03-01  Sam Tebbs

* gcc.target/aarch64/return_address_sign_b_1.c: New file.
* gcc.target/aarch64/return_address_sign_b_2.c: New file.
* gcc.target/aarch64/return_address_sign_b_3.c: New file.
* gcc.target/aarch64/return_address_sign_b_exception.c: New file.
* gcc.target/aarch64/return_address_sign_ab_exception.c: New file.
* gcc.target/aarch64/return_address_sign_builtin.c: New file

libgcc/
2019-03-01  Sam Tebbs

* config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): New
function.
* config/aarch64/aarch64-unwind.h (aarch64_post_extract_frame_addr,
aarch64_post_frob_eh_handler_addr): Add check for b-key.
* config/aarch64/aarch64-unwind-h (aarch64_post_extract_frame_addr,
aarch64_post_frob_eh_handler_addr, aarch64_post_frob_update_context):
Rename RA_A_SIGNED_BIT to RA_SIGNED_BIT.
* unwind-dw2-fde.c (get_cie_encoding): Add check for 'B' in augmentation
string.
* unwind-dw2.c (extract_cie_info): Add check for 'B' in augmentation
string.
(RA_A_SIGNED_BIT): Rename to RA_SIGNED_BIT.

diff --git a/gcc/config/aarch64/aarch64-bti-insert.c 
b/gcc/config/aarch64/aarch64-bti-insert.c
index 
e519a0f0ac1751f4268e03381757bc1a10c13144..db8ebb1ba8e45b4bf7cd2f27ae8a2c606a1a6c89
 100644
--- a/gcc/config/aarch64/aarch64-bti-insert.c
+++ b/gcc/config/aarch64/aarch64-bti-insert.c
@@ -106,7 +106,9 @@ aarch64_pac_insn_p (rtx x)
  int unspec_val = XINT (sub, 1);
  switch (unspec_val)
{
-   case UNSPEC_PACISP:
+   case UNSPEC_PACIASP:
+/* fall-through.  */
+case UNSPEC_PACIBSP:
  return true;
 
default:
diff --git a/gcc/config/aarch64/aarch64-builtins.c

Re: [PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2019-01-31 Thread Sam Tebbs

On 23/01/2019 10:22, Sam Tebbs wrote:
> On 14/01/2019 10:43, Kyrill Tkachov wrote:
>
>> On 08/01/19 11:38, Sam Tebbs wrote:
>>
>>
>>
>> On 1/7/19 6:28 PM, James Greenhalgh wrote:
>>
>> > On Fri, Dec 21, 2018 at 09:00:10AM -0600, Sam Tebbs wrote:
>>
>> >> On 11/9/18 11:04 AM, Sam Tebbs wrote:
>>
>> >
>>
>> > 
>>
>> >
>>
>> >> Attached is an improved patch with "hint" removed from the test scans,
>>
>> >> pauth_hint_num_a and pauth_hint_num_b merged into pauth_hint_num and the
>>
>> >> "gcc_assert (cfun->machine->frame.laid_out)" removal reverted since was
>>
>> >> an unnecessary change.
>>
>> >>
>>
>> >> OK for trunk?
>>
>> > While the AArch64 parts look OK to me and are buried behind an option so 
>> > are
>>
>> > relatively safe even though we're late in development, you'll need someone
>>
>> > else to approve the libgcc changes. Especially as you change a generic
>>
>> > routine with an undocumented (?) AArch64-specific change.
>>
>> >
>>
>> > Thanks,
>>
>> > James
>>
>>
>>
>> Thanks James, CC'ing Ian Lance Taylor.
>>
>>
>> Jeff, could you help with reviewing the libgcc changes please?
>> I believe the latest version was posted at:
>> https://gcc.gnu.org/ml/gcc-patches/2018-12/msg01569.html
>>
>> Thanks,
>> Kyrill
> ping 3. The preceding two patches were committed a while ago but require
> the minor libgcc changes in this patch, which are the only parts left to
> be reviewed.
ping 4
>>> The documentation relevant to the libgcc change is expected to be
>>>
>>> published in the near future.
>>>
>>>
>>>
>>> >
>>>
>>> >> gcc/
>>>
>>> >> 2018-12-21  Sam Tebbs
>>>
>>> >>
>>>
>>> >>   * config/aarch64/aarch64-builtins.c (aarch64_builtins): Add
>>>
>>> >>   AARCH64_PAUTH_BUILTIN_AUTIB1716 and 
>>> >>AARCH64_PAUTH_BUILTIN_PACIB1716.
>>>
>>> >>   * config/aarch64/aarch64-builtins.c 
>>> >>(aarch64_init_pauth_hint_builtins):
>>>
>>> >>   Add autib1716 and pacib1716 initialisation.
>>>
>>> >>   * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add 
>>> >>checks
>>>
>>> >>   for autib1716 and pacib1716.
>>>
>>> >>   * config/aarch64/aarch64-protos.h (aarch64_key_type,
>>>
>>> >>   aarch64_post_cfi_startproc): Define.
>>>
>>> >>   * config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define 
>>> >>extern.
>>>
>>> >>   * config/aarch64/aarch64.c 
>>> >>(aarch64_return_address_signing_enabled): Add
>>>
>>> >>   check for b-key.
>>>
>>> >>   * config/aarch64/aarch64.c (aarch64_ra_sign_key,
>>>
>>> >>   aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define.
>>>
>>> >>   * config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define.
>>>
>>> >>   * config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key".
>>>
>>> >>   * config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716,
>>>
>>> >>   UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716,
>>>
>>> >>   UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>>
>>> >>   * config/aarch64/aarch64.md (do_return): Add check for b-key.
>>>
>>> >>   * config/aarch64/aarch64.md (sp): Replace
>>>
>>> >>   pauth_hint_num_a with pauth_hint_num.
>>>
>>> >>   * config/aarch64/aarch64.md (1716): Replace
>>>
>>> >>   pauth_hint_num_a with pauth_hint_num.
>>>
>>> >>   * config/aarch64/aarch64.opt (msign-return-address=): Deprecate.
>>>
>>> >>   * config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP,
>>>
>>> >>   UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>>
>>> >>   * config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716,
>>>
>>> >>   UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716.
>>>
>>> >>   * config/aarch64/iterators.md (pauth_mnem_prefix): Add 
>>> >>UNSPEC_AUTIA1716,
>>>
>>> >>   UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, 
>>> >>UNSPEC_AUTIASP,
>>>
>>> >>   UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>>
>>> >>   * config/aarch64/iterators.md (pauth_hint_num_a): Replace
>>>
>>> >>   UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and
>>>
>>> >>   UNSPEC_AUTIA1716 respectively.
>>>
>>> >>   * config/aarch64/iterators.md (pauth_hint_num_a): Rename to 
>>> >>pauth_hint_num
>>>
>>> >>   and add UNSPEC_PACIBSP, UNSPEC_AUTIBSP, UNSPEC_PACIB1716, 
>>> >>UNSPEC_AUTIB1716.
>>>
>>> >>
>>>
>>> >> gcc/testsuite
>>>
>>> >> 2018-12-21  Sam Tebbs
>>>
>>> >>
>>>
>>> >>   * gcc.target/aarch64/return_address_sign_1.c (dg-final): Replace
>>>
>>> >>   "autiasp" and "paciasp" with "hint\t29 // autisp" and
>>>
>>> >>   "hint\t25 // pacisp" respectively.
>>>
>>> >>   * gcc.target/aarch64/return_address_sign_2.c (dg-final): Replace
>>>
>>> >>   "paciasp" with "hint\t25 // pacisp".
>>>
>>> >>   * gcc.target/aarch64/return_address_sign_3.c (dg-final): Replace
>>>
>>> >>   "paciasp" and "autiasp" with "pacisp" and "autisp" respectively.
>>>
>>> >>   * gcc.target/aarch64/return_address_sign_b_1.c: New file.
>>>
>>> >>   * gcc.t

Re: [PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2019-01-23 Thread Sam Tebbs
On 14/01/2019 10:43, Kyrill Tkachov wrote:

>
> On 08/01/19 11:38, Sam Tebbs wrote:
>>
>> On 1/7/19 6:28 PM, James Greenhalgh wrote:
>> > On Fri, Dec 21, 2018 at 09:00:10AM -0600, Sam Tebbs wrote:
>> >> On 11/9/18 11:04 AM, Sam Tebbs wrote:
>> >
>> > 
>> >
>> >> Attached is an improved patch with "hint" removed from the test 
>> scans,
>> >> pauth_hint_num_a and pauth_hint_num_b merged into pauth_hint_num 
>> and the
>> >> "gcc_assert (cfun->machine->frame.laid_out)" removal reverted 
>> since was
>> >> an unnecessary change.
>> >>
>> >> OK for trunk?
>> > While the AArch64 parts look OK to me and are buried behind an 
>> option so are
>> > relatively safe even though we're late in development, you'll need 
>> someone
>> > else to approve the libgcc changes. Especially as you change a generic
>> > routine with an undocumented (?) AArch64-specific change.
>> >
>> > Thanks,
>> > James
>>
>> Thanks James, CC'ing Ian Lance Taylor.
>>
>
> Jeff, could you help with reviewing the libgcc changes please?
> I believe the latest version was posted at:
> https://gcc.gnu.org/ml/gcc-patches/2018-12/msg01569.html
>
> Thanks,
> Kyrill
ping 3. The preceding two patches were committed a while ago but require 
the minor libgcc changes in this patch, which are the only parts left to 
be reviewed.
>
>> The documentation relevant to the libgcc change is expected to be
>> published in the near future.


Re: [PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2019-01-14 Thread Kyrill Tkachov



On 08/01/19 11:38, Sam Tebbs wrote:


On 1/7/19 6:28 PM, James Greenhalgh wrote:
> On Fri, Dec 21, 2018 at 09:00:10AM -0600, Sam Tebbs wrote:
>> On 11/9/18 11:04 AM, Sam Tebbs wrote:
>
> 
>
>> Attached is an improved patch with "hint" removed from the test scans,
>> pauth_hint_num_a and pauth_hint_num_b merged into pauth_hint_num and the
>> "gcc_assert (cfun->machine->frame.laid_out)" removal reverted since was
>> an unnecessary change.
>>
>> OK for trunk?
> While the AArch64 parts look OK to me and are buried behind an option so are
> relatively safe even though we're late in development, you'll need someone
> else to approve the libgcc changes. Especially as you change a generic
> routine with an undocumented (?) AArch64-specific change.
>
> Thanks,
> James

Thanks James, CC'ing Ian Lance Taylor.



Jeff, could you help with reviewing the libgcc changes please?
I believe the latest version was posted at:
https://gcc.gnu.org/ml/gcc-patches/2018-12/msg01569.html

Thanks,
Kyrill


The documentation relevant to the libgcc change is expected to be
published in the near future.

>
>> gcc/
>> 2018-12-21  Sam Tebbs
>>
>>   * config/aarch64/aarch64-builtins.c (aarch64_builtins): Add
>>   AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716.
>>   * config/aarch64/aarch64-builtins.c (aarch64_init_pauth_hint_builtins):
>>   Add autib1716 and pacib1716 initialisation.
>>   * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add 
checks
>>   for autib1716 and pacib1716.
>>   * config/aarch64/aarch64-protos.h (aarch64_key_type,
>>   aarch64_post_cfi_startproc): Define.
>>   * config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define extern.
>>   * config/aarch64/aarch64.c (aarch64_return_address_signing_enabled): 
Add
>>   check for b-key.
>>   * config/aarch64/aarch64.c (aarch64_ra_sign_key,
>>   aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define.
>>   * config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define.
>>   * config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key".
>>   * config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716,
>>   UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716,
>>   UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>   * config/aarch64/aarch64.md (do_return): Add check for b-key.
>>   * config/aarch64/aarch64.md (sp): Replace
>>   pauth_hint_num_a with pauth_hint_num.
>>   * config/aarch64/aarch64.md (1716): Replace
>>   pauth_hint_num_a with pauth_hint_num.
>>   * config/aarch64/aarch64.opt (msign-return-address=): Deprecate.
>>   * config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP,
>>   UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>   * config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716,
>>   UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716.
>>   * config/aarch64/iterators.md (pauth_mnem_prefix): Add 
UNSPEC_AUTIA1716,
>>   UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_AUTIASP,
>>   UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>   * config/aarch64/iterators.md (pauth_hint_num_a): Replace
>>   UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and
>>   UNSPEC_AUTIA1716 respectively.
>>   * config/aarch64/iterators.md (pauth_hint_num_a): Rename to 
pauth_hint_num
>>   and add UNSPEC_PACIBSP, UNSPEC_AUTIBSP, UNSPEC_PACIB1716, 
UNSPEC_AUTIB1716.
>>
>> gcc/testsuite
>> 2018-12-21  Sam Tebbs
>>
>>   * gcc.target/aarch64/return_address_sign_1.c (dg-final): Replace
>>   "autiasp" and "paciasp" with "hint\t29 // autisp" and
>>   "hint\t25 // pacisp" respectively.
>>   * gcc.target/aarch64/return_address_sign_2.c (dg-final): Replace
>>   "paciasp" with "hint\t25 // pacisp".
>>   * gcc.target/aarch64/return_address_sign_3.c (dg-final): Replace
>>   "paciasp" and "autiasp" with "pacisp" and "autisp" respectively.
>>   * gcc.target/aarch64/return_address_sign_b_1.c: New file.
>>   * gcc.target/aarch64/return_address_sign_b_2.c: New file.
>>   * gcc.target/aarch64/return_address_sign_b_3.c: New file.
>>   * gcc.target/aarch64/return_address_sign_b_exception.c: New file.
>>   * gcc.target/aarch64/return_address_sign_builtin.c: New file
>>
>> libgcc/
>> 2018-12-21  Sam Tebbs
>>
>>   * config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): New
>>   function.
>>   * config/aarch64/aarch64-unwind.h (aarch64_post_extract_frame_addr,
>>   aarch64_post_frob_eh_handler_addr): Add check for b-key.
>>   * unwind-dw2-fde.c (get_cie_encoding): Add check for 'B' in 
augmentation
>>   string.
>>   * unwind-dw2.c (extract_cie_info): Add check for 'B' in augmentation
>>   string.
>>




Re: [PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2019-01-08 Thread Sam Tebbs

On 1/7/19 6:28 PM, James Greenhalgh wrote:
> On Fri, Dec 21, 2018 at 09:00:10AM -0600, Sam Tebbs wrote:
>> On 11/9/18 11:04 AM, Sam Tebbs wrote:
>   
> 
>
>> Attached is an improved patch with "hint" removed from the test scans,
>> pauth_hint_num_a and pauth_hint_num_b merged into pauth_hint_num and the
>> "gcc_assert (cfun->machine->frame.laid_out)" removal reverted since was
>> an unnecessary change.
>>
>> OK for trunk?
> While the AArch64 parts look OK to me and are buried behind an option so are
> relatively safe even though we're late in development, you'll need someone
> else to approve the libgcc changes. Especially as you change a generic
> routine with an undocumented (?) AArch64-specific change.
>
> Thanks,
> James

Thanks James, CC'ing Ian Lance Taylor.

The documentation relevant to the libgcc change is expected to be 
published in the near future.

>
>> gcc/
>> 2018-12-21  Sam Tebbs
>>
>>  * config/aarch64/aarch64-builtins.c (aarch64_builtins): Add
>>  AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716.
>>  * config/aarch64/aarch64-builtins.c (aarch64_init_pauth_hint_builtins):
>>  Add autib1716 and pacib1716 initialisation.
>>  * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add checks
>>  for autib1716 and pacib1716.
>>  * config/aarch64/aarch64-protos.h (aarch64_key_type,
>>  aarch64_post_cfi_startproc): Define.
>>  * config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define extern.
>>  * config/aarch64/aarch64.c (aarch64_return_address_signing_enabled): Add
>>  check for b-key.
>>  * config/aarch64/aarch64.c (aarch64_ra_sign_key,
>>  aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define.
>>  * config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define.
>>  * config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key".
>>  * config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716,
>>  UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716,
>>  UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>  * config/aarch64/aarch64.md (do_return): Add check for b-key.
>>  * config/aarch64/aarch64.md (sp): Replace
>>  pauth_hint_num_a with pauth_hint_num.
>>  * config/aarch64/aarch64.md (1716): Replace
>>  pauth_hint_num_a with pauth_hint_num.
>>  * config/aarch64/aarch64.opt (msign-return-address=): Deprecate.
>>  * config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP,
>>  UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>  * config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716,
>>  UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716.
>>  * config/aarch64/iterators.md (pauth_mnem_prefix): Add UNSPEC_AUTIA1716,
>>  UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_AUTIASP,
>>  UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>  * config/aarch64/iterators.md (pauth_hint_num_a): Replace
>>  UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and
>>  UNSPEC_AUTIA1716 respectively.
>>  * config/aarch64/iterators.md (pauth_hint_num_a): Rename to 
>> pauth_hint_num
>>  and add UNSPEC_PACIBSP, UNSPEC_AUTIBSP, UNSPEC_PACIB1716, 
>> UNSPEC_AUTIB1716.
>>
>> gcc/testsuite
>> 2018-12-21  Sam Tebbs
>>
>>  * gcc.target/aarch64/return_address_sign_1.c (dg-final): Replace
>>  "autiasp" and "paciasp" with "hint\t29 // autisp" and
>>  "hint\t25 // pacisp" respectively.
>>  * gcc.target/aarch64/return_address_sign_2.c (dg-final): Replace
>>  "paciasp" with "hint\t25 // pacisp".
>>  * gcc.target/aarch64/return_address_sign_3.c (dg-final): Replace
>>  "paciasp" and "autiasp" with "pacisp" and "autisp" respectively.
>>  * gcc.target/aarch64/return_address_sign_b_1.c: New file.
>>  * gcc.target/aarch64/return_address_sign_b_2.c: New file.
>>  * gcc.target/aarch64/return_address_sign_b_3.c: New file.
>>  * gcc.target/aarch64/return_address_sign_b_exception.c: New file.
>>  * gcc.target/aarch64/return_address_sign_builtin.c: New file
>>
>> libgcc/
>> 2018-12-21  Sam Tebbs
>>
>>  * config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): New
>>  function.
>>  * config/aarch64/aarch64-unwind.h (aarch64_post_extract_frame_addr,
>>  aarch64_post_frob_eh_handler_addr): Add check for b-key.
>>  * unwind-dw2-fde.c (get_cie_encoding): Add check for 'B' in augmentation
>>  string.
>>  * unwind-dw2.c (extract_cie_info): Add check for 'B' in augmentation
>>  string.
>>


Re: [PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2019-01-07 Thread James Greenhalgh
On Fri, Dec 21, 2018 at 09:00:10AM -0600, Sam Tebbs wrote:
> On 11/9/18 11:04 AM, Sam Tebbs wrote:
 


> Attached is an improved patch with "hint" removed from the test scans, 
> pauth_hint_num_a and pauth_hint_num_b merged into pauth_hint_num and the 
> "gcc_assert (cfun->machine->frame.laid_out)" removal reverted since was 
> an unnecessary change.
> 
> OK for trunk?

While the AArch64 parts look OK to me and are buried behind an option so are
relatively safe even though we're late in development, you'll need someone
else to approve the libgcc changes. Especially as you change a generic
routine with an undocumented (?) AArch64-specific change.

Thanks,
James

> 
> gcc/
> 2018-12-21  Sam Tebbs
> 
>   * config/aarch64/aarch64-builtins.c (aarch64_builtins): Add
>   AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716.
>   * config/aarch64/aarch64-builtins.c (aarch64_init_pauth_hint_builtins):
>   Add autib1716 and pacib1716 initialisation.
>   * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add checks
>   for autib1716 and pacib1716.
>   * config/aarch64/aarch64-protos.h (aarch64_key_type,
>   aarch64_post_cfi_startproc): Define.
>   * config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define extern.
>   * config/aarch64/aarch64.c (aarch64_return_address_signing_enabled): Add
>   check for b-key.
>   * config/aarch64/aarch64.c (aarch64_ra_sign_key,
>   aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define.
>   * config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define.
>   * config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key".
>   * config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716,
>   UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716,
>   UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>   * config/aarch64/aarch64.md (do_return): Add check for b-key.
>   * config/aarch64/aarch64.md (sp): Replace
>   pauth_hint_num_a with pauth_hint_num.
>   * config/aarch64/aarch64.md (1716): Replace
>   pauth_hint_num_a with pauth_hint_num.
>   * config/aarch64/aarch64.opt (msign-return-address=): Deprecate.
>   * config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP,
>   UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>   * config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716,
>   UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716.
>   * config/aarch64/iterators.md (pauth_mnem_prefix): Add UNSPEC_AUTIA1716,
>   UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_AUTIASP,
>   UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>   * config/aarch64/iterators.md (pauth_hint_num_a): Replace
>   UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and
>   UNSPEC_AUTIA1716 respectively.
>   * config/aarch64/iterators.md (pauth_hint_num_a): Rename to 
> pauth_hint_num
>   and add UNSPEC_PACIBSP, UNSPEC_AUTIBSP, UNSPEC_PACIB1716, 
> UNSPEC_AUTIB1716.
> 
> gcc/testsuite
> 2018-12-21  Sam Tebbs
> 
>   * gcc.target/aarch64/return_address_sign_1.c (dg-final): Replace
>   "autiasp" and "paciasp" with "hint\t29 // autisp" and
>   "hint\t25 // pacisp" respectively.
>   * gcc.target/aarch64/return_address_sign_2.c (dg-final): Replace
>   "paciasp" with "hint\t25 // pacisp".
>   * gcc.target/aarch64/return_address_sign_3.c (dg-final): Replace
>   "paciasp" and "autiasp" with "pacisp" and "autisp" respectively.
>   * gcc.target/aarch64/return_address_sign_b_1.c: New file.
>   * gcc.target/aarch64/return_address_sign_b_2.c: New file.
>   * gcc.target/aarch64/return_address_sign_b_3.c: New file.
>   * gcc.target/aarch64/return_address_sign_b_exception.c: New file.
>   * gcc.target/aarch64/return_address_sign_builtin.c: New file
> 
> libgcc/
> 2018-12-21  Sam Tebbs
> 
>   * config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): New
>   function.
>   * config/aarch64/aarch64-unwind.h (aarch64_post_extract_frame_addr,
>   aarch64_post_frob_eh_handler_addr): Add check for b-key.
>   * unwind-dw2-fde.c (get_cie_encoding): Add check for 'B' in augmentation
>   string.
>   * unwind-dw2.c (extract_cie_info): Add check for 'B' in augmentation
>   string.
> 


Re: [PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2019-01-04 Thread Sam Tebbs

On 12/21/18 3:00 PM, Sam Tebbs wrote:
> On 11/9/18 11:04 AM, Sam Tebbs wrote:
>> On 11/02/2018 06:01 PM, Sam Tebbs wrote:
>>
>>> On 11/02/2018 05:35 PM, Sam Tebbs wrote:
>>>
 Hi all,

 This patch adds support for the Armv8.3-A pointer authentication 
 instructions
 that use the B-key (pacib*, autib* and retab). This required adding 
 builtins for
 pacib1716 and autib1716, adding the "b-key" feature to the 
 -mbranch-protection
 option, and required emitting a new CFI directive ".cfi_b_key_frame" which
 causes GAS to add 'B' to the CIE augmentation string. I also had to add a 
 new
 hook called ASM_POST_CFI_STARTPROC which is triggered when the 
 .cfi_startproc
 directive is emitted.

 The libgcc stack unwinder has been amended to authenticate return addresses
 with the B key when the function has been signed with the B key.

 The previous patch in this series is here:
 https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00104.html

 Bootstrapped successfully and regression tested on aarch64-none-elf.

 OK for trunk?

 gcc/
 2018-11-02  Sam Tebbs  

* config/aarch64/aarch64-builtins.c (aarch64_builtins): Add
AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716.
* config/aarch64/aarch64-builtins.c (aarch64_init_pauth_hint_builtins):
Add autib1716 and pacib1716 initialisation.
* config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add checks
for autib1716 and pacib1716.
* config/aarch64/aarch64-protos.h (aarch64_key_type,
aarch64_post_cfi_startproc): Define.
* config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define extern.
* config/aarch64/aarch64.c (aarch64_return_address_signing_enabled): Add
check for b-key, remove frame.laid_out assertion.
* config/aarch64/aarch64.c (aarch64_ra_sign_key,
aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define.
* config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define.
* config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key".
* config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716,
UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716,
UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP.
* config/aarch64/aarch64.md (do_return): Add check for b-key.
* config/aarch64/aarch64.md (sp): Add check for
signing key and scope selected.
* config/aarch64/aarch64.md (1716): Add check for
signing key and scope selected.
* config/aarch64/aarch64.opt (msign-return-address=): Deprecate.
* config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP,
UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
* config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716,
UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716.
* config/aarch64/iterators.md (pauth_mnem_prefix): Add UNSPEC_AUTIA1716,
UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_AUTIASP,
UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
* config/aarch64/iterators.md (pauth_hint_num_a): Replace
UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and
UNSPEC_AUTIA1716 respectively.
* config/aarch64/iterators.md (pauth_hint_num_b): New int attribute.

 gcc/testsuite
 2018-11-02  Sam Tebbs  

* gcc.target/aarch64/return_address_sign_1.c (dg-final): Replace
"autiasp" and "paciasp" with "hint\t29 // autisp" and
"hint\t25 // pacisp" respectively.
* gcc.target/aarch64/return_address_sign_2.c (dg-final): Replace
"paciasp" with "hint\t25 // pacisp".
* gcc.target/aarch64/return_address_sign_3.c (dg-final): Replace
"paciasp" and "autiasp" with "pacisp" and "autisp" respectively.
* gcc.target/aarch64/return_address_sign_b_1.c: New file.
* gcc.target/aarch64/return_address_sign_b_2.c: New file.
* gcc.target/aarch64/return_address_sign_b_3.c: New file.
* gcc.target/aarch64/return_address_sign_b_exception.c: New file.
* gcc.target/aarch64/return_address_sign_builtin.c: New file

 libgcc/
 2018-11-02  Sam Tebbs  

* config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): New
function.
* config/aarch64/aarch64-unwind.h (aarch64_post_extract_frame_addr,
aarch64_post_frob_eh_handler_addr): Add check for b-key.
* unwind-dw2-fde.c (get_cie_encoding): Add check for 'B' in augmentation
string.
* unwind-dw2.c (extract_cie_info): Add check for 'B' in augmentation
string.
>>> Attached is an updated patch rebased on an improvement to the
>>> -mbranch-protection option documentation.
>> ping
> Attached is an improved patch with "hint" removed from the test scans,
> pauth_hint_num_a and pauth_hint_num

Re: [PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2018-12-21 Thread Sam Tebbs
On 11/9/18 11:04 AM, Sam Tebbs wrote:
> On 11/02/2018 06:01 PM, Sam Tebbs wrote:
>
>> On 11/02/2018 05:35 PM, Sam Tebbs wrote:
>>
>>> Hi all,
>>>
>>> This patch adds support for the Armv8.3-A pointer authentication 
>>> instructions
>>> that use the B-key (pacib*, autib* and retab). This required adding 
>>> builtins for
>>> pacib1716 and autib1716, adding the "b-key" feature to the 
>>> -mbranch-protection
>>> option, and required emitting a new CFI directive ".cfi_b_key_frame" which
>>> causes GAS to add 'B' to the CIE augmentation string. I also had to add a 
>>> new
>>> hook called ASM_POST_CFI_STARTPROC which is triggered when the 
>>> .cfi_startproc
>>> directive is emitted.
>>>
>>> The libgcc stack unwinder has been amended to authenticate return addresses
>>> with the B key when the function has been signed with the B key.
>>>
>>> The previous patch in this series is here:
>>> https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00104.html
>>>
>>> Bootstrapped successfully and regression tested on aarch64-none-elf.
>>>
>>> OK for trunk?
>>>
>>> gcc/
>>> 2018-11-02  Sam Tebbs  
>>>
>>> * config/aarch64/aarch64-builtins.c (aarch64_builtins): Add
>>> AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716.
>>> * config/aarch64/aarch64-builtins.c (aarch64_init_pauth_hint_builtins):
>>> Add autib1716 and pacib1716 initialisation.
>>> * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add checks
>>> for autib1716 and pacib1716.
>>> * config/aarch64/aarch64-protos.h (aarch64_key_type,
>>> aarch64_post_cfi_startproc): Define.
>>> * config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define extern.
>>> * config/aarch64/aarch64.c (aarch64_return_address_signing_enabled): Add
>>> check for b-key, remove frame.laid_out assertion.
>>> * config/aarch64/aarch64.c (aarch64_ra_sign_key,
>>> aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define.
>>> * config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define.
>>> * config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key".
>>> * config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716,
>>> UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716,
>>> UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>> * config/aarch64/aarch64.md (do_return): Add check for b-key.
>>> * config/aarch64/aarch64.md (sp): Add check for
>>> signing key and scope selected.
>>> * config/aarch64/aarch64.md (1716): Add check for
>>> signing key and scope selected.
>>> * config/aarch64/aarch64.opt (msign-return-address=): Deprecate.
>>> * config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP,
>>> UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>> * config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716,
>>> UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716.
>>> * config/aarch64/iterators.md (pauth_mnem_prefix): Add UNSPEC_AUTIA1716,
>>> UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_AUTIASP,
>>> UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>> * config/aarch64/iterators.md (pauth_hint_num_a): Replace
>>> UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and
>>> UNSPEC_AUTIA1716 respectively.
>>> * config/aarch64/iterators.md (pauth_hint_num_b): New int attribute.
>>>
>>> gcc/testsuite
>>> 2018-11-02  Sam Tebbs  
>>>
>>> * gcc.target/aarch64/return_address_sign_1.c (dg-final): Replace
>>> "autiasp" and "paciasp" with "hint\t29 // autisp" and
>>> "hint\t25 // pacisp" respectively.
>>> * gcc.target/aarch64/return_address_sign_2.c (dg-final): Replace
>>> "paciasp" with "hint\t25 // pacisp".
>>> * gcc.target/aarch64/return_address_sign_3.c (dg-final): Replace
>>> "paciasp" and "autiasp" with "pacisp" and "autisp" respectively.
>>> * gcc.target/aarch64/return_address_sign_b_1.c: New file.
>>> * gcc.target/aarch64/return_address_sign_b_2.c: New file.
>>> * gcc.target/aarch64/return_address_sign_b_3.c: New file.
>>> * gcc.target/aarch64/return_address_sign_b_exception.c: New file.
>>> * gcc.target/aarch64/return_address_sign_builtin.c: New file
>>>
>>> libgcc/
>>> 2018-11-02  Sam Tebbs  
>>>
>>> * config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): New
>>> function.
>>> * config/aarch64/aarch64-unwind.h (aarch64_post_extract_frame_addr,
>>> aarch64_post_frob_eh_handler_addr): Add check for b-key.
>>> * unwind-dw2-fde.c (get_cie_encoding): Add check for 'B' in augmentation
>>> string.
>>> * unwind-dw2.c (extract_cie_info): Add check for 'B' in augmentation
>>> string.
>> Attached is an updated patch rebased on an improvement to the
>> -mbranch-protection option documentation.
> ping

Attached is an improved patch with "hint" removed from the test scans, 
pauth_hint_num_a and pauth_hint_num_b merged into pauth_hint_num and the 
"gcc_assert (cfun->machine->frame.laid_out)" re

Re: [PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2018-11-09 Thread Sam Tebbs
On 11/02/2018 06:01 PM, Sam Tebbs wrote:

> On 11/02/2018 05:35 PM, Sam Tebbs wrote:
>
>> Hi all,
>>
>> This patch adds support for the Armv8.3-A pointer authentication instructions
>> that use the B-key (pacib*, autib* and retab). This required adding builtins 
>> for
>> pacib1716 and autib1716, adding the "b-key" feature to the 
>> -mbranch-protection
>> option, and required emitting a new CFI directive ".cfi_b_key_frame" which
>> causes GAS to add 'B' to the CIE augmentation string. I also had to add a new
>> hook called ASM_POST_CFI_STARTPROC which is triggered when the .cfi_startproc
>> directive is emitted.
>>
>> The libgcc stack unwinder has been amended to authenticate return addresses
>> with the B key when the function has been signed with the B key.
>>
>> The previous patch in this series is here:
>> https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00104.html
>>
>> Bootstrapped successfully and regression tested on aarch64-none-elf.
>>
>> OK for trunk?
>>
>> gcc/
>> 2018-11-02  Sam Tebbs  
>>
>>  * config/aarch64/aarch64-builtins.c (aarch64_builtins): Add
>>  AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716.
>>  * config/aarch64/aarch64-builtins.c (aarch64_init_pauth_hint_builtins):
>>  Add autib1716 and pacib1716 initialisation.
>>  * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add checks
>>  for autib1716 and pacib1716.
>>  * config/aarch64/aarch64-protos.h (aarch64_key_type,
>>  aarch64_post_cfi_startproc): Define.
>>  * config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define extern.
>>  * config/aarch64/aarch64.c (aarch64_return_address_signing_enabled): Add
>>  check for b-key, remove frame.laid_out assertion.
>>  * config/aarch64/aarch64.c (aarch64_ra_sign_key,
>>  aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define.
>>  * config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define.
>>  * config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key".
>>  * config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716,
>>  UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716,
>>  UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>  * config/aarch64/aarch64.md (do_return): Add check for b-key.
>>  * config/aarch64/aarch64.md (sp): Add check for
>>  signing key and scope selected.
>>  * config/aarch64/aarch64.md (1716): Add check for
>>  signing key and scope selected.
>>  * config/aarch64/aarch64.opt (msign-return-address=): Deprecate.
>>  * config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP,
>>  UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>  * config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716,
>>  UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716.
>>  * config/aarch64/iterators.md (pauth_mnem_prefix): Add UNSPEC_AUTIA1716,
>>  UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_AUTIASP,
>>  UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>>  * config/aarch64/iterators.md (pauth_hint_num_a): Replace
>>  UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and
>>  UNSPEC_AUTIA1716 respectively.
>>  * config/aarch64/iterators.md (pauth_hint_num_b): New int attribute.
>>
>> gcc/testsuite
>> 2018-11-02  Sam Tebbs  
>>
>>  * gcc.target/aarch64/return_address_sign_1.c (dg-final): Replace
>>  "autiasp" and "paciasp" with "hint\t29 // autisp" and
>>  "hint\t25 // pacisp" respectively.
>>  * gcc.target/aarch64/return_address_sign_2.c (dg-final): Replace
>>  "paciasp" with "hint\t25 // pacisp".
>>  * gcc.target/aarch64/return_address_sign_3.c (dg-final): Replace
>>  "paciasp" and "autiasp" with "pacisp" and "autisp" respectively.
>>  * gcc.target/aarch64/return_address_sign_b_1.c: New file.
>>  * gcc.target/aarch64/return_address_sign_b_2.c: New file.
>>  * gcc.target/aarch64/return_address_sign_b_3.c: New file.
>>  * gcc.target/aarch64/return_address_sign_b_exception.c: New file.
>>  * gcc.target/aarch64/return_address_sign_builtin.c: New file
>>
>> libgcc/
>> 2018-11-02  Sam Tebbs  
>>
>>  * config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): New
>>  function.
>>  * config/aarch64/aarch64-unwind.h (aarch64_post_extract_frame_addr,
>>  aarch64_post_frob_eh_handler_addr): Add check for b-key.
>>  * unwind-dw2-fde.c (get_cie_encoding): Add check for 'B' in augmentation
>>  string.
>>  * unwind-dw2.c (extract_cie_info): Add check for 'B' in augmentation
>>  string.
> Attached is an updated patch rebased on an improvement to the
> -mbranch-protection option documentation.

ping


Re: [PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2018-11-02 Thread Sam Tebbs
On 11/02/2018 05:35 PM, Sam Tebbs wrote:

> Hi all,
>
> This patch adds support for the Armv8.3-A pointer authentication instructions
> that use the B-key (pacib*, autib* and retab). This required adding builtins 
> for
> pacib1716 and autib1716, adding the "b-key" feature to the -mbranch-protection
> option, and required emitting a new CFI directive ".cfi_b_key_frame" which
> causes GAS to add 'B' to the CIE augmentation string. I also had to add a new
> hook called ASM_POST_CFI_STARTPROC which is triggered when the .cfi_startproc
> directive is emitted.
>
> The libgcc stack unwinder has been amended to authenticate return addresses
> with the B key when the function has been signed with the B key.
>
> The previous patch in this series is here:
> https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00104.html
>
> Bootstrapped successfully and regression tested on aarch64-none-elf.
>
> OK for trunk?
>
> gcc/
> 2018-11-02  Sam Tebbs  
>
>   * config/aarch64/aarch64-builtins.c (aarch64_builtins): Add
>   AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716.
>   * config/aarch64/aarch64-builtins.c (aarch64_init_pauth_hint_builtins):
>   Add autib1716 and pacib1716 initialisation.
>   * config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add checks
>   for autib1716 and pacib1716.
>   * config/aarch64/aarch64-protos.h (aarch64_key_type,
>   aarch64_post_cfi_startproc): Define.
>   * config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define extern.
>   * config/aarch64/aarch64.c (aarch64_return_address_signing_enabled): Add
>   check for b-key, remove frame.laid_out assertion.
>   * config/aarch64/aarch64.c (aarch64_ra_sign_key,
>   aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define.
>   * config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define.
>   * config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key".
>   * config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716,
>   UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716,
>   UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>   * config/aarch64/aarch64.md (do_return): Add check for b-key.
>   * config/aarch64/aarch64.md (sp): Add check for
>   signing key and scope selected.
>   * config/aarch64/aarch64.md (1716): Add check for
>   signing key and scope selected.
>   * config/aarch64/aarch64.opt (msign-return-address=): Deprecate.
>   * config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP,
>   UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>   * config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716,
>   UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716.
>   * config/aarch64/iterators.md (pauth_mnem_prefix): Add UNSPEC_AUTIA1716,
>   UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_AUTIASP,
>   UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
>   * config/aarch64/iterators.md (pauth_hint_num_a): Replace
>   UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and
>   UNSPEC_AUTIA1716 respectively.
>   * config/aarch64/iterators.md (pauth_hint_num_b): New int attribute.
>
> gcc/testsuite
> 2018-11-02  Sam Tebbs  
>
>   * gcc.target/aarch64/return_address_sign_1.c (dg-final): Replace
>   "autiasp" and "paciasp" with "hint\t29 // autisp" and
>   "hint\t25 // pacisp" respectively.
>   * gcc.target/aarch64/return_address_sign_2.c (dg-final): Replace
>   "paciasp" with "hint\t25 // pacisp".
>   * gcc.target/aarch64/return_address_sign_3.c (dg-final): Replace
>   "paciasp" and "autiasp" with "pacisp" and "autisp" respectively.
>   * gcc.target/aarch64/return_address_sign_b_1.c: New file.
>   * gcc.target/aarch64/return_address_sign_b_2.c: New file.
>   * gcc.target/aarch64/return_address_sign_b_3.c: New file.
>   * gcc.target/aarch64/return_address_sign_b_exception.c: New file.
>   * gcc.target/aarch64/return_address_sign_builtin.c: New file
>
> libgcc/
> 2018-11-02  Sam Tebbs  
>
>   * config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): New
>   function.
>   * config/aarch64/aarch64-unwind.h (aarch64_post_extract_frame_addr,
>   aarch64_post_frob_eh_handler_addr): Add check for b-key.
>   * unwind-dw2-fde.c (get_cie_encoding): Add check for 'B' in augmentation
>   string.
>   * unwind-dw2.c (extract_cie_info): Add check for 'B' in augmentation
>   string.

Attached is an updated patch rebased on an improvement to the 
-mbranch-protection option documentation.
diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c
index 8cced94..d676f36 100644
--- a/gcc/config/aarch64/aarch64-builtins.c
+++ b/gcc/config/aarch64/aarch64-builtins.c
@@ -398,6 +398,8 @@ enum aarch64_builtins
   /* ARMv8.3-A Pointer Authentication Builtins.  */
   AARCH64_PAUTH_BUILTIN_AUTIA1716,
   AARCH64_PAUTH_BUILTIN_PACIA1716,
+

[PATCH 3/3][GCC][AARCH64] Add support for pointer authentication B key

2018-11-02 Thread Sam Tebbs
Hi all,

This patch adds support for the Armv8.3-A pointer authentication instructions
that use the B-key (pacib*, autib* and retab). This required adding builtins for
pacib1716 and autib1716, adding the "b-key" feature to the -mbranch-protection
option, and required emitting a new CFI directive ".cfi_b_key_frame" which
causes GAS to add 'B' to the CIE augmentation string. I also had to add a new
hook called ASM_POST_CFI_STARTPROC which is triggered when the .cfi_startproc
directive is emitted.

The libgcc stack unwinder has been amended to authenticate return addresses
with the B key when the function has been signed with the B key.

The previous patch in this series is here:
https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00104.html

Bootstrapped successfully and regression tested on aarch64-none-elf.

OK for trunk?

gcc/
2018-11-02  Sam Tebbs

* config/aarch64/aarch64-builtins.c (aarch64_builtins): Add
AARCH64_PAUTH_BUILTIN_AUTIB1716 and AARCH64_PAUTH_BUILTIN_PACIB1716.
* config/aarch64/aarch64-builtins.c (aarch64_init_pauth_hint_builtins):
Add autib1716 and pacib1716 initialisation.
* config/aarch64/aarch64-builtins.c (aarch64_expand_builtin): Add checks
for autib1716 and pacib1716.
* config/aarch64/aarch64-protos.h (aarch64_key_type,
aarch64_post_cfi_startproc): Define.
* config/aarch64/aarch64-protos.h (aarch64_ra_sign_key): Define extern.
* config/aarch64/aarch64.c (aarch64_return_address_signing_enabled): Add
check for b-key, remove frame.laid_out assertion.
* config/aarch64/aarch64.c (aarch64_ra_sign_key,
aarch64_post_cfi_startproc, aarch64_handle_pac_ret_b_key): Define.
* config/aarch64/aarch64.h (TARGET_ASM_POST_CFI_STARTPROC): Define.
* config/aarch64/aarch64.c (aarch64_pac_ret_subtypes): Add "b-key".
* config/aarch64/aarch64.md (unspec): Add UNSPEC_AUTIA1716,
UNSPEC_AUTIB1716, UNSPEC_AUTIASP, UNSPEC_AUTIBSP, UNSPEC_PACIA1716,
UNSPEC_PACIB1716, UNSPEC_PACIASP, UNSPEC_PACIBSP.
* config/aarch64/aarch64.md (do_return): Add check for b-key.
* config/aarch64/aarch64.md (sp): Add check for
signing key and scope selected.
* config/aarch64/aarch64.md (1716): Add check for
signing key and scope selected.
* config/aarch64/aarch64.opt (msign-return-address=): Deprecate.
* config/aarch64/iterators.md (PAUTH_LR_SP): Add UNSPEC_AUTIASP,
UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
* config/aarch64/iterators.md (PAUTH_17_16): Add UNSPEC_AUTIA1716,
UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716.
* config/aarch64/iterators.md (pauth_mnem_prefix): Add UNSPEC_AUTIA1716,
UNSPEC_AUTIB1716, UNSPEC_PACIA1716, UNSPEC_PACIB1716, UNSPEC_AUTIASP,
UNSPEC_AUTIBSP, UNSPEC_PACIASP, UNSPEC_PACIBSP.
* config/aarch64/iterators.md (pauth_hint_num_a): Replace
UNSPEC_PACI1716 and UNSPEC_AUTI1716 with UNSPEC_PACIA1716 and
UNSPEC_AUTIA1716 respectively.
* config/aarch64/iterators.md (pauth_hint_num_b): New int attribute.

gcc/testsuite
2018-11-02  Sam Tebbs

* gcc.target/aarch64/return_address_sign_1.c (dg-final): Replace
"autiasp" and "paciasp" with "hint\t29 // autisp" and
"hint\t25 // pacisp" respectively.
* gcc.target/aarch64/return_address_sign_2.c (dg-final): Replace
"paciasp" with "hint\t25 // pacisp".
* gcc.target/aarch64/return_address_sign_3.c (dg-final): Replace
"paciasp" and "autiasp" with "pacisp" and "autisp" respectively.
* gcc.target/aarch64/return_address_sign_b_1.c: New file.
* gcc.target/aarch64/return_address_sign_b_2.c: New file.
* gcc.target/aarch64/return_address_sign_b_3.c: New file.
* gcc.target/aarch64/return_address_sign_b_exception.c: New file.
* gcc.target/aarch64/return_address_sign_builtin.c: New file

libgcc/
2018-11-02  Sam Tebbs

* config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): New
function.
* config/aarch64/aarch64-unwind.h (aarch64_post_extract_frame_addr,
aarch64_post_frob_eh_handler_addr): Add check for b-key.
* unwind-dw2-fde.c (get_cie_encoding): Add check for 'B' in augmentation
string.
* unwind-dw2.c (extract_cie_info): Add check for 'B' in augmentation
string.

diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c
index 8cced94567008e28b1761ec8771589a3925f2904..d676f36c157c486cc9cbe6bffe0a7389ba0ccdd8 100644
--- a/gcc/config/aarch64/aarch64-builtins.c
+++ b/gcc/config/aarch64/aarch64-builtins.c
@@ -398,6 +398,8 @@ enum aarch64_builtins
   /* ARMv8.3-A Pointer Authentication Builtins.  */
   AARCH64_PAUTH_BUILTIN_AUTIA1716,
   AARCH64_PAUTH_BUILTIN_PACIA1716,
+  AARCH64_PAUTH_BUILTIN_AUTIB1716,
+  AARCH64_PAUTH_BUILTIN_PACIB1716,
   AARCH64_PAUTH_BUILTIN_XPACLRI,
   AARCH64_BUILTIN_MAX
 };
@@ -971,6