Skip to content

Commit 38f5c97

Browse files
author
Jethro Beekman
committed
Revert "Remove some dead code from sgx"
This reverts commit 1346619.
1 parent 4358be4 commit 38f5c97

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/libstd/sys/sgx/abi/mem.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ fn image_base() -> u64 {
3434
base
3535
}
3636

37+
pub fn is_enclave_range(p: *const u8, len: usize) -> bool {
38+
let start=p as u64;
39+
let end=start + (len as u64);
40+
start >= image_base() &&
41+
end <= image_base() + (unsafe { ENCLAVE_SIZE } as u64) // unsafe ok: link-time constant
42+
}
43+
3744
pub fn is_user_range(p: *const u8, len: usize) -> bool {
3845
let start=p as u64;
3946
let end=start + (len as u64);

src/libstd/sys/sgx/abi/usercalls/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ pub fn read(fd: Fd, buf: &mut [u8]) -> IoResult<usize> {
3333
}
3434
}
3535

36+
pub fn read_alloc(fd: Fd) -> IoResult<Vec<u8>> {
37+
unsafe {
38+
let mut userbuf = alloc::User::<ByteBuffer>::uninitialized();
39+
raw::read_alloc(fd, userbuf.as_raw_mut_ptr()).from_sgx_result()?;
40+
Ok(copy_user_buffer(&userbuf))
41+
}
42+
}
43+
3644
pub fn write(fd: Fd, buf: &[u8]) -> IoResult<usize> {
3745
unsafe {
3846
let userbuf = alloc::User::new_from_enclave(buf);

0 commit comments

Comments
 (0)