diff --git a/aes-t-tables/prefetcher_notes b/aes-t-tables/prefetcher_notes new file mode 100644 index 0000000..40fb639 --- /dev/null +++ b/aes-t-tables/prefetcher_notes @@ -0,0 +1,9 @@ +Core 2 : + MSR 0x1A0 [9] HW prfetcher disable + MSR 0x1A0 [19] Adjacent Cache line HW prfetcher disable + MSR 0x1A0 [37] DCU HW prfetcher disable + MSR 0x1A0 [39] IP HW prfetcher disable + +Sandy Bridge + MSR 0x1A4 (420) [0,1,2,3] various prefetcher disable + diff --git a/aes-t-tables/setup.sh b/aes-t-tables/setup.sh new file mode 100644 index 0000000..6ee6436 --- /dev/null +++ b/aes-t-tables/setup.sh @@ -0,0 +1,9 @@ +# For citron vert or Cyber cobaye - run with sudo +# disable prefetchers +wrmsr -a 420 15 + +# performance cpu frequency governor +cpupower frequency-set -g performance + +# No Turbo Boost +echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo diff --git a/aes-t-tables/src/naive_flush_and_reload.rs b/aes-t-tables/src/naive_flush_and_reload.rs new file mode 100644 index 0000000..204a20a --- /dev/null +++ b/aes-t-tables/src/naive_flush_and_reload.rs @@ -0,0 +1,49 @@ +use crate::{CacheStatus, ChannelFatalError, SideChannelError, SingleAddrCacheSideChannel}; +use cache_utils::calibration::only_reload; +use cache_utils::flush; + +#[derive(Debug)] +pub struct NaiveFlushAndReload { + pub threshold: u64, + current: Option<*const u8>, +} + +impl NaiveFlushAndReload { + pub fn from_threshold(threshold: u64) -> Self { + NaiveFlushAndReload { + threshold, + current: None, + } + } +} + +impl SingleAddrCacheSideChannel for NaiveFlushAndReload { + fn test_single(&mut self, addr: *const u8) -> Result { + if self.current != Some(addr) { + panic!(); // FIXME + } + let t = unsafe { only_reload(addr) }; + if t > self.threshold { + Ok(CacheStatus::Miss) + } else { + Ok(CacheStatus::Hit) + } + } + + fn prepare_single(&mut self, addr: *const u8) -> Result<(), SideChannelError> { + unsafe { flush(addr) }; + self.current = Some(addr); + Ok(()) + } + + fn victim_single(&mut self, operation: &dyn Fn()) { + operation() + } + + fn calibrate_single( + &mut self, + _addresses: impl IntoIterator, + ) -> Result<(), ChannelFatalError> { + Ok(()) + } +}