Skip to content

Commit

Permalink
Add aarch64 optimise_barrier
Browse files Browse the repository at this point in the history
  • Loading branch information
ctz committed Oct 12, 2024
1 parent 5a7fae0 commit b158c68
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions graviola/src/low/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub(crate) mod cpu;
pub(crate) mod curve25519_x25519;
pub(crate) mod curve25519_x25519base;
pub(crate) mod ghash;
pub(crate) mod optimise_barrier;
pub(crate) mod p256_montjadd;
pub(crate) mod p256_montjdouble;
pub(crate) mod p256_montjmixadd;
Expand Down
14 changes: 14 additions & 0 deletions graviola/src/low/aarch64/optimise_barrier.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT-0

pub fn optimise_barrier_u8(v: u8) -> u8 {
let ret: u8;
// SAFETY: inline assembly, which does nothing but block the optimiser
// from seeing the data dependency between `v` and `ret`.
unsafe {
core::arch::asm!(
"/* {v:w} */",
v = inout(reg) v => ret,
)
};
ret
}
10 changes: 0 additions & 10 deletions graviola/src/low/generic/optimise_barrier.rs

This file was deleted.

4 changes: 1 addition & 3 deletions graviola/src/low/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ mod generic {
pub(super) mod ct_equal;
#[cfg(test)]
pub(crate) mod ghash;
#[cfg(target_arch = "aarch64")]
pub(super) mod optimise_barrier;
pub(crate) mod poly1305;
pub(super) mod sha256;
pub(super) mod sha512;
Expand Down Expand Up @@ -152,11 +150,11 @@ cfg_if::cfg_if! {
pub(crate) use aarch64::p384_montjadd::p384_montjadd;
pub(crate) use aarch64::p384_montjdouble::p384_montjdouble;
pub(crate) use aarch64::sha256::sha256_compress_blocks;
pub(crate) use aarch64::optimise_barrier::optimise_barrier_u8;

pub(crate) use generic::chacha20;
pub(crate) use generic::aes_gcm;
pub(crate) use generic::sha512::sha512_compress_blocks;
pub(crate) use generic::optimise_barrier::optimise_barrier_u8;
} else {
compile_error!("This crate only supports x86_64 or aarch64");
}
Expand Down

0 comments on commit b158c68

Please sign in to comment.