================
@@ -1877,49 +1877,179 @@ class _LIBUNWIND_HIDDEN Registers_arm64 {
 
   uint64_t  getSP() const         { return _registers.__sp; }
   void      setSP(uint64_t value) { _registers.__sp = value; }
+
   uint64_t  getIP() const {
     uint64_t value = _registers.__pc;
-#if defined(_LIBUNWIND_TARGET_AARCH64_AUTHENTICATED_UNWINDING)
+
+    if (!isReturnAddressSigned())
+      return value;
+
+#if !defined(_LIBUNWIND_IS_NATIVE_ONLY)
+    abortCrossRASigning();
+#else
     // Note the value of the PC was signed to its address in the register state
     // but everyone else expects it to be sign by the SP, so convert on return.
-    value = (uint64_t)ptrauth_auth_and_resign((void *)_registers.__pc,
-                                              ptrauth_key_return_address,
-                                              &_registers.__pc,
-                                              ptrauth_key_return_address,
-                                              getSP());
+    register uint64_t x17 __asm("x17") = value;
----------------
kovdan01 wrote:

I agree that using inline assembly instead of intrinsics harms readability, but 
it looks like that we have no other choice for pac-ret. While for arm64e or 
pauthtest we know that the compiler supports intrinsics, we have no such 
guarantee when building "regular" libunwind for aarch64. And this "regular" 
libunwind should still support signed LR in case if some frames have it signed.

As for using proper mnemonics for hint-encoded instructions - I'll dive into 
this deeper and see if smth could be enhanced while keeping builds possible w/o 
manually targeting the version of aarch64 architecture which supports pauth.

P.S. Inline assembly with hint-encoded instructions was already used for 
handling signed LR in case of pac-ret (not arm64e or pauthtest), but it was 
just "we see signed LR -> we authenticate it and store w/o any signature in the 
context struct and use regular non-auth logic further". This patch is an 
attempt to keep the LR signed and adopt the arm64e/pauthtest logic for handling 
signed LR in case of pac-ret.

https://github.com/llvm/llvm-project/pull/171717
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to