[PATCH v3 23/23] aarch64: Fix nonlocal goto tests incompatible with GCS

2024-11-08 Thread Yury Khrustalev
gcc/testsuite/ChangeLog: * gcc.target/aarch64/gcs-nonlocal-3.c: New test. * gcc.target/aarch64/sme/nonlocal_goto_4.c: Update. * gcc.target/aarch64/sme/nonlocal_goto_5.c: Update. * gcc.target/aarch64/sme/nonlocal_goto_6.c: Update. --- .../gcc.target/aarch64/gcs-nonlo

[PATCH v3 22/23] aarch64: Fix tests incompatible with GCS

2024-11-08 Thread Yury Khrustalev
From: Matthieu Longo gcc/testsuite/ChangeLog: * g++.target/aarch64/return_address_sign_ab_exception.C: Update. * gcc.target/aarch64/eh_return.c: Update. --- .../return_address_sign_ab_exception.C| 19 +-- gcc/testsuite/gcc.target/aarch64/eh_return.c | 13

[PATCH v3 20/23] aarch64: Introduce indirect_return attribute

2024-11-08 Thread Yury Khrustalev
. * config/arm/aarch-common-protos.h (aarch_fun_is_indirect_return): New. * config/arm/arm.cc (aarch_fun_is_indirect_return): New. Co-authored-by: Yury Khrustalev --- gcc/config/aarch64/aarch64-opts.h| 2 ++ gcc/config/aarch64/aarch64-protos.h | 2 +- gcc/config/aarch64

[PATCH v3 17/23] aarch64: Emit GNU property NOTE for GCS

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/ChangeLog: * config/aarch64/aarch64.cc (GNU_PROPERTY_AARCH64_FEATURE_1_GCS): Define. (aarch64_file_end_indicate_exec_stack): Set GCS property bit. --- gcc/config/aarch64/aarch64.cc | 5 + 1 file changed, 5 insertions(+) diff --git a/gcc/confi

[PATCH v3 19/23] aarch64: libatomic: add GCS marking to asm

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy libatomic/ChangeLog: * config/linux/aarch64/atomic_16.S (FEATURE_1_GCS): Define. (GCS_FLAG): Define if GCS is enabled. (GNU_PROPERTY): Add GCS_FLAG. --- libatomic/config/linux/aarch64/atomic_16.S | 11 +-- 1 file changed, 9 insertions(+), 2 de

[PATCH v3 18/23] aarch64: libgcc: add GCS marking to asm

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy libgcc/ChangeLog: * config/aarch64/aarch64-asm.h (FEATURE_1_GCS): Define. (GCS_FLAG): Define if GCS is enabled. (GNU_PROPERTY): Add GCS_FLAG. --- libgcc/config/aarch64/aarch64-asm.h | 16 ++-- 1 file changed, 14 insertions(+), 2 deletions(

[PATCH v3 15/23] aarch64: Add target pragma tests for gcs

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/pragma_cpp_predefs_4.c: Add gcs specific tests. --- .../gcc.target/aarch64/pragma_cpp_predefs_4.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/gcc/testsuite/gcc.target/aarch64/pragma_cp

[PATCH v3 21/23] aarch64: Add tests and docs for indirect_return attribute

2024-11-08 Thread Yury Khrustalev
. * gcc.target/aarch64/indirect_return-2.c: New test. Co-authored-by: Yury Khrustalev --- gcc/doc/extend.texi | 10 .../gcc.target/aarch64/indirect_return-1.c| 53 +++ .../gcc.target/aarch64/indirect_return-2.c| 48 + 3 files changed, 111

[PATCH v3 16/23] aarch64: Add GCS support to the unwinder

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy Follows the current linux ABI that uses single signal entry token and shared shadow stack between thread and alt stack. Could be behind __ARM_FEATURE_GCS_DEFAULT ifdef (only do anything special with gcs compat codegen) but there is a runtime check anyway. Change affected test

[PATCH v3 10/23] aarch64: Add __builtin_aarch64_gcs* and __gcs* tests

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/acle/gcs-1.c: New test. * gcc.target/aarch64/gcspopm-1.c: New test. * gcc.target/aarch64/gcspr-1.c: New test. * gcc.target/aarch64/gcsss-1.c: New test. Co-authored-by: Yury Khrustalev --- gcc

[PATCH v3 12/23] aarch64: Add non-local goto and jump tests for GCS

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy These are scan asm tests only, relying on existing execution tests for runtime coverage. gcc/testsuite/ChangeLog: * gcc.target/aarch64/gcs-nonlocal-1.c: New test. * gcc.target/aarch64/gcs-nonlocal-1-track-speculation.c: New test. * gcc.target/aarch64/

[PATCH v3 14/23] aarch64: Add test for GCS ACLE defs

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/pragma_cpp_predefs_1.c: GCS test. --- .../gcc.target/aarch64/pragma_cpp_predefs_1.c | 30 +++ 1 file changed, 30 insertions(+) diff --git a/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_1.c b/gcc/t

[PATCH v3 07/23] aarch64: Add GCS instructions

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy Add instructions for the Guarded Control Stack extension. GCSSS1 and GCSSS2 are always used together in the compiler and an extra "mov xn, 0" should be always added before GCSSS2 to clear the output register. This is needed to get reasonable result when GCS is disabled, when

[PATCH v3 13/23] aarch64: Add ACLE feature macros for GCS

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/ChangeLog: * config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Define macros for GCS. --- gcc/config/aarch64/aarch64-c.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc ind

[PATCH v3 06/23] aarch64: Add __builtin_aarch64_chkfeat and __chkfeat tests

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/acle/chkfeat-1.c: New test. * gcc.target/aarch64/chkfeat-1.c: New test. * gcc.target/aarch64/chkfeat-2.c: New test. Co-authored-by: Yury Khrustalev Co-authored-by: Richard Sandiford --- .../gcc.target

[PATCH v3 05/23] aarch64: Add ACLE __chkfeat intrinsic

2024-11-08 Thread Yury Khrustalev
Note that compared to __builtin_aarch64_chkfeat (x) the ACLE __chkfeat(x) flips the bits to be more intuitive (xor the input to output). gcc/ChangeLog: * config/aarch64/arm_acle.h (__chkfeat): New. --- gcc/config/aarch64/arm_acle.h | 13 + 1 file changed, 13 insertions(+) dif

[PATCH v3 11/23] aarch64: Add GCS support for nonlocal stack save

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy Nonlocal stack save and restore has to also save and restore the GCS pointer. This is used in __builtin_setjmp/longjmp and nonlocal goto. The GCS specific code is only emitted if GCS branch-protection is enabled and the code always checks at runtime if GCS is enabled. The ne

[PATCH v3 09/23] aarch64: Add ACLE __gcs* intrinsics

2024-11-08 Thread Yury Khrustalev
Add the following ACLE intrinsics: - void *__gcspr(void); - uint64_t __gcspopm(void); - void *__gcsss(void *); gcc/ChangeLog: * config/aarch64/arm_acle.h (__gcspr): New. (__gcspopm): New. (__gcsss): New. --- gcc/config/aarch64/arm_acle.h | 9 + 1 file changed,

[PATCH v3 08/23] aarch64: Add GCS builtins

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy Add new builtins for GCS: void *__builtin_aarch64_gcspr (void) uint64_t __builtin_aarch64_gcspopm (void) void *__builtin_aarch64_gcsss (void *) The builtins are always enabled, but should be used behind runtime checks in case the target does not support GCS. They are t

[PATCH v3 01/23] aarch64: Add -mbranch-protection=gcs option

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy This enables Guarded Control Stack (GCS) compatible code generation. The "standard" branch-protection type enables it, and the default depends on the compiler default. gcc/ChangeLog: * config/aarch64/aarch64-protos.h (aarch_gcs_enabled): Declare. * config/aa

[PATCH v3 02/23] aarch64: Add branch-protection target pragma tests

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/pragma_cpp_predefs_4.c: Add branch-protection tests. --- .../gcc.target/aarch64/pragma_cpp_predefs_4.c | 50 +++ 1 file changed, 50 insertions(+) diff --git a/gcc/testsuite/gcc.target/aarch64/prag

[PATCH v3 04/23] aarch64: Add __builtin_aarch64_chkfeat

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy Builtin for chkfeat: the input argument is used to initialize x16 then execute chkfeat and return the updated x16. Note: the ACLE __chkfeat(x) will flip the bits to be more intuitive (xor the input to output), but for the builtin that seems unnecessary complication. gcc/Chan

[PATCH v3 03/23] aarch64: Add support for chkfeat insn

2024-11-08 Thread Yury Khrustalev
From: Szabolcs Nagy This is a hint space instruction to check for enabled HW features and update the x16 register accordingly. Use unspec_volatile to prevent reordering it around calls since calls can enable or disable HW features. gcc/ChangeLog: * config/aarch64/aarch64.md (aarch64_ch

[PATCH v3 00/23] aarch64: Add support for Guarded Control Stack extension

2024-11-08 Thread Yury Khrustalev
to the unwinder aarch64: Emit GNU property NOTE for GCS aarch64: libgcc: add GCS marking to asm aarch64: libatomic: add GCS marking to asm aarch64: Introduce indirect_return attribute Yury Khrustalev (3): aarch64: Add ACLE __chkfeat intrinsic aarch64: Add ACLE __gcs* intrinsics

Re: [PATCH v2 07/21] aarch64: Add GCS builtins

2024-11-08 Thread Yury Khrustalev
Hi Kyrill, On Thu, Oct 31, 2024 at 02:05:00PM +, Kyrylo Tkachov wrote: > Hi Yury, > > > On 31 Oct 2024, at 14:23, Yury Khrustalev wrote: > > > > From: Szabolcs Nagy > > > > Add new builtins for GCS: > > > > void *__builtin_aarch64_gcsp

Re: [PATCH v2 04/21] aarch64: Add __builtin_aarch64_chkfeat

2024-11-08 Thread Yury Khrustalev
Hello Kyrill, On Thu, Oct 31, 2024 at 02:11:02PM +, Kyrylo Tkachov wrote: > > > > On 31 Oct 2024, at 14:23, Yury Khrustalev wrote: > > > > From: Szabolcs Nagy > > > > Builtin for chkfeat: the input argument is used to initialize x16 then > >

Re: [PATCH 14/22] aarch64: Add GCS support to the unwinder

2024-11-08 Thread Yury Khrustalev
Hi Richard, On Thu, Oct 24, 2024 at 05:27:24PM +0100, Richard Sandiford wrote: > Yury Khrustalev writes: > > From: Szabolcs Nagy > > Could you explain these testsuite changes in more detail? It seems > on the face of it that they're changing the tests to test som

Re: [PATCH 19/22] aarch64: Introduce indirect_return attribute

2024-11-08 Thread Yury Khrustalev
Hi Richard, On Thu, Oct 24, 2024 at 06:18:23PM +0100, Richard Sandiford wrote: > Yury Khrustalev writes: > > From: Szabolcs Nagy > > > > Tail calls of indirect_return functions from non-indirect_return > > functions are disallowed even if BTI is disabled, since the

[PATCH v2 10/21] aarch64: Add non-local goto and jump tests for GCS

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy These are scan asm tests only, relying on existing execution tests for runtime coverage. gcc/testsuite/ChangeLog: * gcc.target/aarch64/gcs-nonlocal-1.c: New test. * gcc.target/aarch64/gcs-nonlocal-1-track-speculation.c: New test. * gcc.target/aarch64/

[PATCH v2 15/21] aarch64: Emit GNU property NOTE for GCS

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/ChangeLog: * config/aarch64/aarch64.cc (GNU_PROPERTY_AARCH64_FEATURE_1_GCS): Define. (aarch64_file_end_indicate_exec_stack): Set GCS property bit. --- gcc/config/aarch64/aarch64.cc | 5 + 1 file changed, 5 insertions(+) diff --git a/gcc/confi

[PATCH v2 21/21] aarch64: Fix nonlocal goto tests incompatible with GCS

2024-10-31 Thread Yury Khrustalev
gcc/testsuite/ChangeLog: * gcc.target/aarch64/gcs-nonlocal-3.c: New test. * gcc.target/aarch64/sme/nonlocal_goto_4.c: Update. * gcc.target/aarch64/sme/nonlocal_goto_5.c: Update. * gcc.target/aarch64/sme/nonlocal_goto_6.c: Update. --- .../gcc.target/aarch64/gcs-nonlo

[PATCH v2 08/21] aarch64: Add __builtin_aarch64_gcs* tests

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/gcspopm-1.c: New test. * gcc.target/aarch64/gcspr-1.c: New test. * gcc.target/aarch64/gcsss-1.c: New test. --- gcc/testsuite/gcc.target/aarch64/gcspopm-1.c | 63 gcc/testsuite/gcc.targ

[PATCH v2 05/21] aarch64: Add __builtin_aarch64_chkfeat tests

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/chkfeat-1.c: New test. * gcc.target/aarch64/chkfeat-2.c: New test. Co-authored-by: Richard Sandiford --- gcc/testsuite/gcc.target/aarch64/chkfeat-1.c | 75 gcc/testsuite/gcc.target/aa

[PATCH v2 01/21] aarch64: Add -mbranch-protection=gcs option

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy This enables Guarded Control Stack (GCS) compatible code generation. The "standard" branch-protection type enables it, and the default depends on the compiler default. gcc/ChangeLog: * config/aarch64/aarch64-protos.h (aarch_gcs_enabled): Declare. * config/aa

[PATCH v2 20/21] aarch64: Fix tests incompatible with GCS

2024-10-31 Thread Yury Khrustalev
From: Matthieu Longo gcc/testsuite/ChangeLog: * g++.target/aarch64/return_address_sign_ab_exception.C: Update. * gcc.target/aarch64/eh_return.c: Update. --- .../return_address_sign_ab_exception.C| 19 +-- gcc/testsuite/gcc.target/aarch64/eh_return.c | 13

[PATCH v2 12/21] aarch64: Add test for GCS ACLE defs

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/pragma_cpp_predefs_1.c: GCS test. --- .../gcc.target/aarch64/pragma_cpp_predefs_1.c | 30 +++ 1 file changed, 30 insertions(+) diff --git a/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_1.c b/gcc/t

Re: [PATCH 00/22] aarch64: Add support for Guarded Control Stack extension

2024-10-31 Thread Yury Khrustalev
On Thu, Oct 24, 2024 at 06:47:07PM +0100, Richard Sandiford wrote: > Yury Khrustalev writes: > > This patch series adds support for the Guarded Control Stack extension. > > > > Thanks for this. I've replied to some individual patches, but the > ones I didn't re

Re: [PATCH 18/22] aarch64: libitm: Add GCS support

2024-10-31 Thread Yury Khrustalev
On Thu, Oct 24, 2024 at 05:53:45PM +0100, Richard Sandiford wrote: > Yury Khrustalev writes: > > From: Szabolcs Nagy > > > Don't we still need to pop from the current stack up to the switch point, > in case something further up the call frame wants to switch back to it?

[PATCH v2 17/21] aarch64: libatomic: add GCS marking to asm

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy libatomic/ChangeLog: * config/linux/aarch64/atomic_16.S (FEATURE_1_GCS): Define. (GCS_FLAG): Define if GCS is enabled. (GNU_PROPERTY): Add GCS_FLAG. --- libatomic/config/linux/aarch64/atomic_16.S | 11 +-- 1 file changed, 9 insertions(+), 2 de

[PATCH v2 18/21] aarch64: Introduce indirect_return attribute

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy Tail calls of indirect_return functions from non-indirect_return functions are disallowed even if BTI is disabled, since the call site may have BTI enabled. Following x86, mismatching attribute on function pointers is not a type error even though this can lead to bugs. Neede

[PATCH v2 19/21] aarch64: Add tests and docs for indirect_return attribute

2024-10-31 Thread Yury Khrustalev
. * gcc.target/aarch64/indirect_return-2.c: New test. Co-authored-by: Yury Khrustalev --- gcc/doc/extend.texi | 10 .../gcc.target/aarch64/indirect_return-1.c| 53 +++ .../gcc.target/aarch64/indirect_return-2.c| 48 + 3 files changed, 111

[PATCH v2 11/21] aarch64: Add ACLE feature macros for GCS

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/ChangeLog: * config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Define macros for GCS. --- gcc/config/aarch64/aarch64-c.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc ind

[PATCH v2 07/21] aarch64: Add GCS builtins

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy Add new builtins for GCS: void *__builtin_aarch64_gcspr (void) uint64_t __builtin_aarch64_gcspopm (void) void *__builtin_aarch64_gcsss (void *) The builtins are always enabled, but should be used behind runtime checks in case the target does not support GCS. They are t

[PATCH v2 14/21] aarch64: Add GCS support to the unwinder

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy Follows the current linux ABI that uses single signal entry token and shared shadow stack between thread and alt stack. Could be behind __ARM_FEATURE_GCS_DEFAULT ifdef (only do anything special with gcs compat codegen) but there is a runtime check anyway. Change affected test

[PATCH v2 09/21] aarch64: Add GCS support for nonlocal stack save

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy Nonlocal stack save and restore has to also save and restore the GCS pointer. This is used in __builtin_setjmp/longjmp and nonlocal goto. The GCS specific code is only emitted if GCS branch-protection is enabled and the code always checks at runtime if GCS is enabled. The ne

[PATCH v2 16/21] aarch64: libgcc: add GCS marking to asm

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy libgcc/ChangeLog: * config/aarch64/aarch64-asm.h (FEATURE_1_GCS): Define. (GCS_FLAG): Define if GCS is enabled. (GNU_PROPERTY): Add GCS_FLAG. --- libgcc/config/aarch64/aarch64-asm.h | 16 ++-- 1 file changed, 14 insertions(+), 2 deletions(

[PATCH v2 04/21] aarch64: Add __builtin_aarch64_chkfeat

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy Builtin for chkfeat: the input argument is used to initialize x16 then execute chkfeat and return the updated x16. Note: ACLE __chkfeat(x) plans to flip the bits to be more intuitive (xor the input to output), but for the builtin that seems unnecessary complication. gcc/Chan

[PATCH v2 13/21] aarch64: Add target pragma tests for gcs

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/pragma_cpp_predefs_4.c: Add gcs specific tests. --- .../gcc.target/aarch64/pragma_cpp_predefs_4.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/gcc/testsuite/gcc.target/aarch64/pragma_cp

[PATCH v2 06/21] aarch64: Add GCS instructions

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy Add instructions for the Guarded Control Stack extension. GCSSS1 and GCSSS2 are always used together in the compiler and an extra "mov xn, 0" should be always added before GCSSS2 to clear the output register. This is needed to get reasonable result when GCS is disabled, when

[PATCH v2 02/21] aarch64: Add branch-protection target pragma tests

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/pragma_cpp_predefs_4.c: Add branch-protection tests. --- .../gcc.target/aarch64/pragma_cpp_predefs_4.c | 50 +++ 1 file changed, 50 insertions(+) diff --git a/gcc/testsuite/gcc.target/aarch64/prag

[PATCH v2 03/21] aarch64: Add support for chkfeat insn

2024-10-31 Thread Yury Khrustalev
From: Szabolcs Nagy This is a hint space instruction to check for enabled HW features and update the x16 register accordingly. Use unspec_volatile to prevent reordering it around calls since calls can enable or disable HW features. gcc/ChangeLog: * config/aarch64/aarch64.md (aarch64_ch

[PATCH v2 00/21]aarch64: Add support for Guarded Control Stack extension

2024-10-31 Thread Yury Khrustalev
attribute Yury Khrustalev (1): aarch64: Fix nonlocal goto tests incompatible with GCS gcc/config/aarch64/aarch64-builtins.cc| 95 + gcc/config/aarch64/aarch64-c.cc | 3 + gcc/config/aarch64/aarch64-protos.h | 2 + gcc/config/aarch64/aarch64.cc

Re: [PATCH 16/22] aarch64: libgcc: add GCS marking to asm

2024-10-29 Thread Yury Khrustalev
On Thu, Oct 24, 2024 at 05:31:58PM +0100, Richard Sandiford wrote: > Yury Khrustalev writes: > > From: Szabolcs Nagy > > > > libgcc/ChangeLog: > > > > * config/aarch64/aarch64-asm.h (FEATURE_1_GCS): Define. > > (GCS_FLAG): Define if GCS is enable

[PATCH 22/22] aarch64: Fix nonlocal goto tests incompatible with GCS

2024-10-23 Thread Yury Khrustalev
gcc/testsuite/ChangeLog: * gcc.target/aarch64/gcs-nonlocal-3.c: New test. * gcc.target/aarch64/sme/nonlocal_goto_4.c: Update. * gcc.target/aarch64/sme/nonlocal_goto_5.c: Update. * gcc.target/aarch64/sme/nonlocal_goto_6.c: Update. --- .../gcc.target/aarch64/gcs-nonlo

[PATCH 19/22] aarch64: Introduce indirect_return attribute

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy Tail calls of indirect_return functions from non-indirect_return functions are disallowed even if BTI is disabled, since the call site may have BTI enabled. Following x86, mismatching attribute on function pointers is not a type error even though this can lead to bugs. Neede

[PATCH 14/22] aarch64: Add GCS support to the unwinder

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy Follows the current linux ABI that uses single signal entry token and shared shadow stack between thread and alt stack. Could be behind __ARM_FEATURE_GCS_DEFAULT ifdef (only do anything special with gcs compat codegen) but there is a runtime check anyway. Change affected test

[PATCH 18/22] aarch64: libitm: Add GCS support

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy Transaction begin and abort use setjmp/longjmp like operations that need to be updated for GCS compatibility. We use similar logic to libc setjmp/longjmp that support switching stack and thus switching GCS (e.g. due to longjmp out of a makecontext stack), this is kept even tho

[PATCH 21/22] aarch64: Fix tests incompatible with GCS

2024-10-23 Thread Yury Khrustalev
From: Matthieu Longo gcc/testsuite/ChangeLog: * g++.target/aarch64/return_address_sign_ab_exception.C: Update. * gcc.target/aarch64/eh_return.c: Update. --- .../return_address_sign_ab_exception.C| 19 +-- gcc/testsuite/gcc.target/aarch64/eh_return.c | 13

[PATCH 12/22] aarch64: Add test for GCS ACLE defs

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/pragma_cpp_predefs_1.c: GCS test. --- .../gcc.target/aarch64/pragma_cpp_predefs_1.c | 30 +++ 1 file changed, 30 insertions(+) diff --git a/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_1.c b/gcc/t

[PATCH 16/22] aarch64: libgcc: add GCS marking to asm

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy libgcc/ChangeLog: * config/aarch64/aarch64-asm.h (FEATURE_1_GCS): Define. (GCS_FLAG): Define if GCS is enabled. (GNU_PROPERTY): Add GCS_FLAG. --- libgcc/config/aarch64/aarch64-asm.h | 16 ++-- 1 file changed, 14 insertions(+), 2 deletions(

[PATCH 07/22] aarch64: Add GCS builtins

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy Add new builtins for GCS: void *__builtin_aarch64_gcspr (void) uint64_t __builtin_aarch64_gcspopm (void) void *__builtin_aarch64_gcsss (void *) The builtins are always enabled, but should be used behind runtime checks in case the target does not support GCS. They are t

[PATCH 17/22] aarch64: libatomic: add GCS marking to asm

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy libatomic/ChangeLog: * config/linux/aarch64/atomic_16.S (FEATURE_1_GCS): Define. (GCS_FLAG): Define if GCS is enabled. (GNU_PROPERTY): Add GCS_FLAG. --- libatomic/config/linux/aarch64/atomic_16.S | 11 +-- 1 file changed, 9 insertions(+), 2 de

[PATCH 10/22] aarch64: Add non-local goto and jump tests for GCS

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy These are scan asm tests only, relying on existing execution tests for runtime coverage. gcc/testsuite/ChangeLog: * gcc.target/aarch64/gcs-nonlocal-1.c: New test. * gcc.target/aarch64/gcs-nonlocal-2.c: New test. --- .../gcc.target/aarch64/gcs-nonlocal-1.c

[PATCH 20/22] aarch64: Add tests and docs for indirect_return attribute

2024-10-23 Thread Yury Khrustalev
-authored-by: Yury Khrustalev --- gcc/doc/extend.texi | 5 .../gcc.target/aarch64/indirect_return.c | 25 +++ 2 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/gcc.target/aarch64/indirect_return.c diff --git a/gcc/doc/extend.texi b

[PATCH 13/22] aarch64: Add target pragma tests for gcs

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/pragma_cpp_predefs_4.c: Add gcs specific tests. --- .../gcc.target/aarch64/pragma_cpp_predefs_4.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/gcc/testsuite/gcc.target/aarch64/pragma_cp

[PATCH 09/22] aarch64: Add GCS support for nonlocal stack save

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy Nonlocal stack save and restore has to also save and restore the GCS pointer. This is used in __builtin_setjmp/longjmp and nonlocal goto. The GCS specific code is only emitted if GCS branch-protection is enabled and the code always checks at runtime if GCS is enabled. The ne

[PATCH 15/22] aarch64: Emit GNU property NOTE for GCS

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/ChangeLog: * config/aarch64/aarch64.cc (GNU_PROPERTY_AARCH64_FEATURE_1_GCS): Define. (aarch64_file_end_indicate_exec_stack): Set GCS property bit. --- gcc/config/aarch64/aarch64.cc | 5 + 1 file changed, 5 insertions(+) diff --git a/gcc/confi

[PATCH 04/22] aarch64: Add __builtin_aarch64_chkfeat

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy Builtin for chkfeat: the input argument is used to initialize x16 then execute chkfeat and return the updated x16. Note: ACLE __chkfeat(x) plans to flip the bits to be more intuitive (xor the input to output), but for the builtin that seems unnecessary complication. gcc/Chan

[PATCH 11/22] aarch64: Add ACLE feature macros for GCS

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/ChangeLog: * config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Define macros for GCS. --- gcc/config/aarch64/aarch64-c.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc ind

[PATCH 06/22] aarch64: Add GCS instructions

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy Add instructions for the Guarded Control Stack extension. GCSSS1 and GCSSS2 are modelled as a single GCSSS unspec, because they are always used together in the compiler. Before GCSPOPM and GCSSS2 an extra "mov xn, 0" is added to clear the output register, this is needed to g

[PATCH 08/22] aarch64: Add __builtin_aarch64_gcs* tests

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/gcspopm-1.c: New test. * gcc.target/aarch64/gcspr-1.c: New test. * gcc.target/aarch64/gcsss-1.c: New test. --- gcc/testsuite/gcc.target/aarch64/gcspopm-1.c | 69 gcc/testsuite/gcc.targ

[PATCH 03/22] aarch64: Add support for chkfeat insn

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy This is a hint space instruction to check for enabled HW features and update the x16 register accordingly. Use unspec_volatile to prevent reordering it around calls since calls can enable or disable HW features. gcc/ChangeLog: * config/aarch64/aarch64.md (aarch64_ch

[PATCH 05/22] aarch64: Add __builtin_aarch64_chkfeat tests

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/chkfeat-1.c: New test. * gcc.target/aarch64/chkfeat-2.c: New test. --- gcc/testsuite/gcc.target/aarch64/chkfeat-1.c | 75 gcc/testsuite/gcc.target/aarch64/chkfeat-2.c | 15 2 files change

[PATCH 02/22] aarch64: Add branch-protection target pragma tests

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy gcc/testsuite/ChangeLog: * gcc.target/aarch64/pragma_cpp_predefs_4.c: Add branch-protection tests. --- .../gcc.target/aarch64/pragma_cpp_predefs_4.c | 50 +++ 1 file changed, 50 insertions(+) diff --git a/gcc/testsuite/gcc.target/aarch64/prag

[PATCH 01/22] aarch64: Add -mbranch-protection=gcs option

2024-10-23 Thread Yury Khrustalev
From: Szabolcs Nagy This enables Guarded Control Stack (GCS) compatible code generation. The "standard" branch-protection type enables it, and the default depends on the compiler default. gcc/ChangeLog: * config/aarch64/aarch64-protos.h (aarch_gcs_enabled): Declare. * config/aa

[PATCH 00/22] aarch64: Add support for Guarded Control Stack extension

2024-10-23 Thread Yury Khrustalev
GCS support to the unwinder aarch64: Emit GNU property NOTE for GCS aarch64: libgcc: add GCS marking to asm aarch64: libatomic: add GCS marking to asm aarch64: libitm: Add GCS support aarch64: Introduce indirect_return attribute Yury Khrustalev (1): aarch64: Fix nonlocal goto tests

Re: [PATCH 1/1] aarch64: Sync aarch64-sys-regs.def with Binutils

2024-03-20 Thread Yury Khrustalev
Hi Richard, > On 20 Mar 2024, at 1:55 PM, Richard Earnshaw (lists) > wrote: > > On 20/03/2024 11:21, Yury Khrustalev wrote: >> This patch updates `aarch64-sys-regs.def', bringing it into sync with >> the Binutils source. >> >> gcc/ChangeLog: >>

[PATCH 1/1] aarch64: Sync aarch64-sys-regs.def with Binutils

2024-03-20 Thread Yury Khrustalev
This patch updates `aarch64-sys-regs.def', bringing it into sync with the Binutils source. gcc/ChangeLog: * config/aarch64/aarch64-sys-regs.def: Copy from Binutils. --- gcc/config/aarch64/aarch64-sys-regs.def | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/config/aarch64/aarch64-sys-

[PATCH 0/1] aarch64: Sync aarch64-sys-regs.def with Binutils

2024-03-20 Thread Yury Khrustalev
Hi, This patch updates `aarch64-sys-regs.def', bringing it into sync with the Binutils source. Regression tested on aarch64-none-linux-gnu and no regressions have been found. Is it OK for GCC master? I don't have commit access so I need someone to commit on my behalf. Thanks,