Fix page table copying bug.
This commit is contained in:
parent
94b52c5730
commit
113093f919
|
@ -186,7 +186,7 @@ env_setup_vm(struct Env *e)
|
||||||
// - The functions in kern/pmap.h are handy.
|
// - The functions in kern/pmap.h are handy.
|
||||||
p->pp_ref++;
|
p->pp_ref++;
|
||||||
e->env_pgdir = page2kva(p);
|
e->env_pgdir = page2kva(p);
|
||||||
memcpy(e->env_pgdir + PDX(UTOP), kern_pgdir + PDX(UTOP), NPDENTRIES - PDX(UTOP));
|
memcpy(e->env_pgdir + PDX(UTOP), kern_pgdir + PDX(UTOP), sizeof(pde_t) * (NPDENTRIES - PDX(UTOP)));
|
||||||
|
|
||||||
// UVPT maps the env's own page table read-only.
|
// UVPT maps the env's own page table read-only.
|
||||||
// Permissions: kernel R, user R
|
// Permissions: kernel R, user R
|
||||||
|
@ -276,11 +276,10 @@ region_alloc(struct Env *e, void *va, size_t len)
|
||||||
// You should round va down, and round (va + len) up.
|
// You should round va down, and round (va + len) up.
|
||||||
// (Watch out for corner-cases!)
|
// (Watch out for corner-cases!)
|
||||||
va = ROUNDDOWN(va, PGSIZE);
|
va = ROUNDDOWN(va, PGSIZE);
|
||||||
len = ROUNDUP(len, PGSIZE);
|
size_t count = ROUNDUP(len, PGSIZE) / PGSIZE;
|
||||||
void* last_va = va + len;
|
|
||||||
struct PageInfo* p;
|
struct PageInfo* p;
|
||||||
|
|
||||||
while(va < last_va) {
|
while(count--) {
|
||||||
if(!(p = page_alloc(0)))
|
if(!(p = page_alloc(0)))
|
||||||
panic("Failed to allocate memory");
|
panic("Failed to allocate memory");
|
||||||
if(page_insert(e->env_pgdir, p, va, PTE_U | PTE_W))
|
if(page_insert(e->env_pgdir, p, va, PTE_U | PTE_W))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user