Update cache util for new nightly

This commit is contained in:
Guillume DIDIER 2021-01-05 11:40:34 +01:00
parent b276f09d1e
commit d90d572bc9
5 changed files with 43 additions and 37 deletions

View File

@ -2,7 +2,7 @@ use cache_utils::flush;
use cache_utils::mmap::MMappedMemory;
pub fn main() {
let m = MMappedMemory::new(2 << 20);
let m = MMappedMemory::new(2 << 20, true);
let array = m.slice();
loop {
unsafe {

View File

@ -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)
}

View File

@ -24,6 +24,9 @@ use std::sync::Arc;
#[cfg(feature = "use_std")]
use std::thread;
#[cfg(feature = "use_std")]
pub use crate::calibrate_2t::*;
extern crate alloc;
use crate::calibration::Verbosity::*;
use alloc::vec;
@ -37,9 +40,9 @@ use atomic::Atomic;
use core::hash::Hash;
use core::ops::{Add, AddAssign};
#[cfg(feature = "no_std")]
use hashbrown::HashMap;
pub use hashbrown::HashMap;
#[cfg(feature = "use_std")]
use std::collections::HashMap;
pub use std::collections::HashMap;
#[derive(Ord, PartialOrd, Eq, PartialEq)]
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>
where
K: Hash + Eq,

View File

@ -21,6 +21,9 @@ pub mod prefetcher;
pub mod frequency;
#[cfg(feature = "use_std")]
mod calibrate_2t;
use core::arch::x86_64 as arch_x86;
use core::ptr;

View File

@ -4,7 +4,6 @@
//fn execute_on_core(FnOnce)
#![feature(vec_resize_default)]
use cache_utils::calibration::calibrate_flush;
use cache_utils::calibration::Verbosity;
@ -35,7 +34,7 @@ struct Page {
}
*/
pub fn main() {
let m = MMappedMemory::new(SIZE);
let m = MMappedMemory::new(SIZE, true);
let array = m.slice();
let old = sched_getaffinity(Pid::from_raw(0)).unwrap();