1 | /* |
---|
2 | * vmm.c - virtual memory manager related operations interface. |
---|
3 | * |
---|
4 | * Authors Ghassan Almaless (2008,2009,2010,2011, 2012) |
---|
5 | * Mohamed Lamine Karaoui (2015) |
---|
6 | * Alain Greiner (2016) |
---|
7 | * |
---|
8 | * Copyright (c) UPMC Sorbonne Universites |
---|
9 | * |
---|
10 | * This file is part of ALMOS-MKH. |
---|
11 | * |
---|
12 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
13 | * under the terms of the GNU General Public License as published by |
---|
14 | * the Free Software Foundation; version 2.0 of the License. |
---|
15 | * |
---|
16 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
19 | * General Public License for more details. |
---|
20 | * |
---|
21 | * You should have received a copy of the GNU General Public License |
---|
22 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
23 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
24 | */ |
---|
25 | |
---|
26 | #include <kernel_config.h> |
---|
27 | #include <hal_types.h> |
---|
28 | #include <hal_special.h> |
---|
29 | #include <hal_gpt.h> |
---|
30 | #include <printk.h> |
---|
31 | #include <memcpy.h> |
---|
32 | #include <rwlock.h> |
---|
33 | #include <list.h> |
---|
34 | #include <bits.h> |
---|
35 | #include <process.h> |
---|
36 | #include <thread.h> |
---|
37 | #include <vseg.h> |
---|
38 | #include <cluster.h> |
---|
39 | #include <scheduler.h> |
---|
40 | #include <vfs.h> |
---|
41 | #include <mapper.h> |
---|
42 | #include <page.h> |
---|
43 | #include <kmem.h> |
---|
44 | #include <vmm.h> |
---|
45 | |
---|
46 | ////////////////////////////////////////////////////////////////////////////////// |
---|
47 | // Extern global variables |
---|
48 | ////////////////////////////////////////////////////////////////////////////////// |
---|
49 | |
---|
50 | extern process_t process_zero; // defined in cluster.c file |
---|
51 | |
---|
52 | |
---|
53 | //////////////////////////////////// |
---|
54 | void vmm_init( process_t * process ) |
---|
55 | { |
---|
56 | error_t error; |
---|
57 | vseg_t * vseg_kentry; |
---|
58 | vseg_t * vseg_args; |
---|
59 | vseg_t * vseg_envs; |
---|
60 | vseg_t * vseg_heap; |
---|
61 | intptr_t base; |
---|
62 | intptr_t size; |
---|
63 | |
---|
64 | // get pointer on VMM |
---|
65 | vmm_t * vmm = &process->vmm; |
---|
66 | |
---|
67 | // check UTILS zone size |
---|
68 | if( (CONFIG_VMM_KENTRY_SIZE + CONFIG_VMM_ARGS_SIZE + CONFIG_VMM_ENVS_SIZE ) > |
---|
69 | CONFIG_VMM_ELF_BASE ) |
---|
70 | { |
---|
71 | printk("\n[PANIC] in %s : UTILS zone too small for process %x\n", |
---|
72 | __FUNCTION__ , process->pid ); |
---|
73 | hal_core_sleep(); |
---|
74 | } |
---|
75 | |
---|
76 | // check max number of stacks slots |
---|
77 | if( CONFIG_THREAD_MAX_PER_CLUSTER > 32 ) |
---|
78 | { |
---|
79 | printk("\n[PANIC] in %s : max number of threads per cluster for a single process" |
---|
80 | " cannot be larger than 32\n", __FUNCTION__ ); |
---|
81 | hal_core_sleep(); |
---|
82 | } |
---|
83 | |
---|
84 | // check STACK zone size |
---|
85 | if( (CONFIG_VMM_STACK_SIZE * CONFIG_THREAD_MAX_PER_CLUSTER) > |
---|
86 | (CONFIG_VMM_VSPACE_SIZE - CONFIG_VMM_STACK_BASE) ) |
---|
87 | { |
---|
88 | printk("\n[PANIC] in %s : STACK zone too small for process %x\n", |
---|
89 | __FUNCTION__ , process->pid ); |
---|
90 | hal_core_sleep(); |
---|
91 | } |
---|
92 | |
---|
93 | // initialize the rwlock protecting the vsegs list |
---|
94 | rwlock_init( &vmm->vsegs_lock ); |
---|
95 | |
---|
96 | // initialize local list of vsegs and radix-tree |
---|
97 | vmm->vsegs_nr = 0; |
---|
98 | list_root_init( &vmm->vsegs_root ); |
---|
99 | error = grdxt_init( &vmm->grdxt, |
---|
100 | CONFIG_VMM_GRDXT_W1, |
---|
101 | CONFIG_VMM_GRDXT_W2, |
---|
102 | CONFIG_VMM_GRDXT_W3 ); |
---|
103 | if( error ) |
---|
104 | { |
---|
105 | printk("\n[PANIC] in %s : cannot initialize radix tree for process %x\n", |
---|
106 | __FUNCTION__ , process->pid ); |
---|
107 | hal_core_sleep(); |
---|
108 | } |
---|
109 | |
---|
110 | // register kentry vseg in VMM |
---|
111 | base = 1 << CONFIG_PPM_PAGE_SHIFT; |
---|
112 | size = CONFIG_VMM_KENTRY_SIZE << CONFIG_PPM_PAGE_SHIFT; |
---|
113 | vseg_kentry = vmm_create_vseg( process , base , size , VSEG_TYPE_CODE ); |
---|
114 | if( vseg_kentry == NULL ) |
---|
115 | { |
---|
116 | printk("\n[PANIC] in %s : cannot register kent vseg for process %x\n", |
---|
117 | __FUNCTION__ , process->pid ); |
---|
118 | hal_core_sleep(); |
---|
119 | } |
---|
120 | vmm->kent_vpn_base = 1; |
---|
121 | |
---|
122 | // register the args vseg in VMM |
---|
123 | base = (CONFIG_VMM_KENTRY_SIZE + 1 )<<CONFIG_PPM_PAGE_SHIFT; |
---|
124 | size = CONFIG_VMM_ARGS_SIZE << CONFIG_PPM_PAGE_SHIFT; |
---|
125 | vseg_args = vmm_create_vseg( process , base , size , VSEG_TYPE_DATA ); |
---|
126 | if( vseg_args == NULL ) |
---|
127 | { |
---|
128 | printk("\n[PANIC] in %s : cannot register args vseg for process %x\n", |
---|
129 | __FUNCTION__ , process->pid ); |
---|
130 | hal_core_sleep(); |
---|
131 | } |
---|
132 | vmm->args_vpn_base = CONFIG_VMM_KENTRY_SIZE + 1; |
---|
133 | |
---|
134 | // register the envs vseg in VMM |
---|
135 | base = (CONFIG_VMM_KENTRY_SIZE + CONFIG_VMM_ARGS_SIZE + 1 )<<CONFIG_PPM_PAGE_SHIFT; |
---|
136 | size = CONFIG_VMM_ENVS_SIZE << CONFIG_PPM_PAGE_SHIFT; |
---|
137 | vseg_envs = vmm_create_vseg( process , base , size , VSEG_TYPE_DATA ); |
---|
138 | if( vseg_envs == NULL ) |
---|
139 | { |
---|
140 | printk("\n[PANIC] in %s : cannot register envs vseg for process %x\n", |
---|
141 | __FUNCTION__ , process->pid ); |
---|
142 | hal_core_sleep(); |
---|
143 | } |
---|
144 | vmm->envs_vpn_base = CONFIG_VMM_KENTRY_SIZE + CONFIG_VMM_ARGS_SIZE + 1; |
---|
145 | |
---|
146 | // register the heap vseg in VMM |
---|
147 | base = CONFIG_VMM_HEAP_BASE << CONFIG_PPM_PAGE_SHIFT; |
---|
148 | size = (CONFIG_VMM_MMAP_BASE-CONFIG_VMM_HEAP_BASE) << CONFIG_PPM_PAGE_SHIFT; |
---|
149 | vseg_heap = vmm_create_vseg( process , base , size , VSEG_TYPE_HEAP ); |
---|
150 | if( vseg_heap == NULL ) |
---|
151 | { |
---|
152 | printk("\n[PANIC] in %s : cannot register heap vseg in for process %x\n", |
---|
153 | __FUNCTION__ , process->pid ); |
---|
154 | hal_core_sleep(); |
---|
155 | } |
---|
156 | vmm->heap_vpn_base = CONFIG_VMM_HEAP_BASE; |
---|
157 | |
---|
158 | // initialize generic page table |
---|
159 | error = hal_gpt_create( &vmm->gpt ); |
---|
160 | if( error ) |
---|
161 | { |
---|
162 | printk("PANIC in %s : cannot initialize page table\n", __FUNCTION__ ); |
---|
163 | hal_core_sleep(); |
---|
164 | } |
---|
165 | |
---|
166 | // initialize STACK allocator |
---|
167 | vmm->stack_mgr.bitmap = 0; |
---|
168 | vmm->stack_mgr.vpn_base = CONFIG_VMM_STACK_BASE; |
---|
169 | |
---|
170 | // initialize MMAP allocator |
---|
171 | vmm->mmap_mgr.vpn_base = CONFIG_VMM_MMAP_BASE; |
---|
172 | vmm->mmap_mgr.vpn_size = CONFIG_VMM_STACK_BASE - CONFIG_VMM_MMAP_BASE; |
---|
173 | vmm->mmap_mgr.first_free_vpn = CONFIG_VMM_MMAP_BASE; |
---|
174 | uint32_t i; |
---|
175 | for( i = 0 ; i < 32 ; i++ ) list_root_init( &vmm->mmap_mgr.zombi_list[i] ); |
---|
176 | |
---|
177 | // initialize instrumentation counters |
---|
178 | vmm->pgfault_nr = 0; |
---|
179 | vmm->u_err_nr = 0; |
---|
180 | vmm->m_err_nr = 0; |
---|
181 | |
---|
182 | hal_fence(); |
---|
183 | } |
---|
184 | |
---|
185 | ////////////////////////////////////////// |
---|
186 | error_t vmm_copy( process_t * dst_process, |
---|
187 | process_t * src_process ) |
---|
188 | { |
---|
189 | error_t error; |
---|
190 | |
---|
191 | vmm_t * src_vmm = &src_process->vmm; |
---|
192 | vmm_t * dst_vmm = &dst_process->vmm; |
---|
193 | |
---|
194 | // take the src_vmm vsegs_lock |
---|
195 | rwlock_wr_lock( &src_vmm->vsegs_lock ); |
---|
196 | |
---|
197 | // initialize dst_vmm vsegs_lock |
---|
198 | rwlock_init( &dst_vmm->vsegs_lock ); |
---|
199 | |
---|
200 | // initialize the dst_vmm vsegs list and the radix tree |
---|
201 | dst_vmm->vsegs_nr = 0; |
---|
202 | list_root_init( &dst_vmm->vsegs_root ); |
---|
203 | error = grdxt_init( &dst_vmm->grdxt, |
---|
204 | CONFIG_VMM_GRDXT_W1, |
---|
205 | CONFIG_VMM_GRDXT_W2, |
---|
206 | CONFIG_VMM_GRDXT_W3 ); |
---|
207 | if( error ) |
---|
208 | { |
---|
209 | printk("\n[ERROR] in %s : cannot initialize radix tree for process %x\n", |
---|
210 | __FUNCTION__ , dst_process->pid ); |
---|
211 | return ENOMEM; |
---|
212 | } |
---|
213 | |
---|
214 | // loop on src_vmm list of vsegs to create |
---|
215 | // and register vsegs copies in dst_vmm |
---|
216 | list_entry_t * iter; |
---|
217 | vseg_t * src_vseg; |
---|
218 | vseg_t * dst_vseg; |
---|
219 | LIST_FOREACH( &src_vmm->vsegs_root , iter ) |
---|
220 | { |
---|
221 | // get pointer on current src_vseg |
---|
222 | src_vseg = LIST_ELEMENT( iter , vseg_t , list ); |
---|
223 | |
---|
224 | // allocate memory for a new dst_vseg |
---|
225 | dst_vseg = vseg_alloc(); |
---|
226 | |
---|
227 | if( dst_vseg == NULL ) |
---|
228 | { |
---|
229 | // release all allocated vsegs |
---|
230 | LIST_FOREACH( &dst_vmm->vsegs_root , iter ) |
---|
231 | { |
---|
232 | dst_vseg = LIST_ELEMENT( iter , vseg_t , list ); |
---|
233 | vseg_free( dst_vseg ); |
---|
234 | } |
---|
235 | return ENOMEM; |
---|
236 | } |
---|
237 | |
---|
238 | // copy src_vseg to dst_vseg |
---|
239 | vseg_init_from_ref( dst_vseg , XPTR( local_cxy , src_vseg ) ); |
---|
240 | |
---|
241 | // register dst_vseg in dst_vmm |
---|
242 | vseg_attach( dst_vmm , dst_vseg ); |
---|
243 | } |
---|
244 | |
---|
245 | // release the src_vmm vsegs_lock |
---|
246 | rwlock_wr_unlock( &src_vmm->vsegs_lock ); |
---|
247 | |
---|
248 | // initialize generic page table |
---|
249 | error = hal_gpt_create( &dst_vmm->gpt ); |
---|
250 | |
---|
251 | if( error ) |
---|
252 | { |
---|
253 | printk("\n[ERROR] in %s : cannot initialize page table\n", __FUNCTION__ ); |
---|
254 | return ENOMEM; |
---|
255 | } |
---|
256 | |
---|
257 | // initialize STACK allocator |
---|
258 | dst_vmm->stack_mgr.bitmap = 0; |
---|
259 | dst_vmm->stack_mgr.vpn_base = CONFIG_VMM_STACK_BASE; |
---|
260 | |
---|
261 | // initialize MMAP allocator |
---|
262 | dst_vmm->mmap_mgr.vpn_base = CONFIG_VMM_MMAP_BASE; |
---|
263 | dst_vmm->mmap_mgr.vpn_size = CONFIG_VMM_STACK_BASE - CONFIG_VMM_MMAP_BASE; |
---|
264 | dst_vmm->mmap_mgr.first_free_vpn = CONFIG_VMM_MMAP_BASE; |
---|
265 | uint32_t i; |
---|
266 | for( i = 0 ; i < 32 ; i++ ) list_root_init( &dst_vmm->mmap_mgr.zombi_list[i] ); |
---|
267 | |
---|
268 | // initialize instrumentation counters |
---|
269 | dst_vmm->pgfault_nr = 0; |
---|
270 | dst_vmm->u_err_nr = 0; |
---|
271 | dst_vmm->m_err_nr = 0; |
---|
272 | |
---|
273 | // copy base addresses |
---|
274 | dst_vmm->kent_vpn_base = src_vmm->kent_vpn_base; |
---|
275 | dst_vmm->args_vpn_base = src_vmm->args_vpn_base; |
---|
276 | dst_vmm->envs_vpn_base = src_vmm->envs_vpn_base; |
---|
277 | dst_vmm->heap_vpn_base = src_vmm->heap_vpn_base; |
---|
278 | dst_vmm->code_vpn_base = src_vmm->code_vpn_base; |
---|
279 | dst_vmm->data_vpn_base = src_vmm->data_vpn_base; |
---|
280 | |
---|
281 | dst_vmm->entry_point = src_vmm->entry_point; |
---|
282 | |
---|
283 | // HEAP TODO : new heap for child ??? |
---|
284 | dst_vmm->heap_vseg = src_vmm->heap_vseg; |
---|
285 | |
---|
286 | // initialize generic page table |
---|
287 | error = hal_gpt_create( &dst_vmm->gpt ); |
---|
288 | |
---|
289 | if( error ) |
---|
290 | { |
---|
291 | printk("\n[ERROR] in %s : cannot initialize page table\n", __FUNCTION__ ); |
---|
292 | return ENOMEM; |
---|
293 | } |
---|
294 | |
---|
295 | // copy GPT content from src_vmm to dst_vmm, activating "Copy-On-Write" |
---|
296 | // TODO register Copy-On_Write in page descriptors |
---|
297 | bool_t cow = true; |
---|
298 | hal_gpt_copy( &dst_vmm->gpt , &src_vmm->gpt , cow ); |
---|
299 | |
---|
300 | hal_fence(); |
---|
301 | |
---|
302 | return 0; |
---|
303 | } |
---|
304 | |
---|
305 | /////////////////////////////////////// |
---|
306 | void vmm_destroy( process_t * process ) |
---|
307 | { |
---|
308 | vseg_t * vseg; |
---|
309 | |
---|
310 | // get pointer on VMM |
---|
311 | vmm_t * vmm = &process->vmm; |
---|
312 | |
---|
313 | // get lock protecting vseg list |
---|
314 | rwlock_wr_lock( &vmm->vsegs_lock ); |
---|
315 | |
---|
316 | // remove all vsegs registered in vmm |
---|
317 | while( !list_is_empty( &vmm->vsegs_root ) ) |
---|
318 | { |
---|
319 | vseg = LIST_FIRST( &vmm->vsegs_root , vseg_t , list ); |
---|
320 | vseg_detach( vmm , vseg ); |
---|
321 | vseg_free( vseg ); |
---|
322 | } |
---|
323 | |
---|
324 | // delete vsegs radix_tree |
---|
325 | grdxt_destroy( &vmm->grdxt ); |
---|
326 | |
---|
327 | // release lock |
---|
328 | rwlock_wr_unlock(&vmm->vsegs_lock); |
---|
329 | |
---|
330 | // remove all vsegs from zombi_lists in MMAP allocator |
---|
331 | uint32_t i; |
---|
332 | for( i = 0 ; i<32 ; i++ ) |
---|
333 | { |
---|
334 | while( !list_is_empty( &vmm->mmap_mgr.zombi_list[i] ) ) |
---|
335 | { |
---|
336 | vseg = LIST_FIRST( &vmm->mmap_mgr.zombi_list[i] , vseg_t , list ); |
---|
337 | vseg_detach( vmm , vseg ); |
---|
338 | vseg_free( vseg ); |
---|
339 | } |
---|
340 | } |
---|
341 | |
---|
342 | // release memory allocated to the local page table |
---|
343 | hal_gpt_destroy( &vmm->gpt ); |
---|
344 | } |
---|
345 | |
---|
346 | ///////////////////////////////////////////////// |
---|
347 | vseg_t * vmm_check_conflict( process_t * process, |
---|
348 | vpn_t vpn_base, |
---|
349 | vpn_t vpn_size ) |
---|
350 | { |
---|
351 | vmm_t * vmm = &process->vmm; |
---|
352 | vseg_t * vseg; |
---|
353 | list_entry_t * iter; |
---|
354 | |
---|
355 | // scan the list of registered vsegs |
---|
356 | LIST_FOREACH( &vmm->vsegs_root , iter ) |
---|
357 | { |
---|
358 | vseg = LIST_ELEMENT( iter , vseg_t , list ); |
---|
359 | if( ((vpn_base + vpn_size) > vseg->vpn_base) && |
---|
360 | (vpn_base < (vseg->vpn_base + vseg->vpn_size)) ) return vseg; |
---|
361 | } |
---|
362 | return NULL; |
---|
363 | } |
---|
364 | |
---|
365 | //////////////////////////////////////////////////////////////////////////////////////////// |
---|
366 | // This static function is called by the vmm_create_vseg() function, and implements |
---|
367 | // the VMM stack_vseg specific allocator. |
---|
368 | //////////////////////////////////////////////////////////////////////////////////////////// |
---|
369 | // @ vmm : pointer on VMM. |
---|
370 | // @ vpn_base : (return value) first allocated page |
---|
371 | // @ vpn_size : (return value) number of allocated pages |
---|
372 | //////////////////////////////////////////////////////////////////////////////////////////// |
---|
373 | static error_t vmm_stack_alloc( vmm_t * vmm, |
---|
374 | vpn_t * vpn_base, |
---|
375 | vpn_t * vpn_size ) |
---|
376 | { |
---|
377 | // get stack allocator pointer |
---|
378 | stack_mgr_t * mgr = &vmm->stack_mgr; |
---|
379 | |
---|
380 | // get lock on stack allocator |
---|
381 | spinlock_lock( &mgr->lock ); |
---|
382 | |
---|
383 | // get first free slot index in bitmap |
---|
384 | int32_t index = bitmap_ffc( &mgr->bitmap , 4 ); |
---|
385 | if( (index < 0) || (index > 31) ) return ENOMEM; |
---|
386 | |
---|
387 | // update bitmap |
---|
388 | bitmap_set( &mgr->bitmap , index ); |
---|
389 | |
---|
390 | // release lock on stack allocator |
---|
391 | spinlock_unlock( &mgr->lock ); |
---|
392 | |
---|
393 | // returns vpn_base, vpn_size (one page non allocated) |
---|
394 | *vpn_base = mgr->vpn_base + index * CONFIG_VMM_STACK_SIZE + 1; |
---|
395 | *vpn_size = CONFIG_VMM_STACK_SIZE - 1; |
---|
396 | return 0; |
---|
397 | } |
---|
398 | |
---|
399 | //////////////////////////////////////////////////////////////////////////////////////////// |
---|
400 | // This static function is called by the vmm_create_vseg() function, and implements |
---|
401 | // the VMM MMAP specific allocator. |
---|
402 | //////////////////////////////////////////////////////////////////////////////////////////// |
---|
403 | // @ vmm : [in] pointer on VMM. |
---|
404 | // @ npages : [in] requested number of pages. |
---|
405 | // @ vpn_base : [out] first allocated page. |
---|
406 | // @ vpn_size : [out] actual number of allocated pages. |
---|
407 | //////////////////////////////////////////////////////////////////////////////////////////// |
---|
408 | static error_t vmm_mmap_alloc( vmm_t * vmm, |
---|
409 | vpn_t npages, |
---|
410 | vpn_t * vpn_base, |
---|
411 | vpn_t * vpn_size ) |
---|
412 | { |
---|
413 | uint32_t index; |
---|
414 | vseg_t * vseg; |
---|
415 | vpn_t base; |
---|
416 | vpn_t size; |
---|
417 | vpn_t free; |
---|
418 | |
---|
419 | // mmap vseg size must be power of 2 |
---|
420 | // compute actual size and index in zombi_list array |
---|
421 | size = POW2_ROUNDUP( npages ); |
---|
422 | index = bits_log2( size ); |
---|
423 | |
---|
424 | // get mmap allocator pointer |
---|
425 | mmap_mgr_t * mgr = &vmm->mmap_mgr; |
---|
426 | |
---|
427 | // get lock on mmap allocator |
---|
428 | spinlock_lock( &mgr->lock ); |
---|
429 | |
---|
430 | // get vseg from zombi_list or from mmap zone |
---|
431 | if( list_is_empty( &mgr->zombi_list[index] ) ) // from mmap zone |
---|
432 | { |
---|
433 | // check overflow |
---|
434 | free = mgr->first_free_vpn; |
---|
435 | if( (free + size) > mgr->vpn_size ) return ENOMEM; |
---|
436 | |
---|
437 | // update STACK allocator |
---|
438 | mgr->first_free_vpn += size; |
---|
439 | |
---|
440 | // compute base |
---|
441 | base = free; |
---|
442 | } |
---|
443 | else // from zombi_list |
---|
444 | { |
---|
445 | // get pointer on zombi vseg from zombi_list |
---|
446 | vseg = LIST_FIRST( &mgr->zombi_list[index] , vseg_t , list ); |
---|
447 | |
---|
448 | // remove vseg from free-list |
---|
449 | list_unlink( &vseg->list ); |
---|
450 | |
---|
451 | // compute base |
---|
452 | base = vseg->vpn_base; |
---|
453 | } |
---|
454 | |
---|
455 | // release lock on mmap allocator |
---|
456 | spinlock_unlock( &mgr->lock ); |
---|
457 | |
---|
458 | // returns vpn_base, vpn_size |
---|
459 | *vpn_base = base; |
---|
460 | *vpn_size = size; |
---|
461 | return 0; |
---|
462 | } |
---|
463 | |
---|
464 | ////////////////////////////////////////////// |
---|
465 | vseg_t * vmm_create_vseg( process_t * process, |
---|
466 | intptr_t base, |
---|
467 | intptr_t size, |
---|
468 | uint32_t type ) |
---|
469 | { |
---|
470 | vseg_t * vseg; // created vseg pointer |
---|
471 | vpn_t vpn_base; // vseg first page |
---|
472 | vpn_t vpn_size; // number of pages |
---|
473 | error_t error; |
---|
474 | |
---|
475 | // get pointer on VMM |
---|
476 | vmm_t * vmm = &process->vmm; |
---|
477 | |
---|
478 | vmm_dmsg("\n[INFO] %s enter for process %x / base = %x / size = %x / type = %s\n", |
---|
479 | __FUNCTION__ , process->pid , base , size , vseg_type_str(type) ); |
---|
480 | |
---|
481 | // compute base, size, vpn_base, vpn_size, depending on type |
---|
482 | // we use the VMM specific allocators for STACK and MMAP vsegs |
---|
483 | if( type == VSEG_TYPE_STACK ) |
---|
484 | { |
---|
485 | // get vpn_base and vpn_size from STACK allocator |
---|
486 | error = vmm_stack_alloc( vmm , &vpn_base , &vpn_size ); |
---|
487 | if( error ) |
---|
488 | { |
---|
489 | printk("\n[ERROR] in %s : no vspace for stack vseg / process %x in cluster %x\n", |
---|
490 | __FUNCTION__ , process->pid , local_cxy ); |
---|
491 | return NULL; |
---|
492 | } |
---|
493 | |
---|
494 | // compute vseg base and size from vpn_base and vpn_size |
---|
495 | base = vpn_base << CONFIG_PPM_PAGE_SHIFT; |
---|
496 | size = vpn_size << CONFIG_PPM_PAGE_SHIFT; |
---|
497 | } |
---|
498 | else if( (type == VSEG_TYPE_ANON) || |
---|
499 | (type == VSEG_TYPE_FILE) || |
---|
500 | (type == VSEG_TYPE_REMOTE) ) |
---|
501 | { |
---|
502 | // get vpn_base and vpn_size from MMAP allocator |
---|
503 | vpn_t npages = size >> CONFIG_PPM_PAGE_SHIFT; |
---|
504 | error = vmm_mmap_alloc( vmm , npages , &vpn_base , &vpn_size ); |
---|
505 | if( error ) |
---|
506 | { |
---|
507 | printk("\n[ERROR] in %s : no vspace for mmap vseg / process %x in cluster %x\n", |
---|
508 | __FUNCTION__ , process->pid , local_cxy ); |
---|
509 | return NULL; |
---|
510 | } |
---|
511 | |
---|
512 | // compute vseg base and size from vpn_base and vpn_size |
---|
513 | base = vpn_base << CONFIG_PPM_PAGE_SHIFT; |
---|
514 | size = vpn_size << CONFIG_PPM_PAGE_SHIFT; |
---|
515 | } |
---|
516 | else |
---|
517 | { |
---|
518 | vpn_base = ARROUND_DOWN( base , CONFIG_PPM_PAGE_SIZE ) >> CONFIG_PPM_PAGE_SHIFT; |
---|
519 | vpn_size = ARROUND_UP( base + size , CONFIG_PPM_PAGE_SIZE ) >> CONFIG_PPM_PAGE_SHIFT; |
---|
520 | } |
---|
521 | |
---|
522 | // check collisions |
---|
523 | vseg = vmm_check_conflict( process , vpn_base , vpn_size ); |
---|
524 | if( vseg != NULL ) |
---|
525 | { |
---|
526 | printk("\n[ERROR] in %s for process %x : new vseg [vpn_base = %x / vpn_size = %x]\n" |
---|
527 | " overlap existing vseg [vpn_base = %x / vpn_size = %x]\n", |
---|
528 | __FUNCTION__ , process->pid, vpn_base, vpn_size, |
---|
529 | vseg->vpn_base, vseg->vpn_size ); |
---|
530 | return NULL; |
---|
531 | } |
---|
532 | |
---|
533 | // allocate physical memory for vseg descriptor |
---|
534 | vseg = vseg_alloc(); |
---|
535 | if( vseg == NULL ) |
---|
536 | { |
---|
537 | printk("\n[ERROR] in %s for process %x : cannot allocate memory for vseg\n", |
---|
538 | __FUNCTION__ , process->pid ); |
---|
539 | return NULL; |
---|
540 | } |
---|
541 | |
---|
542 | // initialize vseg descriptor |
---|
543 | vseg_init( vseg , base, size , vpn_base , vpn_size , type , local_cxy , 0 , 0 ); |
---|
544 | |
---|
545 | // update "heap_vseg" in VMM |
---|
546 | process->vmm.heap_vseg = vseg; |
---|
547 | |
---|
548 | // attach vseg to vmm |
---|
549 | rwlock_wr_lock( &vmm->vsegs_lock ); |
---|
550 | vseg_attach( vmm , vseg ); |
---|
551 | rwlock_wr_unlock( &vmm->vsegs_lock ); |
---|
552 | |
---|
553 | vmm_dmsg("\n[INFO] : %s exit for process %x, vseg [%x, %x] has been mapped\n", |
---|
554 | __FUNCTION__ , process->pid , vseg->min , vseg->max ); |
---|
555 | |
---|
556 | return vseg; |
---|
557 | } |
---|
558 | |
---|
559 | ///////////////////////////////////// |
---|
560 | void vmm_remove_vseg( vseg_t * vseg ) |
---|
561 | { |
---|
562 | // get pointers on calling process and VMM |
---|
563 | thread_t * this = CURRENT_THREAD; |
---|
564 | process_t * process = this->process; |
---|
565 | vmm_t * vmm = &this->process->vmm; |
---|
566 | uint32_t type = vseg->type; |
---|
567 | |
---|
568 | // detach vseg from VMM |
---|
569 | rwlock_wr_lock( &vmm->vsegs_lock ); |
---|
570 | vseg_detach( &process->vmm , vseg ); |
---|
571 | rwlock_wr_unlock( &vmm->vsegs_lock ); |
---|
572 | |
---|
573 | // release the stack slot to VMM stack allocator if STACK type |
---|
574 | if( type == VSEG_TYPE_STACK ) |
---|
575 | { |
---|
576 | // get pointer on stack allocator |
---|
577 | stack_mgr_t * mgr = &vmm->stack_mgr; |
---|
578 | |
---|
579 | // compute slot index |
---|
580 | uint32_t index = ((vseg->vpn_base - mgr->vpn_base - 1) / CONFIG_VMM_STACK_SIZE); |
---|
581 | |
---|
582 | // update stacks_bitmap |
---|
583 | spinlock_lock( &mgr->lock ); |
---|
584 | bitmap_clear( &mgr->bitmap , index ); |
---|
585 | spinlock_unlock( &mgr->lock ); |
---|
586 | } |
---|
587 | |
---|
588 | // release the vseg to VMM mmap allocator if MMAP type |
---|
589 | if( (type == VSEG_TYPE_ANON) || (type == VSEG_TYPE_FILE) || (type == VSEG_TYPE_REMOTE) ) |
---|
590 | { |
---|
591 | // get pointer on mmap allocator |
---|
592 | mmap_mgr_t * mgr = &vmm->mmap_mgr; |
---|
593 | |
---|
594 | // compute zombi_list index |
---|
595 | uint32_t index = bits_log2( vseg->vpn_size ); |
---|
596 | |
---|
597 | // update zombi_list |
---|
598 | spinlock_lock( &mgr->lock ); |
---|
599 | list_add_first( &mgr->zombi_list[index] , &vseg->list ); |
---|
600 | spinlock_unlock( &mgr->lock ); |
---|
601 | } |
---|
602 | |
---|
603 | // release physical memory allocated for vseg descriptor if no MMAP type |
---|
604 | if( (type != VSEG_TYPE_ANON) && (type != VSEG_TYPE_FILE) && (type != VSEG_TYPE_REMOTE) ) |
---|
605 | { |
---|
606 | vseg_free( vseg ); |
---|
607 | } |
---|
608 | } |
---|
609 | |
---|
610 | ////////////////////////////////////////////// |
---|
611 | error_t vmm_map_kernel_vseg( vseg_t * vseg, |
---|
612 | uint32_t attr ) |
---|
613 | { |
---|
614 | vpn_t vpn; // VPN of PTE to be set |
---|
615 | vpn_t vpn_min; // VPN of first PTE to be set |
---|
616 | vpn_t vpn_max; // VPN of last PTE to be set (excluded) |
---|
617 | ppn_t ppn; // PPN of allocated physical page |
---|
618 | uint32_t order; // ln( number of small pages for one single PTE ) |
---|
619 | page_t * page; |
---|
620 | error_t error; |
---|
621 | |
---|
622 | // check vseg type : must be a kernel vseg |
---|
623 | uint32_t type = vseg->type; |
---|
624 | assert( ((type==VSEG_TYPE_KCODE) || (type==VSEG_TYPE_KDATA) || (type==VSEG_TYPE_KDEV)), |
---|
625 | __FUNCTION__ , "not a kernel vseg\n" ); |
---|
626 | |
---|
627 | // get pointer on page table |
---|
628 | gpt_t * gpt = &process_zero.vmm.gpt; |
---|
629 | |
---|
630 | // define number of small pages per PTE |
---|
631 | if( attr & GPT_SMALL ) order = 0; // 1 small page |
---|
632 | else order = 9; // 512 small pages |
---|
633 | |
---|
634 | // loop on pages in vseg |
---|
635 | vpn_min = vseg->vpn_base; |
---|
636 | vpn_max = vpn_min + vseg->vpn_size; |
---|
637 | for( vpn = vpn_min ; vpn < vpn_max ; vpn++ ) |
---|
638 | { |
---|
639 | // allocate a physical page from local PPM |
---|
640 | kmem_req_t req; |
---|
641 | req.type = KMEM_PAGE; |
---|
642 | req.size = order; |
---|
643 | req.flags = AF_KERNEL | AF_ZERO; |
---|
644 | page = (page_t *)kmem_alloc( &req ); |
---|
645 | if( page == NULL ) |
---|
646 | { |
---|
647 | printk("\n[ERROR] in %s : cannot allocate physical memory\n", __FUNCTION__ ); |
---|
648 | return ENOMEM; |
---|
649 | } |
---|
650 | |
---|
651 | // set page table entry |
---|
652 | ppn = ppm_page2ppn( page ); |
---|
653 | error = hal_gpt_set_pte( gpt , vpn , ppn , attr ); |
---|
654 | if( error ) |
---|
655 | { |
---|
656 | printk("\n[ERROR] in %s : cannot register PPE\n", __FUNCTION__ ); |
---|
657 | return ENOMEM; |
---|
658 | } |
---|
659 | } |
---|
660 | |
---|
661 | return 0; |
---|
662 | } |
---|
663 | |
---|
664 | ///////////////////////////////////////// |
---|
665 | void vmm_unmap_vseg( process_t * process, |
---|
666 | vseg_t * vseg ) |
---|
667 | { |
---|
668 | vpn_t vpn; // VPN of current PTE |
---|
669 | vpn_t vpn_min; // VPN of first PTE |
---|
670 | vpn_t vpn_max; // VPN of last PTE (excluded) |
---|
671 | |
---|
672 | // get pointer on process page table |
---|
673 | gpt_t * gpt = &process->vmm.gpt; |
---|
674 | |
---|
675 | // loop on pages in vseg |
---|
676 | vpn_min = vseg->vpn_base; |
---|
677 | vpn_max = vpn_min + vseg->vpn_size; |
---|
678 | for( vpn = vpn_min ; vpn < vpn_max ; vpn++ ) |
---|
679 | { |
---|
680 | hal_gpt_reset_pte( gpt , vpn ); |
---|
681 | } |
---|
682 | } |
---|
683 | |
---|
684 | ///////////////////////////////////////////// |
---|
685 | error_t vmm_resize_vseg( process_t * process, |
---|
686 | intptr_t base, |
---|
687 | intptr_t size ) |
---|
688 | { |
---|
689 | error_t error; |
---|
690 | |
---|
691 | // get pointer on process VMM |
---|
692 | vmm_t * vmm = &process->vmm; |
---|
693 | |
---|
694 | intptr_t addr_min = base; |
---|
695 | intptr_t addr_max = base + size; |
---|
696 | uint32_t shift = CONFIG_PPM_PAGE_SHIFT; |
---|
697 | |
---|
698 | // get pointer on vseg |
---|
699 | vseg_t * vseg = grdxt_lookup( &vmm->grdxt , (uint32_t)(base >> shift) ); |
---|
700 | |
---|
701 | if( vseg == NULL) return EINVAL; |
---|
702 | |
---|
703 | // get VMM lock protecting vsegs list |
---|
704 | rwlock_wr_lock( &vmm->vsegs_lock ); |
---|
705 | |
---|
706 | if( (vseg->min > addr_min) || (vseg->max < addr_max) ) // region not included in vseg |
---|
707 | { |
---|
708 | error = EINVAL; |
---|
709 | } |
---|
710 | else if( (vseg->min == addr_min) && (vseg->max == addr_max) ) // vseg must be removed |
---|
711 | { |
---|
712 | vmm_remove_vseg( vseg ); |
---|
713 | error = 0; |
---|
714 | } |
---|
715 | else if( vseg->min == addr_min ) // vseg must be resized |
---|
716 | { |
---|
717 | printk("\n[PANIC] in %s : resize not implemented yet\n", __FUNCTION__ ); |
---|
718 | hal_core_sleep(); |
---|
719 | error = 0; |
---|
720 | } |
---|
721 | else if( vseg->max == addr_max ) // vseg must be resized |
---|
722 | { |
---|
723 | printk("\n[PANIC] in %s : resize not implemented yet\n", __FUNCTION__ ); |
---|
724 | hal_core_sleep(); |
---|
725 | error = 0; |
---|
726 | } |
---|
727 | else // vseg cut in three regions => vseg must be resized & new vseg created |
---|
728 | { |
---|
729 | printk("\n[PANIC] in %s : resize not implemented yet\n", __FUNCTION__ ); |
---|
730 | hal_core_sleep(); |
---|
731 | error = 0; |
---|
732 | } |
---|
733 | |
---|
734 | // release VMM lock |
---|
735 | rwlock_wr_unlock( &vmm->vsegs_lock ); |
---|
736 | |
---|
737 | return error; |
---|
738 | } |
---|
739 | |
---|
740 | /////////////////////////////////////////// |
---|
741 | vseg_t * vmm_get_vseg( process_t * process, |
---|
742 | intptr_t vaddr ) |
---|
743 | { |
---|
744 | |
---|
745 | // get pointer on process VMM |
---|
746 | vmm_t * vmm = &process->vmm; |
---|
747 | |
---|
748 | // get lock protecting the vseg list |
---|
749 | rwlock_rd_lock( &vmm->vsegs_lock ); |
---|
750 | |
---|
751 | // get pointer on vseg from radix tree |
---|
752 | vseg_t * vseg = grdxt_lookup( &vmm->grdxt, (uint32_t)(vaddr >> CONFIG_PPM_PAGE_SHIFT) ); |
---|
753 | |
---|
754 | // release the lock |
---|
755 | rwlock_rd_unlock( &vmm->vsegs_lock ); |
---|
756 | |
---|
757 | return vseg; |
---|
758 | } |
---|
759 | |
---|
760 | ///////////////////////////////////////// |
---|
761 | error_t vmm_get_pte( process_t * process, |
---|
762 | vpn_t vpn, |
---|
763 | uint32_t * ret_attr, |
---|
764 | ppn_t * ret_ppn ) |
---|
765 | { |
---|
766 | vseg_t * vseg; // pointer on vseg containing VPN |
---|
767 | ppn_t ppn; // PPN from GPT entry |
---|
768 | uint32_t attr; // attributes from GPT entry |
---|
769 | error_t error; |
---|
770 | |
---|
771 | // this function must be called by a thread running in the reference cluster |
---|
772 | assert( (GET_CXY( process->ref_xp ) == local_cxy ) , __FUNCTION__ , |
---|
773 | " not called in the reference cluster\n" ); |
---|
774 | |
---|
775 | // get VMM pointer |
---|
776 | vmm_t * vmm = &process->vmm; |
---|
777 | |
---|
778 | // access GPT to get PTE attributes and PPN |
---|
779 | hal_gpt_get_pte( &vmm->gpt , vpn , &attr , &ppn ); |
---|
780 | |
---|
781 | // if PTE unmapped => allocate one small physical page to map it |
---|
782 | if( (attr & GPT_MAPPED) == 0 ) |
---|
783 | { |
---|
784 | // get vseg pointer |
---|
785 | vseg = vmm_get_vseg( process , vpn<<CONFIG_PPM_PAGE_SHIFT ); |
---|
786 | |
---|
787 | if( vseg == NULL ); |
---|
788 | { |
---|
789 | printk("\n[ERROR] in %s : out of segment / process = %x / vpn = %x\n", |
---|
790 | __FUNCTION__ , process->pid , vpn ); |
---|
791 | return EINVAL; |
---|
792 | } |
---|
793 | |
---|
794 | // select the target cluster for physical mapping |
---|
795 | uint32_t target_cxy; |
---|
796 | if( vseg->flags & VSEG_DISTRIB ) // depends on VPN LSB |
---|
797 | { |
---|
798 | uint32_t x_width = LOCAL_CLUSTER->x_width; |
---|
799 | uint32_t y_width = LOCAL_CLUSTER->y_width; |
---|
800 | target_cxy = vpn & ((1<<(x_width + y_width)) - 1); |
---|
801 | } |
---|
802 | else // defined in vseg descriptor |
---|
803 | { |
---|
804 | target_cxy = vseg->cxy; |
---|
805 | } |
---|
806 | |
---|
807 | // allocate memory for page fault |
---|
808 | kmem_req_t req; |
---|
809 | page_t * page; |
---|
810 | if( target_cxy == local_cxy ) // target cluster is the local cluster |
---|
811 | { |
---|
812 | req.type = KMEM_PAGE; |
---|
813 | req.size = 0; |
---|
814 | req.flags = AF_NONE; |
---|
815 | page = (page_t *)kmem_alloc( &req ); |
---|
816 | |
---|
817 | error = ( page == NULL ) ? 1 : 0; |
---|
818 | ppn = ppm_page2ppn( page ); |
---|
819 | } |
---|
820 | else // target cluster is not the local cluster |
---|
821 | { |
---|
822 | rpc_pmem_get_pages_client( target_cxy , 0 , &error , &ppn ); |
---|
823 | } |
---|
824 | |
---|
825 | if( error ) |
---|
826 | { |
---|
827 | printk("\n[ERROR] in %s : cannot allocate memory / process = %x / vpn = %x\n", |
---|
828 | __FUNCTION__ , process->pid , vpn ); |
---|
829 | return ENOMEM; |
---|
830 | } |
---|
831 | |
---|
832 | // define GPT attributes from vseg flags |
---|
833 | attr = GPT_MAPPED | GPT_SMALL; |
---|
834 | if( vseg->flags & VSEG_USER ) attr |= GPT_USER; |
---|
835 | if( vseg->flags & VSEG_WRITE ) attr |= GPT_WRITABLE; |
---|
836 | if( vseg->flags & VSEG_EXEC ) attr |= GPT_EXECUTABLE; |
---|
837 | if( vseg->flags & VSEG_CACHE ) attr |= GPT_CACHABLE; |
---|
838 | |
---|
839 | // set the missing PTE in local VMM |
---|
840 | error = hal_gpt_set_pte( &vmm->gpt , vpn , ppn , attr ); |
---|
841 | if( error ) |
---|
842 | { |
---|
843 | printk("\n[ERROR] in %s : cannot register PTE / process = %x / vpn = %x\n", |
---|
844 | __FUNCTION__ , process->pid , vpn ); |
---|
845 | return ENOMEM; |
---|
846 | } |
---|
847 | } |
---|
848 | |
---|
849 | *ret_ppn = ppn; |
---|
850 | *ret_attr = attr; |
---|
851 | return 0; |
---|
852 | } |
---|
853 | |
---|
854 | /////////////////////////////////////////////////// |
---|
855 | error_t vmm_handle_page_fault( process_t * process, |
---|
856 | vseg_t * vseg, |
---|
857 | vpn_t vpn ) |
---|
858 | { |
---|
859 | uint32_t attr; // missing page attributes |
---|
860 | ppn_t ppn; // missing page PPN |
---|
861 | error_t error; // return value |
---|
862 | |
---|
863 | // get local VMM pointer |
---|
864 | vmm_t * vmm = &process->vmm; |
---|
865 | |
---|
866 | // get reference process cluster and local pointer |
---|
867 | cxy_t ref_cxy = GET_CXY( process->ref_xp ); |
---|
868 | process_t * ref_ptr = (process_t *)GET_PTR( process->ref_xp ); |
---|
869 | |
---|
870 | // get missing PTE attributes and PPN |
---|
871 | if( local_cxy != ref_cxy ) // local cluster is not the reference cluster |
---|
872 | { |
---|
873 | rpc_vmm_get_pte_client( ref_cxy , ref_ptr , vpn , &attr , &ppn , &error ); |
---|
874 | } |
---|
875 | else // local cluster is the reference cluster |
---|
876 | { |
---|
877 | error = vmm_get_pte( process , vpn , &attr , &ppn ); |
---|
878 | } |
---|
879 | |
---|
880 | // check page allocation error |
---|
881 | if( error ) |
---|
882 | { |
---|
883 | printk("\n[ERROR] in %s : cannot allocate memory / process = %x / vpn = %x\n", |
---|
884 | __FUNCTION__ , process->pid , vpn ); |
---|
885 | return ENOMEM; |
---|
886 | } |
---|
887 | |
---|
888 | // set the missing PTE in local VMM |
---|
889 | error = hal_gpt_set_pte( &vmm->gpt , vpn , attr , ppn ); |
---|
890 | if( error ) |
---|
891 | { |
---|
892 | printk("\n[ERROR] in %s : cannot register PTE / process = %x / vpn = %x\n", |
---|
893 | __FUNCTION__ , process->pid , vpn ); |
---|
894 | return ENOMEM; |
---|
895 | } |
---|
896 | |
---|
897 | return 0; |
---|
898 | } |
---|
899 | |
---|
900 | /////////////////////////////////////////// |
---|
901 | error_t vmm_v2p_translate( bool_t ident, |
---|
902 | void * ptr, |
---|
903 | paddr_t * paddr ) |
---|
904 | { |
---|
905 | process_t * process = CURRENT_THREAD->process; |
---|
906 | |
---|
907 | if( ident ) // identity mapping |
---|
908 | { |
---|
909 | *paddr = (paddr_t)PADDR( local_cxy , (lpa_t)ptr ); |
---|
910 | return 0; |
---|
911 | } |
---|
912 | |
---|
913 | // access page table |
---|
914 | error_t error; |
---|
915 | vpn_t vpn; |
---|
916 | uint32_t attr; |
---|
917 | ppn_t ppn; |
---|
918 | uint32_t offset; |
---|
919 | |
---|
920 | vpn = (vpn_t)( (intptr_t)ptr >> CONFIG_PPM_PAGE_SHIFT ); |
---|
921 | offset = (uint32_t)( ((intptr_t)ptr) & CONFIG_PPM_PAGE_MASK ); |
---|
922 | |
---|
923 | if( local_cxy == GET_CXY( process->ref_xp) ) // calling process is reference process |
---|
924 | { |
---|
925 | error = vmm_get_pte( process, vpn , &attr , &ppn ); |
---|
926 | } |
---|
927 | else // calling process is not reference process |
---|
928 | { |
---|
929 | cxy_t ref_cxy = GET_CXY( process->ref_xp ); |
---|
930 | process_t * ref_ptr = (process_t *)GET_PTR( process->ref_xp ); |
---|
931 | rpc_vmm_get_pte_client( ref_cxy , ref_ptr , vpn , &attr , &ppn , &error ); |
---|
932 | } |
---|
933 | |
---|
934 | // set paddr |
---|
935 | *paddr = (((paddr_t)ppn) << CONFIG_PPM_PAGE_SHIFT) | offset; |
---|
936 | |
---|
937 | return error; |
---|
938 | } |
---|
939 | |
---|
940 | /* |
---|
941 | |
---|
942 | /////////////////////////////////////////////////////////////////// |
---|
943 | /////////////////////////////////////////////////////////////////// |
---|
944 | error_t vmm_inval_shared_page( vseg_t *vseg, vma_t vaddr, ppn_t ppn) |
---|
945 | { |
---|
946 | pmm_page_info_t current; |
---|
947 | error_t err; |
---|
948 | |
---|
949 | error= pmm_get_page(&vseg->vmm->pmm, vaddr, ¤t); |
---|
950 | |
---|
951 | if((err) || (current.ppn != ppn)) |
---|
952 | goto ended; |
---|
953 | |
---|
954 | current.ppn = 0; |
---|
955 | current.attr = 0; |
---|
956 | current.cluster = NULL; |
---|
957 | |
---|
958 | error= pmm_set_page(&vseg->vmm->pmm, vaddr, ¤t); |
---|
959 | |
---|
960 | ended: |
---|
961 | return err; |
---|
962 | } |
---|
963 | |
---|
964 | error_t vmm_update_shared_page( vseg_t *vseg, vma_t vaddr, ppn_t ppn) |
---|
965 | { |
---|
966 | pmm_page_info_t current; |
---|
967 | error_t err; |
---|
968 | |
---|
969 | error= pmm_get_page(&vseg->vmm->pmm, vaddr, ¤t); |
---|
970 | |
---|
971 | if((err) || (current.attr != 0)) |
---|
972 | goto ended; |
---|
973 | |
---|
974 | current.ppn = ppn; |
---|
975 | current.attr = vseg->vm_pgprot; |
---|
976 | current.cluster = NULL; // this function is called after invalidate one |
---|
977 | |
---|
978 | error= pmm_set_page(&vseg->vmm->pmm, vaddr , ¤t); |
---|
979 | |
---|
980 | ended: |
---|
981 | return err; |
---|
982 | } |
---|
983 | |
---|
984 | // Hypothesis: the vseg is shared-anon, mapper list is rdlocked, page is locked |
---|
985 | error_t vmm_migrate_shared_page_seq( vseg_t *vseg, struct page_s *page, struct page_s **new) |
---|
986 | { |
---|
987 | register vseg_t *reg; |
---|
988 | register struct process_s *process; |
---|
989 | register struct process_s *this_process; |
---|
990 | struct page_s *new_pg; |
---|
991 | struct list_entry *iter; |
---|
992 | kmem_req_t req; |
---|
993 | vma_t vaddr; |
---|
994 | ppn_t ppn; |
---|
995 | error_t err; |
---|
996 | |
---|
997 | vaddr = (page->index << PMM_PAGE_SHIFT) + vseg->vm_start + vseg->vm_offset; |
---|
998 | ppn = ppm_page2ppn(page); |
---|
999 | this_process = (new == NULL) ? NULL : current_process; |
---|
1000 | iter = &vseg->vm_shared_list; |
---|
1001 | error = ECANCELED; |
---|
1002 | |
---|
1003 | // Invalidate All |
---|
1004 | do |
---|
1005 | { |
---|
1006 | reg = list_element(iter, vseg_t, vm_shared_list); |
---|
1007 | |
---|
1008 | process = vmm_get_process(reg->vmm); |
---|
1009 | |
---|
1010 | if(process != this_process) |
---|
1011 | { |
---|
1012 | error= vmm_inval_shared_page(reg, vaddr, ppn); |
---|
1013 | |
---|
1014 | if(err) goto fail_inval; |
---|
1015 | } |
---|
1016 | |
---|
1017 | assert(vseg->vm_mapper.m_home_cid == current_cid); |
---|
1018 | iter = list_next(&vseg->vm_mapper.m_reg_root, iter); |
---|
1019 | |
---|
1020 | }while(iter != NULL); |
---|
1021 | |
---|
1022 | req.type = KMEM_PAGE; |
---|
1023 | req.size = 0; |
---|
1024 | req.excep_code = AF_USER; |
---|
1025 | |
---|
1026 | new_pg = kmem_alloc(&req); |
---|
1027 | *new = new_pg; |
---|
1028 | |
---|
1029 | if(new_pg == NULL) |
---|
1030 | { |
---|
1031 | error= ENOMEM; |
---|
1032 | goto fail_alloc; |
---|
1033 | } |
---|
1034 | |
---|
1035 | page_copy(new_pg, page); |
---|
1036 | |
---|
1037 | page_lock(new_pg); |
---|
1038 | |
---|
1039 | new_pg->mapper = page->mapper; |
---|
1040 | new_pg->index = page->index; |
---|
1041 | |
---|
1042 | // TODO: do the complet job regading dirty page |
---|
1043 | if(PAGE_IS(page, PG_DIRTY)) |
---|
1044 | PAGE_SET(new_pg, PG_DIRTY); |
---|
1045 | |
---|
1046 | ppn = ppm_page2ppn(new_pg); |
---|
1047 | iter = &vseg->vm_shared_list; |
---|
1048 | |
---|
1049 | // Update All |
---|
1050 | do |
---|
1051 | { |
---|
1052 | reg = list_element(iter, vseg_t, vm_shared_list); |
---|
1053 | |
---|
1054 | process = vmm_get_process(reg->vmm); |
---|
1055 | |
---|
1056 | if(process != this_process) |
---|
1057 | (void) vmm_update_shared_page(reg, vaddr, ppn); |
---|
1058 | |
---|
1059 | assert(vseg->vm_mapper.m_home_cid == current_cid); |
---|
1060 | iter = list_next(&vseg->vm_mapper.m_reg_root, iter); |
---|
1061 | |
---|
1062 | |
---|
1063 | }while(iter != NULL); |
---|
1064 | |
---|
1065 | page_unlock(new_pg); |
---|
1066 | |
---|
1067 | fail_alloc: |
---|
1068 | fail_inval: |
---|
1069 | return err; |
---|
1070 | } |
---|
1071 | |
---|
1072 | //TODO: revisit all manipulation of the page->refcount |
---|
1073 | /////////////////////////////////////////////////////////////// |
---|
1074 | static inline error_t vmm_do_migrate( vseg_t * vseg, |
---|
1075 | pmm_page_info_t * pinfo, |
---|
1076 | uint32_t vaddr ) |
---|
1077 | { |
---|
1078 | kmem_req_t req; |
---|
1079 | pmm_page_info_t current; |
---|
1080 | page_t * newpage; |
---|
1081 | cluster_t * cluster; |
---|
1082 | thread_t * this; |
---|
1083 | error_t err; |
---|
1084 | ppn_t ppn; |
---|
1085 | |
---|
1086 | assert( pinfo->ppn != 0 ); |
---|
1087 | |
---|
1088 | ppn = pinfo->ppn; |
---|
1089 | this = current_thread; |
---|
1090 | newpage = NULL; |
---|
1091 | cluster = current_cluster; |
---|
1092 | |
---|
1093 | current.attr = 0; |
---|
1094 | current.ppn = 0; |
---|
1095 | |
---|
1096 | error= pmm_lock_page(&vseg->vmm->pmm, vaddr, ¤t); |
---|
1097 | |
---|
1098 | if(error|| (current.isAtomic == false) || |
---|
1099 | (current.ppn != ppn) || !(current.attr & PMM_MIGRATE)) |
---|
1100 | { |
---|
1101 | #if CONFIG_SHOW_SPURIOUS_PGFAULT |
---|
1102 | printk(INFO, "%s: pid %d, tid %d, cpu %d, nothing to do for vaddr %x\n", |
---|
1103 | __FUNCTION__, |
---|
1104 | this->process->pid, |
---|
1105 | this->info.order, |
---|
1106 | cpu_get_id(), |
---|
1107 | vaddr); |
---|
1108 | #endif |
---|
1109 | this->info.spurious_pgfault_cntr ++; |
---|
1110 | pmm_unlock_page(&vseg->vmm->pmm, vaddr, ¤t); |
---|
1111 | pmm_tlb_flush_vaddr(vaddr, PMM_DATA); |
---|
1112 | return 0; |
---|
1113 | } |
---|
1114 | |
---|
1115 | if(!ppn_is_local(ppn)) |
---|
1116 | { |
---|
1117 | req.type = KMEM_PAGE; |
---|
1118 | req.size = 0; |
---|
1119 | req.excep_code = AF_PGFAULT; |
---|
1120 | |
---|
1121 | newpage = kmem_alloc(&req); |
---|
1122 | |
---|
1123 | if(newpage) |
---|
1124 | { |
---|
1125 | newpage->mapper = NULL;//? |
---|
1126 | ppn_copy(ppm_page2ppn(newpage), ppn); |
---|
1127 | |
---|
1128 | if(current.attr & PMM_COW) |
---|
1129 | { |
---|
1130 | current.attr |= PMM_WRITE; |
---|
1131 | current.attr &= ~(PMM_COW); |
---|
1132 | } |
---|
1133 | |
---|
1134 | current.ppn = ppm_page2ppn(newpage); |
---|
1135 | } |
---|
1136 | } |
---|
1137 | |
---|
1138 | current.attr |= PMM_PRESENT; |
---|
1139 | current.attr &= ~(PMM_MIGRATE); |
---|
1140 | current.attr &= ~(PMM_LOCKED); |
---|
1141 | current.cluster = NULL; |
---|
1142 | |
---|
1143 | //also unlock the table entry |
---|
1144 | error= pmm_set_page(&vseg->vmm->pmm, vaddr, ¤t); |
---|
1145 | |
---|
1146 | if(err) |
---|
1147 | { |
---|
1148 | // TODO: we should differ the kmem_free call |
---|
1149 | //page_unlock(page); |
---|
1150 | (void)pmm_unlock_page(&vseg->vmm->pmm, vaddr, ¤t); |
---|
1151 | req.ptr = newpage; |
---|
1152 | kmem_free(&req); |
---|
1153 | return err; |
---|
1154 | } |
---|
1155 | |
---|
1156 | |
---|
1157 | if(newpage) |
---|
1158 | { |
---|
1159 | ppn_refcount_down(ppn); |
---|
1160 | current_thread->info.remote_pages_cntr ++; |
---|
1161 | #if CONFIG_SHOW_REMOTE_PGALLOC |
---|
1162 | printk(INFO, "%s: pid %d, tid %x, cpu %d, cid %d: got new remote page from cluster %d (vaddr %x)\n", |
---|
1163 | __FUNCTION__, |
---|
1164 | current_process->pid, |
---|
1165 | current_thread, |
---|
1166 | cpu_get_id(), |
---|
1167 | cluster->id, |
---|
1168 | newpage->cid, |
---|
1169 | vaddr); |
---|
1170 | #endif |
---|
1171 | } |
---|
1172 | |
---|
1173 | #if CONFIG_SHOW_VMMMGRT_MSG |
---|
1174 | printk(INFO, "%s: pid %d, tid %d, cpu %d: Asked to migrate page (vaddr %x) from cluster %d to cluster %d, error%d\n", |
---|
1175 | __FUNCTION__, |
---|
1176 | current_process->pid, |
---|
1177 | current_thread->info.order, |
---|
1178 | cpu_get_id(), |
---|
1179 | vaddr, |
---|
1180 | ppn_ppn2cid(ppn), |
---|
1181 | cluster->id, |
---|
1182 | err); |
---|
1183 | #endif |
---|
1184 | |
---|
1185 | return err; |
---|
1186 | } |
---|
1187 | |
---|
1188 | error_t vmm_do_cow( vseg_t *vseg, pmm_page_info_t *pinfo, uint32_t vaddr) |
---|
1189 | { |
---|
1190 | register struct page_s *newpage; |
---|
1191 | register struct page_s *page; |
---|
1192 | register struct thread_s *this; |
---|
1193 | register error_t err; |
---|
1194 | register uint32_t count; |
---|
1195 | register bool_t isCountDown; |
---|
1196 | pmm_page_info_t old; |
---|
1197 | pmm_page_info_t new; |
---|
1198 | kmem_req_t req; |
---|
1199 | |
---|
1200 | this = current_thread; |
---|
1201 | old.attr = 0; |
---|
1202 | newpage = NULL; |
---|
1203 | isCountDown = true; |
---|
1204 | |
---|
1205 | vmm_dmsg(2,"%s: pid %d, tid %d, cpu %d, vaddr %x\n", |
---|
1206 | __FUNCTION__, |
---|
1207 | this->process->pid, |
---|
1208 | this->info.order, |
---|
1209 | cpu_get_id(), |
---|
1210 | vaddr); |
---|
1211 | |
---|
1212 | |
---|
1213 | error= pmm_lock_page(&vseg->vmm->pmm, vaddr, &old); |
---|
1214 | |
---|
1215 | //TODO: check this condition |
---|
1216 | if(error|| (old.isAtomic == false) || !(old.attr & PMM_COW)) |
---|
1217 | { |
---|
1218 | #if CONFIG_SHOW_SPURIOUS_PGFAULT |
---|
1219 | printk(INFO, "%s: pid %d, tid %d, cpu %d, nothing to do for vaddr %x\n", |
---|
1220 | __FUNCTION__, |
---|
1221 | this->process->pid, |
---|
1222 | this->info.order, |
---|
1223 | cpu_get_id(), |
---|
1224 | vaddr); |
---|
1225 | #endif |
---|
1226 | this->info.spurious_pgfault_cntr ++; |
---|
1227 | pmm_tlb_flush_vaddr(vaddr, PMM_DATA); |
---|
1228 | pmm_unlock_page(&vseg->vmm->pmm, vaddr, &old); |
---|
1229 | return err; |
---|
1230 | //goto VMM_COW_END; |
---|
1231 | } |
---|
1232 | |
---|
1233 | //if the ppn is local and the others (processus with wich we share the page) |
---|
1234 | //has done cow, then use the old.ppn directly |
---|
1235 | if(ppn_is_local(old.ppn)) |
---|
1236 | { |
---|
1237 | page = ppm_ppn2page(¤t_cluster->ppm, old.ppn); |
---|
1238 | |
---|
1239 | if(page->mapper == NULL) |
---|
1240 | { |
---|
1241 | count = page_refcount_get(page); |
---|
1242 | if(count == 1) |
---|
1243 | { |
---|
1244 | newpage = page;//don't copy the page. use it directly. |
---|
1245 | isCountDown = false; |
---|
1246 | vmm_dmsg(2, "%s: pid %d, tid %d, cpu %d, reuse same page for vaddr %x, pg_addr %x\n", |
---|
1247 | __FUNCTION__, |
---|
1248 | this->process->pid, |
---|
1249 | this->info.order, |
---|
1250 | cpu_get_id(), |
---|
1251 | vaddr, |
---|
1252 | ppm_page2addr(page)); |
---|
1253 | } |
---|
1254 | } |
---|
1255 | //else: we need to do the cow even if it's local! |
---|
1256 | |
---|
1257 | } |
---|
1258 | |
---|
1259 | //else: alocate newpage and copy the data from the remote node |
---|
1260 | //also defcount down the ppn |
---|
1261 | if(newpage == NULL) |
---|
1262 | { |
---|
1263 | req.type = KMEM_PAGE; |
---|
1264 | req.size = 0; |
---|
1265 | req.excep_code = AF_PGFAULT; |
---|
1266 | |
---|
1267 | if((newpage = kmem_alloc(&req)) == NULL) |
---|
1268 | { |
---|
1269 | (void)pmm_unlock_page(&vseg->vmm->pmm, vaddr, &old); |
---|
1270 | return ENOMEM; |
---|
1271 | } |
---|
1272 | |
---|
1273 | newpage->mapper = NULL; |
---|
1274 | |
---|
1275 | ppn_copy(ppm_page2ppn(newpage), old.ppn); |
---|
1276 | assert(isCountDown); |
---|
1277 | |
---|
1278 | vmm_dmsg(2, |
---|
1279 | "%s: pid %d, tid %d, cpu %d, newpage for vaddr %x, pg_addr %x\n", |
---|
1280 | __FUNCTION__, |
---|
1281 | this->process->pid, |
---|
1282 | this->info.order, |
---|
1283 | cpu_get_id(), |
---|
1284 | vaddr, |
---|
1285 | ppm_page2addr(newpage)); |
---|
1286 | |
---|
1287 | if(newpage->cid != current_cid) |
---|
1288 | this->info.remote_pages_cntr ++; |
---|
1289 | } |
---|
1290 | |
---|
1291 | new.attr = vseg->vm_pgprot | PMM_WRITE; |
---|
1292 | new.attr &= ~(PMM_COW | PMM_MIGRATE); |
---|
1293 | new.ppn = ppm_page2ppn(newpage); |
---|
1294 | new.cluster = NULL; |
---|
1295 | |
---|
1296 | //this also unlock the table entry (if no error) |
---|
1297 | error= pmm_set_page(&vseg->vmm->pmm, vaddr, &new); |
---|
1298 | |
---|
1299 | if(err) |
---|
1300 | { |
---|
1301 | (void)pmm_unlock_page(&vseg->vmm->pmm, vaddr, &old); |
---|
1302 | req.ptr = newpage; |
---|
1303 | kmem_free(&req); |
---|
1304 | vmm_dmsg(3, "%s: ended [ error%d ]\n", __FUNCTION__, err); |
---|
1305 | return err; |
---|
1306 | } |
---|
1307 | |
---|
1308 | if(isCountDown) ppn_refcount_down(old.ppn); |
---|
1309 | |
---|
1310 | vmm_dmsg(2, "%s, pid %d, tid %d, cpu %d, COW ended [vaddr %x]\n", |
---|
1311 | __FUNCTION__, |
---|
1312 | this->process->pid, |
---|
1313 | this->info.order, |
---|
1314 | cpu_get_id(), |
---|
1315 | vaddr); |
---|
1316 | |
---|
1317 | return 0; |
---|
1318 | } |
---|
1319 | |
---|
1320 | |
---|
1321 | //refcount is taken on the file at mmap |
---|
1322 | static inline error_t vmm_do_mapped( vseg_t *vseg, uint32_t vaddr, uint32_t excep_code) |
---|
1323 | { |
---|
1324 | ppn_t ppn; |
---|
1325 | error_t err; |
---|
1326 | uint32_t index; |
---|
1327 | bool_t isDone; |
---|
1328 | pmm_page_info_t info; |
---|
1329 | pmm_page_info_t current; |
---|
1330 | struct thread_s *this; |
---|
1331 | |
---|
1332 | this = current_thread; |
---|
1333 | |
---|
1334 | current.attr = 1; |
---|
1335 | current.ppn = 1; |
---|
1336 | isDone = false; |
---|
1337 | |
---|
1338 | error= pmm_lock_page(&vseg->vmm->pmm, vaddr, ¤t); |
---|
1339 | |
---|
1340 | if(err) return err; |
---|
1341 | |
---|
1342 | if((current.isAtomic == false) || (current.attr != 0)) |
---|
1343 | { |
---|
1344 | #if CONFIG_SHOW_SPURIOUS_PGFAULT |
---|
1345 | printk(INFO, "%s: pid %d, tid %d, cpu %d, nothing to do for vaddr %x\n", |
---|
1346 | __FUNCTION__, |
---|
1347 | this->process->pid, |
---|
1348 | this->info.order, |
---|
1349 | cpu_get_id(), |
---|
1350 | vaddr); |
---|
1351 | #endif |
---|
1352 | this->info.spurious_pgfault_cntr ++; |
---|
1353 | pmm_tlb_flush_vaddr(vaddr, PMM_DATA); |
---|
1354 | return 0; |
---|
1355 | } |
---|
1356 | |
---|
1357 | index = ((vaddr - vseg->vm_start) + vseg->vm_offset) >> PMM_PAGE_SHIFT; |
---|
1358 | |
---|
1359 | //also hold a refcount! |
---|
1360 | ppn = mapper_get_ppn(&vseg->vm_mapper, |
---|
1361 | index, |
---|
1362 | MAPPER_SYNC_OP); |
---|
1363 | |
---|
1364 | if(!ppn) |
---|
1365 | { |
---|
1366 | error= pmm_unlock_page(&vseg->vmm->pmm, vaddr, ¤t); |
---|
1367 | assert(!err); //FIXME: liberate the ppn ... |
---|
1368 | return (VFS_FILE_IS_NULL(vseg->vm_file)) ? EIO : ENOMEM; |
---|
1369 | } |
---|
1370 | |
---|
1371 | info.attr = vseg->vm_pgprot; |
---|
1372 | info.ppn = ppn; |
---|
1373 | info.cluster = NULL; |
---|
1374 | |
---|
1375 | //also unlock the page |
---|
1376 | error= pmm_set_page(&vseg->vmm->pmm, vaddr, &info); |
---|
1377 | |
---|
1378 | assert(!err);//FIXME: liberate the ppn and unlock the table entry ... |
---|
1379 | //error= pmm_unlock_page(&vseg->vmm->pmm, vaddr, ¤t); |
---|
1380 | |
---|
1381 | return err; |
---|
1382 | } |
---|
1383 | |
---|
1384 | ///////////////////////////////////////////////////// |
---|
1385 | static inline error_t vmm_do_aod( vseg_t *vseg, uint32_t vaddr) |
---|
1386 | { |
---|
1387 | register error_t err; |
---|
1388 | register struct page_s *page; |
---|
1389 | register struct cluster_s *cluster; |
---|
1390 | struct thread_s *this; |
---|
1391 | pmm_page_info_t old; |
---|
1392 | pmm_page_info_t new; |
---|
1393 | kmem_req_t req; |
---|
1394 | |
---|
1395 | page = NULL; |
---|
1396 | old.attr = 0; |
---|
1397 | this = current_thread; |
---|
1398 | |
---|
1399 | error= pmm_lock_page(&vseg->vmm->pmm, vaddr, &old); |
---|
1400 | |
---|
1401 | if(err) return err; |
---|
1402 | |
---|
1403 | if(old.isAtomic == false) |
---|
1404 | { |
---|
1405 | this->info.spurious_pgfault_cntr ++; |
---|
1406 | pmm_tlb_flush_vaddr(vaddr, PMM_DATA); |
---|
1407 | return 0; |
---|
1408 | } |
---|
1409 | |
---|
1410 | req.type = KMEM_PAGE; |
---|
1411 | req.size = 0; |
---|
1412 | req.excep_code = AF_PGFAULT | AF_ZERO; |
---|
1413 | |
---|
1414 | if((page = kmem_alloc(&req)) == NULL) |
---|
1415 | { |
---|
1416 | (void)pmm_unlock_page(&vseg->vmm->pmm, vaddr, &old); |
---|
1417 | return ENOMEM; |
---|
1418 | } |
---|
1419 | |
---|
1420 | page->mapper = NULL; |
---|
1421 | |
---|
1422 | new.attr = vseg->vm_pgprot; |
---|
1423 | new.ppn = ppm_page2ppn(page); |
---|
1424 | new.cluster = NULL; |
---|
1425 | |
---|
1426 | error= pmm_set_page(&vseg->vmm->pmm, vaddr, &new); |
---|
1427 | |
---|
1428 | if(err) goto fail_set_pg; |
---|
1429 | |
---|
1430 | cluster = current_cluster; |
---|
1431 | |
---|
1432 | if(page->cid != cluster->id) |
---|
1433 | this->info.remote_pages_cntr ++; |
---|
1434 | |
---|
1435 | return 0; |
---|
1436 | |
---|
1437 | fail_set_pg: |
---|
1438 | (void)pmm_unlock_page(&vseg->vmm->pmm, vaddr, &old); |
---|
1439 | req.ptr = page; |
---|
1440 | kmem_free(&req); |
---|
1441 | |
---|
1442 | vmm_dmsg(3, "%s: ended [ error%d ]\n", __FUNCTION__, err); |
---|
1443 | return err; |
---|
1444 | } |
---|
1445 | |
---|
1446 | VSEGION_PAGE_FAULT(vmm_default_pagefault) |
---|
1447 | { |
---|
1448 | register struct thread_s *this; |
---|
1449 | register error_t err; |
---|
1450 | pmm_page_info_t info; |
---|
1451 | |
---|
1452 | if((error= pmm_get_page(&vseg->vmm->pmm, vaddr, &info))) |
---|
1453 | return err; |
---|
1454 | |
---|
1455 | if((info.attr != 0) && (info.ppn != 0)) |
---|
1456 | { |
---|
1457 | if((info.attr & PMM_COW) && pmm_except_isWrite(excep_code)) |
---|
1458 | { |
---|
1459 | error= vmm_do_cow(vseg, &info, vaddr); |
---|
1460 | return err; |
---|
1461 | } |
---|
1462 | |
---|
1463 | if(info.attr & PMM_MIGRATE) |
---|
1464 | return vmm_do_migrate(vseg, &info, vaddr); |
---|
1465 | |
---|
1466 | if(info.attr & PMM_PRESENT) |
---|
1467 | { |
---|
1468 | this = current_thread; |
---|
1469 | |
---|
1470 | #if CONFIG_SHOW_SPURIOUS_PGFAULT |
---|
1471 | printk(WARNING, "WARNING: %s: pid %d, tid %d, cpu %d, excep_code %x but vaddr is valid %x, attr %x, ppn %x\n", |
---|
1472 | __FUNCTION__, |
---|
1473 | this->process->pid, |
---|
1474 | this->info.order, |
---|
1475 | cpu_get_id(), |
---|
1476 | excep_code, |
---|
1477 | vaddr, |
---|
1478 | info.attr, |
---|
1479 | info.ppn); |
---|
1480 | #endif |
---|
1481 | |
---|
1482 | current_thread->info.spurious_pgfault_cntr ++; |
---|
1483 | pmm_tlb_flush_vaddr(vaddr, PMM_UNKNOWN); |
---|
1484 | return 0; |
---|
1485 | } |
---|
1486 | |
---|
1487 | current_thread->info.spurious_pgfault_cntr ++; |
---|
1488 | pmm_tlb_flush_vaddr(vaddr, PMM_UNKNOWN); |
---|
1489 | return 0; |
---|
1490 | #if 0 |
---|
1491 | #if CONFIG_SHOW_VMM_ERROR_MSG |
---|
1492 | printk(ERROR, |
---|
1493 | "ERROR: %s: pid %d, cpu %d, Unexpected page attributes configuration for vaddr %x, found: ppn %x, attr %x\n", |
---|
1494 | __FUNCTION__, |
---|
1495 | current_process->pid, |
---|
1496 | cpu_get_id(), |
---|
1497 | vaddr, |
---|
1498 | info.ppn, |
---|
1499 | info.attr); |
---|
1500 | #endif |
---|
1501 | |
---|
1502 | return EPERM; |
---|
1503 | #endif |
---|
1504 | } |
---|
1505 | |
---|
1506 | if(!MAPPER_IS_NULL(vseg->vm_mapper)) |
---|
1507 | return vmm_do_mapped(vseg, vaddr, excep_code); |
---|
1508 | |
---|
1509 | return vmm_do_aod(vseg, vaddr); |
---|
1510 | } |
---|
1511 | */ |
---|
1512 | |
---|