Implement VM #63

Merged
td1223 merged 94 commits from vm/merged/themis into master 2024-12-06 05:07:14 +00:00
16 changed files with 477 additions and 74 deletions
Showing only changes of commit 0288e13206 - Show all commits

View File

@@ -156,22 +156,12 @@ page_fault (struct intr_frame *f)
user = (f->error_code & PF_U) != 0; user = (f->error_code & PF_U) != 0;
#ifdef VM #ifdef VM
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 (not_present && is_user_vaddr(upage))
{ {
if (try_fetch_page (upage, write)) struct thread *t = thread_current ();
return; void *esp = user ? f->esp : t->curr_esp;
}
if (user)
{
if (not_present)
{
/* Check if the non-present user page is in the swap partition. /* Check if the non-present user page is in the swap partition.
If so, swap it back into main memory, updating the PTE for If so, swap it back into main memory, updating the PTE for
the faulted virtual address to point to the newly allocated the faulted virtual address to point to the newly allocated
@@ -189,16 +179,19 @@ page_fault (struct intr_frame *f)
/* Handle user page faults that need to be resolved by dynamic /* Handle user page faults that need to be resolved by dynamic
stack growth by checking if this is such a fault and responding stack growth by checking if this is such a fault and responding
accordingly. */ accordingly. */
if (handle_stack_fault (fault_addr, f->esp)) return; if (handle_stack_fault (fault_addr, esp)) return;
}
}
else
{
/* Handle kernel page faults that need to be resolved by dynamic stack
growth by checking if this is such a fault and responding
accordingly. */
if (not_present && handle_stack_fault (fault_addr, t->curr_esp)) return;
/* Handle user page faults that need to be resolved by lazy loading
of executable files by checking if they contain entries in the
SPT hash map and responding accordingly. */
if (try_fetch_page (upage, write))
return;
}
/* Allows for page faults within a kernel context to communicate with
user pages for sending error codes. */
if (!user)
{
f->eip = (void *)f->eax; f->eip = (void *)f->eax;
f->eax = 0xffffffff; f->eax = 0xffffffff;
return; return;