File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -149,6 +149,11 @@ impl PageTableEntry {
149149 ( self . physical_address_and_flags & PageTableEntryFlags :: TABLE_OR_4KIB_PAGE . bits ( ) ) != 0
150150 }
151151
152+ /// Mark this as an invalid (not present) entry
153+ fn unset ( & mut self ) {
154+ self . physical_address_and_flags = 0 ;
155+ }
156+
152157 /// Mark this as a valid (present) entry and set address translation and flags.
153158 ///
154159 /// # Arguments
@@ -161,6 +166,10 @@ impl PageTableEntry {
161166 physical_address. is_aligned_to( BasePageSize :: SIZE ) ,
162167 "Physical address is not on a 4 KiB page boundary (physical_address = {physical_address:p})"
163168 ) ;
169+ assert ! (
170+ !physical_address. is_null( ) ,
171+ "Cannot set a page table entry with null address"
172+ ) ;
164173
165174 let mut flags_to_set = flags;
166175 flags_to_set. insert ( PageTableEntryFlags :: PRESENT ) ;
@@ -414,7 +423,7 @@ impl<L: PageTableLevel> PageTableMethods for PageTable<L> {
414423
415424 if flags == PageTableEntryFlags :: BLANK {
416425 // in this case we unmap the pages
417- self . entries [ index] . set ( physical_address , flags ) ;
426+ self . entries [ index] . unset ( )
418427 } else {
419428 self . entries [ index] . set ( physical_address, S :: MAP_EXTRA_FLAG | flags) ;
420429 }
You can’t perform that action at this time.
0 commit comments