MCPcopy Create free account
hub / github.com/PLSysSec/wave / wave_alloc_linmem

Function wave_alloc_linmem

src/tcb/sbox_mem.rs:225–239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

223#[trusted]
224#[ensures(valid_linmem(result))]
225fn wave_alloc_linmem() -> usize {
226 let linmem_ptr = mmap(
227 0, // let the kernel place the region anywhere
228 EIGHT_GB, // Linmem + guard page = 8GB
229 bitwise_or(PROT_READ, PROT_WRITE), // its read/write
230 bitwise_or(MAP_PRIVATE, MAP_ANONYMOUS), // should not be shared or backed-up to a file
231 -1, // no file descrptor since we aren't backing to a file
232 0, // this arg doesn't matter since we aren't backing to a file
233 );
234 // let x: [u8; 4] = [0,1,2,3];
235 // assert!( cool_ptr((&x).as_ptr()) );
236 mprotect(linmem_ptr + FOUR_GB, FOUR_GB, PROT_NONE); // Make second 4GB of linear memory a guard page
237 memset(linmem_ptr, 0, FOUR_GB); // memzero
238 linmem_ptr
239}

Callers 1

setupFunction · 0.85

Calls 4

mmapFunction · 0.85
bitwise_orFunction · 0.85
mprotectFunction · 0.85
memsetFunction · 0.85

Tested by

no test coverage detected