kern: add new overflow checks on KMemoryRegions

This commit is contained in:
Michael Scire 2020-12-01 17:14:23 -08:00 committed by SciresM
parent 748893fe77
commit 0a1465f198
8 changed files with 32 additions and 1 deletions

View file

@ -52,6 +52,8 @@ namespace ams::kern {
/* Initialize the memory manager and the KPageBuffer slabheap. */
{
const auto &management_region = KMemoryLayout::GetPoolManagementRegion();
MESOSPHERE_ABORT_UNLESS(management_region.GetEndAddress() != 0);
Kernel::GetMemoryManager().Initialize(management_region.GetAddress(), management_region.GetSize());
init::InitializeKPageBufferSlabHeap();
}
@ -68,6 +70,8 @@ namespace ams::kern {
/* Initialize the Dynamic Slab Heaps. */
{
const auto &pt_heap_region = KMemoryLayout::GetPageTableHeapRegion();
MESOSPHERE_ABORT_UNLESS(pt_heap_region.GetEndAddress() != 0);
Kernel::InitializeResourceManagers(pt_heap_region.GetAddress(), pt_heap_region.GetSize());
}
}
@ -124,6 +128,13 @@ namespace ams::kern {
/* Resume all threads suspended while we initialized. */
KThread::ResumeThreadsSuspendedForInit();
/* Validate that all reserved dram blocks are valid. */
for (const auto &region : KMemoryLayout::GetPhysicalMemoryRegionTree()) {
if (region.IsDerivedFrom(KMemoryRegionType_DramReservedBase)) {
MESOSPHERE_ABORT_UNLESS(region.GetEndAddress() != 0);
}
}
}
cpu::SynchronizeAllCores();