Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpufeatures: Support dynamic feature detection on iOS and derivative platforms #848

Merged

Conversation

complexspaces
Copy link
Contributor

This PR adds support for dynamic feature detection on iOS, watchOS, and tvOS, bringing full support to all of Apple's platforms and following up #435.

I'm not entirely sure what the previous comment about lack of sysctl(3) support meant, FWIW. iOS supports the same kernel calls that macOS does (for the most part, but especially low-level ones like this) because they're based on the same kernel and, more importantly, the function appears in the public headers inside each platform's SDK.

To confirm/prove that there wasn't any problematic filtering occurring on iOS, I ran these changes on both the iOS simulator and on a real device (iPad Pro 3rd gen). The results make sense AFAICT because this specific model runs a full-fledged M1 processor in it.

Test code:

cpufeatures::new!(armcaps, "aes", "sha2", "sha3");

let feature_set = armcaps::init();
if feature_set.get() {
    log::info!("we had support for AES, SHA2, and SHA3 instructions")
} else {
   log::info!("no support for SHA3");
}

Results in iOS simulator:

INFO  2023-03-16T22:20:04.778 ThreadId(1) we had support for AES, SHA2, and SHA3 instructions

Results on physical device:

INFO  2023-03-16T22:33:11.875 ThreadId(1) we had support for AES, SHA2, and SHA3 instructions

@complexspaces complexspaces force-pushed the improved-apple-platform-support branch from c9c6782 to bce55df Compare March 16, 2023 22:57
@tarcieri
Copy link
Member

#378 was the previous issue discussing this

@complexspaces
Copy link
Contributor Author

I read through that issue, but I didn't see any specific mention of iOS unavailability (nor the PR I linked beyond the same comment that existed in the code). Did I miss something in that issue?

@tarcieri
Copy link
Member

Re-reviewing #378 I agree.

If it works that's great, but I have no way of confirming.

Is there any way of adding CI support?

@complexspaces
Copy link
Contributor Author

Is there any way of adding CI support?

That's a good question. I don't know if there's actually a way to test this implementation today with GitHub Actions as they don't yet offer hosted M1 runners (Rust is also waiting on this). Without those, there's no way to run the aarch64-apple-ios-sim simulator via XCode.

If it works that's great, but I have no way of confirming.

Is this something you would consider a blocker for merging? I can attempt to collect a more live demo if it would be considered useful.

@tarcieri
Copy link
Member

I can go ahead and merge this and we can see if complaints pop up or not.

@tarcieri tarcieri merged commit 0642706 into RustCrypto:master Mar 18, 2023
@complexspaces complexspaces deleted the improved-apple-platform-support branch March 22, 2023 19:58
@tarcieri tarcieri mentioned this pull request Mar 25, 2023
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.

None yet

2 participants