summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreistar <33970527+eistar@users.noreply.github.com>2022-02-01 10:34:16 +0800
committerGitHub <noreply@github.com>2022-01-31 18:34:16 -0800
commit34a1175291f9531e85afdb89aaa77707f45fc8e4 (patch)
treee6d41a5ea864fde0e7fae1a1fe9a5a77bacf204e
parent81e58d0068858978c2415ae115144078434ea31d (diff)
downloadenv-34a1175291f9531e85afdb89aaa77707f45fc8e4.zip
env-34a1175291f9531e85afdb89aaa77707f45fc8e4.tar.gz
env-34a1175291f9531e85afdb89aaa77707f45fc8e4.tar.bz2
Reverse memcpy direction when evicts a page. (#34)
In "evict" function in v/vm.c, when evict a dirty page in user space, memcpy should be from that page, rather than to evicted page.
-rw-r--r--v/vm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/v/vm.c b/v/vm.c
index 9802fb7..277b67c 100644
--- a/v/vm.c
+++ b/v/vm.c
@@ -120,7 +120,7 @@ static void evict(unsigned long addr)
uintptr_t sstatus = set_csr(sstatus, SSTATUS_SUM);
if (memcmp((void*)addr, uva2kva(addr), PGSIZE)) {
assert(user_llpt[addr/PGSIZE] & PTE_D);
- memcpy((void*)addr, uva2kva(addr), PGSIZE);
+ memcpy(uva2kva(addr), (void*)addr, PGSIZE);
}
write_csr(sstatus, sstatus);