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 {
34
34
base
35
35
}
36
36
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
+
37
44
pub fn is_user_range ( p : * const u8 , len : usize ) -> bool {
38
45
let start=p as u64 ;
39
46
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> {
33
33
}
34
34
}
35
35
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
+
36
44
pub fn write ( fd : Fd , buf : & [ u8 ] ) -> IoResult < usize > {
37
45
unsafe {
38
46
let userbuf = alloc:: User :: new_from_enclave ( buf) ;
You can’t perform that action at this time.
0 commit comments