MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / _fetch_page_for_varea

Function _fetch_page_for_varea

components/mm/mm_anon.c:309–361  ·  view source on GitHub ↗

get the backup page in kernel for the address in user space */

Source from the content-addressed store, hash-verified

307
308/* get the backup page in kernel for the address in user space */
309static void _fetch_page_for_varea(struct rt_varea *varea, struct rt_aspace_fault_msg *msg, rt_bool_t need_map)
310{
311 void *paddr;
312 char *frame_ka;
313 rt_aspace_t curr_aspace = varea->aspace;
314 rt_aspace_t backup = _anon_obj_get_backup(varea->mem_obj);
315
316 RDWR_LOCK(curr_aspace);
317
318 /**
319 * if the page is already mapped(this may caused by data race while other
320 * thread success to take the lock and mapped the page before this), return okay
321 */
322 paddr = rt_hw_mmu_v2p(curr_aspace, msg->fault_vaddr);
323 if (paddr == ARCH_MAP_FAILED)
324 {
325 if (backup == curr_aspace)
326 {
327 rt_mm_dummy_mapper.on_page_fault(varea, msg);
328 if (msg->response.status != MM_FAULT_STATUS_UNRECOVERABLE)
329 {
330 /* if backup == curr_aspace, a page fetch always binding with a pte filling */
331 _map_page_in_varea(backup, varea, msg, msg->fault_vaddr);
332 if (msg->response.status != MM_FAULT_STATUS_UNRECOVERABLE)
333 {
334 rt_pages_free(msg->response.vaddr, 0);
335 }
336 }
337 }
338 else
339 {
340 frame_ka = _get_page_from_backup(backup, msg->off);
341 if (frame_ka)
342 {
343 msg->response.vaddr = frame_ka;
344 msg->response.size = ARCH_PAGE_SIZE;
345 if (!need_map)
346 {
347 msg->response.status = MM_FAULT_STATUS_OK;
348 }
349 else
350 {
351 _map_page_in_varea(curr_aspace, varea, msg, msg->fault_vaddr);
352 }
353 }
354 }
355 }
356 else
357 {
358 msg->response.status = MM_FAULT_STATUS_OK_MAPPED;
359 }
360 RDWR_UNLOCK(curr_aspace);
361}
362
363static void _anon_page_fault(struct rt_varea *varea, struct rt_aspace_fault_msg *msg)
364{

Callers 3

_anon_page_faultFunction · 0.85
_anon_page_readFunction · 0.85
_anon_page_writeFunction · 0.85

Calls 5

_anon_obj_get_backupFunction · 0.85
_map_page_in_vareaFunction · 0.85
rt_pages_freeFunction · 0.85
_get_page_from_backupFunction · 0.85
rt_hw_mmu_v2pFunction · 0.50

Tested by

no test coverage detected