fix: lazy load executable files of user processes even when accessed in a kernel context

This commit is contained in:
Themis Demetriades
2024-12-04 22:21:31 +00:00
parent 723055f485
commit 60faf995ea

View File

@@ -158,6 +158,16 @@ page_fault (struct intr_frame *f)
#ifdef VM
struct thread *t = thread_current ();
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 (not_present)
@@ -193,15 +203,6 @@ page_fault (struct intr_frame *f)
f->eax = 0xffffffff;
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
/* To implement virtual memory, delete the rest of the function