Implement VM #63

Merged
td1223 merged 94 commits from vm/merged/themis into master 2024-12-06 05:07:14 +00:00
10 changed files with 70 additions and 353 deletions
Showing only changes of commit af7f2ba873 - Show all commits

View File

@@ -5,12 +5,14 @@
#include "threads/vaddr.h" #include "threads/vaddr.h"
#include "userprog/pagedir.h" #include "userprog/pagedir.h"
#define MAX_STACK_ACCESS_DIST 32
/* Validates a given address for being <=32 bytes away from the stack pointer or /* Validates a given address for being <=32 bytes away from the stack pointer or
above the stack */ above the stack */
bool needs_new_page (void *addr, void *esp) bool needs_new_page (void *addr, void *esp)
{ {
return (is_user_vaddr (addr) && return (is_user_vaddr (addr) &&
(uint32_t*)addr >= ((uint32_t*)esp - 32) && (uint32_t*)addr >= ((uint32_t*)esp - MAX_STACK_ACCESS_DIST) &&
((PHYS_BASE - pg_round_down (addr)) ((PHYS_BASE - pg_round_down (addr))
<= MAX_STACK_SIZE)); <= MAX_STACK_SIZE));
} }