@@ -69,11 +69,11 @@ pub extern "C" fn permission_pfhandler(info: &mut PfInfo, priv_data: *mut c_void
6969 let prot = ProtFlags :: from_bits ( pd. access as u8 ) . unwrap ( ) ;
7070 let rw_bit = unsafe { pd. pf . pfec . bits . rw ( ) } ;
7171 if ( rw_bit == 1 ) && ( prot == ProtFlags :: W ) {
72- if emm:: user_mm_modify_perms ( addr, SE_PAGE_SIZE , ProtFlags :: W | ProtFlags :: R ) . is_err ( ) {
72+ if emm:: mm_modify_perms ( addr, SE_PAGE_SIZE , ProtFlags :: W | ProtFlags :: R ) . is_err ( ) {
7373 panic ! ( )
7474 } ;
7575 } else if ( rw_bit == 0 ) && prot. contains ( ProtFlags :: R ) {
76- if emm:: user_mm_modify_perms ( addr, SE_PAGE_SIZE , prot) . is_err ( ) {
76+ if emm:: mm_modify_perms ( addr, SE_PAGE_SIZE , prot) . is_err ( ) {
7777 panic ! ( )
7878 } ;
7979 } else {
@@ -87,12 +87,12 @@ pub extern "C" fn permission_pfhandler(info: &mut PfInfo, priv_data: *mut c_void
8787fn test_modify_perms ( ) -> SgxStatus {
8888 let mut pd = PfData :: default ( ) ;
8989 // example 1:
90- let mut options = EmaOptions :: new ( 0 , ALLOC_SIZE , AllocFlags :: COMMIT_NOW ) ;
90+ let mut options = EmaOptions :: new ( None , ALLOC_SIZE , AllocFlags :: COMMIT_NOW ) ;
9191 options. handle (
9292 Some ( permission_pfhandler) ,
9393 Some ( & mut pd as * mut PfData as * mut c_void ) ,
9494 ) ;
95- let base = emm:: user_mm_alloc ( & mut options) . unwrap ( ) ;
95+ let base = emm:: mm_alloc_user ( & mut options) . unwrap ( ) ;
9696
9797 let data = unsafe { ( base as * const u8 ) . read ( ) } ;
9898 assert ! ( data == 0 ) ;
@@ -104,7 +104,7 @@ fn test_modify_perms() -> SgxStatus {
104104 // write success without PF
105105 assert ! ( unsafe { pd. pf. pfec. errcd } == 0 ) ;
106106
107- let res = emm:: user_mm_modify_perms ( base, ALLOC_SIZE / 2 , ProtFlags :: R ) ;
107+ let res = emm:: mm_modify_perms ( base, ALLOC_SIZE / 2 , ProtFlags :: R ) ;
108108 assert ! ( res. is_ok( ) ) ;
109109
110110 pd. access = ProtFlags :: R . bits ( ) as i32 ;
@@ -156,55 +156,55 @@ fn test_dynamic_expand_tcs() -> SgxStatus {
156156#[ no_mangle]
157157fn test_modify_types ( ) -> SgxStatus {
158158 // example 1:
159- let mut options = EmaOptions :: new ( 0 , SE_PAGE_SIZE , AllocFlags :: COMMIT_NOW ) ;
160- let base = emm:: user_mm_alloc ( & mut options) . unwrap ( ) ;
159+ let mut options = EmaOptions :: new ( None , SE_PAGE_SIZE , AllocFlags :: COMMIT_NOW ) ;
160+ let base = emm:: mm_alloc_user ( & mut options) . unwrap ( ) ;
161161
162- let res = emm:: user_mm_modify_type ( base, SE_PAGE_SIZE , PageType :: Tcs ) ;
162+ let res = emm:: mm_modify_type ( base, SE_PAGE_SIZE , PageType :: Tcs ) ;
163163 assert ! ( res. is_ok( ) ) ;
164164
165- let res = emm:: user_mm_uncommit ( base, SE_PAGE_SIZE ) ;
165+ let res = emm:: mm_uncommit ( base, SE_PAGE_SIZE ) ;
166166 assert ! ( res. is_ok( ) ) ;
167167
168168 // example 2:
169- let mut options = EmaOptions :: new ( 0 , SE_PAGE_SIZE , AllocFlags :: COMMIT_NOW ) ;
170- let base = emm:: user_mm_alloc ( & mut options) . unwrap ( ) ;
169+ let mut options = EmaOptions :: new ( None , SE_PAGE_SIZE , AllocFlags :: COMMIT_NOW ) ;
170+ let base = emm:: mm_alloc_user ( & mut options) . unwrap ( ) ;
171171
172- let res = emm:: user_mm_modify_perms ( base, SE_PAGE_SIZE , ProtFlags :: NONE ) ;
172+ let res = emm:: mm_modify_perms ( base, SE_PAGE_SIZE , ProtFlags :: NONE ) ;
173173 assert ! ( res. is_ok( ) ) ;
174174
175- let res = emm:: user_mm_uncommit ( base, SE_PAGE_SIZE ) ;
175+ let res = emm:: mm_uncommit ( base, SE_PAGE_SIZE ) ;
176176 assert ! ( res. is_ok( ) ) ;
177177
178178 // example 3:
179- let res = emm:: user_mm_dealloc ( 0 , ALLOC_SIZE ) ;
179+ let res = emm:: mm_dealloc ( 0 , ALLOC_SIZE ) ;
180180 assert ! ( res == Err ( EINVAL ) ) ;
181181
182- let mut options = EmaOptions :: new ( 0 , ALLOC_SIZE , AllocFlags :: COMMIT_NOW ) ;
183- let base = emm:: user_mm_alloc ( & mut options) . unwrap ( ) ;
182+ let mut options = EmaOptions :: new ( None , ALLOC_SIZE , AllocFlags :: COMMIT_NOW ) ;
183+ let base = emm:: mm_alloc_user ( & mut options) . unwrap ( ) ;
184184
185- let res = emm:: user_mm_modify_type ( base + SE_PAGE_SIZE , SE_PAGE_SIZE , PageType :: Frist ) ;
185+ let res = emm:: mm_modify_type ( base + SE_PAGE_SIZE , SE_PAGE_SIZE , PageType :: Frist ) ;
186186 assert ! ( res == Err ( EPERM ) ) ;
187187
188- let res = emm:: user_mm_modify_perms (
188+ let res = emm:: mm_modify_perms (
189189 base + SE_PAGE_SIZE ,
190190 SE_PAGE_SIZE ,
191191 ProtFlags :: R | ProtFlags :: X ,
192192 ) ;
193193 assert ! ( res. is_ok( ) ) ;
194194
195- let res = emm:: user_mm_modify_type ( base + SE_PAGE_SIZE , SE_PAGE_SIZE , PageType :: Tcs ) ;
195+ let res = emm:: mm_modify_type ( base + SE_PAGE_SIZE , SE_PAGE_SIZE , PageType :: Tcs ) ;
196196 assert ! ( res == Err ( EACCES ) ) ;
197197
198- let res = emm:: user_mm_modify_type ( base, SE_PAGE_SIZE , PageType :: Tcs ) ;
198+ let res = emm:: mm_modify_type ( base, SE_PAGE_SIZE , PageType :: Tcs ) ;
199199 assert ! ( res. is_ok( ) ) ;
200200
201- let res = emm:: user_mm_uncommit ( base, ALLOC_SIZE ) ;
201+ let res = emm:: mm_uncommit ( base, ALLOC_SIZE ) ;
202202 assert ! ( res. is_ok( ) ) ;
203203
204- let res = emm:: user_mm_modify_type ( base, SE_PAGE_SIZE , PageType :: Tcs ) ;
204+ let res = emm:: mm_modify_type ( base, SE_PAGE_SIZE , PageType :: Tcs ) ;
205205 assert ! ( res == Err ( EACCES ) ) ;
206206
207- let res = emm:: user_mm_dealloc ( base, ALLOC_SIZE ) ;
207+ let res = emm:: mm_dealloc ( base, ALLOC_SIZE ) ;
208208 assert ! ( res. is_ok( ) ) ;
209209
210210 println ! ( "Successfully run modify types!" ) ;
@@ -213,44 +213,48 @@ fn test_modify_types() -> SgxStatus {
213213
214214#[ no_mangle]
215215fn test_commit_and_uncommit ( ) -> SgxStatus {
216- let res = emm:: user_mm_dealloc ( 0 , ALLOC_SIZE ) ;
216+ let res = emm:: mm_dealloc ( 0 , ALLOC_SIZE ) ;
217217 assert ! ( res == Err ( EINVAL ) ) ;
218218
219- let mut options = EmaOptions :: new ( 0 , ALLOC_SIZE , AllocFlags :: COMMIT_NOW ) ;
220- let base = emm:: user_mm_alloc ( & mut options) . unwrap ( ) ;
219+ let mut options = EmaOptions :: new ( None , ALLOC_SIZE , AllocFlags :: COMMIT_NOW ) ;
220+ let base = emm:: mm_alloc_user ( & mut options) . unwrap ( ) ;
221221
222- let res = emm:: user_mm_commit ( base, ALLOC_SIZE ) ;
222+ let res = emm:: mm_commit ( base, ALLOC_SIZE ) ;
223223 assert ! ( res. is_ok( ) ) ;
224224
225- let mut options = EmaOptions :: new ( base, ALLOC_SIZE , AllocFlags :: COMMIT_NOW | AllocFlags :: FIXED ) ;
226- let res = emm:: user_mm_alloc ( & mut options) ;
225+ let mut options = EmaOptions :: new (
226+ Some ( base) ,
227+ ALLOC_SIZE ,
228+ AllocFlags :: COMMIT_NOW | AllocFlags :: FIXED ,
229+ ) ;
230+ let res = emm:: mm_alloc_user ( & mut options) ;
227231
228232 assert ! ( res == Err ( EEXIST ) ) ;
229233
230- let res = emm:: user_mm_uncommit ( base, ALLOC_SIZE ) ;
234+ let res = emm:: mm_uncommit ( base, ALLOC_SIZE ) ;
231235 assert ! ( res. is_ok( ) ) ;
232236
233- let res = emm:: user_mm_uncommit ( base, ALLOC_SIZE ) ;
237+ let res = emm:: mm_uncommit ( base, ALLOC_SIZE ) ;
234238 assert ! ( res. is_ok( ) ) ;
235239
236- let res = emm:: user_mm_commit ( base, ALLOC_SIZE ) ;
240+ let res = emm:: mm_commit ( base, ALLOC_SIZE ) ;
237241 assert ! ( res. is_ok( ) ) ;
238242
239- let res = emm:: user_mm_dealloc ( base, ALLOC_SIZE ) ;
243+ let res = emm:: mm_dealloc ( base, ALLOC_SIZE ) ;
240244 assert ! ( res. is_ok( ) ) ;
241245
242- let res = emm:: user_mm_dealloc ( base, ALLOC_SIZE ) ;
246+ let res = emm:: mm_dealloc ( base, ALLOC_SIZE ) ;
243247 assert ! ( res == Err ( EINVAL ) ) ;
244248
245- let res = emm:: user_mm_uncommit ( base, ALLOC_SIZE ) ;
249+ let res = emm:: mm_uncommit ( base, ALLOC_SIZE ) ;
246250 assert ! ( res == Err ( EINVAL ) ) ;
247251
248252 let mut options = EmaOptions :: new (
249- 0 ,
253+ None ,
250254 ALLOC_SIZE ,
251255 AllocFlags :: COMMIT_ON_DEMAND | AllocFlags :: FIXED ,
252256 ) ;
253- let base2 = emm:: user_mm_alloc ( & mut options) . unwrap ( ) ;
257+ let base2 = emm:: mm_alloc_user ( & mut options) . unwrap ( ) ;
254258
255259 assert ! ( base == base2) ;
256260
@@ -260,7 +264,7 @@ fn test_commit_and_uncommit() -> SgxStatus {
260264 ptr. add ( ALLOC_SIZE - 1 ) . write ( 0xFF ) ;
261265 } ;
262266
263- let res = emm:: user_mm_dealloc ( base2, ALLOC_SIZE ) ;
267+ let res = emm:: mm_dealloc ( base2, ALLOC_SIZE ) ;
264268 assert ! ( res. is_ok( ) ) ;
265269
266270 println ! ( "Successfully run commit and uncommit!" ) ;
@@ -283,13 +287,13 @@ fn test_stack_expand() -> SgxStatus {
283287
284288#[ no_mangle]
285289fn test_emm_alloc_dealloc ( ) -> SgxStatus {
286- let res = emm:: user_mm_dealloc ( 0 , ALLOC_SIZE ) ;
290+ let res = emm:: mm_dealloc ( 0 , ALLOC_SIZE ) ;
287291 assert ! ( res == Err ( EINVAL ) ) ;
288292
289- let mut options = EmaOptions :: new ( 0 , ALLOC_SIZE , AllocFlags :: COMMIT_NOW ) ;
290- let base = emm:: user_mm_alloc ( & mut options) . unwrap ( ) ;
293+ let mut options = EmaOptions :: new ( None , ALLOC_SIZE , AllocFlags :: COMMIT_NOW ) ;
294+ let base = emm:: mm_alloc_user ( & mut options) . unwrap ( ) ;
291295
292- let res = emm:: user_mm_dealloc ( base, ALLOC_SIZE ) ;
296+ let res = emm:: mm_dealloc ( base, ALLOC_SIZE ) ;
293297 assert ! ( res. is_ok( ) ) ;
294298 println ! ( "Successfully run alloc and dealloc!" ) ;
295299 SgxStatus :: Success
0 commit comments