Change address reporting to fit the grading script's standards.
This commit is contained in:
parent
8cd1daf8dd
commit
0fe97e52c3
@ -563,13 +563,14 @@ int
|
||||
user_mem_check(struct Env *env, const void *va, size_t len, int perm)
|
||||
{
|
||||
// LAB 3: Your code here.
|
||||
uintptr_t to_report = (uintptr_t) va;
|
||||
const char* bottom = ROUNDDOWN(va, PGSIZE);
|
||||
size_t aligned_count = ROUNDUP(len, PGSIZE) / PGSIZE;
|
||||
pde_t mask = PTE_P | PTE_U | PTE_W;
|
||||
pde_t perms = mask;
|
||||
|
||||
#define VALID ((perms & (perm | PTE_P)) == (perm | PTE_P))
|
||||
#define DO_CHECK if(!VALID) { user_mem_check_addr = (uintptr_t) bottom; return -E_FAULT; }
|
||||
#define DO_CHECK if(!VALID) { user_mem_check_addr = to_report; return -E_FAULT; }
|
||||
|
||||
while(aligned_count--) {
|
||||
perms &= env->env_pgdir[PDX(bottom)] & mask;
|
||||
@ -577,6 +578,7 @@ user_mem_check(struct Env *env, const void *va, size_t len, int perm)
|
||||
perms &= (*pgdir_walk(env->env_pgdir, bottom, 0)) & mask;
|
||||
DO_CHECK;
|
||||
bottom += PGSIZE;
|
||||
to_report = (uintptr_t) bottom;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user