diff --git a/risc_v/ch3/src/lib.rs b/risc_v/ch3/src/lib.rs index 4c56d01..a7c7371 100755 --- a/risc_v/ch3/src/lib.rs +++ b/risc_v/ch3/src/lib.rs @@ -97,11 +97,12 @@ pub fn id_map_range(root: &mut page::Table, end: usize, bits: i64) { + let start_aligned = start & !(page::PAGE_SIZE - 1); let num_pages = (page::align_val(end, 12) - - (start & !(page::PAGE_SIZE - 1))) + - start_aligned) / page::PAGE_SIZE; for i in 0..num_pages { - let m = (start & !(page::PAGE_SIZE - 1)) + (i << 12); + let m = start_aligned + (i << 12); page::map(root, m, m, bits); } }