Stub the interface to create functions.

This may be turned into a impl of Function.
This commit is contained in:
Guillume DIDIER 2021-10-19 16:17:44 +02:00
parent cde062b1d6
commit 8edaabea8a
3 changed files with 54 additions and 1 deletions

40
Cargo.lock generated
View File

@ -77,6 +77,18 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" 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]] [[package]]
name = "bootloader" name = "bootloader"
version = "0.9.18" version = "0.9.18"
@ -211,6 +223,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "funty"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1847abb9cb65d566acd5942e94aea9c8f547ad02c98e1649326fc0e8910b8b1e"
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.3" version = "0.2.3"
@ -353,6 +371,7 @@ name = "prefetcher_reverse"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"basic_timing_cache_channel", "basic_timing_cache_channel",
"bitvec",
"cache_side_channel", "cache_side_channel",
"cache_utils", "cache_utils",
"flush_flush", "flush_flush",
@ -362,6 +381,12 @@ dependencies = [
"rand", "rand",
] ]
[[package]]
name = "radium"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb"
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.8.3" version = "0.8.3"
@ -438,6 +463,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "tap"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]] [[package]]
name = "turn_lock" name = "turn_lock"
version = "0.1.0" 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" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "wyz"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "129e027ad65ce1453680623c3fb5163cbf7107bfe1aa32257e7d0e63f9ced188"
dependencies = [
"tap",
]
[[package]] [[package]]
name = "x86_64" name = "x86_64"
version = "0.14.3" version = "0.14.3"

View File

@ -15,3 +15,4 @@ basic_timing_cache_channel = { path = "../basic_timing_cache_channel" }
nix = "0.20.0" nix = "0.20.0"
rand = "0.8.3" rand = "0.8.3"
lazy_static = "1.4.0" lazy_static = "1.4.0"
bitvec = "0.22.3"

View File

@ -1,10 +1,11 @@
use bitvec::prelude::*;
use cache_utils::mmap::MMappedMemory; use cache_utils::mmap::MMappedMemory;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use std::collections::LinkedList; use std::collections::LinkedList;
use std::sync::Mutex; use std::sync::Mutex;
struct WXRange { struct WXRange {
bitmap: Vec<bool>, // fixme bit vector bitmap: BitVec, // fixme bit vector
pages: Vec<MMappedMemory<u8>>, pages: Vec<MMappedMemory<u8>>,
} }
@ -27,6 +28,13 @@ pub struct FunctionTemplate {
ip: *const u8, ip: *const u8,
end: *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! { lazy_static! {
static ref wx_allocator: Mutex<WXAllocator> = Mutex::new(WXAllocator::new()); static ref wx_allocator: Mutex<WXAllocator> = Mutex::new(WXAllocator::new());
} }
@ -42,6 +50,10 @@ const TIMED_CLFLUSH: FunctionTemplate = FunctionTemplate {
end: timed_clflush_template_end as *const u8, end: timed_clflush_template_end as *const u8,
}; };
pub fn allocate_function(align: usize, template: FunctionTemplate) -> Function {
unimplemented!()
}
global_asm!( global_asm!(
".global timed_maccess_template", ".global timed_maccess_template",
"timed_maccess_template:", "timed_maccess_template:",