From 4d31a8d7d1543e608067724eb0dc28afdcda5ed4 Mon Sep 17 00:00:00 2001 From: Adam Gemmell Date: Thu, 11 Nov 2021 17:19:53 +0000 Subject: [PATCH] Split aarch64 `pauth` feature into `paca` and `pacg` and stabilise --- crates/std_detect/src/detect/arch/aarch64.rs | 9 ++++++--- crates/std_detect/src/detect/os/aarch64.rs | 4 ++++ crates/std_detect/src/detect/os/linux/aarch64.rs | 4 ++-- crates/std_detect/tests/cpu-detection.rs | 3 ++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/std_detect/src/detect/arch/aarch64.rs b/crates/std_detect/src/detect/arch/aarch64.rs index 5c3f604bea..5d2fb6d4d5 100644 --- a/crates/std_detect/src/detect/arch/aarch64.rs +++ b/crates/std_detect/src/detect/arch/aarch64.rs @@ -31,7 +31,8 @@ features! { /// * `"flagm"` - FEAT_FLAGM /// * `"ssbs"` - FEAT_SSBS /// * `"sb"` - FEAT_SB - /// * `"pauth"` - FEAT_PAuth + /// * `"paca"` - FEAT_PAuth (address authentication) + /// * `"pacg"` - FEAT_Pauth (generic authentication) /// * `"dpb"` - FEAT_DPB /// * `"dpb2"` - FEAT_DPB2 /// * `"sve2"` - FEAT_SVE2 @@ -101,8 +102,10 @@ features! { /// FEAT_SSBS (speculative store bypass safe) @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sb: "sb"; /// FEAT_SB (speculation barrier) - @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] pauth: "pauth"; - /// FEAT_PAuth (pointer authentication) + @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] paca: "paca"; + /// FEAT_PAuth (address authentication) + @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] pacg: "pacg"; + /// FEAT_PAuth (generic authentication) @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] dpb: "dpb"; /// FEAT_DPB (aka dcpop - data cache clean to point of persistence) @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] dpb2: "dpb2"; diff --git a/crates/std_detect/src/detect/os/aarch64.rs b/crates/std_detect/src/detect/os/aarch64.rs index 0fd2702731..169c51b961 100644 --- a/crates/std_detect/src/detect/os/aarch64.rs +++ b/crates/std_detect/src/detect/os/aarch64.rs @@ -87,7 +87,11 @@ pub(crate) fn detect_features() -> cache::Initializer { ); } + // Check for either APA or API field + enable_feature(Feature::paca, bits_shift(aa64isar1, 11, 4) >= 1); enable_feature(Feature::rcpc, bits_shift(aa64isar1, 23, 20) >= 1); + // Check for either GPA or GPI field + enable_feature(Feature::pacg, bits_shift(aa64isar1, 31, 24) >= 1); } value diff --git a/crates/std_detect/src/detect/os/linux/aarch64.rs b/crates/std_detect/src/detect/os/linux/aarch64.rs index 4dc6362057..b6a2e5218c 100644 --- a/crates/std_detect/src/detect/os/linux/aarch64.rs +++ b/crates/std_detect/src/detect/os/linux/aarch64.rs @@ -230,8 +230,8 @@ impl AtHwcap { enable_feature(Feature::flagm, self.flagm); enable_feature(Feature::ssbs, self.ssbs); enable_feature(Feature::sb, self.sb); - // FEAT_PAuth provides both paca & pacg - enable_feature(Feature::pauth, self.paca && self.pacg); + enable_feature(Feature::paca, self.paca); + enable_feature(Feature::pacg, self.pacg); enable_feature(Feature::dpb, self.dcpop); enable_feature(Feature::dpb2, self.dcpodp); enable_feature(Feature::rand, self.rng); diff --git a/crates/std_detect/tests/cpu-detection.rs b/crates/std_detect/tests/cpu-detection.rs index adbe4fa9a7..ca8bf28f44 100644 --- a/crates/std_detect/tests/cpu-detection.rs +++ b/crates/std_detect/tests/cpu-detection.rs @@ -55,7 +55,8 @@ fn aarch64_linux() { println!("flagm: {}", is_aarch64_feature_detected!("flagm")); println!("ssbs: {}", is_aarch64_feature_detected!("ssbs")); println!("sb: {}", is_aarch64_feature_detected!("sb")); - println!("pauth: {}", is_aarch64_feature_detected!("pauth")); + println!("paca: {}", is_aarch64_feature_detected!("paca")); + println!("pacg: {}", is_aarch64_feature_detected!("pacg")); println!("dpb: {}", is_aarch64_feature_detected!("dpb")); println!("dpb2: {}", is_aarch64_feature_detected!("dpb2")); println!("sve2: {}", is_aarch64_feature_detected!("sve2"));