8000 Arm feature detection on Apple platforms should use sysctlbyname · Issue #20188 · openssl/openssl · GitHub
[go: up one dir, main page]

Skip to content
Arm feature detection on Apple platforms should use sysctlbyname #20188
@davidben

Description

@davidben

As discussed in #14838, the SIGILL-based feature detection that OpenSSL uses on Arm is incorrect and causes problems. On Apple platforms, the API to use is sysctlbyname:
https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics

OpenSSL broadly uses sysctlbyname, but still runs the probing mechanism on Apple platforms. It just happens to filter out the not-always-available features on this line:

# if defined(__aarch64__) && !defined(__APPLE__)

But then later PRs regressed this by not similarly guarding such features: #17916 and #15361. I ran into this because OpenSSL's regression here seems to interfere with debugging things on macOS with lldb, but the SIGILL mechanism is also not thread-safe.

But that limited __APPLE__ guard is also the wrong way to do this. Instead one should completely disable the SIGILL mechanism on platforms where a real API is available. Indeed, as it's not thread-safe, best not to have it at all and just use the correct APIs on all platforms, combined with the preprocessor defines from ACLE to handle always-available features since older Apple platforms didn't provide runtime detection for such features. (BoringSSL handles all its detection without SIGILL.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0