diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2024-11-03 12:12:41 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2024-11-03 12:12:41 +0000 |
| commit | 67be3c58bef94fece14d4e3a79f3559649e9a74c (patch) | |
| tree | cde69f6c050c715cd41eb20d4b93f92f3d0e44ff /arch/x86_64/include | |
| parent | 9292814545ab5df5aa69d4f75a6d9230f3e03f5b (diff) | |
| download | teachos-67be3c58bef94fece14d4e3a79f3559649e9a74c.tar.xz teachos-67be3c58bef94fece14d4e3a79f3559649e9a74c.zip | |
rename member and use correct address
Diffstat (limited to 'arch/x86_64/include')
3 files changed, 17 insertions, 10 deletions
diff --git a/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp b/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp index c9989ae..e29590d 100644 --- a/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp +++ b/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp @@ -120,10 +120,10 @@ namespace teachos::arch::memory::multiboot uint32_t name_table_index; ///< Index into the section header string table, specifies the name of the section. elf_section_type type; ///< Categorizes the sections content and semantics. elf_section_flags flags; ///< 1-bit flgas that describe section attributes. - uint64_t virtual_address; ///< If section appears in memory image of a process, gives address at which the sections - ///< first byte should reside, otherwise 0. - uint64_t file_offset; ///< Offset from the beginning of the file to the first byte in the section. SHT_NOBITS - ///< contains the conceptual placement instead (because it occupies no space in the file). + uint64_t physical_address; ///< If section appears in memory image of a process, gives address at which the + ///< sections first byte should reside, otherwise 0. + uint64_t file_offset; ///< Offset from the beginning of the file to the first byte in the section. SHT_NOBITS + ///< contains the conceptual placement instead (because it occupies no space in the file). uint64_t section_size; ///< Complete section size in bytes, SHT_NOBITS may have non-zero value but will always ///< occupy no space in the file. uint32_t other_section; ///< Section header table index link, behaviour varies on type diff --git a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp index d7365a0..84f0471 100644 --- a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp +++ b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp @@ -57,7 +57,9 @@ namespace teachos::arch::memory::paging private: /** - * @brief Remaps the kernel elf sections. This is done with switching the current level 4 page table recursive + * @brief Remaps the kernel elf sections. + * + * This is done with switching the current level 4 page table recursive * mapping to any unmapped address in memory and then actually mapping the level 4 page table on that address. * Once the remapping process is done we can restore the original recursive mapping with the complete remapped * kernel. @@ -74,11 +76,16 @@ namespace teachos::arch::memory::paging auto remap_elf_kernel_sections(inactive_page_table inactive_table, temporary_page & temporary_page, active_page_table & active_table) -> void { - auto const backup = allocator::physical_frame::containing_address(PAGE_TABLE_LEVEL_4_ADDRESS); + auto physical_address = active_table.translate_address(PAGE_TABLE_LEVEL_4_ADDRESS); + exception_handling::assert(!physical_address.has_value(), + "[Kernel Mapper] Physical address for active table not mapped"); + + auto const backup = allocator::physical_frame::containing_address(physical_address.value()); auto page_table_level4 = temporary_page.map_table_frame(backup, active_table); active_table.active_handle[511].set_entry(inactive_table.page_table_level_4_frame, entry::PRESENT | entry::WRITABLE); + tlb_flush_all(); map_elf_kernel_sections(active_table); @@ -102,11 +109,11 @@ namespace teachos::arch::memory::paging { continue; } - exception_handling::assert(section.virtual_address % allocator::PAGE_FRAME_SIZE == 0U, + exception_handling::assert(section.physical_address % allocator::PAGE_FRAME_SIZE == 0U, "[Kernel Mapper] Section must be page aligned"); - auto const start_frame = allocator::physical_frame::containing_address(section.virtual_address); + auto const start_frame = allocator::physical_frame::containing_address(section.physical_address); auto const end_frame = - allocator::physical_frame::containing_address(section.virtual_address + section.section_size); + allocator::physical_frame::containing_address(section.physical_address + section.section_size); allocator::physical_frame_iterator const begin{start_frame}; allocator::physical_frame_iterator const end{end_frame}; diff --git a/arch/x86_64/include/arch/memory/paging/tlb.hpp b/arch/x86_64/include/arch/memory/paging/tlb.hpp index 1194720..85c4152 100644 --- a/arch/x86_64/include/arch/memory/paging/tlb.hpp +++ b/arch/x86_64/include/arch/memory/paging/tlb.hpp @@ -5,7 +5,7 @@ namespace teachos::arch::memory::paging { - std::size_t constexpr PAGE_TABLE_LEVEL_4_ADDRESS = 0xffffffff'fffff000; + virtual_address constexpr PAGE_TABLE_LEVEL_4_ADDRESS = 0xffffffff'fffff000; /** * @brief Invalidates any translation lookaside buffer (TLB) entry for the page table the given address is cotained |
