[libunwind] [libunwind][AArch64] Protect PC within libunwind's context. (PR #113368)

John Brawn via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 29 06:17:38 PDT 2024


================
@@ -1823,9 +1823,48 @@ extern "C" void *__libunwind_cet_get_jump_target() {
 #endif
 
 class _LIBUNWIND_HIDDEN Registers_arm64 {
+protected:
+  /// The program counter is used effectively as a return address
+  /// when the context is restored therefore protect it with PAC.
+  /// The base address of the context is used with the A key for
+  /// authentication and signing. Return address authentication is
+  /// still managed according to the unwind info.
+  inline uint64_t getAuthSalt() const {
+    return reinterpret_cast<uint64_t>(this);
+  }
+#if defined(_LIBUNWIND_IS_NATIVE_ONLY)
+  // Authenticate the given pointer and return with the raw value
+  // if the authentication is succeeded.
+  inline uint64_t auth(uint64_t ptr, uint64_t salt) const {
+    register uint64_t x17 __asm("x17") = ptr;
+    register uint64_t x16 __asm("x16") = salt;
+    asm volatile("hint  0xc" // autia1716
----------------
john-brawn-arm wrote:

This would be better on one line, same as the pacia1716 below.

https://github.com/llvm/llvm-project/pull/113368


More information about the cfe-commits mailing list