From 326b97a9fa0716b91edb08b4da12dc1365c2e4bc Mon Sep 17 00:00:00 2001 From: Yifan Wu Date: Fri, 13 May 2022 00:58:11 -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 e0e88e5f..d5cf59f7 100644 --- a/os/src/mm/address.rs +++ b/os/src/mm/address.rs @@ -85,7 +85,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 {