diff --git a/Cargo.lock b/Cargo.lock index cc15281..2f6206b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -77,6 +77,18 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +[[package]] +name = "bitvec" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5237f00a8c86130a0cc317830e558b966dd7850d48a953d998c813f01a41b527" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "bootloader" version = "0.9.18" @@ -211,6 +223,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +[[package]] +name = "funty" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1847abb9cb65d566acd5942e94aea9c8f547ad02c98e1649326fc0e8910b8b1e" + [[package]] name = "getrandom" version = "0.2.3" @@ -353,6 +371,7 @@ name = "prefetcher_reverse" version = "0.1.0" dependencies = [ "basic_timing_cache_channel", + "bitvec", "cache_side_channel", "cache_utils", "flush_flush", @@ -362,6 +381,12 @@ dependencies = [ "rand", ] +[[package]] +name = "radium" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" + [[package]] name = "rand" version = "0.8.3" @@ -438,6 +463,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "turn_lock" version = "0.1.0" @@ -481,6 +512,15 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +[[package]] +name = "wyz" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "129e027ad65ce1453680623c3fb5163cbf7107bfe1aa32257e7d0e63f9ced188" +dependencies = [ + "tap", +] + [[package]] name = "x86_64" version = "0.14.3" diff --git a/prefetcher_reverse/Cargo.toml b/prefetcher_reverse/Cargo.toml index c0a5528..e150af7 100644 --- a/prefetcher_reverse/Cargo.toml +++ b/prefetcher_reverse/Cargo.toml @@ -15,3 +15,4 @@ basic_timing_cache_channel = { path = "../basic_timing_cache_channel" } nix = "0.20.0" rand = "0.8.3" lazy_static = "1.4.0" +bitvec = "0.22.3" diff --git a/prefetcher_reverse/src/ip_tool.rs b/prefetcher_reverse/src/ip_tool.rs index d8c384a..346c030 100644 --- a/prefetcher_reverse/src/ip_tool.rs +++ b/prefetcher_reverse/src/ip_tool.rs @@ -1,10 +1,11 @@ +use bitvec::prelude::*; use cache_utils::mmap::MMappedMemory; use lazy_static::lazy_static; use std::collections::LinkedList; use std::sync::Mutex; struct WXRange { - bitmap: Vec, // fixme bit vector + bitmap: BitVec, // fixme bit vector pages: Vec>, } @@ -27,6 +28,13 @@ pub struct FunctionTemplate { ip: *const u8, end: *const u8, } + +pub struct Function { + fun: unsafe extern "C" fn(*const u8) -> u64, + ip: *const u8, + end: *const u8, + size: usize, +} lazy_static! { static ref wx_allocator: Mutex = Mutex::new(WXAllocator::new()); } @@ -42,6 +50,10 @@ const TIMED_CLFLUSH: FunctionTemplate = FunctionTemplate { end: timed_clflush_template_end as *const u8, }; +pub fn allocate_function(align: usize, template: FunctionTemplate) -> Function { + unimplemented!() +} + global_asm!( ".global timed_maccess_template", "timed_maccess_template:",