[all-commits] [llvm/llvm-project] 7e7e81: [libunwind] Add GCS support for AArch64 (#99335)

John Brawn via All-commits all-commits at lists.llvm.org
Tue Aug 20 00:31:15 PDT 2024


  Branch: refs/heads/release/19.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 7e7e8125cfabf7daf5de63612e6f2c646dd8cad3
      https://github.com/llvm/llvm-project/commit/7e7e8125cfabf7daf5de63612e6f2c646dd8cad3
  Author: John Brawn <john.brawn at arm.com>
  Date:   2024-08-20 (Tue, 20 Aug 2024)

  Changed paths:
    M libunwind/CMakeLists.txt
    M libunwind/src/Registers.hpp
    M libunwind/src/UnwindCursor.hpp
    M libunwind/src/UnwindLevel1.c
    M libunwind/src/UnwindRegistersRestore.S
    M libunwind/src/cet_unwind.h
    M libunwind/test/CMakeLists.txt
    M libunwind/test/configs/llvm-libunwind-merged.cfg.in
    M libunwind/test/configs/llvm-libunwind-shared.cfg.in
    M libunwind/test/configs/llvm-libunwind-static.cfg.in

  Log Message:
  -----------
  [libunwind] Add GCS support for AArch64 (#99335)

AArch64 GCS (Guarded Control Stack) is similar enough to CET that we can
re-use the existing code that is guarded by _LIBUNWIND_USE_CET, so long
as we also add defines to locate the GCS stack and pop the entries from
it. We also need the jumpto function to exit using br instead of ret, to
prevent it from popping the GCS stack.

GCS support is enabled using the LIBUNWIND_ENABLE_GCS cmake option. This
enables -mbranch-protection=standard, which enables GCS. For the places
we need to use GCS instructions we use the target attribute, as there's
not a command-line option to enable a specific architecture extension.

(cherry picked from commit b32aac4358c1f6639de7c453656cd74fbab75d71)


  Commit: c3da16b094511e42022e534b5eb665dbc3f8db0f
      https://github.com/llvm/llvm-project/commit/c3da16b094511e42022e534b5eb665dbc3f8db0f
  Author: John Brawn <john.brawn at arm.com>
  Date:   2024-08-20 (Tue, 20 Aug 2024)

  Changed paths:
    M libunwind/src/cet_unwind.h

  Log Message:
  -----------
  [libunwind] Be more careful about enabling GCS (#101973)

We need both GCS to be enabled by the compiler (which we do by checking
if __ARM_FEATURE_GCS_DEFAULT is defined) and for arm_acle.h to define
the GCS intrinsics. Check the latter by checking if _CHKFEAT_GCS is
defined.

(cherry picked from commit c649194a71b47431f2eb2e041435d564e3b51072)


  Commit: 72d2932da5a7c70885a1fdfaa809ff1ede0984ff
      https://github.com/llvm/llvm-project/commit/72d2932da5a7c70885a1fdfaa809ff1ede0984ff
  Author: John Brawn <john.brawn at arm.com>
  Date:   2024-08-20 (Tue, 20 Aug 2024)

  Changed paths:
    M libunwind/src/UnwindRegistersRestore.S
    M libunwind/src/assembly.h

  Log Message:
  -----------
  [libunwind] Fix problems caused by combining BTI and GCS (#102322)

The libunwind assembly files need adjustment in order to work correctly
when both BTI and GCS are both enabled (which will be the case when
using -mbranch-protection=standard):
* __libunwind_Registers_arm64_jumpto can't use br to jump to the return
location, instead we need to use gcspush then ret.
* Because we indirectly call __libunwind_Registers_arm64_jumpto it needs
to start with bti jc.
 * We need to set the GCS GNU property bit when it's enabled.

---------

Co-authored-by: Daniel Kiss <daniel.kristof.kiss at gmail.com>
(cherry picked from commit 39529107b46032ef0875ac5b809ab5b60cd15a40)


Compare: https://github.com/llvm/llvm-project/compare/64b8514e6c1a...72d2932da5a7

To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list