Skip to content

Commit 62a4ce0

Browse files
committed
fix Page::from_page_table_indices
When we construct the address from the page table indices, we don't make the address canonical. This was fine in the previous versions where we automatically corrected this in `VirtAddr::new`, but that's no longer the case. Instead we can use `VirtAddr::new_truncate`.
1 parent e1945fa commit 62a4ce0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/structures/paging/page.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl Page<Size1GiB> {
171171
let mut addr = 0;
172172
addr.set_bits(39..48, u64::from(p4_index));
173173
addr.set_bits(30..39, u64::from(p3_index));
174-
Page::containing_address(VirtAddr::new(addr))
174+
Page::containing_address(VirtAddr::new_truncate(addr))
175175
}
176176
}
177177

@@ -189,7 +189,7 @@ impl Page<Size2MiB> {
189189
addr.set_bits(39..48, u64::from(p4_index));
190190
addr.set_bits(30..39, u64::from(p3_index));
191191
addr.set_bits(21..30, u64::from(p2_index));
192-
Page::containing_address(VirtAddr::new(addr))
192+
Page::containing_address(VirtAddr::new_truncate(addr))
193193
}
194194
}
195195

@@ -209,7 +209,7 @@ impl Page<Size4KiB> {
209209
addr.set_bits(30..39, u64::from(p3_index));
210210
addr.set_bits(21..30, u64::from(p2_index));
211211
addr.set_bits(12..21, u64::from(p1_index));
212-
Page::containing_address(VirtAddr::new(addr))
212+
Page::containing_address(VirtAddr::new_truncate(addr))
213213
}
214214

215215
/// Returns the level 1 page table index of this page.

0 commit comments

Comments
 (0)