diff --git a/kernel/defs.h b/kernel/defs.h index 3172cb3..fb2672e 100644 --- a/kernel/defs.h +++ b/kernel/defs.h @@ -192,9 +192,10 @@ void unmappages(pagetable_t, uint64, uint64, int); uint64 walkaddr(pagetable_t, uint64); int copyout(pagetable_t, uint64, char *, uint64); int copyin(pagetable_t, char *, uint64, uint64); -int copyinstr(pagetable_t pagetable, char *dst, uint64 srcva, uint64 max); +int copyinstr(pagetable_t, char *, uint64, uint64); char* map_kstack(); uint64 kernelpa(uint64); +void clearpteu(pagetable_t, uint64); // plic.c void plicinit(void); diff --git a/kernel/exec.c b/kernel/exec.c index b21afbb..c25dfb0 100644 --- a/kernel/exec.c +++ b/kernel/exec.c @@ -68,6 +68,7 @@ exec(char *path, char **argv) sz = PGROUNDUP(sz); if((sz = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0) goto bad; + clearpteu(pagetable, sz-2*PGSIZE); sp = sz; stackbase = sp - PGSIZE; diff --git a/kernel/vm.c b/kernel/vm.c index 96f2ffa..cbea684 100644 --- a/kernel/vm.c +++ b/kernel/vm.c @@ -436,3 +436,13 @@ kernelpa(uint64 va) { pa = PTE2PA(*pte); return pa+off; } + +void +clearpteu(pagetable_t pagetable, uint64 va) { + pte_t *pte; + + pte = walk(pagetable, va, 0); + if(pte == 0) + panic("clearpteu"); + *pte &= ~PTE_U; +}