diff --git a/os/src/mm/address.rs b/os/src/mm/address.rs index 2b7c5863..81099008 100644 --- a/os/src/mm/address.rs +++ b/os/src/mm/address.rs @@ -87,7 +87,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 {