[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 edited https://github.com/llvm/llvm-project/pull/143230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -30,6 +30,45 @@ EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT, _Unwind_Personality_Fn); #endif +#if __has_feature(ptrauth_qualifier) +#include +#if __has_feature(ptrauth_restricted_intptr_qualif

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -30,6 +30,51 @@ EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT, _Unwind_Personality_Fn); #endif +#if __has_feature(ptrauth_calls) kovdan01 wrote: As discussed previously, let's u

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -377,13 +391,31 @@ const char *CFI_Parser::parseCIE(A &addressSpace, pint_t cie, case 'z': cieInfo->fdesHaveAugmentationData = true; break; - case 'P': + case 'P': { cieInfo->personalityEncoding = addressSpace.get8(p); ++p;

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -47,10 +47,10 @@ struct _LIBCXXABI_HIDDEN __cxa_exception { // In Wasm, a destructor returns its argument void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *); #else -void (_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *); +void(_LIBCXXABI_DTOR_FUNC* _

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -1047,18 +1051,26 @@ class UnwindCursor : public AbstractUnwindCursor{ bool getInfoFromFdeCie(const typename CFI_Parser::FDE_Info &fdeInfo, const typename CFI_Parser::CIE_Info &cieInfo, pint_t pc, uintptr_t dso_base); - bo

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -47,10 +47,11 @@ struct _LIBCXXABI_HIDDEN __cxa_exception { // In Wasm, a destructor returns its argument void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *); #else -void (_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *); +void(_LIBCXXABI_DTOR_FUNC*

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -79,16 +79,18 @@ struct _LIBCXXABI_HIDDEN __cxa_exception { // http://sourcery.mentor.com/archives/cxx-abi-dev/msg01924.html // The layout of this structure MUST match the layout of __cxa_exception, with // primaryException instead of referenceCount. +// The tags used in the

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 requested changes to this pull request. https://github.com/llvm/llvm-project/pull/143230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -681,7 +681,18 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_arm64_jumpto) // context struct, because it is allocated on the stack, and an exception // could clobber the de-allocated portion of the stack after sp has been // restored. - ldrx16, [x0, #0x0

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -61,10 +62,10 @@ struct _LIBCXXABI_HIDDEN __cxa_exception { int propagationCount; #else int handlerSwitchValue; -const unsigned char *actionRecord; -const unsigned char *languageSpecificData; -void *catchTemp; -void *adjustedPtr; +const unsigned c

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 { uint64_t getSP() const { return _registers.__sp; } void setSP(uint64_t value) { _registers.__sp = value; } - uint64_t getIP() const { return _registers.__pc; } - void setIP(uint

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 requested changes to this pull request. https://github.com/llvm/llvm-project/pull/143230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 edited https://github.com/llvm/llvm-project/pull/143230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 edited https://github.com/llvm/llvm-project/pull/143230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -694,7 +705,12 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_arm64_jumpto) gcspushm x30 Lnogcs: #endif + +#if __has_feature(ptrauth_calls) + retab +#else kovdan01 wrote: Closing the thread in favor of: 1. (To be fixed in scope of this PR) Comment

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -30,6 +30,51 @@ EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT, _Unwind_Personality_Fn); #endif +#if __has_feature(ptrauth_calls) +#include + +#if __has_feature(ptrauth_restricted_intptr_qualifie

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -680,11 +682,19 @@ int CompactUnwinder_arm64::stepWithCompactEncodingFrame( savedRegisterLoc -= 8; } - uint64_t fp = registers.getFP(); + Registers_arm64::reg_t fp = registers.getFP(); // fp points to old fp registers.setFP(addressSpace.get64(fp)); - // old

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -30,6 +30,45 @@ EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT, _Unwind_Personality_Fn); #endif +#if __has_feature(ptrauth_qualifier) +#include +#if __has_feature(ptrauth_restricted_intptr_qualif

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -807,7 +812,12 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) strd31, [x0, #0x208] #endif movx0, #0 // return UNW_ESUCCESS + +#if __has_feature(ptrauth_calls) + retab +#else kovdan01 wrote: Closing the thread in favor of:

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -126,6 +130,36 @@ _LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum, // First, get the FDE for the old location and then update it. co->getInfo(&info); co->setInfoBasedOnIPRegister(false); + +#if __has_feature(ptrauth_calls) +

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -103,10 +104,68 @@ #define _LIBCXXABI_DTOR_FUNC #endif -#if __cplusplus < 201103L -# define _LIBCXXABI_NOEXCEPT throw() -#else -# define _LIBCXXABI_NOEXCEPT noexcept +#if __has_include() +# include #endif +#if __has_extension(ptrauth_qualifier) + +// The actual value

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -541,7 +588,33 @@ struct scan_results }; } // unnamed namespace +} // extern "C" + +namespace { +// The logical model for casting authenticated function pointers makes +// it impossible to directly cast them without breaking the authentication, +// as a result we need this

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -118,22 +119,51 @@ _LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum, typedef LocalAddressSpace::pint_t pint_t; AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; if (co->validReg(regNum)) { -co->setReg(regNum, (pint_t)value);

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -63,10 +63,11 @@ class DwarfInstructions { pint_t cfa, const RegisterLocation &savedReg); static pint_t getCFA(A &addressSpace, const PrologInfo &prolog, - const R ®isters) { -if (prolog.cfaRegister != 0) -

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-22 Thread Daniil Kovalev via cfe-commits
@@ -43,6 +43,102 @@ #define LIBUNWIND_AVAIL #endif +#if __has_feature(ptrauth_calls) + + #include + + #if __has_extension(ptrauth_restricted_intptr_qualifier) kovdan01 wrote: We do not have `__ptrauth_restricted_intptr`, so let's avoid including these c

[clang] [PAC][clang] Handle pauthtest environment and ABI in Linux-specific code (PR #113151)

2025-09-22 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: @MaskRay Could you please take a look at this PR considering the latest comment from @asl? https://github.com/llvm/llvm-project/pull/113151#issuecomment-2513491319 https://github.com/llvm/llvm-project/pull/113151 ___ cfe-commits maili

[clang] [clang][ptrauth] Warn about the use of a weak signing schema (PR #157779)

2025-09-19 Thread Daniil Kovalev via cfe-commits
@@ -0,0 +1,60 @@ +// RUN: %clang_cc1 -triple arm64e-apple-ios -fptrauth-calls -fptrauth-intrinsics -fsyntax-only -Wno-unused-variable -verify %s +// RUN: %clang_cc1 -triple arm64e-apple-ios -DNO_PTRAUTH -fsyntax-only -Wno-unused-variable -verify=noptrauth %s + +// noptrauth-no-d

[clang] [PAC][clang] Add new features to pauthtest ABI (PR #113150)

2025-09-17 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 updated https://github.com/llvm/llvm-project/pull/113150 >From 63eb66f8f7feb97932f22a1e3ac93a1aca4f913e Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Mon, 21 Oct 2024 10:58:04 +0300 Subject: [PATCH] [PAC][clang] Add new features to pauthtest ABI Enable init/fi

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-17 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: > > * Fix personality pointer authentication on non-Apple targets: > > [[runtimes][PAC] Harden unwinding when possible #143230 > > (comment)](https://github.com/llvm/llvm-project/pull/143230#discussion_r2318636296) > > I'm not sure what's going on in this diff as it does not ap

[clang] [PAC][clang] Handle pauthtest environment and ABI in Linux-specific code (PR #113151)

2025-09-17 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: > > ELF PAuth is an object file format specific feature that isn't coupled with > > a specific OS. Keeping it in generic code might help other OSes (e.g. > > *BSD), if they ever adopt PAuth. > > In fact, it is coupled. The idea here is that PAuth effectively defines > another

[clang] [PAC][clang] Add new features to pauthtest ABI (PR #113150)

2025-09-17 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: @MaskRay Would be glad to see your feedback considering the info from my comments above https://github.com/llvm/llvm-project/pull/113150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/lis

[clang] [PAC][clang] Handle pauthtest environment and ABI in Linux-specific code (PR #113151)

2025-09-16 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 edited https://github.com/llvm/llvm-project/pull/113151 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [PAC][clang] Handle pauthtest environment and ABI in Linux-specific code (PR #113151)

2025-09-15 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 updated https://github.com/llvm/llvm-project/pull/113151 >From 89e975db84dea437417fa443429df017a30d6d3c Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Mon, 21 Oct 2024 12:00:19 +0300 Subject: [PATCH 1/2] [PAC][clang] Handle pauthtest environment and ABI in Linu

[clang] [PAC][clang] Add new features to pauthtest ABI (PR #113150)

2025-09-15 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 closed https://github.com/llvm/llvm-project/pull/113150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-15 Thread Daniil Kovalev via cfe-commits
@@ -557,7 +596,19 @@ set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context, reinterpret_cast(unwind_exception)); _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), static_cast(results.ttypeIndex)); +#if defined(__A

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-15 Thread Daniil Kovalev via cfe-commits
@@ -126,6 +130,36 @@ _LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum, // First, get the FDE for the old location and then update it. co->getInfo(&info); co->setInfoBasedOnIPRegister(false); + +#if __has_feature(ptrauth_calls) +

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-15 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 edited https://github.com/llvm/llvm-project/pull/143230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-15 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 edited https://github.com/llvm/llvm-project/pull/143230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-12 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: > In principle I could set up this configuration right? (Obviously not actually > test it, but in principle at least be able to verify it builds before pushing > the update) @ojhunt It would be very nice if you could do it and ensure things are at least building w/o compile er

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-09 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: @ojhunt Thanks! So could you please adopt the code snippet from my previous comment to make things explicitly unsupported for Linux? And also I kindly ask you to fix p.4 from https://github.com/llvm/llvm-project/pull/143230#issuecomment-3249013139 (we've already discussed that

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: Thanks @ojhunt for updates! These resolve some of the previously found issues, but many problems are still present (both previously reported and newly found). I tried to resolve all the threads which are now no longer relevant, so please treat all the opened threads as issues w

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
@@ -126,6 +130,36 @@ _LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum, // First, get the FDE for the old location and then update it. co->getInfo(&info); co->setInfoBasedOnIPRegister(false); + +#if __has_feature(ptrauth_calls) +

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
@@ -1047,18 +1051,26 @@ class UnwindCursor : public AbstractUnwindCursor{ bool getInfoFromFdeCie(const typename CFI_Parser::FDE_Info &fdeInfo, const typename CFI_Parser::CIE_Info &cieInfo, pint_t pc, uintptr_t dso_base); - bo

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
@@ -681,7 +681,18 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_arm64_jumpto) // context struct, because it is allocated on the stack, and an exception // could clobber the de-allocated portion of the stack after sp has been // restored. - ldrx16, [x0, #0x0

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
@@ -103,6 +103,52 @@ #define _LIBCXXABI_DTOR_FUNC #endif +#if __has_include() +# include +#endif kovdan01 wrote: @ojhunt Can we get rid of `__has_include()` check here and switch to `__has_feature(ptrauth_calls) || defined(__PTRAUTH__)` just as a couple of

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
@@ -377,13 +395,32 @@ const char *CFI_Parser::parseCIE(A &addressSpace, pint_t cie, case 'z': cieInfo->fdesHaveAugmentationData = true; break; - case 'P': + case 'P': { cieInfo->personalityEncoding = addressSpace.get8(p); ++p;

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: Cannot add inline comment, so commenting on the whole file: `stepWithDwarf` function contains piece of logic for handling signed RA. This works properly for pac-ret, but it interferes with logic for ptrauth-returns which is a part of pauthtest

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
@@ -238,7 +282,20 @@ COMPILER_RT_ABI _Unwind_Reason_Code __gcc_personality_v0( _Unwind_SetGR(context, __builtin_eh_return_data_regno(0), (uintptr_t)exceptionObject); _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), 0); - _Unwind_Set

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
@@ -16,6 +16,12 @@ #include #endif +#if __has_feature(ptrauth_calls) || defined(__PTRAUTH__) kovdan01 wrote: It's probably worth submitting changes related to `__PTRAUTH__` introduced in #153912 as a separate PR while keeping this PR only focused on unwind

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
@@ -557,7 +596,19 @@ set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context, reinterpret_cast(unwind_exception)); _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), static_cast(results.ttypeIndex)); +#if defined(__A

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
@@ -541,7 +588,33 @@ struct scan_results }; } // unnamed namespace +} // extern "C" + +namespace { +// The logical model for casting authenticated function pointers makes +// it impossible to directly cast them without breaking the authentication, +// as a result we need this

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
@@ -377,13 +391,31 @@ const char *CFI_Parser::parseCIE(A &addressSpace, pint_t cie, case 'z': cieInfo->fdesHaveAugmentationData = true; break; - case 'P': + case 'P': { cieInfo->personalityEncoding = addressSpace.get8(p); ++p;

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 requested changes to this pull request. https://github.com/llvm/llvm-project/pull/143230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
@@ -30,6 +30,45 @@ EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT, _Unwind_Personality_Fn); #endif +#if __has_feature(ptrauth_qualifier) +#include +#if __has_feature(ptrauth_restricted_intptr_qualif

[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

2025-09-03 Thread Daniil Kovalev via cfe-commits
@@ -557,7 +630,21 @@ set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context, reinterpret_cast(unwind_exception)); _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), static_cast(results.ttypeIndex)); +#if __has_featu

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-07-29 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 requested changes to this pull request. https://github.com/llvm/llvm-project/pull/143230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-07-29 Thread Daniil Kovalev via cfe-commits
@@ -21,6 +21,44 @@ #include "cxa_handlers.h" #include "private_typeinfo.h" #include "unwind.h" +#include "libunwind.h" + +#if __has_include() +# include +#endif + +#if __has_extension(ptrauth_qualifier) +// The actual value of the discriminators listed below is not important.

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-07-29 Thread Daniil Kovalev via cfe-commits
@@ -103,10 +104,68 @@ #define _LIBCXXABI_DTOR_FUNC #endif -#if __cplusplus < 201103L kovdan01 wrote: I suppose this was removed accidentally during merging. W/o this, the build is just broken. https://github.com/llvm/llvm-project/pull/143230 ___

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-07-29 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: > (if linux folk could retest to see how badly I have broken everything that > would be great) @ojhunt A couple of quick observations: 1. It looks like that you forgot to add explicit declarations of copy constructor and assignment operator for `Registers_arm64`. Now, compiler

[clang] [PAC][clang] Add new features to pauthtest ABI (PR #113150)

2025-07-20 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: @MaskRay Would be glad to see your feedback considering the info from my comments above https://github.com/llvm/llvm-project/pull/113150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/lis

[clang] [PAC][clang] Add new features to pauthtest ABI (PR #113150)

2025-07-03 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: @MaskRay Could you please give a feedback (considering my latest comment above)? https://github.com/llvm/llvm-project/pull/113150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cf

[clang] [PAC][clang] Add new features to pauthtest ABI (PR #113150)

2025-06-25 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: > Driver options need to have some stability guarantee, while CC1 options can > be more freely changed. So I'd be concerned if we commit to certain forms of > driver options with known ergonomics issues. The Clang driver options should > come last in the patch stack, with other

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-25 Thread Daniil Kovalev via cfe-commits
@@ -109,4 +110,38 @@ # define _LIBCXXABI_NOEXCEPT noexcept #endif +#if __has_include() +# include +#endif + +#if defined(__APPLE__) && __has_feature(ptrauth_qualifier) kovdan01 wrote: It looks like that `__has_feature(ptrauth_qualifier)` should be replaced

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits
@@ -83,7 +83,13 @@ __llvm_profile_iterate_data(const __llvm_profile_data *Data) { /* This method is only used in value profiler mock testing. */ COMPILER_RT_VISIBILITY void * __llvm_get_function_addr(const __llvm_profile_data *Data) { - return Data->FunctionPointer; + void

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits
@@ -83,7 +83,13 @@ __llvm_profile_iterate_data(const __llvm_profile_data *Data) { /* This method is only used in value profiler mock testing. */ COMPILER_RT_VISIBILITY void * __llvm_get_function_addr(const __llvm_profile_data *Data) { - return Data->FunctionPointer; + void

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits
@@ -1877,6 +1946,32 @@ inline Registers_arm64::Registers_arm64(const void *registers) { memcpy(_vectorHalfRegisters, static_cast(registers) + sizeof(GPRs), sizeof(_vectorHalfRegisters)); +#if __has_feature(ptrauth_calls) + uint64_t pcRegister = 0; + memcp

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits
@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 { uint64_t getSP() const { return _registers.__sp; } void setSP(uint64_t value) { _registers.__sp = value; } - uint64_t getIP() const { return _registers.__pc; } - void setIP(uint

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits
@@ -541,7 +554,33 @@ struct scan_results }; } // unnamed namespace +} +namespace { +// The logical model for casting authenticated function pointers makes +// it impossible to directly cast them without breaking the authentication, +// as a result we need this pair of helpe

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits
@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 { uint64_t getSP() const { return _registers.__sp; } void setSP(uint64_t value) { _registers.__sp = value; } - uint64_t getIP() const { return _registers.__pc; } - void setIP(uint

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits
@@ -207,7 +211,8 @@ bool DwarfInstructions::isReturnAddressSignedWithPC(A &addressSpace, #endif template -int DwarfInstructions::stepWithDwarf(A &addressSpace, pint_t pc, +int DwarfInstructions::stepWithDwarf(A &addressSpace, kovdan01 wrote: In this functio

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits
@@ -207,7 +211,8 @@ bool DwarfInstructions::isReturnAddressSignedWithPC(A &addressSpace, #endif template -int DwarfInstructions::stepWithDwarf(A &addressSpace, pint_t pc, +int DwarfInstructions::stepWithDwarf(A &addressSpace, + typen

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 edited https://github.com/llvm/llvm-project/pull/143230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-17 Thread Daniil Kovalev via cfe-commits
@@ -126,6 +130,36 @@ _LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum, // First, get the FDE for the old location and then update it. co->getInfo(&info); co->setInfoBasedOnIPRegister(false); + +#if __has_feature(ptrauth_calls) +

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-17 Thread Daniil Kovalev via cfe-commits
@@ -1877,6 +1946,32 @@ inline Registers_arm64::Registers_arm64(const void *registers) { memcpy(_vectorHalfRegisters, static_cast(registers) + sizeof(GPRs), sizeof(_vectorHalfRegisters)); +#if __has_feature(ptrauth_calls) kovdan01 wrote: It

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-17 Thread Daniil Kovalev via cfe-commits
@@ -83,7 +83,13 @@ __llvm_profile_iterate_data(const __llvm_profile_data *Data) { /* This method is only used in value profiler mock testing. */ COMPILER_RT_VISIBILITY void * __llvm_get_function_addr(const __llvm_profile_data *Data) { - return Data->FunctionPointer; + void

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-17 Thread Daniil Kovalev via cfe-commits
@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 { uint64_t getSP() const { return _registers.__sp; } void setSP(uint64_t value) { _registers.__sp = value; } - uint64_t getIP() const { return _registers.__pc; } - void setIP(uint

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-17 Thread Daniil Kovalev via cfe-commits
@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 { uint64_t getSP() const { return _registers.__sp; } void setSP(uint64_t value) { _registers.__sp = value; } - uint64_t getIP() const { return _registers.__pc; } - void setIP(uint

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-17 Thread Daniil Kovalev via cfe-commits
@@ -83,7 +83,13 @@ __llvm_profile_iterate_data(const __llvm_profile_data *Data) { /* This method is only used in value profiler mock testing. */ COMPILER_RT_VISIBILITY void * __llvm_get_function_addr(const __llvm_profile_data *Data) { - return Data->FunctionPointer; + void

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-17 Thread Daniil Kovalev via cfe-commits
@@ -93,6 +98,13 @@ class _LIBUNWIND_HIDDEN Registers_x86 { uint32_t getEDI() const { return _registers.__edi; } void setEDI(uint32_t value) { _registers.__edi = value; } + typedef uint32_t reg_t; + typedef uint32_t link_reg_t; + void loadAndAuthenticateLin

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-17 Thread Daniil Kovalev via cfe-commits
@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 { uint64_t getSP() const { return _registers.__sp; } void setSP(uint64_t value) { _registers.__sp = value; } - uint64_t getIP() const { return _registers.__pc; } - void setIP(uint

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-17 Thread Daniil Kovalev via cfe-commits
@@ -1877,6 +1946,32 @@ inline Registers_arm64::Registers_arm64(const void *registers) { memcpy(_vectorHalfRegisters, static_cast(registers) + sizeof(GPRs), sizeof(_vectorHalfRegisters)); +#if __has_feature(ptrauth_calls) + uint64_t pcRegister = 0; + memcp

[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)

2025-02-17 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: > Any other feedback on this patch? > > For those who haven't followed the RFC, the RFC received positive reviews, > and we have reached a consensus to move forward with the proposal. > https://discourse.llvm.org/t/rfc-ptrauth-qualifier/80710/31 @ahatanak I personally have no

[clang] [PAC] Do not support some values of branch-protection with ptrauth-returns (PR #125280)

2025-01-31 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 ready_for_review https://github.com/llvm/llvm-project/pull/125280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [PAC] Do not support some values of branch-protection with ptrauth-returns (PR #125280)

2025-01-31 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 created https://github.com/llvm/llvm-project/pull/125280 This patch does two things. 1. Previously, when checking driver arguments, we emitted an error for unsupported values of `-mbranch-protection` when using pauthtest ABI. The reason for that was ptrauth-returns

[clang] [PAC][clang] Add new features to pauthtest ABI (PR #113150)

2024-12-17 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 updated https://github.com/llvm/llvm-project/pull/113150 >From 838b0d0ed5592b2a74560373252f17b49ae64ee7 Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Mon, 21 Oct 2024 10:58:04 +0300 Subject: [PATCH] [PAC][clang] Add new features to pauthtest ABI Enable init/fi

[clang] [PAC][clang] Add new features to pauthtest ABI (PR #113150)

2024-12-16 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 updated https://github.com/llvm/llvm-project/pull/113150 >From 8384b1df4f7bbf454580b7486988e1808df9825d Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Mon, 21 Oct 2024 10:58:04 +0300 Subject: [PATCH] [PAC][clang] Add new features to pauthtest ABI Enable init/fi

[clang] [llvm] [PAC][ELF][AArch64] Support signed personality function pointer (PR #119361)

2024-12-15 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 closed https://github.com/llvm/llvm-project/pull/119361 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [PAC][ELF][AArch64] Support signed personality function pointer (PR #119361)

2024-12-15 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 updated https://github.com/llvm/llvm-project/pull/119361 >From 944b2f8fb6357c5ef9efbdaf0c2c3dcd8cb9f890 Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Tue, 10 Dec 2024 08:48:09 +0300 Subject: [PATCH 1/2] [PAC][ELF][AArch64] Support signed personality function p

[clang] [llvm] [PAC][ELF][AArch64] Support signed personality function pointer (PR #119361)

2024-12-10 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 ready_for_review https://github.com/llvm/llvm-project/pull/119361 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [PAC][ELF][AArch64] Support signed personality function pointer (PR #119361)

2024-12-10 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: @MaskRay Regarding your comment https://github.com/llvm/llvm-project/pull/113148#discussion_r1866992275: > We should add a subclass of MachineModuleInfoELF similar to > `AMDGPUMachineModuleInfo`, then move `HasSignedpersonality` there. Here you > can use a static_cast. Maybe

[clang] [llvm] [PAC][ELF][AArch64] Support signed personality function pointer (PR #119361)

2024-12-10 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 created https://github.com/llvm/llvm-project/pull/119361 Re-apply #113148 after revert in #119331 If function pointer signing is enabled, sign personality function pointer stored in `.DW.ref.__gxx_personality_v0` section with IA key, 0x7EAD = `ptrauth_string_discri

[clang] [llvm] Revert "[PAC][ELF][AArch64] Support signed personality function pointer" (PR #119331)

2024-12-09 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 ready_for_review https://github.com/llvm/llvm-project/pull/119331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Revert "[PAC][ELF][AArch64] Support signed personality function pointer" (PR #119331)

2024-12-09 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 closed https://github.com/llvm/llvm-project/pull/119331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Revert "[PAC][ELF][AArch64] Support signed personality function pointer" (PR #119331)

2024-12-09 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 created https://github.com/llvm/llvm-project/pull/119331 Reverts llvm/llvm-project#113148 See buildbot failure https://lab.llvm.org/buildbot/#/builders/190/builds/11048 >From 4fe98aa2253925a6bc24bd30f2c654756c77cc28 Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Dat

[clang] [llvm] [PAC][ELF][AArch64] Support signed personality function pointer (PR #113148)

2024-12-09 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 closed https://github.com/llvm/llvm-project/pull/113148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [PAC][ELF][AArch64] Support signed personality function pointer (PR #113148)

2024-12-08 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: @MaskRay Please let me know if latest changes fix your previous comments and if this could be merged. https://github.com/llvm/llvm-project/pull/113148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-b

[clang] [PAC][clang] Add new features to pauthtest ABI (PR #113150)

2024-12-07 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 updated https://github.com/llvm/llvm-project/pull/113150 >From 74814fd9424853399196b7d1e73f6171b0f1980b Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Mon, 21 Oct 2024 10:58:04 +0300 Subject: [PATCH] [PAC][clang] Add new features to pauthtest ABI Enable init/fi

[clang] [PAC][Driver] Add `-faarch64-jump-table-hardening` flag (PR #113149)

2024-12-05 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 closed https://github.com/llvm/llvm-project/pull/113149 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [PAC][clang] Add new features to pauthtest ABI (PR #113150)

2024-12-05 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 updated https://github.com/llvm/llvm-project/pull/113150 >From f670756ad5e120a3c81025565ab96c3aea12cd3e Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Mon, 21 Oct 2024 10:58:04 +0300 Subject: [PATCH] [PAC][clang] Add new features to pauthtest ABI Enable init/fi

  1   2   3   4   5   >