Fix DLSS and FSR crash: vkCreateDevice ErrorInitializationFailed #2274
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2274
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2274"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Ekt0re on GitHub · 2026-11-14 15:16 UTC · original
Ekt0re:fix-dlss-virtualAlloc→main· +393 −81 · 6 files · 5 commits · draftFix
vkCreateDevicecrash (ErrorInitializationFailed) with DLSS or FSR via two-phase guest address space reservationDescription
This PR fixes the immediate crash at startup when DLSS or FSR is enabled (
--pssr-upscaler DLSS), which failed with:The guest address space reservation is now split into two phases, so that the NVIDIA driver can create the Vulkan device before the entire virtual address space is occupied by placeholders.
Reference: original issue "DLSS and FSR crashes the PS5 Pro game on startup" (RTX 4070 Ti, driver 621.24, Windows 11).
Root cause
1. The original crash (
vkCreateDevice→-3)VK_NVX_binary_import,VK_NVX_image_view_handle,VK_KHR_buffer_device_address,VK_KHR_push_descriptor.VK_NVX_binary_importimports CUDA code into the driver. When it is requested invkCreateDevice, the CUDA runtime embedded in the NVIDIA driver reserves roughly 52 GB of virtual address space for UVA (Unified Virtual Addressing).VirtualAlloc2withMEM_RESERVE_PLACEHOLDER), leaving the driver with no 64-bit address space available in its preferred area. As a result,vkCreateDevicefailed.2. The cascading error (
address != DriverDmemBase)Simply moving the whole reservation after
Graphics::Initialize()led to a second problem:0x0500000000to0x1200000000, overlapping the fixed address ofGen5Driver(DriverDmemBase = 0x0fe0000000, 63.5 GB);Gen5Driver::Initialize()found the range occupied, its DMEM was relocated to0x1200000000, and theaddress != DriverDmemBaseassert failed.Solution: two-phase reservation
In the PS5 memory model, all fixed and critical addresses (e.g.
DriverDmemBaseand the pthread thread stacks) live in Region 0 (0x40000–0x1000000000, the first 64 GB). Regions 1 and 2 (64 GB to 1 TB) are dynamic and used for free-address allocations.Phase 1:
Memory::Initialize()[0x40000, 0x1000000000]) is reserved immediately.DriverDmemBaseand the system addresses stay protected from any host DLL or driver.Phase 2: window and Vulkan device creation
vkCreateDevicesucceeds with all the DLSS and FSR extensions.0x1100000000), with no conflicts.Phase 3:
ReserveGuestAddressSpace()beforeGen5Driver::Initialize()agc.cppright after GPU initialization. It reserves Regions 1 and 2 and runs the consistency checks (SelfTest,SelfTestSub64SharedPlaceholderAlias).Gen5Driver::Initialize()maps its DMEM exactly atDriverDmemBase = 0x0fe0000000.Main changes
src/kernel/memoryAddressSpace.incReserveGuestRegions()now accepts a region range[first_region, last_region). The constructor reserves only Region 0. NewReserveRemainingGuestRegions()method for Regions 1–2. Updated the Windows branch (VirtualAlloc2), theoccupiedhandling, and the Linux/POSIX branch (mmap).src/kernel/memory.cpp/memory.hInitialize()no longer runs the self-tests. NewReserveGuestAddressSpace()function that completes the reservation and runsSelfTestandSelfTestSub64SharedPlaceholderAlias.src/libs/agc.cppReserveGuestAddressSpace()afterInitializeGpu()and beforeGen5Driver::Initialize().src/emulator.cppTesting
DLSS mode (
--trinity --pssr-upscaler DLSS --dlss-folder C:\DLSS):The game starts normally, and DLSS and FSR compiles and runs graphics and compute shaders without crashing. Tested on several games, both PS5 Pro and non-Pro.
Linear mode (
--trinity --pssr-upscaler Linear): no regressions; starts and runs normally.FSR mode: no regressions; starts and runs normally.
Notes for reviewers
Gen5Driver::Initialize(), as before.mmap) branch follows the same phased logic, but has not been tested on Linux or Mac.ReserveGuestAddressSpace()(i.e. before the end ofInitializeGpu()) will not find the reservation already in place. No such cases are currently known.AI Use
Claude AI was used to investigate the root cause of the problem and to write this documentation. Testing and code review were done by me personally.
@coderabbitai[bot] on GitHub · 2026-11-14 15:25 UTC · original · edited 2026-11-19 20:27 UTC
No actionable comments were generated in the recent review.
Walkthrough
GuestAddressSpace now reserves region 0 during construction and reserves regions 1 and 2 through a separate call. The memory API performs that reservation before running address-space self-tests. AGC calls the API after GPU initialization and before native driver startup. Emulator comments describe the initialization order and the stated NGX failure condition. Tests cover aligned free-range calculation, preservation of an existing mapping, and reservation before test execution.
Suggested reviewers:
nmzik,thecruzChange: Bug fix
Merge Risk:
Minimal · up to
a0da8The change defers reservation of the upper guest address regions until after Vulkan device creation, which addresses the reported DLSS and FSR startup failure. No outstanding defects were found in the reviewed changes. The non-Windows reservation paths were not tested on Linux or Mac, but this does not currently block merging.
Pre-merge checks:
4
Full details: Title check
Explanation
The title names the specific crash (vkCreateDevice ErrorInitializationFailed) and the affected features (DLSS and FSR). The changeset splits guest address space reservation into phases, which addresses that crash. The title does not name the fix mechanism, but it describes the main change from the developer's perspective.
Full details: Description check
Explanation
The description explains the crash, its root cause, and the two-phase reservation fix. It lists the changed files and the testing done. This matches the changeset in src/kernel/memoryAddressSpace.inc, src/kernel/memory.cpp, src/kernel/memory.h, src/libs/agc.cpp, and src/emulator.cpp.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
ce7e2457-ff02-4745-bad0-80808f1f6976Reviewing files that changed from the base of the PR and between
cfcedef18fanda0da859fbb.src/kernel/memory.cppsrc/kernel/memory.hsrc/libs/agc.cpptests/VirtualMemoryAllocationTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@ -968,2 +967,4 @@g_pooled_memory = std::make_unique<PooledMemory>();g_virtual_ranges = std::make_unique<VirtualRanges>();// SelfTest and SelfTestSub64SharedPlaceholderAlias require the guest regions to be// reserved first; they are therefore deferred to ReserveGuestAddressSpace().@coderabbitai[bot] on GitHub · 2026-11-14 15:25 UTC · original · edited 2026-11-14 16:14 UTC
Update the memory-test harness for two-phase initialization.
tests/VirtualMemoryAllocationTests.cppinitializesMemory::Lifecyclewithout callingReserveGuestAddressSpace(). Its pool-reservation test then requests a range at or above0x1000000000.With only Region 0 reserved,
KernelMemoryPoolReservedelegates toKernelReserveVirtualRange, andFindGuestFreeRangereturns zero. The call returnsKERNEL_ERROR_ENOMEM, soCheckOkfails.Call
ReserveGuestAddressSpace()after Memory initialization in the host-test harness, before tests use Regions 1–2. This does not require GPU initialization in that harness.✅ Addressed in commit
7cea4b2@coderabbitai[bot] on GitHub · 2026-11-14 15:25 UTC · original · reviewed
Actionable comments posted: 1
d6005980-ac74-43ff-b6ed-8429c2ebff14Reviewing files that changed from the base of the PR and between
3e226bff9dand087d3b0dc1.src/emulator.cppsrc/kernel/memory.cppsrc/kernel/memory.hsrc/kernel/memoryAddressSpace.incsrc/libs/agc.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@ -461,0 +592,4 @@// [HOST_USER_MIN, HOST_USER_MAX] and kExtendedMemoryBase).// Must be called after host GPU/DLSS initialization has completed.// Returns true if the regions were newly reserved on this call.bool ReserveRemainingGuestRegions() {@coderabbitai[bot] on GitHub · 2026-11-14 16:19 UTC · original · edited 2026-11-14 18:04 UTC
Delayed Region 1 reservation can overwrite the macOS backing alias.
The constructor now creates the backing alias before
ReserveRemainingGuestRegions()reserves Region 1. On Apple x86_64, the alias uses a null address hint. The kernel can therefore place it inside[0x7000000000, 0xfbffffffff], which Region 1 covers. The non-Linux POSIX loop then maps the whole region withMAP_FIXED, and that call silently replaces the overlapping alias pages withPROT_NONE. Later access through the alias can fault.On a target without
KYTY_LINKED_GUEST_ADDRESS_SPACE, the same overlap makes the hintedmmapreturn a different address. The code then unmaps the result and terminates throughEXIT.The Linux branch scans existing mappings first, so it does not have this problem. The POSIX branch has no equivalent check.
Do not fix this by reserving Region 1 earlier. That would bring back the
vkCreateDevicefailure this change removes. The inspected code does not establish a safe localized correction, so this comment gives no patch. A remedy needs to keep the alias out of Regions 1–2 during the gap, or add an occupancy check to the POSIX path.✅ Addressed in commit
a2013e6@coderabbitai[bot] on GitHub · 2026-11-14 16:19 UTC · original · reviewed
Actionable comments posted: 1
c84b1ab8-f290-4941-98ef-aa1e15b87416Reviewing files that changed from the base of the PR and between
087d3b0dc1and7cea4b2b1e.src/kernel/memory.cppsrc/kernel/memoryAddressSpace.inctests/VirtualMemoryAllocationTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
@coderabbitai[bot] on GitHub · 2026-11-14 18:11 UTC · original · edited 2026-11-14 18:45 UTC
On
src/kernel/memory.hline 220 (outdated):Move the standard-library includes above the namespace.
The
<utility>and<vector>includes sit insideLibs::LibKernel::Memory. Standard headers must not be included inside a namespace. In the allocation-test build,memory.cppincludeskernel/memory.hbefore any standard header, so these includes are the first occurrence there. Their declarations can then land inLibs::LibKernel::Memory, and the include guards block a correct global inclusion. Laterstd::references in that file can then fail to compile. The break affects only thevirtual_memory_allocation_testsbuild, where the macro is defined.Move both includes above the namespace and keep the test guard:
Suggested fix
✅ Addressed in commit
cfcedef@coderabbitai[bot] on GitHub · 2026-11-14 18:11 UTC · original · edited 2026-11-14 18:45 UTC
On
tests/VirtualMemoryAllocationTests.cppline 5994 (outdated):Restore the
TestAsanShadowLifetimeAcrossRangeEditscall in the memory-bottleneck suite.Line 5994 calls
TestAsanShadowUpdatesAcrossRangeEdits, but no declaration or macro with that name exists in the checkout. The only definition isTestAsanShadowLifetimeAcrossRangeEdits. The undeclared identifier stops compilation of this translation unit, so the whole test executable fails to build. The Lifetime test also registers the memory callbacks that the following ASan tests rely on, so its call must remain.If a separate Updates test is intended, add its definition before using the name. Otherwise, restore the existing identifier.
Suggested fix
Committable suggestion
✅ Addressed in commit
cfcedef@coderabbitai[bot] on GitHub · 2026-11-14 18:11 UTC · original · reviewed
Actionable comments posted: 2
8c22cc9c-3427-47fb-a66f-a378db76b632Reviewing files that changed from the base of the PR and between
7cea4b2b1eanda2013e6666.src/kernel/memory.cppsrc/kernel/memory.hsrc/kernel/memoryAddressSpace.inctests/VirtualMemoryAllocationTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.