Hotfix naive basic timing cache channel for use in prefetcher experiments
This commit is contained in:
parent
b7b5cbbfc3
commit
28f75075e3
@ -41,6 +41,7 @@ pub trait TimingChannelPrimitives: Debug + Send + Sync + Default {
|
|||||||
const NEED_RESET: bool;
|
const NEED_RESET: bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct TopologyAwareTimingChannelHandle {
|
pub struct TopologyAwareTimingChannelHandle {
|
||||||
threshold: Threshold,
|
threshold: Threshold,
|
||||||
vpn: VPN,
|
vpn: VPN,
|
||||||
@ -204,7 +205,7 @@ impl<T: TimingChannelPrimitives> TopologyAwareTimingChannel<T> {
|
|||||||
Ok(asvp_best_av_errors)
|
Ok(asvp_best_av_errors)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_core_pairs(
|
pub fn new_with_core_pairs(
|
||||||
core_pairs: impl Iterator<Item = (usize, usize)> + Clone,
|
core_pairs: impl Iterator<Item = (usize, usize)> + Clone,
|
||||||
) -> Result<(Self, usize, usize), TopologyAwareError> {
|
) -> Result<(Self, usize, usize), TopologyAwareError> {
|
||||||
let m = MMappedMemory::new(PAGE_LEN, false);
|
let m = MMappedMemory::new(PAGE_LEN, false);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::TimingChannelPrimitives;
|
use crate::TimingChannelPrimitives;
|
||||||
use cache_side_channel::{
|
use cache_side_channel::{
|
||||||
CacheStatus, ChannelFatalError, ChannelHandle, CoreSpec, SideChannelError,
|
CacheStatus, ChannelFatalError, ChannelHandle, CoreSpec, MultipleAddrCacheSideChannel,
|
||||||
SingleAddrCacheSideChannel,
|
SideChannelError, SingleAddrCacheSideChannel,
|
||||||
};
|
};
|
||||||
use cache_utils::calibration::{get_vpn, only_flush, only_reload, HashMap, Threshold, VPN};
|
use cache_utils::calibration::{get_vpn, only_flush, only_reload, HashMap, Threshold, VPN};
|
||||||
use cache_utils::flush;
|
use cache_utils::flush;
|
||||||
@ -58,16 +58,17 @@ impl<T: TimingChannelPrimitives> NaiveTimingChannel<T> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
handle: NaiveTimingChannelHandle,
|
handle: NaiveTimingChannelHandle,
|
||||||
) -> Result<*const u8, ChannelFatalError> {
|
) -> Result<*const u8, ChannelFatalError> {
|
||||||
if let Some(addr) = self.current.remove(&handle.vpn) {
|
//if let Some(addr) = self.current.remove(&handle.vpn) {
|
||||||
Ok(addr)
|
Ok(addr)
|
||||||
} else {
|
//} else {
|
||||||
Err(ChannelFatalError::Oops)
|
// Err(ChannelFatalError::Oops)
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn test_impl(
|
unsafe fn test_impl(
|
||||||
&self,
|
&self,
|
||||||
handle: &mut NaiveTimingChannelHandle,
|
handle: &mut NaiveTimingChannelHandle,
|
||||||
|
//limit: u32,
|
||||||
reset: bool,
|
reset: bool,
|
||||||
) -> Result<CacheStatus, SideChannelError> {
|
) -> Result<CacheStatus, SideChannelError> {
|
||||||
// This should be handled in prepare / unprepare
|
// This should be handled in prepare / unprepare
|
||||||
@ -87,12 +88,12 @@ impl<T: TimingChannelPrimitives> NaiveTimingChannel<T> {
|
|||||||
addr: *const u8,
|
addr: *const u8,
|
||||||
) -> Result<NaiveTimingChannelHandle, ChannelFatalError> {
|
) -> Result<NaiveTimingChannelHandle, ChannelFatalError> {
|
||||||
let vpn = get_vpn(addr);
|
let vpn = get_vpn(addr);
|
||||||
if self.current.get(&vpn).is_some() {
|
/*if self.current.get(&vpn).is_some() {
|
||||||
return Err(ChannelFatalError::Oops);
|
return Err(ChannelFatalError::Oops);
|
||||||
} else {
|
} else {
|
||||||
self.current.insert(vpn, addr);
|
self.current.insert(vpn, addr);*/
|
||||||
Ok(NaiveTimingChannelHandle { vpn, addr })
|
Ok(NaiveTimingChannelHandle { vpn, addr })
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +140,7 @@ impl<T: TimingChannelPrimitives + Send + Sync> CovertChannel for NaiveTimingChan
|
|||||||
unsafe { self.calibrate_impl(page) }.map_err(|_| ())
|
unsafe { self.calibrate_impl(page) }.map_err(|_| ())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: TimingChannelPrimitives> SingleAddrCacheSideChannel for NaiveTimingChannel<T> {
|
impl<T: TimingChannelPrimitives> SingleAddrCacheSideChannel for NaiveTimingChannel<T> {
|
||||||
type Handle = NaiveTimingChannelHandle;
|
type Handle = NaiveTimingChannelHandle;
|
||||||
|
|
||||||
@ -178,7 +180,52 @@ impl<T: TimingChannelPrimitives> SingleAddrCacheSideChannel for NaiveTimingChann
|
|||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
impl<T: TimingChannelPrimitives> MultipleAddrCacheSideChannel for NaiveTimingChannel<T> {
|
||||||
|
type Handle = NaiveTimingChannelHandle;
|
||||||
|
const MAX_ADDR: u32 = 0;
|
||||||
|
|
||||||
|
unsafe fn test<'a>(
|
||||||
|
&mut self,
|
||||||
|
addresses: &mut Vec<&'a mut Self::Handle>,
|
||||||
|
reset: bool,
|
||||||
|
) -> Result<Vec<(*const u8, CacheStatus)>, SideChannelError>
|
||||||
|
where
|
||||||
|
Self::Handle: 'a,
|
||||||
|
{
|
||||||
|
unsafe { self.test_impl(addresses, Self::MAX_ADDR, reset) }
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn prepare<'a>(
|
||||||
|
&mut self,
|
||||||
|
addresses: &mut Vec<&'a mut Self::Handle>,
|
||||||
|
) -> Result<(), SideChannelError>
|
||||||
|
where
|
||||||
|
Self::Handle: 'a,
|
||||||
|
{
|
||||||
|
unsafe { self.prepare_impl(addresses, Self::MAX_ADDR) }
|
||||||
|
}
|
||||||
|
fn victim(&mut self, operation: &dyn Fn()) {
|
||||||
|
operation()
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn calibrate(
|
||||||
|
&mut self,
|
||||||
|
addresses: impl IntoIterator<Item = *const u8> + Clone,
|
||||||
|
) -> Result<Vec<Self::Handle>, ChannelFatalError> {
|
||||||
|
let mut result = vec![];
|
||||||
|
for addr in addresses {
|
||||||
|
match unsafe { self.calibrate_impl(addr) } {
|
||||||
|
Ok(handle) => result.push(handle),
|
||||||
|
Err(e) => {
|
||||||
|
return Err(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
// Include a helper code to get global threshold model ?
|
// Include a helper code to get global threshold model ?
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
use crate::FRPrimitives;
|
use crate::FRPrimitives;
|
||||||
use basic_timing_cache_channel::naive::NaiveTimingChannel;
|
use basic_timing_cache_channel::naive::NaiveTimingChannel;
|
||||||
|
use cache_side_channel::SingleAddrCacheSideChannel;
|
||||||
|
|
||||||
pub type NaiveFlushAndReload = NaiveTimingChannel<FRPrimitives>;
|
pub type NaiveFlushAndReload = NaiveTimingChannel<FRPrimitives>;
|
||||||
|
|
||||||
|
pub type NFRHandle = <NaiveFlushAndReload as SingleAddrCacheSideChannel>::Handle;
|
||||||
|
Loading…
Reference in New Issue
Block a user