From 34a1175291f9531e85afdb89aaa77707f45fc8e4 Mon Sep 17 00:00:00 2001 From: eistar <33970527+eistar@users.noreply.github.com> Date: Tue, 1 Feb 2022 10:34:16 +0800 Subject: 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. --- v/vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'v') 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); -- cgit v1.1