public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/gcs-13)] libgcc: aarch64: Add SME unwinder support
@ 2024-02-14 15:35 Szabolcs Nagy
0 siblings, 0 replies; only message in thread
From: Szabolcs Nagy @ 2024-02-14 15:35 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b33d3beaf89a1853e304c3c023d49fb130c4fa33
commit b33d3beaf89a1853e304c3c023d49fb130c4fa33
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date: Fri Sep 29 13:55:51 2023 +0100
libgcc: aarch64: Add SME unwinder support
To support the ZA lazy save scheme, the PCS requires the unwinder to
reset the SME state to PSTATE.SM=0, PSTATE.ZA=0, TPIDR2_EL0=0 on entry
to an exception handler. We use the __arm_za_disable SME runtime call
unconditionally to achieve this.
https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#exceptions
The hidden alias is used to avoid a PLT and avoid inconsistent VPCS
marking (we don't rely on special PCS at the call site). In case of
static linking the SME runtime init code is linked in code that raises
exceptions.
libgcc/ChangeLog:
* config/aarch64/__arm_za_disable.S: Add hidden alias.
* config/aarch64/aarch64-unwind.h: Reset the SME state before
EH return via the _Unwind_Frames_Extra hook.
(cherry picked from commit 91d68665b8b7a5dffd0bbf8cd1f74c3c41d4c2d8)
Diff:
---
libgcc/config/aarch64/__arm_za_disable.S | 5 +++++
libgcc/config/aarch64/aarch64-unwind.h | 16 ++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/libgcc/config/aarch64/__arm_za_disable.S b/libgcc/config/aarch64/__arm_za_disable.S
index cff5b9cec47e..03fc28a39317 100644
--- a/libgcc/config/aarch64/__arm_za_disable.S
+++ b/libgcc/config/aarch64/__arm_za_disable.S
@@ -63,3 +63,8 @@ ENTRY (__arm_za_disable)
L(end):
ret
END (__arm_za_disable)
+
+/* Hidden alias used by the unwinder. */
+.global __libgcc_arm_za_disable
+.hidden __libgcc_arm_za_disable
+.set __libgcc_arm_za_disable, __arm_za_disable
diff --git a/libgcc/config/aarch64/aarch64-unwind.h b/libgcc/config/aarch64/aarch64-unwind.h
index 3ad2f8239ed8..df223d8f6bb3 100644
--- a/libgcc/config/aarch64/aarch64-unwind.h
+++ b/libgcc/config/aarch64/aarch64-unwind.h
@@ -77,4 +77,20 @@ aarch64_demangle_return_addr (struct _Unwind_Context *context,
return addr;
}
+/* SME runtime function local to libgcc, streaming compatible
+ and preserves more registers than the base PCS requires, but
+ we don't rely on that here. */
+__attribute__ ((visibility ("hidden")))
+void __libgcc_arm_za_disable (void);
+
+/* Disable the SME ZA state in case an unwound frame used the ZA
+ lazy saving scheme. */
+#undef _Unwind_Frames_Extra
+#define _Unwind_Frames_Extra(x) \
+ do \
+ { \
+ __libgcc_arm_za_disable (); \
+ } \
+ while (0)
+
#endif /* defined AARCH64_UNWIND_H && defined __ILP32__ */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-02-14 15:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-14 15:35 [gcc(refs/vendors/ARM/heads/gcs-13)] libgcc: aarch64: Add SME unwinder support Szabolcs Nagy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).