Skip to content

Commit c62af46

Browse files
author
Jiajie Chen
committed
Fix rv48 table
1 parent 8e25d63 commit c62af46

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/paging/multi_level.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ impl<'a> Mapper for Rv32PageTable<'a> {
8080
}
8181
}
8282

83-
8483
/// This struct is a three level page table with `Mapper` trait implemented.
8584
#[cfg(riscv64)]
8685
pub struct Rv39PageTable<'a> {
@@ -217,12 +216,12 @@ impl<'a> Rv48PageTable<'a> {
217216

218217
let p2_table = if p3_table[p3_index].is_unused() {
219218
let frame = allocator.alloc().ok_or(MapToError::FrameAllocationFailed)?;
220-
self.root_table[p3_index].set(frame.clone(), F::VALID);
219+
p3_table[p3_index].set(frame.clone(), F::VALID);
221220
let p2_table: &mut PageTable = unsafe { frame.as_kernel_mut(self.linear_offset) };
222221
p2_table.zero();
223222
p2_table
224223
} else {
225-
let frame = self.root_table[p3_index].frame();
224+
let frame = p3_table[p3_index].frame();
226225
unsafe { frame.as_kernel_mut(self.linear_offset) }
227226
};
228227

@@ -249,7 +248,12 @@ impl<'a> Mapper for Rv48PageTable<'a> {
249248
flags: PageTableFlags,
250249
allocator: &mut impl FrameAllocator,
251250
) -> Result<MapperFlush, MapToError> {
252-
let p1_table = self.create_p1_if_not_exist(page.p4_index(), page.p3_index(), page.p2_index(), allocator)?;
251+
let p1_table = self.create_p1_if_not_exist(
252+
page.p4_index(),
253+
page.p3_index(),
254+
page.p2_index(),
255+
allocator,
256+
)?;
253257
if !p1_table[page.p1_index()].is_unused() {
254258
return Err(MapToError::PageAlreadyMapped);
255259
}
@@ -304,4 +308,4 @@ impl<'a> Mapper for Rv48PageTable<'a> {
304308
let p1_table: &mut PageTable = unsafe { p1_frame.as_kernel_mut(self.linear_offset) };
305309
Ok(&mut p1_table[page.p1_index()])
306310
}
307-
}
311+
}

0 commit comments

Comments
 (0)