Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ostd/specs/mm/page_table/cursor/cursor_fn_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl<'rcu, C: PageTableConfig, A: InAtomicMode> CursorMut<'rcu, C, A> {
||| self.inner.va >= self.inner.barrier_va.end
||| C::item_into_raw(item).1 > C::HIGHEST_TRANSLATION_LEVEL()
||| C::item_into_raw(item).1 >= self.inner.guard_level
||| (!C::TOP_LEVEL_CAN_UNMAP_spec() && C::item_into_raw(item).1 >= NR_LEVELS)
||| (!C::TOP_LEVEL_CAN_UNMAP && C::item_into_raw(item).1 >= NR_LEVELS)
||| self.inner.va % page_size(C::item_into_raw(item).1) != 0
||| self.inner.va + page_size(C::item_into_raw(item).1) > self.inner.barrier_va.end
}
Expand Down
11 changes: 1 addition & 10 deletions ostd/src/mm/kspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,7 @@ unsafe impl PageTableConfig for KernelPtConfig {
256..512
}

open spec fn TOP_LEVEL_CAN_UNMAP_spec() -> bool {
false
}

fn TOP_LEVEL_CAN_UNMAP() -> (b: bool)
ensures
b == Self::TOP_LEVEL_CAN_UNMAP_spec(),
{
false
}
const TOP_LEVEL_CAN_UNMAP: bool = false;

type E = PageTableEntry;
type C = PagingConsts;
Expand Down
8 changes: 4 additions & 4 deletions ostd/src/mm/page_table/cursor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ impl<'rcu, C: PageTableConfig, A: InAtomicMode> Cursor<'rcu, C, A> {

match cur_child {
ChildRef::PageTable(pt) => {
if find_unmap_subtree && cur_entry_fits_range && (C::TOP_LEVEL_CAN_UNMAP()
if find_unmap_subtree && cur_entry_fits_range && (C::TOP_LEVEL_CAN_UNMAP
|| self.level != C::NR_LEVELS()) {

proof {
Expand Down Expand Up @@ -3214,7 +3214,7 @@ impl<'rcu, C: PageTableConfig, A: InAtomicMode> CursorMut<'rcu, C, A> {
CursorOwner::<'rcu, C>::node_unlocked(*old(guards)),
),
// panic
!C::TOP_LEVEL_CAN_UNMAP_spec() ==> old(owner).level < NR_LEVELS,
!C::TOP_LEVEL_CAN_UNMAP ==> old(owner).level < NR_LEVELS,
ensures
final(owner)@.mappings == old(owner)@.mappings - PageTableOwner(
old(owner).cur_subtree(),
Expand Down Expand Up @@ -3696,8 +3696,8 @@ impl<'rcu, C: PageTableConfig, A: InAtomicMode> CursorMut<'rcu, C, A> {
},
Child::PageTable(pt) => {
// debug_assert_eq!(pt.level(), level - 1);
if !C::TOP_LEVEL_CAN_UNMAP() {
assert(!C::TOP_LEVEL_CAN_UNMAP_spec());
if !C::TOP_LEVEL_CAN_UNMAP {
assert(!C::TOP_LEVEL_CAN_UNMAP);
if level as usize == NR_LEVELS {
assert(owner.level == NR_LEVELS);

Expand Down
9 changes: 1 addition & 8 deletions ostd/src/mm/page_table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,7 @@ pub unsafe trait PageTableConfig: Clone + Debug + Send + Sync + 'static {
/// This is for the kernel page table, whose second-top-level page
/// tables need `'static` lifetime to be shared with user page tables.
/// Other page tables do not need to set this to `false`.
open spec fn TOP_LEVEL_CAN_UNMAP_spec() -> bool {
true
}

fn TOP_LEVEL_CAN_UNMAP() -> (b: bool)
ensures
b == Self::TOP_LEVEL_CAN_UNMAP_spec(),
;
const TOP_LEVEL_CAN_UNMAP: bool = true;

/// The type of the page table entry.
type E: PageTableEntryTrait;
Expand Down
8 changes: 0 additions & 8 deletions ostd/src/mm/vm_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1433,18 +1433,10 @@ unsafe impl PageTableConfig for UserPtConfig {
0..MAX_USERSPACE_VADDR
}

open spec fn TOP_LEVEL_CAN_UNMAP_spec() -> (b: bool) {
true
}

fn TOP_LEVEL_INDEX_RANGE() -> Range<usize> {
0..256
}

fn TOP_LEVEL_CAN_UNMAP() -> (b: bool) {
true
}

type E = PageTableEntry;

type C = PagingConsts;
Expand Down