File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -135,6 +135,11 @@ impl PageTableEntry {
135135 ( self . physical_address_and_flags & PageTableEntryFlags :: EXECUTABLE . bits ( ) ) != 0
136136 }
137137
138+ /// Mark this as an invalid (not present) entry
139+ fn unset ( & mut self ) {
140+ self . physical_address_and_flags = PhysAddr :: zero ( ) ;
141+ }
142+
138143 /// Mark this as a valid (present) entry and set address translation and flags.
139144 ///
140145 /// # Arguments
@@ -377,10 +382,15 @@ impl<L: PageTableLevel> PageTableMethods for PageTable<L> {
377382 let index = page. table_index :: < L > ( ) ;
378383 let flush = self . entries [ index] . is_present ( ) ;
379384
380- self . entries [ index] . set (
381- physical_address,
382- S :: MAP_EXTRA_FLAG | PageTableEntryFlags :: ACCESSED | PageTableEntryFlags :: DIRTY | flags,
383- ) ;
385+ if physical_address. is_null ( ) && flags == PageTableEntryFlags :: BLANK {
386+ // Clear PTE
387+ self . entries [ index] . unset ( ) ;
388+ } else {
389+ self . entries [ index] . set (
390+ physical_address,
391+ S :: MAP_EXTRA_FLAG | PageTableEntryFlags :: ACCESSED | PageTableEntryFlags :: DIRTY | flags,
392+ ) ;
393+ }
384394
385395 if flush {
386396 page. flush_from_tlb ( ) ;
You can’t perform that action at this time.
0 commit comments