fix: lazy load executable files of user processes even when accessed in a kernel context
This commit is contained in:
@@ -158,6 +158,16 @@ page_fault (struct intr_frame *f)
|
|||||||
#ifdef VM
|
#ifdef VM
|
||||||
struct thread *t = thread_current ();
|
struct thread *t = thread_current ();
|
||||||
void *upage = pg_round_down (fault_addr);
|
void *upage = pg_round_down (fault_addr);
|
||||||
|
|
||||||
|
/* If the fault address is in a user page that is not present, then it might
|
||||||
|
be an executable file page that needs to be lazily loaded. So, we check the
|
||||||
|
SPT to determine if this is the case, and if so load the page from disk. */
|
||||||
|
if (not_present && is_user_vaddr (upage))
|
||||||
|
{
|
||||||
|
if (try_fetch_page (upage, write))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (user)
|
if (user)
|
||||||
{
|
{
|
||||||
if (not_present)
|
if (not_present)
|
||||||
@@ -193,15 +203,6 @@ page_fault (struct intr_frame *f)
|
|||||||
f->eax = 0xffffffff;
|
f->eax = 0xffffffff;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the fault address is in a user page that is not present, then it might
|
|
||||||
just need to be lazily loaded. So, we check our SPT to see if the page
|
|
||||||
is expected to have data loaded in memory. */
|
|
||||||
if (not_present && is_user_vaddr (upage) && upage != NULL)
|
|
||||||
{
|
|
||||||
if (try_fetch_page (upage, write))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* To implement virtual memory, delete the rest of the function
|
/* To implement virtual memory, delete the rest of the function
|
||||||
|
|||||||
Reference in New Issue
Block a user