Kernel: Make PageTable non-copyable and non-movable

Also PageTable destructor now verifies that is has allocated something
instead of assuming paddr of 0.
This commit is contained in:
Bananymous 2024-11-26 00:58:35 +02:00
parent 6f118c1be1
commit 48e030bca3
3 changed files with 9 additions and 0 deletions

View File

@ -272,6 +272,9 @@ namespace Kernel
PageTable::~PageTable() PageTable::~PageTable()
{ {
if (m_highest_paging_struct == 0)
return;
uint64_t* pdpt = reinterpret_cast<uint64_t*>(P2V(m_highest_paging_struct)); uint64_t* pdpt = reinterpret_cast<uint64_t*>(P2V(m_highest_paging_struct));
for (uint32_t pdpte = 0; pdpte < 3; pdpte++) for (uint32_t pdpte = 0; pdpte < 3; pdpte++)

View File

@ -576,6 +576,9 @@ namespace Kernel
PageTable::~PageTable() PageTable::~PageTable()
{ {
if (m_highest_paging_struct == 0)
return;
// NOTE: we only loop until 256 since after that is hhdm // NOTE: we only loop until 256 since after that is hhdm
const uint64_t* pml4 = P2V(m_highest_paging_struct); const uint64_t* pml4 = P2V(m_highest_paging_struct);
for (uint64_t pml4e = 0; pml4e < 256; pml4e++) for (uint64_t pml4e = 0; pml4e < 256; pml4e++)

View File

@ -22,6 +22,9 @@ namespace Kernel
class PageTable class PageTable
{ {
BAN_NON_COPYABLE(PageTable);
BAN_NON_MOVABLE(PageTable);
public: public:
using flags_t = uint16_t; using flags_t = uint16_t;
enum Flags : flags_t enum Flags : flags_t