diff --git a/bios/stage-4/src/main.rs b/bios/stage-4/src/main.rs index cf159a61..ce597ae2 100644 --- a/bios/stage-4/src/main.rs +++ b/bios/stage-4/src/main.rs @@ -221,13 +221,6 @@ fn create_page_tables(frame_allocator: &mut impl FrameAllocator) -> Pa // We identity-mapped all memory, so the offset between physical and virtual addresses is 0 let phys_offset = VirtAddr::new(0); - // copy the currently active level 4 page table, because it might be read-only - let bootloader_page_table = { - let frame = x86_64::registers::control::Cr3::read().0; - let table: *mut PageTable = (phys_offset + frame.start_address().as_u64()).as_mut_ptr(); - unsafe { OffsetPageTable::new(&mut *table, phys_offset) } - }; - // create a new page table hierarchy for the kernel let (kernel_page_table, kernel_level_4_frame) = { // get an unused frame for new level 4 page table @@ -246,7 +239,6 @@ fn create_page_tables(frame_allocator: &mut impl FrameAllocator) -> Pa }; PageTables { - bootloader: bootloader_page_table, kernel: kernel_page_table, kernel_level_4_frame, } diff --git a/common/src/lib.rs b/common/src/lib.rs index 8a701f23..59d20952 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -605,8 +605,6 @@ pub fn switch_to_kernel(page_tables: PageTables, mappings: Mappings, boot_info: /// Provides access to the page tables of the bootloader and kernel address space. pub struct PageTables { - /// Provides access to the page tables of the bootloader address space. - pub bootloader: OffsetPageTable<'static>, /// Provides access to the page tables of the kernel address space (not active). pub kernel: OffsetPageTable<'static>, /// The physical frame where the level 4 page table of the kernel address space is stored. diff --git a/uefi/src/main.rs b/uefi/src/main.rs index 93dfb6c7..7a9444e6 100644 --- a/uefi/src/main.rs +++ b/uefi/src/main.rs @@ -389,41 +389,6 @@ fn create_page_tables( // UEFI identity-maps all memory, so the offset between physical and virtual addresses is 0 let phys_offset = VirtAddr::new(0); - // copy the currently active level 4 page table, because it might be read-only - log::trace!("switching to new level 4 table"); - let bootloader_page_table = { - let old_table = { - let frame = x86_64::registers::control::Cr3::read().0; - let ptr: *const PageTable = (phys_offset + frame.start_address().as_u64()).as_ptr(); - unsafe { &*ptr } - }; - let new_frame = frame_allocator - .allocate_frame() - .expect("Failed to allocate frame for new level 4 table"); - let new_table: &mut PageTable = { - let ptr: *mut PageTable = - (phys_offset + new_frame.start_address().as_u64()).as_mut_ptr(); - // create a new, empty page table - unsafe { - ptr.write(PageTable::new()); - &mut *ptr - } - }; - - // copy the first entry (we don't need to access more than 512 GiB; also, some UEFI - // implementations seem to create an level 4 table entry 0 in all slots) - new_table[0] = old_table[0].clone(); - - // the first level 4 table entry is now identical, so we can just load the new one - unsafe { - x86_64::registers::control::Cr3::write( - new_frame, - x86_64::registers::control::Cr3Flags::empty(), - ); - OffsetPageTable::new(&mut *new_table, phys_offset) - } - }; - // create a new page table hierarchy for the kernel let (kernel_page_table, kernel_level_4_frame) = { // get an unused frame for new level 4 page table @@ -442,7 +407,6 @@ fn create_page_tables( }; bootloader_x86_64_common::PageTables { - bootloader: bootloader_page_table, kernel: kernel_page_table, kernel_level_4_frame, }