From c19f4c019aa58ace3133dec52030d7fce5e5e1d8 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 28 May 2023 18:05:30 +0300 Subject: [PATCH] Kernel: Add invalidate() to MMU --- kernel/arch/x86_64/MMU.cpp | 6 ++++++ kernel/include/kernel/Memory/MMU.h | 1 + 2 files changed, 7 insertions(+) diff --git a/kernel/arch/x86_64/MMU.cpp b/kernel/arch/x86_64/MMU.cpp index 6b8f269f..7cc64bf1 100644 --- a/kernel/arch/x86_64/MMU.cpp +++ b/kernel/arch/x86_64/MMU.cpp @@ -149,6 +149,12 @@ namespace Kernel s_current = this; } + void MMU::invalidate(vaddr_t vaddr) + { + ASSERT(this == s_current); + asm volatile("invlpg (%0)" :: "r"(vaddr) : "memory"); + } + void MMU::identity_map_page(paddr_t address, flags_t flags) { address &= PAGE_MASK; diff --git a/kernel/include/kernel/Memory/MMU.h b/kernel/include/kernel/Memory/MMU.h index 0f6bcd4e..62973606 100644 --- a/kernel/include/kernel/Memory/MMU.h +++ b/kernel/include/kernel/Memory/MMU.h @@ -43,6 +43,7 @@ namespace Kernel vaddr_t get_free_page() const; vaddr_t get_free_contiguous_pages(size_t page_count) const; + void invalidate(vaddr_t); void load(); void lock() const { m_lock.lock(); }