Reproduce the pattern from the other paper
This commit is contained in:
parent
3f0f12d118
commit
84cf28f21c
@ -149,7 +149,7 @@ impl<T: TimingChannelPrimitives> NaiveTimingChannel<T> {
|
||||
addresses: &mut Vec<&mut NaiveTimingChannelHandle>,
|
||||
limit: u32,
|
||||
) -> Result<(), SideChannelError> {
|
||||
// Iterate on addresse prparig them, error early exit
|
||||
// Iterate on addresses preparing them, error early exit
|
||||
let mut i = 0;
|
||||
for handle in addresses {
|
||||
match unsafe { self.prepare_one_impl(handle) } {
|
||||
|
37
prefetcher_reverse/src/bin/rpa_patterns.rs
Normal file
37
prefetcher_reverse/src/bin/rpa_patterns.rs
Normal file
@ -0,0 +1,37 @@
|
||||
#![deny(unsafe_op_in_unsafe_fn)]
|
||||
use basic_timing_cache_channel::TopologyAwareError;
|
||||
use cache_side_channel::CacheStatus::Hit;
|
||||
use cache_side_channel::{
|
||||
set_affinity, ChannelHandle, CoreSpec, MultipleAddrCacheSideChannel, SingleAddrCacheSideChannel,
|
||||
};
|
||||
use cache_utils::calibration::PAGE_LEN;
|
||||
use cache_utils::maccess;
|
||||
use cache_utils::mmap;
|
||||
use cache_utils::mmap::MMappedMemory;
|
||||
use flush_flush::{FFHandle, FFPrimitives, FlushAndFlush};
|
||||
use nix::Error;
|
||||
use prefetcher_reverse::{reference_patterns, Prober, CACHE_LINE_LEN, PAGE_CACHELINE_LEN};
|
||||
use rand::seq::SliceRandom;
|
||||
use std::iter::Cycle;
|
||||
use std::ops::Range;
|
||||
|
||||
pub const NUM_ITERATION: usize = 1 << 10;
|
||||
pub const NUM_PAGES: usize = 256;
|
||||
|
||||
fn exp(delay: u64) {
|
||||
for (name, pattern) in reference_patterns() {
|
||||
let mut prober = Prober::new(63).unwrap();
|
||||
prober.set_delay(delay);
|
||||
|
||||
println!("{}", name);
|
||||
let result = prober.full_page_probe(pattern, NUM_ITERATION as u32, 100);
|
||||
println!("{}", result);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
for delay in [0, 5, 10, 50] {
|
||||
println!("Delay after each access: {} us", delay);
|
||||
exp(delay);
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ use rand::seq::SliceRandom;
|
||||
use std::fmt::{Display, Error, Formatter};
|
||||
use std::iter::{Cycle, Peekable};
|
||||
use std::ops::Range;
|
||||
use std::{thread, time};
|
||||
|
||||
// NB these may need to be changed / dynamically measured.
|
||||
pub const CACHE_LINE_LEN: usize = 64;
|
||||
@ -30,6 +31,7 @@ pub struct Prober {
|
||||
ff_channel: FlushAndFlush,
|
||||
fr_channel: FlushAndReload,
|
||||
//fr_channel: NaiveFlushAndReload,
|
||||
delay: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
@ -133,6 +135,9 @@ fn max_stride(offset: usize, len: usize) -> (isize, isize) {
|
||||
}
|
||||
|
||||
impl Prober {
|
||||
// turn page into page groups, which can vary in size.
|
||||
// calibrate on all pages in a group with offsets within the groups.
|
||||
// keep track of the max offset
|
||||
pub fn new(num_pages: usize) -> Result<Prober, ProberError> {
|
||||
let mut vec = Vec::new();
|
||||
let mut handles = Vec::new();
|
||||
@ -195,9 +200,14 @@ impl Prober {
|
||||
page_indexes,
|
||||
ff_channel,
|
||||
fr_channel,
|
||||
delay: 0,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_delay(&mut self, delay: u64) {
|
||||
self.delay = delay;
|
||||
}
|
||||
|
||||
/*
|
||||
fn probe(&mut self, probe_type: Probe, offset: usize) -> CacheStatus {
|
||||
let page_index = self.page_indexes.peek().unwrap();
|
||||
@ -234,7 +244,10 @@ impl Prober {
|
||||
let mut pattern_res = vec![CacheStatus::Miss; pattern.pattern.len()];
|
||||
for (i, offset) in pattern.pattern.iter().enumerate() {
|
||||
let h = &mut self.fr_handles[page_index][*offset];
|
||||
pattern_res[i] = unsafe { self.fr_channel.test_single(h, false) }.unwrap()
|
||||
pattern_res[i] = unsafe { self.fr_channel.test_single(h, false) }.unwrap();
|
||||
if self.delay > 0 {
|
||||
thread::sleep(time::Duration::from_nanos(self.delay)); // FIXME parameter magic
|
||||
}
|
||||
//pattern_res[i] = unsafe { self.fr_channel.test_single(h, false) }.unwrap()
|
||||
//pattern_res[i] = Miss;
|
||||
//unsafe { only_reload(h.to_const_u8_pointer()) };
|
||||
@ -500,3 +513,17 @@ impl Display for FullPageDualProbeResults {
|
||||
write!(f, "Num_iteration: {}", self.num_iteration)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reference_patterns() -> [(&'static str, Vec<usize>); 9] {
|
||||
[
|
||||
("Pattern 1", vec![0, 1, 2, 3]),
|
||||
("Pattern 2", vec![0, 1]),
|
||||
("Pattern 3", vec![0, 19]),
|
||||
("Pattern 4 (I)", vec![0, 1, 2, 44]),
|
||||
("Pattern 4 (II)", vec![63, 62, 61, 19]),
|
||||
("Pattern 5 (I)", vec![0, 1, 2, 63, 62, 44]),
|
||||
("Pattern 5 (II)", vec![63, 62, 61, 0, 1, 2, 19]),
|
||||
("Pattern 5 (III)", vec![63, 62, 61, 0, 1, 2, 44]),
|
||||
("Pattern 5 (IV)", vec![0, 1, 2, 63, 62, 61, 19]),
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user