diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2024-11-01 15:32:24 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2024-11-01 15:32:24 +0000 |
| commit | 38cda6bf579f7b09d06ad73c9f4ab893939727a2 (patch) | |
| tree | c745deb418d93de274b321795fe0ce79c62b2b98 /arch/x86_64/include | |
| parent | 86f19267c7ca4e14ac6169f758130b3c27e62cdb (diff) | |
| download | teachos-38cda6bf579f7b09d06ad73c9f4ab893939727a2.tar.xz teachos-38cda6bf579f7b09d06ad73c9f4ab893939727a2.zip | |
extract tlb methods and finish implementation of with
Diffstat (limited to 'arch/x86_64/include')
| -rw-r--r-- | arch/x86_64/include/arch/memory/paging/active_page_table.hpp | 22 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/paging/tlb.hpp | 26 |
2 files changed, 31 insertions, 17 deletions
diff --git a/arch/x86_64/include/arch/memory/paging/active_page_table.hpp b/arch/x86_64/include/arch/memory/paging/active_page_table.hpp index e2c205b..30ae455 100644 --- a/arch/x86_64/include/arch/memory/paging/active_page_table.hpp +++ b/arch/x86_64/include/arch/memory/paging/active_page_table.hpp @@ -3,6 +3,7 @@ #include "arch/exception_handling/assert.hpp" #include "arch/memory/allocator/concept.hpp" +#include "arch/memory/paging/tlb.hpp" #include "arch/memory/paging/virtual_page.hpp" #include <array> @@ -10,8 +11,6 @@ namespace teachos::arch::memory::paging { - std::size_t constexpr PAGE_TABLE_LEVEL_4_ADDRESS = 0xffffffff'fffff000; - /** * @brief Currently active level 4 page table, is used to ensure there is only ever one valid instance and it cannot * be copied or constructed again. @@ -55,18 +54,6 @@ namespace teachos::arch::memory::paging auto translate_huge_page(virtual_page page) -> std::optional<allocator::physical_frame>; /** - * @brief Invalidates any translation lookaside buffer (TLB) entry for the page table the given address is cotained - * in. See https://www.felixcloutier.com/x86/invlpg for more information on the used x86 instruction. - * - * @param address Memory address, which will be used to determine the contained page and flush the TLB entry for - * that page. - */ - static auto invalidate_page_cache(virtual_address address) -> void - { - asm volatile("invlpg (%0)" ::"r"(address) : "memory"); - } - - /** * @brief Maps a virtual page to a physical frame in the page table with the specified flags. * * @note Allocates and maps an entry in every page level if it does not exists yet down to level 1. If the level 1 @@ -171,9 +158,12 @@ namespace teachos::arch::memory::paging break; } } - invalidate_page_cache(page.start_address()); + + tlb_flush(page.start_address()); } + page_table_handle active_handle; + private: /** * @brief Private constructor should only be used by create or get method, which ensures to create only ever one @@ -214,8 +204,6 @@ namespace teachos::arch::memory::paging entry.set_unused(); allocator.deallocate_frame(frame.value()); } - - page_table_handle active_handle; }; } // namespace teachos::arch::memory::paging diff --git a/arch/x86_64/include/arch/memory/paging/tlb.hpp b/arch/x86_64/include/arch/memory/paging/tlb.hpp new file mode 100644 index 0000000..e74eb74 --- /dev/null +++ b/arch/x86_64/include/arch/memory/paging/tlb.hpp @@ -0,0 +1,26 @@ +#ifndef TEACHOS_ARCH_X86_64_MEMORY_PAGING_TLB_HPP +#define TEACHOS_ARCH_X86_64_MEMORY_PAGING_TLB_HPP + +#include "arch/memory/paging/virtual_page.hpp" + +namespace teachos::arch::memory::paging +{ + std::size_t 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 + * in. See https://www.felixcloutier.com/x86/invlpg for more information on the used x86 instruction. + * + * @param address Memory address, which will be used to determine the contained page and flush the TLB entry for + * that page. + */ + auto tlb_flush(virtual_address address) -> void; + + /** + * @brief Invalidates the translation lookaside buffer (TLB) entry for all page tables + */ + auto tlb_flush_all() -> void; + +} // namespace teachos::arch::memory::paging + +#endif
\ No newline at end of file |
