fix: modify stack growth to use frame allocation to allow for page swapping
This commit is contained in:
@@ -170,11 +170,11 @@ page_fault (struct intr_frame *f)
|
|||||||
void *upage = pg_round_down (fault_addr);
|
void *upage = pg_round_down (fault_addr);
|
||||||
if (not_present && is_user_vaddr (upage) && upage != NULL)
|
if (not_present && is_user_vaddr (upage) && upage != NULL)
|
||||||
{
|
{
|
||||||
if (is_valid_stack_access (fault_addr, esp))
|
if (fetch_page (upage, write))
|
||||||
if (grow_stack (upage))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fetch_page (upage, write))
|
if (is_valid_stack_access (fault_addr, esp))
|
||||||
|
if (grow_stack (upage))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,14 +232,14 @@ static bool
|
|||||||
grow_stack (void *upage)
|
grow_stack (void *upage)
|
||||||
{
|
{
|
||||||
/* Allocate new page for stack */
|
/* Allocate new page for stack */
|
||||||
void *kpage = palloc_get_page (PAL_USER | PAL_ZERO);
|
void *new_page = frame_alloc (PAL_ZERO, upage, thread_current ());
|
||||||
if (kpage == NULL)
|
if (new_page == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Install the page into user page table */
|
/* 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user