Implement VM #63

Merged
td1223 merged 94 commits from vm/merged/themis into master 2024-12-06 05:07:14 +00:00
11 changed files with 243 additions and 62 deletions
Showing only changes of commit 47a7dfae04 - Show all commits

View File

@@ -155,11 +155,15 @@ page_fault (struct intr_frame *f)
user = (f->error_code & PF_U) != 0;
#ifdef VM
struct thread *t = thread_current ();
if (user)
{
if (not_present)
{
struct thread *t = thread_current ();
/* Check if the non-present user page is in the swap partition.
If so, swap it back into main memory, updating the PTE for
the faulted virtual address to point to the newly allocated
frame. */
if (page_in_swap (t, fault_addr))
{
size_t swap_slot = page_get_swap (t, fault_addr);
@@ -171,15 +175,18 @@ page_fault (struct intr_frame *f)
if (pagedir_set_page (t->pagedir, upage, kpage, writeable)) return;
}
/* Handle page faults that need to be resolved by dynamic stack growth
by checking if this is such a fault and resolving it appropriately. */
/* Handle user page faults that need to be resolved by dynamic
stack growth by checking if this is such a fault and responding
accordingly. */
if (handle_stack_fault (fault_addr, f->esp)) return;
}
}
else
{
/* Allows for stack growth in kernel context, due to syscall failure */
if (handle_stack_fault (fault_addr, thread_current ()->curr_esp)) return;
/* 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;
f->eip = (void *)f->eax;
f->eax = 0xffffffff;