File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -117,19 +117,28 @@ fn bootloader_main(
117117 PhysFrame :: containing_address ( PhysAddr :: new ( GIGABYTE ) ) ;
118118 let end_frame = PhysFrame :: containing_address ( PhysAddr :: new ( max_phys_addr - 1 ) ) ;
119119 for frame in PhysFrame :: range_inclusive ( start_frame, end_frame) {
120- unsafe {
120+ let flusher = unsafe {
121121 bootloader_page_table
122122 . identity_map (
123123 frame,
124124 PageTableFlags :: PRESENT | PageTableFlags :: WRITABLE ,
125125 & mut frame_allocator,
126126 )
127127 . unwrap ( )
128- . flush ( )
129128 } ;
129+ // skip flushing the entry from the TLB for now, as we will
130+ // flush the entire TLB at the end of the loop.
131+ flusher. ignore ( ) ;
130132 }
131133 }
132134
135+ // once all the physical memory is mapped, flush the TLB by reloading the
136+ // CR3 register.
137+ //
138+ // we perform a single flush here rather than flushing each individual entry as
139+ // it's mapped using `invlpg`, for efficiency.
140+ x86_64:: instructions:: tlb:: flush_all ( ) ;
141+
133142 let framebuffer_addr = PhysAddr :: new ( unsafe { VBEModeInfo_physbaseptr } . into ( ) ) ;
134143 let mut error = None ;
135144 let framebuffer_info = unsafe {
You can’t perform that action at this time.
0 commit comments