Skip to content

Keep ARMv8.3+ code out of SimSIMD instead of disabling branch protection - #33

Merged
Algunenano merged 1 commit into
ClickHouse/v6.5.15from
pac-ret-without-arch-bump
Nov 16, 2026
Merged

Algunenano merged 1 commit into
ClickHouse/v6.5.15from
pac-ret-without-arch-bump

Conversation

@Algunenano

Copy link
Copy Markdown
Member

#32 avoided retaa (SIGILL on cores without FEAT_PAuth, such as Graviton2 and Ampere Altra) by adding branch-protection=none to the ARMv8.3+ targets, which left those functions unsigned under -mbranch-protection=pac-ret. This fixes the root cause instead, so that every function stays signed:

  • _simsimd_capabilities_arm was compiled for arch=armv8.5-a+sve only so that the assembler accepts mrs ..., ID_AA64ZFR0_EL1. It now reads the register by its encoding, S3_0_C0_C4_4, and the target block is gone.
  • The bf16 kernels need the features, not the architecture bump: +simd+bf16 and +sve+sve2+bf16 replace arch=armv8.6-a+....

Verification with ClickHouse master plus this change:

  • c/lib.c: with the arm_release flags it has 0 retaa and 104 signed functions (with Do not sign return addresses in functions built for ARMv8.3 and later #32 it had 102 of 109 signed).
  • Full ClickHouse binary (RelWithDebInfo, and ThinLTO built like arm_release): it links without -Wpass-failed. A full disassembly finds no retaa/retab and no other PAuth instruction outside the HINT space.
  • Neoverse N1 (Graviton2): both binaries run natively. That covers server start, a bf16 HNSW vector index, cosineDistance/L2Distance, stack traces and the query profiler. A control binary containing retaa dies with SIGILL on the same machine.
  • Neoverse V2: the same queries pass, and here the probe takes the SVE path that reads S3_0_C0_C4_4.

Related: ClickHouse/ClickHouse#131748
Related: ClickHouse/ClickHouse#131784
Related: #32
Related: https://github.com/ClickHouse/clickhouse-private/issues/86596#issuecomment-6913945178

🤖 Generated with Claude Code

The previous fix (#32) added `branch-protection=none` to the targets of ARMv8.3 and later, because
in such functions the compiler folds `autiasp; ret` into `retaa`, which raises SIGILL on cores
without `FEAT_PAuth` (Graviton2, Ampere Altra). That left these functions without return address
signing. Fix the root cause instead:

- `_simsimd_capabilities_arm` was compiled for `arch=armv8.5-a+sve` only so that the assembler
  accepts `mrs ..., ID_AA64ZFR0_EL1`. Read the register by its encoding `S3_0_C0_C4_4` and drop
  the `target` block.
- The bf16 kernels only need the features, not the architecture bump: use `+simd+bf16` and
  `+sve+sve2+bf16` instead of `arch=armv8.6-a+...`.

All functions are signed again under `-mbranch-protection=pac-ret`, and the ClickHouse binary
contains no `retaa`/`retab` or other non-`HINT` PAuth instructions. Verified on Neoverse N1
(Graviton2) and Neoverse V2.

See ClickHouse/ClickHouse#131748
Related: #32

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Algunenano
Algunenano merged commit 3768ac5 into ClickHouse/v6.5.15 Nov 16, 2026
alexey-milovidov pushed a commit to groeneai/ClickHouse that referenced this pull request Nov 17, 2026
…h protection

Bumps `contrib/SimSIMD` to the merge of ClickHouse/SimSIMD#33. The CPU
probe `_simsimd_capabilities_arm` reads `ID_AA64ZFR0_EL1` by its encoding instead of being
compiled for `arch=armv8.5-a+sve`, and the bf16 kernels use `+simd+bf16` / `+sve+sve2+bf16`
instead of `arch=armv8.6-a+...`. Nothing in `SimSIMD` is compiled for ARMv8.3 or later anymore,
so it no longer needs `branch-protection=none` and all of its functions are signed under
`-mbranch-protection=pac-ret`, without `retaa` that would raise SIGILL on cores without
`FEAT_PAuth`.

The bump also brings ClickHouse/SimSIMD#30 (typed kernel dispatch).

Related: ClickHouse/SimSIMD#33
Related: ClickHouse#131748
Related: ClickHouse#131784

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant