Fix logic bug in RISC_V env_user_mem_walk
authorAndrew Waterman <waterman@cs.berkeley.edu>
Mon, 7 Jan 2013 03:33:43 +0000 (19:33 -0800)
committerAndrew Waterman <waterman@cs.berkeley.edu>
Mon, 7 Jan 2013 03:33:43 +0000 (19:33 -0800)
Manifested itself as sys_fork causing a kernel page fault

kern/arch/riscv/env.c

index baddfb3..a2ed60a 100644 (file)
@@ -123,7 +123,7 @@ user_mem_walk_recursive(env_t* e, uintptr_t start, size_t len,
 
        for(uintptr_t idx = start_idx; idx <= end_idx; idx++)
        {
-               uintptr_t pgaddr = ROUNDDOWN(start, pgsize) + idx*pgsize;
+               uintptr_t pgaddr = ROUNDDOWN(start, pgsize) + (idx-start_idx)*pgsize;
                pte_t* pte = &pt[idx];
 
                if(*pte & PTE_T)