-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zeroize: add support for ARM64 SIMD registers (nightly-only) (#749)
Similar to the implementation for `x86`/`x86_64`, this commit adds nightly-only support for zeroizing ARM64 SIMD registers. Support is gated behind an `aarch64` feature so as to avoid breaking compilation on stable Rust. The feature is a no-op on non-`aarch64` targets.
- Loading branch information
Showing
4 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//! [`Zeroize`] impls for ARM64 SIMD registers. | ||
//! | ||
//! Support for this is gated behind an `aarch64` feature because | ||
//! support for `core::arch::aarch64` is currently nightly-only. | ||
|
||
use crate::{atomic_fence, volatile_write, Zeroize}; | ||
|
||
use core::arch::aarch64::*; | ||
|
||
macro_rules! impl_zeroize_for_simd_register { | ||
($(($type:ty, $vdupq:ident)),+) => { | ||
$( | ||
#[cfg_attr(docsrs, doc(cfg(target_arch = "aarch64")))] | ||
#[cfg_attr(docsrs, doc(cfg(target_feature = "neon")))] | ||
impl Zeroize for $type { | ||
fn zeroize(&mut self) { | ||
volatile_write(self, unsafe { $vdupq(0) }); | ||
atomic_fence(); | ||
} | ||
} | ||
)+ | ||
}; | ||
} | ||
|
||
// TODO(tarcieri): other NEON register types? | ||
impl_zeroize_for_simd_register! { | ||
(uint8x8_t, vdup_n_u8), | ||
(uint8x16_t, vdupq_n_u8), | ||
(uint16x4_t, vdup_n_u16), | ||
(uint16x8_t, vdupq_n_u16), | ||
(uint32x2_t, vdup_n_u32), | ||
(uint32x4_t, vdupq_n_u32), | ||
(uint64x1_t, vdup_n_u64), | ||
(uint64x2_t, vdupq_n_u64) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters