diff --git a/app/src/main/cpp/skyline/common/address_space.inc b/app/src/main/cpp/skyline/common/address_space.inc index f2ba8bb6..75673b8e 100644 --- a/app/src/main/cpp/skyline/common/address_space.inc +++ b/app/src/main/cpp/skyline/common/address_space.inc @@ -406,7 +406,7 @@ namespace skyline { if (searchSuccessor != this->blocks.end()) allocStart = searchPredecessor->virt; else - throw exception("Unexpected allocator state!"); + return {}; // AS is full } diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/as_gpu.cpp b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/as_gpu.cpp index 712c5a99..887757d1 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/as_gpu.cpp +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/as_gpu.cpp @@ -65,10 +65,13 @@ namespace skyline::service::nvdrv::device::nvhost { auto &allocator{pageSize == VM::PageSize ? *vm.smallPageAllocator : *vm.bigPageAllocator}; - if (flags.fixed) + if (flags.fixed) { allocator.AllocateFixed(static_cast(offset >> pageSizeBits), pages); - else + } else { offset = static_cast(allocator.Allocate(pages)) << pageSizeBits; + if (!offset) + throw exception("Failed to allocate free space in the GPU AS!"); + } u64 size{static_cast(pages) * pageSize}; @@ -236,6 +239,9 @@ namespace skyline::service::nvdrv::device::nvhost { u32 pageSizeBits{bigPage ? vm.bigPageSizeBits : VM::PageSizeBits}; offset = static_cast(allocator.Allocate(static_cast(util::AlignUp(size, pageSize) >> pageSizeBits))) << pageSizeBits; + if (!offset) + throw exception("Failed to allocate free space in the GPU AS!"); + asCtx->gmmu.Map(offset, cpuPtr, size); auto mapping{std::make_shared(cpuPtr, offset, size, false, bigPage, false)}; diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/gpu_channel.cpp b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/gpu_channel.cpp index f3b6066a..c558be72 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/gpu_channel.cpp +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/gpu_channel.cpp @@ -182,6 +182,8 @@ namespace skyline::service::nvdrv::device::nvhost { // Allocate pages in the GPU AS pushBufferAddr = static_cast(asAllocator->Allocate((static_cast(pushBufferWords) >> AsGpu::VM::PageSizeBits) + 1)) << AsGpu::VM::PageSizeBits; + if (!pushBufferAddr) + throw exception("Failed to allocate channel pushbuffer!"); // Map onto the GPU asCtx->gmmu.Map(pushBufferAddr, reinterpret_cast(pushBufferMemory.data()), pushBufferSize);