-
Notifications
You must be signed in to change notification settings - Fork 289
std_detect: Support run-time detection on aarch64 OpenBSD #1374
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
Conversation
r? @Amanieu (rustbot has picked a reviewer for you, use r? to override) |
crates/std_detect/src/detect/mod.rs
Outdated
@@ -56,6 +56,12 @@ cfg_if! { | |||
mod aarch64; | |||
#[path = "os/freebsd/mod.rs"] | |||
mod os; | |||
} else if #[cfg(all(target_os = "openbsd", target_arch = "aarch64", feature = "libc"))] { | |||
#[allow(dead_code)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That module has code that calls the mrs instruction, but it is not used on OpenBSD.
Added a comment mentioning it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks fine to me.
bbba57f
to
fb30f62
Compare
fb30f62
to
7e9e266
Compare
64: detect: Support run-time detection of FEAT_LSE on aarch64 OpenBSD r=taiki-e a=taiki-e As of nightly-2023-01-23, is_aarch64_feature_detected doesn't support run-time detection of FEAT_LSE on OpenBSD. This patch also supports run-time detection of FEAT_LSE on aarch64 FreeBSD without "std" feature. This patch also adds preliminary support for run-time detection of FEAT_LSE2 and FEAT_LSE128. This is currently only used in tests but will be used in the library in the future. ~~As well as #63, I will send a patch to stdarch later.~~ Filed rust-lang/stdarch#1374. Co-authored-by: Taiki Endo <[email protected]>
OpenBSD doesn't trap the mrs instruction, but exposes the system registers through sysctl.
openbsd/src@d335af9
So, we can support run-time detection using the register parsing code in os/aarch64.rs (currently used on aarch64 FreeBSD) and sysctl. (See also go's patch that does the same thing as this patch: golang/go@cd54ef1. See also OpenBSD libcrypto patch: openbsd/src@be689f1.)
Tested on aarch64 OpenBSD VM 7.2-current/7.2-stable/7.1-stable.
The following screenshot is from a test on 7.2-current:
On 7.2-stable/7.1-stable, the features referring to ID_AA64PFR0_EL1 returns false because the patch that supports ID_AA64PFR0_EL1 (openbsd/src@c7654cd) is not included: