Yury Khrustalev <yury.khrusta...@arm.com> writes: > This patch series adds support for the Guarded Control Stack extension [1]. > > GCS marking for binaries is specified in [2]. > ACLE intrinsics are discussed in [3]. > > Regression tested on AArch64 and no regressions have been found. > Applies to 5a674367c6d in trunk. > > Is this OK for trunk?
Thanks the updates. The new version LGTM. Pushed to trunk with an extra pair of parentheses around: + return (UINTVAL (cookie) >> AARCH64_NUM_ISA_MODES) & 1 == 1; in patch 20. Richard > Sources and branches: > - binutils-gdb: sourceware.org/git/binutils-gdb.git users/ARM/gcs > - gcc: this patch series > - glibc: sourceware.org/git/glibc.git arm/gcs-v2 > - kernel: git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git > for-next/gcs > > Cross-building the toolchain for target aarch64-none-linux-gnu: > - build and install binutils-gdb > - build and install GCC stage 1 > - install kernel headers > - install glibc headers > - build and install GCC stage 2 configuring with > --enable-standard-branch-protection > - build and install glibc > - build and install GCC stage 3 along with target libraries configuring with > --enable-standard-branch-protection > > FVP model provided by the Shrinkwrap tool [4] can be used for testing. > > To enabled GCS, run tests with environment var: > > GLIBC_TUNABLES=glibc.cpu.aarch64_gcs=1:glibc.cpu.aarch64_gcs_policy=2 > > See details about Glibc tunables in corresponding Glibc patch [5]. > > Corresponding binutils patch [6]. > > [1] https://developer.arm.com/documentation/ddi0487/ka/ (chapter D11) > [2] https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst > [3] https://github.com/ARM-software/acle/pull/260 > [4] https://git.gitlab.arm.com/tooling/shrinkwrap.git > [5] > https://inbox.sourceware.org/libc-alpha/20241023083920.466015-1-yury.khrusta...@arm.com/ > [6] > https://inbox.sourceware.org/binutils/20241014101743.3222246-1-yury.khrusta...@arm.com/ > > --- > > Changes in v4: > - Fixed pragma GCC target for the __chkfeat ACLE intrinsic. > - Fixed Pmode with ptr_mode in impl of GCS builtins. > - Fixed force_reg with in gen_reg_rtx restore_stack_nonlocal. > - Update wording of some comments and fixed style issues. > - Fixed indirect_return tests and added new tests for function type error. > - Fixed link to v2 patch series below. > > Link to v3: > https://inbox.sourceware.org/gcc-patches/20241108144816.2681175-1-yury.khrusta...@arm.com/ > > Changes in v3: > - Implemented ACLE intrinsics __chkfeat, __gcspr, __gcspopm, and __gcsss > along > with corresponding tests. > - Changed implementation of the indirect_return attribute to use ABI cookie > of the call instruction. > - Fixed minor test inconsistencies. > > Link to v2: > https://inbox.sourceware.org/gcc-patches/20241031132323.948159-1-yury.khrusta...@arm.com/ > > Changes in v2: > - Updated implementation of __builtin_aarch64_chkfeat and tests based on > comments. > - Implemented GCSSS1 and GCSSS2 as two separate instructions. > - Updated __builtin_aarch64_gcsss accordingly as well as tests. > - Changed mode used for STACK_SAVEAREA for non-local goto to avoid > unnecessary alignment requirements. > - Support for GCS is removed from libitm. This library will remain > non-GCS-compatible. > - Fixed description of the indirect_return attribute in the manual. > - Added test for a sibling call from an indirect_return function to an > indirect_return function. > - Added tests for indirect_return functions when BTI is not enabled. > > Link to v1: > https://inbox.sourceware.org/gcc-patches/20241023110528.487830-1-yury.khrusta...@arm.com/ > > --- > > Matthieu Longo (1): > aarch64: Fix tests incompatible with GCS > > Richard Ball (1): > aarch64: Add tests and docs for indirect_return attribute > > Szabolcs Nagy (18): > aarch64: Add -mbranch-protection=gcs option > aarch64: Add branch-protection target pragma tests > aarch64: Add support for chkfeat insn > aarch64: Add __builtin_aarch64_chkfeat > aarch64: Add __builtin_aarch64_chkfeat and __chkfeat tests > aarch64: Add GCS instructions > aarch64: Add GCS builtins > aarch64: Add __builtin_aarch64_gcs* and __gcs* tests > aarch64: Add GCS support for nonlocal stack save > aarch64: Add non-local goto and jump tests for GCS > aarch64: Add ACLE feature macros for GCS > aarch64: Add test for GCS ACLE defs > aarch64: Add target pragma tests for gcs > aarch64: Add 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: 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/config/aarch64/aarch64-c.cc | 3 + > gcc/config/aarch64/aarch64-opts.h | 2 + > gcc/config/aarch64/aarch64-protos.h | 4 +- > gcc/config/aarch64/aarch64.cc | 91 ++++++++++-- > gcc/config/aarch64/aarch64.h | 8 ++ > gcc/config/aarch64/aarch64.md | 133 +++++++++++++++++- > gcc/config/aarch64/aarch64.opt | 3 + > gcc/config/aarch64/arm_acle.h | 22 +++ > gcc/config/arm/aarch-bti-insert.cc | 23 ++- > gcc/config/arm/aarch-common-protos.h | 1 + > gcc/config/arm/arm.cc | 9 ++ > gcc/configure | 2 +- > gcc/configure.ac | 6 +- > gcc/doc/extend.texi | 10 ++ > gcc/doc/invoke.texi | 5 +- > .../return_address_sign_ab_exception.C | 19 ++- > .../gcc.target/aarch64/acle/chkfeat-1.c | 20 +++ > gcc/testsuite/gcc.target/aarch64/acle/gcs-1.c | 42 ++++++ > gcc/testsuite/gcc.target/aarch64/chkfeat-1.c | 75 ++++++++++ > gcc/testsuite/gcc.target/aarch64/chkfeat-2.c | 30 ++++ > gcc/testsuite/gcc.target/aarch64/eh_return.c | 13 ++ > .../gcs-nonlocal-1-track-speculation.c | 7 + > .../gcc.target/aarch64/gcs-nonlocal-1.c | 7 + > .../gcc.target/aarch64/gcs-nonlocal-1.h | 20 +++ > .../gcs-nonlocal-2-track-speculation.c | 7 + > .../gcc.target/aarch64/gcs-nonlocal-2.c | 7 + > .../gcc.target/aarch64/gcs-nonlocal-2.h | 16 +++ > .../gcc.target/aarch64/gcs-nonlocal-3.c | 33 +++++ > gcc/testsuite/gcc.target/aarch64/gcspopm-1.c | 63 +++++++++ > gcc/testsuite/gcc.target/aarch64/gcspr-1.c | 31 ++++ > gcc/testsuite/gcc.target/aarch64/gcsss-1.c | 48 +++++++ > .../gcc.target/aarch64/indirect_return-1.c | 53 +++++++ > .../gcc.target/aarch64/indirect_return-2.c | 49 +++++++ > .../gcc.target/aarch64/indirect_return-3.c | 9 ++ > .../gcc.target/aarch64/pragma_cpp_predefs_1.c | 30 ++++ > .../gcc.target/aarch64/pragma_cpp_predefs_4.c | 85 +++++++++++ > .../gcc.target/aarch64/sme/nonlocal_goto_4.c | 2 +- > .../gcc.target/aarch64/sme/nonlocal_goto_5.c | 2 +- > .../gcc.target/aarch64/sme/nonlocal_goto_6.c | 2 +- > gcc/tree-nested.cc | 4 +- > libatomic/config/linux/aarch64/atomic_16.S | 11 +- > libgcc/config/aarch64/aarch64-asm.h | 16 ++- > libgcc/config/aarch64/aarch64-unwind.h | 59 +++++++- > 44 files changed, 1137 insertions(+), 37 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/aarch64/acle/chkfeat-1.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/acle/gcs-1.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/chkfeat-1.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/chkfeat-2.c > create mode 100644 > gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1-track-speculation.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-1.h > create mode 100644 > gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2-track-speculation.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-2.h > create mode 100644 gcc/testsuite/gcc.target/aarch64/gcs-nonlocal-3.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/gcspopm-1.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/gcspr-1.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/gcsss-1.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/indirect_return-1.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/indirect_return-2.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/indirect_return-3.c