Update syscall handling of invalid pointers by preloading pages using the helper try_fetch_page

This commit is contained in:
sBubshait
2024-11-29 18:55:28 +00:00
parent d047a3c242
commit 8047c65227
3 changed files with 30 additions and 13 deletions

View File

@@ -13,7 +13,7 @@ static long long page_fault_cnt;
static void kill (struct intr_frame *);
static void page_fault (struct intr_frame *);
static bool try_fetch_page (void *upage, bool write);
bool try_fetch_page (void *upage, bool write);
/* Registers handlers for interrupts that can be caused by user
programs.
@@ -149,6 +149,14 @@ page_fault (struct intr_frame *f)
write = (f->error_code & PF_W) != 0;
user = (f->error_code & PF_U) != 0;
if (!user)
{
f->eip = (void *)f->eax;
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. */
@@ -170,7 +178,7 @@ page_fault (struct intr_frame *f)
kill (f);
}
static bool
bool
try_fetch_page (void *upage, bool write)
{
/* Check if the page is in the supplemental page table. That is, it is a page