Update cache util for new nightly
This commit is contained in:
parent
b276f09d1e
commit
d90d572bc9
@ -2,7 +2,7 @@ use cache_utils::flush;
|
|||||||
use cache_utils::mmap::MMappedMemory;
|
use cache_utils::mmap::MMappedMemory;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let m = MMappedMemory::new(2 << 20);
|
let m = MMappedMemory::new(2 << 20, true);
|
||||||
let array = m.slice();
|
let array = m.slice();
|
||||||
loop {
|
loop {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
use crate::calibration::{CalibrateResult, CalibrateResult2T, HashMap, ASVP};
|
||||||
|
|
||||||
|
pub fn calibration_result_to_ASVP<T, Analysis: Fn(CalibrateResult) -> T>(
|
||||||
|
results: Vec<CalibrateResult2T>,
|
||||||
|
analysis: Analysis,
|
||||||
|
slicing: &impl Fn(usize) -> u8,
|
||||||
|
) -> Result<HashMap<ASVP, T>, nix::Error> {
|
||||||
|
let mut analysis_result: HashMap<ASVP, T> = HashMap::new();
|
||||||
|
for calibrate_2t_result in results {
|
||||||
|
let attacker = calibrate_2t_result.main_core;
|
||||||
|
let victim = calibrate_2t_result.helper_core;
|
||||||
|
match calibrate_2t_result.res {
|
||||||
|
Err(e) => return Err(e),
|
||||||
|
Ok(calibrate_1t_results) => {
|
||||||
|
for result_1t in calibrate_1t_results {
|
||||||
|
let offset = result_1t.offset;
|
||||||
|
let page = result_1t.page;
|
||||||
|
let addr = page + offset as usize;
|
||||||
|
let slice = slicing(addr as usize);
|
||||||
|
let analysed = analysis(result_1t);
|
||||||
|
let asvp = ASVP {
|
||||||
|
attacker,
|
||||||
|
slice,
|
||||||
|
victim,
|
||||||
|
page,
|
||||||
|
};
|
||||||
|
analysis_result.insert(asvp, analysed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(analysis_result)
|
||||||
|
}
|
@ -24,6 +24,9 @@ use std::sync::Arc;
|
|||||||
#[cfg(feature = "use_std")]
|
#[cfg(feature = "use_std")]
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
|
#[cfg(feature = "use_std")]
|
||||||
|
pub use crate::calibrate_2t::*;
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use crate::calibration::Verbosity::*;
|
use crate::calibration::Verbosity::*;
|
||||||
use alloc::vec;
|
use alloc::vec;
|
||||||
@ -37,9 +40,9 @@ use atomic::Atomic;
|
|||||||
use core::hash::Hash;
|
use core::hash::Hash;
|
||||||
use core::ops::{Add, AddAssign};
|
use core::ops::{Add, AddAssign};
|
||||||
#[cfg(feature = "no_std")]
|
#[cfg(feature = "no_std")]
|
||||||
use hashbrown::HashMap;
|
pub use hashbrown::HashMap;
|
||||||
#[cfg(feature = "use_std")]
|
#[cfg(feature = "use_std")]
|
||||||
use std::collections::HashMap;
|
pub use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Ord, PartialOrd, Eq, PartialEq)]
|
#[derive(Ord, PartialOrd, Eq, PartialEq)]
|
||||||
pub enum Verbosity {
|
pub enum Verbosity {
|
||||||
@ -1576,38 +1579,6 @@ impl Threshold {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn calibration_result_to_ASVP<T, Analysis: Fn(CalibrateResult) -> T>(
|
|
||||||
results: Vec<CalibrateResult2T>,
|
|
||||||
analysis: Analysis,
|
|
||||||
slicing: &impl Fn(usize) -> u8,
|
|
||||||
) -> Result<HashMap<ASVP, T>, nix::Error> {
|
|
||||||
let mut analysis_result: HashMap<ASVP, T> = HashMap::new();
|
|
||||||
for calibrate_2t_result in results {
|
|
||||||
let attacker = calibrate_2t_result.main_core;
|
|
||||||
let victim = calibrate_2t_result.helper_core;
|
|
||||||
match calibrate_2t_result.res {
|
|
||||||
Err(e) => return Err(e),
|
|
||||||
Ok(calibrate_1t_results) => {
|
|
||||||
for result_1t in calibrate_1t_results {
|
|
||||||
let offset = result_1t.offset;
|
|
||||||
let page = result_1t.page;
|
|
||||||
let addr = page + offset as usize;
|
|
||||||
let slice = slicing(addr as usize);
|
|
||||||
let analysed = analysis(result_1t);
|
|
||||||
let asvp = ASVP {
|
|
||||||
attacker,
|
|
||||||
slice,
|
|
||||||
victim,
|
|
||||||
page,
|
|
||||||
};
|
|
||||||
analysis_result.insert(asvp, analysed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(analysis_result)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn map_values<K, U, V, F>(input: HashMap<K, U>, f: F) -> HashMap<K, V>
|
pub fn map_values<K, U, V, F>(input: HashMap<K, U>, f: F) -> HashMap<K, V>
|
||||||
where
|
where
|
||||||
K: Hash + Eq,
|
K: Hash + Eq,
|
||||||
|
@ -21,6 +21,9 @@ pub mod prefetcher;
|
|||||||
|
|
||||||
pub mod frequency;
|
pub mod frequency;
|
||||||
|
|
||||||
|
#[cfg(feature = "use_std")]
|
||||||
|
mod calibrate_2t;
|
||||||
|
|
||||||
use core::arch::x86_64 as arch_x86;
|
use core::arch::x86_64 as arch_x86;
|
||||||
use core::ptr;
|
use core::ptr;
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
//fn execute_on_core(FnOnce)
|
//fn execute_on_core(FnOnce)
|
||||||
|
|
||||||
#![feature(vec_resize_default)]
|
|
||||||
|
|
||||||
use cache_utils::calibration::calibrate_flush;
|
use cache_utils::calibration::calibrate_flush;
|
||||||
use cache_utils::calibration::Verbosity;
|
use cache_utils::calibration::Verbosity;
|
||||||
@ -35,7 +34,7 @@ struct Page {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let m = MMappedMemory::new(SIZE);
|
let m = MMappedMemory::new(SIZE, true);
|
||||||
let array = m.slice();
|
let array = m.slice();
|
||||||
|
|
||||||
let old = sched_getaffinity(Pid::from_raw(0)).unwrap();
|
let old = sched_getaffinity(Pid::from_raw(0)).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user