diff --git a/kernel/arch/i686/PageTable.cpp b/kernel/arch/i686/PageTable.cpp index c953b2b0a5..60d568a09f 100644 --- a/kernel/arch/i686/PageTable.cpp +++ b/kernel/arch/i686/PageTable.cpp @@ -369,13 +369,12 @@ namespace Kernel if (flags & Flags::Reserved) extra_flags |= Flags::Reserved; - if (s_has_pat) - { - if (memory_type == MemoryType::WriteCombining) - extra_flags |= (1ull << 7); - if (memory_type == MemoryType::WriteThrough) - extra_flags |= (1ull << 7) | (1ull << 3); - } + if (memory_type == MemoryType::Uncached) + extra_flags |= (1ull << 4); + if (s_has_pat && memory_type == MemoryType::WriteCombining) + extra_flags |= (1ull << 7); + if (s_has_pat && memory_type == MemoryType::WriteThrough) + extra_flags |= (1ull << 7) | (1ull << 3); // NOTE: we add present here, since it has to be available in higher level structures flags_t uwr_flags = (flags & (Flags::UserSupervisor | Flags::ReadWrite)) | Flags::Present; diff --git a/kernel/arch/x86_64/PageTable.cpp b/kernel/arch/x86_64/PageTable.cpp index 313d8d2b73..65cd0bfebb 100644 --- a/kernel/arch/x86_64/PageTable.cpp +++ b/kernel/arch/x86_64/PageTable.cpp @@ -417,6 +417,8 @@ namespace Kernel if (flags & Flags::Reserved) extra_flags |= Flags::Reserved; + if (memory_type == MemoryType::Uncached) + extra_flags |= (1ull << 4); if (memory_type == MemoryType::WriteCombining) extra_flags |= (1ull << 7); if (memory_type == MemoryType::WriteThrough) diff --git a/kernel/include/kernel/Memory/PageTable.h b/kernel/include/kernel/Memory/PageTable.h index aa92b27379..a1cc2b83ee 100644 --- a/kernel/include/kernel/Memory/PageTable.h +++ b/kernel/include/kernel/Memory/PageTable.h @@ -37,6 +37,7 @@ namespace Kernel enum MemoryType { Normal, + Uncached, WriteCombining, WriteThrough, }; diff --git a/kernel/kernel/Memory/DMARegion.cpp b/kernel/kernel/Memory/DMARegion.cpp index ae61ba6f14..6ab9e592e6 100644 --- a/kernel/kernel/Memory/DMARegion.cpp +++ b/kernel/kernel/Memory/DMARegion.cpp @@ -26,7 +26,7 @@ namespace Kernel vaddr_guard.disable(); paddr_guard.disable(); - PageTable::kernel().map_range_at(paddr, vaddr, size, PageTable::Flags::ReadWrite | PageTable::Flags::Present); + PageTable::kernel().map_range_at(paddr, vaddr, size, PageTable::Flags::ReadWrite | PageTable::Flags::Present, PageTable::MemoryType::Uncached); return BAN::UniqPtr::adopt(region_ptr); } diff --git a/kernel/kernel/PCI.cpp b/kernel/kernel/PCI.cpp index cc94ea1a70..66c77c3af8 100644 --- a/kernel/kernel/PCI.cpp +++ b/kernel/kernel/PCI.cpp @@ -246,7 +246,7 @@ namespace Kernel::PCI { vaddr_t vaddr = PageTable::kernel().reserve_free_page(KERNEL_OFFSET); ASSERT(vaddr); - PageTable::kernel().map_page_at(pcie_paddr, vaddr, PageTable::Flags::ReadWrite | PageTable::Flags::Present); + PageTable::kernel().map_page_at(pcie_paddr, vaddr, PageTable::Flags::ReadWrite | PageTable::Flags::Present, PageTable::MemoryType::Uncached); m_mmio_config = vaddr; }