File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -117,19 +117,28 @@ fn bootloader_main(
117
117
PhysFrame :: containing_address ( PhysAddr :: new ( GIGABYTE ) ) ;
118
118
let end_frame = PhysFrame :: containing_address ( PhysAddr :: new ( max_phys_addr - 1 ) ) ;
119
119
for frame in PhysFrame :: range_inclusive ( start_frame, end_frame) {
120
- unsafe {
120
+ let flusher = unsafe {
121
121
bootloader_page_table
122
122
. identity_map (
123
123
frame,
124
124
PageTableFlags :: PRESENT | PageTableFlags :: WRITABLE ,
125
125
& mut frame_allocator,
126
126
)
127
127
. unwrap ( )
128
- . flush ( )
129
128
} ;
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 ( ) ;
130
132
}
131
133
}
132
134
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
+
133
142
let framebuffer_addr = PhysAddr :: new ( unsafe { VBEModeInfo_physbaseptr } . into ( ) ) ;
134
143
let mut error = None ;
135
144
let framebuffer_info = unsafe {
You can’t perform that action at this time.
0 commit comments