fix: modify stack growth to use frame allocation to allow for page swapping
This commit is contained in:
@@ -170,12 +170,12 @@ page_fault (struct intr_frame *f)
|
||||
void *upage = pg_round_down (fault_addr);
|
||||
if (not_present && is_user_vaddr (upage) && upage != NULL)
|
||||
{
|
||||
if (fetch_page (upage, write))
|
||||
return;
|
||||
|
||||
if (is_valid_stack_access (fault_addr, esp))
|
||||
if (grow_stack (upage))
|
||||
return;
|
||||
|
||||
if (fetch_page (upage, write))
|
||||
return;
|
||||
}
|
||||
|
||||
/* If the page fault occurred in kernel mode, then we intentionally indicate
|
||||
@@ -232,14 +232,14 @@ static bool
|
||||
grow_stack (void *upage)
|
||||
{
|
||||
/* Allocate new page for stack */
|
||||
void *kpage = palloc_get_page (PAL_USER | PAL_ZERO);
|
||||
if (kpage == NULL)
|
||||
void *new_page = frame_alloc (PAL_ZERO, upage, thread_current ());
|
||||
if (new_page == NULL)
|
||||
return false;
|
||||
|
||||
/* Install the page into user page table */
|
||||
if (!install_page (upage, kpage, true))
|
||||
if (!pagedir_set_page (thread_current ()->pagedir, upage, new_page, true))
|
||||
{
|
||||
palloc_free_page (kpage);
|
||||
frame_free (new_page);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user