aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-10-26 08:47:56 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-10-26 08:47:56 +0000
commit878751001c3de6e7fb24c6212957cd5d753a62d1 (patch)
tree0bc4a934ad6b6e414e24d2f4b410918b9ae2578e
parentbca36b0c10fcae447c90e211e83987fea28eecdc (diff)
downloadteachos-878751001c3de6e7fb24c6212957cd5d753a62d1.tar.xz
teachos-878751001c3de6e7fb24c6212957cd5d753a62d1.zip
Commit TLB flush
-rw-r--r--arch/x86_64/include/arch/memory/paging/page_mapper.hpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/arch/x86_64/include/arch/memory/paging/page_mapper.hpp b/arch/x86_64/include/arch/memory/paging/page_mapper.hpp
index 3590dda..4905e9e 100644
--- a/arch/x86_64/include/arch/memory/paging/page_mapper.hpp
+++ b/arch/x86_64/include/arch/memory/paging/page_mapper.hpp
@@ -9,6 +9,17 @@
namespace teachos::arch::memory::paging
{
+ namespace
+ {
+ /**
+ * @brief Invalidates any translation lookaside buffer (TLB) entries into the page table the given entry is cotained
+ * in. See https://www.felixcloutier.com/x86/invlpg for more information int he used x86 instruction.
+ *
+ * @param entry Any entry into the page table we want to invalidate all cached entries in.
+ */
+ auto invalidate_page_cache(entry * entry) -> void { asm volatile("invlpg (%0)" ::"r"(entry) : "memory"); }
+ } // namespace
+
/**
* @brief Creates a single instance of the level 4 page table table and returns handle to it or alternatively returns
* the previously created handle instead. The instance is owned by this method and is static, meaning it lives on for
@@ -135,7 +146,7 @@ namespace teachos::arch::memory::paging
exception_handling::assert(level1_frame.has_value(),
"[Page Mapper] Attempted to unmap page, which has not been mapped previously");
level1_entry.set_unused();
- // TODO: Flush the translation lookaside buffer to clear the entry from cache as well. (mov cr3, cr3)
+ invalidate_page_cache(&level1_entry);
// TODO: Deallocate and unmap level 1, 2, 3 page table entry if this was the last page in them.
// TODO: Fix deallocate because it is not yet implemented.
allocator.deallocate_frame(level1_frame.value());