Skip to content

Tidy up aarch64 feature detection code in armcap.c - #20305

Closed
tom-cosgrove-arm wants to merge 1 commit into
openssl:masterfrom
tom-cosgrove-arm:issue-20188-armcap-tidy
Closed

tom-cosgrove-arm wants to merge 1 commit into
openssl:masterfrom
tom-cosgrove-arm:issue-20188-armcap-tidy

Conversation

@tom-cosgrove-arm

@tom-cosgrove-arm tom-cosgrove-arm commented Feb 16, 2023 •

Copy link
Copy Markdown
Contributor

Make the SIGILL-based code easier to read, and don't use it on Apple Silicon.

Also fix "error: 'HWCAP(2)_*' macro redefined" warnings on FreeBSD.

Fixes #20188

Much of the code is just moved, but on Apple Silicon we no longer fall through to the SIGILL detection, instead setting those bits that we know will be present, and (continuing) to detect the rest via sysctl().

The SIGILL probing has been refactored to make it (hopefully) simpler to read.

Tested on various systems (Ubuntu, Darwin, FreeBSD) and verified we got the same results before and after.

Note: something that came out of this is that the SIGILL detection for aarch64 RNG doesn't work - we'll look at this later.

Checklist

(none applicable)

Make the SIGILL-based code easier to read, and don't use it on Apple Silicon.

Also fix "error: 'HWCAP(2)_*' macro redefined" warnings on FreeBSD.

Fixes openssl#20188

Change-Id: I5618bbe9444cc40cb5705c6ccbdc331c16bab794
@zorrorffm

Copy link
Copy Markdown
Contributor

This patch has been reviewed internally, it looks good to me.

@paulidale

Copy link
Copy Markdown
Contributor

Is it feasible to drop the SIGILL probing entirely?
I'm guessing not but it would be nice in an ideal world.

@paulidale paulidale added branch: master Applies to master branch approval: review pending This pull request needs review by a committer labels Feb 20, 2023
@tom-cosgrove-arm

Copy link
Copy Markdown
Contributor Author

Is it feasible to drop the SIGILL probing entirely?

The SIGILL probing works (tested on Ubuntu, anyway) and is only used as a compile-time fallback. It's not used if there's another way to get the information: i.e. not used on Windows (where IsProcessorFeaturePresent() is used), macOS, iOS, and anywhere there's getauxval(). But if we don't have any of those, it's the only way to get the info. And with this change it's an either/or, so it shouldn't break anything that would otherwise work.

Regarding the "big.LITTLE" problem: I asked this ages ago, and have been trying to find a reference, but basically there is a recommendation to pair architecturally compatible cores, so in (best) practice this shouldn't be an issue.

@tom-cosgrove-arm

Copy link
Copy Markdown
Contributor Author

Ping for a second reviewer?

@t8m t8m added triaged: refactor The issue/pr requests/implements refactoring tests: exempted The PR is exempt from requirements for testing labels Mar 1, 2023
@t8m t8m added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Mar 1, 2023
@openssl-machine openssl-machine added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Mar 2, 2023
@openssl-machine

Copy link
Copy Markdown
Collaborator

This pull request is ready to merge

@paulidale

Copy link
Copy Markdown
Contributor

Merged, thanks for the contribution.

@paulidale paulidale closed this Mar 2, 2023
openssl-machine pushed a commit that referenced this pull request Mar 2, 2023
Make the SIGILL-based code easier to read, and don't use it on Apple Silicon.

Also fix "error: 'HWCAP(2)_*' macro redefined" warnings on FreeBSD.

Fixes #20188

Change-Id: I5618bbe9444cc40cb5705c6ccbdc331c16bab794

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from #20305)
oraluben pushed a commit to oraluben/openssl that referenced this pull request May 12, 2023
Make the SIGILL-based code easier to read, and don't use it on Apple Silicon.

Also fix "error: 'HWCAP(2)_*' macro redefined" warnings on FreeBSD.

Fixes openssl#20188

Change-Id: I5618bbe9444cc40cb5705c6ccbdc331c16bab794

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20305)

(cherry picked from commit openssl@52a3814)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Applies to master branch tests: exempted The PR is exempt from requirements for testing triaged: refactor The issue/pr requests/implements refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Arm feature detection on Apple platforms should use sysctlbyname

5 participants