[all-commits] [llvm/llvm-project] 609650: PR 93902: [Support] Add SipHash-based 16-bit ptrau...
Ahmed Bougacha via All-commits
all-commits at lists.llvm.org
Tue Jun 4 13:03:41 PDT 2024
Branch: refs/heads/users/ahmedbougacha/expose-siphash-ptrauth-wrapper
Home: https://github.com/llvm/llvm-project
Commit: 609650c163ad3649300ff95ec585f13fac93321e
https://github.com/llvm/llvm-project/commit/609650c163ad3649300ff95ec585f13fac93321e
Author: Ahmed Bougacha <ahmed at bougacha.org>
Date: 2024-06-04 (Tue, 04 Jun 2024)
Changed paths:
A llvm/include/llvm/Support/SipHash.h
M llvm/lib/Support/SipHash.cpp
M llvm/unittests/Support/CMakeLists.txt
A llvm/unittests/Support/SipHashTest.cpp
Log Message:
-----------
PR 93902: [Support] Add SipHash-based 16-bit ptrauth stable hash.
This finally wraps the now-lightly-modified SipHash C reference
implementation, for the main interface we need (16-bit ptrauth
discriminators).
This intentionally doesn't expose a raw interface beyond that to
encourage others to carefully consider their use.
The exact algorithm is the little-endian interpretation of the
non-doubled (i.e. 64-bit) result of applying a SipHash-2-4 using the
constant seed `b5d4c9eb79104a796fec8b1b428781d4` (big-endian), with the
result reduced by modulo to the range of non-zero discriminators (i.e.
`(rawHash % 65535) + 1`).
By "stable" we mean that the result of this hash algorithm will the same
across different compiler versions and target platforms.
The 16-bit hashes are used extensively for the AArch64 ptrauth ABI,
because AArch64 can efficiently load a 16-bit immediate into the high
bits of a register without disturbing the remainder of the value, which
serves as a nice blend operation.
16 bits is also sufficiently compact to not inflate a loader relocation.
We disallow zero to guarantee a different discriminator from the places
in the ABI that use a constant zero.
Co-Authored-By: John McCall <rjmccall at apple.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list