diff --git a/kernel/arch/i686/PageTable.cpp b/kernel/arch/i686/PageTable.cpp index 0a9057d1..d603548f 100644 --- a/kernel/arch/i686/PageTable.cpp +++ b/kernel/arch/i686/PageTable.cpp @@ -272,6 +272,9 @@ namespace Kernel PageTable::~PageTable() { + if (m_highest_paging_struct == 0) + return; + uint64_t* pdpt = reinterpret_cast(P2V(m_highest_paging_struct)); for (uint32_t pdpte = 0; pdpte < 3; pdpte++) diff --git a/kernel/arch/x86_64/PageTable.cpp b/kernel/arch/x86_64/PageTable.cpp index 08b0c389..7f7b34bd 100644 --- a/kernel/arch/x86_64/PageTable.cpp +++ b/kernel/arch/x86_64/PageTable.cpp @@ -576,6 +576,9 @@ namespace Kernel PageTable::~PageTable() { + if (m_highest_paging_struct == 0) + return; + // NOTE: we only loop until 256 since after that is hhdm const uint64_t* pml4 = P2V(m_highest_paging_struct); for (uint64_t pml4e = 0; pml4e < 256; pml4e++) diff --git a/kernel/include/kernel/Memory/PageTable.h b/kernel/include/kernel/Memory/PageTable.h index 12403f5c..d6a4ca31 100644 --- a/kernel/include/kernel/Memory/PageTable.h +++ b/kernel/include/kernel/Memory/PageTable.h @@ -22,6 +22,9 @@ namespace Kernel class PageTable { + BAN_NON_COPYABLE(PageTable); + BAN_NON_MOVABLE(PageTable); + public: using flags_t = uint16_t; enum Flags : flags_t