File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff 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+
3744pub fn is_user_range ( p : * const u8 , len : usize ) -> bool {
3845 let start=p as u64 ;
3946 let end=start + ( len as u64 ) ;
Original file line number Diff line number Diff 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+
3644pub fn write ( fd : Fd , buf : & [ u8 ] ) -> IoResult < usize > {
3745 unsafe {
3846 let userbuf = alloc:: User :: new_from_enclave ( buf) ;
You can’t perform that action at this time.
0 commit comments