[PATCH] MAINTAINERS: Add myself to write after approval

2024-12-02 Thread Yury Khrustalev
Geoffrey Keatinggeoffk Brendan Kehoe - Richard Kenner kenner +Yury Khrustalev ykhrustalev Andi Kleen ak Matthias Klose doko

Re: [PATCH] aarch64: Fix bootstrap build failure due to missing header

2024-11-29 Thread Yury Khrustalev
On Fri, Nov 29, 2024 at 02:31:34PM +, Kyrylo Tkachov wrote: > > > Would you recommend to re-phrase the commit message? > > Thanks for explaining. Yes, I think describing the use case a bit more in the > commit message like you just did would be useful. > Ok with that change. > Kyrill Thanks

[PATCH v2] aarch64: Fix build failure due to missing header

2024-11-29 Thread Yury Khrustalev
Including the "arm_acle.h" header in aarch64-unwind.h requires stdint.h to be present and it may not be available during the first stage of cross-compilation of GCC. When cross-building GCC for the aarch64-none-linux-gnu target (on any supporting host) using the 3-stage bootstrap build process whe

Re: [PATCH] aarch64: Fix bootstrap build failure due to missing header

2024-11-29 Thread Yury Khrustalev
Hi Kyrill, On Fri, Nov 29, 2024 at 02:06:17PM +, Kyrylo Tkachov wrote: > Hi Yury, > > > On 29 Nov 2024, at 13:57, Yury Khrustalev wrote: > > > > Inclusion of "arm_acle.h" would requires stdint.h that may > > not be available during first stage of

[PATCH] aarch64: Fix bootstrap build failure due to missing header

2024-11-29 Thread Yury Khrustalev
Inclusion of "arm_acle.h" would requires stdint.h that may not be available during first stage of cross-compilation. libgcc/ChangeLog: * config/aarch64/aarch64-unwind.h (_CHKFEAT_GCS): Add. --- Regression tested on aarch64-unknown-linux-gnu and no regressions have been found. Is this

[PATCH 0/1] Add ACLE macro _CHKFEAT_GCS

2024-11-21 Thread Yury Khrustalev
Add ACLE macro _CHKFEAT_GCS for AArch64. Regression tested on aarch64-none-linux-gnu and no regressions have been found. Is it OK for trunk? Applies to dbc38dd9e96. I don't have commit access so I need someone to commit on my behalf. --- Yury Khrustalev (1): aarch64: add ACLE

[PATCH 1/1] aarch64: add ACLE macro _CHKFEAT_GCS

2024-11-21 Thread Yury Khrustalev
gcc/ChangeLog: * config/aarch64/arm_acle.h (_CHKFEAT_GCS): New. libgcc/ChangeLog: * config/aarch64/aarch64-unwind.h (_Unwind_Frames_Extra): Update. (_Unwind_Frames_Increment): Update --- gcc/config/aarch64/arm_acle.h | 3 +++ libgcc/config/aarch64/aarch64-unwind.

Re: [COMMITTED] gcc: regenerate configure

2024-11-15 Thread Yury Khrustalev
On Thu, Nov 14, 2024 at 08:53:48PM +, Sam James wrote: > r15-5257-g56ded80b96b0f6 didn't regenerate configure correctly. > > See https://inbox.sourceware.org/gcc-patches/zzzf69gorvpro...@zen.kayari.org/. > > gcc/ChangeLog: > > * configure: Regenerate. > --- > Pushed as obvious. Thank

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

2024-11-15 Thread Yury Khrustalev
Hi Jonathan, On Thu, Nov 14, 2024 at 08:39:07PM +, Jonathan Wakely wrote: > On 14/11/24 12:36 +0000, Yury Khrustalev wrote: > > From: Szabolcs Nagy > > > > ... > > > > @@ -28093,7 +28093,7 @@ if test "${enable_standard_branch_protection+se

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

2024-11-14 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 v4 13/23] aarch64: Add ACLE feature macros for GCS

2024-11-14 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 v4 19/23] aarch64: libatomic: add GCS marking to asm

2024-11-14 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

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

2024-11-14 Thread Yury Khrustalev
Hi Richard, I'll reply to this message only to avoid almost identical emails for each commented on patch. Thank you for your comments and suggestions! I've made fixes as per your comments and uploaded v4: https://inbox.sourceware.org/gcc-patches/20241114123713.4046367-1-yury.khrusta...@arm.com/

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

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

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

2024-11-14 Thread Yury Khrustalev
(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/aarch64.cc| 62 gcc/config/aarch64/aarch64.h | 1 + gcc/config/aarch64

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

2024-11-14 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 v4 23/23] aarch64: Fix nonlocal goto tests incompatible with GCS

2024-11-14 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 v4 10/23] aarch64: Add __builtin_aarch64_gcs* and __gcs* tests

2024-11-14 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 v4 22/23] aarch64: Fix tests incompatible with GCS

2024-11-14 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 v4 09/23] aarch64: Add ACLE __gcs* intrinsics

2024-11-14 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 v4 16/23] aarch64: Add GCS support to the unwinder

2024-11-14 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 v4 08/23] aarch64: Add GCS builtins

2024-11-14 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 v4 07/23] aarch64: Add GCS instructions

2024-11-14 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 v4 05/23] aarch64: Add ACLE __chkfeat intrinsic

2024-11-14 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 v4 15/23] aarch64: Add target pragma tests for gcs

2024-11-14 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 v4 12/23] aarch64: Add non-local goto and jump tests for GCS

2024-11-14 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 v4 06/23] aarch64: Add __builtin_aarch64_chkfeat and __chkfeat tests

2024-11-14 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 v4 04/23] aarch64: Add __builtin_aarch64_chkfeat

2024-11-14 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 v4 02/23] aarch64: Add branch-protection target pragma tests

2024-11-14 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 v4 14/23] aarch64: Add test for GCS ACLE defs

2024-11-14 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 v4 11/23] aarch64: Add GCS support for nonlocal stack save

2024-11-14 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 v4 03/23] aarch64: Add support for chkfeat insn

2024-11-14 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 v4 01/23] aarch64: Add -mbranch-protection=gcs option

2024-11-14 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 v4 00/23] aarch64: Add support for Guarded Control Stack extension

2024-11-14 Thread Yury Khrustalev
GCS marking to asm aarch64: Introduce indirect_return attribute Yury Khrustalev (3): aarch64: Add ACLE __chkfeat intrinsic aarch64: Add ACLE __gcs* intrinsics aarch64: Fix nonlocal goto tests incompatible with GCS gcc/config/aarch64/aarch64-builtins.cc| 92 gcc

[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

  1   2   >