From fdeaca9bb0818bca069ae39c457932b5f7a310ae Mon Sep 17 00:00:00 2001 From: Yifan Wu Date: Fri, 13 May 2022 01:02:12 -0700 Subject: [PATCH] Fix #69. --- os/src/mm/address.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/os/src/mm/address.rs b/os/src/mm/address.rs index dc5d08a8..cf147a08 100644 --- a/os/src/mm/address.rs +++ b/os/src/mm/address.rs @@ -83,7 +83,11 @@ impl From for usize { } impl From for usize { fn from(v: VirtAddr) -> Self { - v.0 + if v.0 >= (1 << (VA_WIDTH_SV39 - 1)) { + v.0 | (!((1 << VA_WIDTH_SV39) - 1)) + } else { + v.0 + } } } impl From for usize {