]> git.lizzy.rs Git - rust.git/commitdiff
Revert "Remove some dead code from `sgx`"
authorJethro Beekman <jethro@fortanix.com>
Wed, 19 Dec 2018 06:46:04 +0000 (12:16 +0530)
committerJethro Beekman <jethro@fortanix.com>
Wed, 19 Dec 2018 06:46:04 +0000 (12:16 +0530)
This reverts commit 134661917bf4b086b027a2c58219d50ba57a1453.

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

index bf32c712216bc35ab84f1839a1bf84a30195254f..508f2ff4d4fa5e4b9cb95308555111550cee95b1 100644 (file)
@@ -34,6 +34,13 @@ fn image_base() -> u64 {
     base
 }
 
+pub fn is_enclave_range(p: *const u8, len: usize) -> bool {
+    let start=p as u64;
+    let end=start + (len as u64);
+    start >= image_base() &&
+        end <= image_base() + (unsafe { ENCLAVE_SIZE } as u64) // unsafe ok: link-time constant
+}
+
 pub fn is_user_range(p: *const u8, len: usize) -> bool {
     let start=p as u64;
     let end=start + (len as u64);
index d1d180e48251f90fcae1d1feeee1f957e03c3220..2bc32c9fefbb73a933bbaf180be5be0f4d377883 100644 (file)
@@ -33,6 +33,14 @@ pub fn read(fd: Fd, buf: &mut [u8]) -> IoResult<usize> {
     }
 }
 
+pub fn read_alloc(fd: Fd) -> IoResult<Vec<u8>> {
+    unsafe {
+        let mut userbuf = alloc::User::<ByteBuffer>::uninitialized();
+        raw::read_alloc(fd, userbuf.as_raw_mut_ptr()).from_sgx_result()?;
+        Ok(copy_user_buffer(&userbuf))
+    }
+}
+
 pub fn write(fd: Fd, buf: &[u8]) -> IoResult<usize> {
     unsafe {
         let userbuf = alloc::User::new_from_enclave(buf);