[GH-ISSUE #789] The Last Of Us Part II (CUSA07820) sceKernelGetDirectMemorySize Halt #204

Closed
opened 2026-02-27 21:05:07 +03:00 by kerem · 11 comments
Owner

Originally created by @StevenMiller123 on GitHub (Sep 5, 2024).
Original GitHub issue: https://github.com/shadps4-emu/shadPS4/issues/789

The Last Of Us Part II verifies the value of sceKernelGetDirectMemorySize, and halts if the returned value differs from what it expects. A log of this behavior can be found at https://github.com/shadps4-emu/shadps4-game-compatibility/issues/66. This behavior is probably because the game sets a flexible memory size, a behavior that appears to be emulated fine.

Through decompiling the game's eboot, I found that the game uses the constant value 0x15f200000 to verify the direct memory size. For reference, the game sets the flexible memory size to 0xce00000, assuming the current emulated behavior is accurate. This would put the expected total memory size at 0x16c000000. For whatever reason, the expected sizes do not change when isPS4Pro is enabled in the config. I'm not sure if I can share any relevant assembly, but if this would be liked and is considered fine, then I will. I cannot provide any decompilation, as my Ghidra couldn't decomp the function this is all contained in.

Originally created by @StevenMiller123 on GitHub (Sep 5, 2024). Original GitHub issue: https://github.com/shadps4-emu/shadPS4/issues/789 The Last Of Us Part II verifies the value of sceKernelGetDirectMemorySize, and halts if the returned value differs from what it expects. A log of this behavior can be found at https://github.com/shadps4-emu/shadps4-game-compatibility/issues/66. This behavior is probably because the game sets a flexible memory size, a behavior that appears to be emulated fine. Through decompiling the game's eboot, I found that the game uses the constant value 0x15f200000 to verify the direct memory size. For reference, the game sets the flexible memory size to 0xce00000, assuming the current emulated behavior is accurate. This would put the expected total memory size at 0x16c000000. For whatever reason, the expected sizes do not change when isPS4Pro is enabled in the config. I'm not sure if I can share any relevant assembly, but if this would be liked and is considered fine, then I will. I cannot provide any decompilation, as my Ghidra couldn't decomp the function this is all contained in.
kerem 2026-02-27 21:05:07 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@dark147x commented on GitHub (Sep 5, 2024):

Cool, I don't know much about development, I just hope to play the game (I played the first part before the PC port on an RPCS3). I wish you good luck!!!

<!-- gh-comment-id:2330774832 --> @dark147x commented on GitHub (Sep 5, 2024): Cool, I don't know much about development, I just hope to play the game (I played the first part before the PC port on an RPCS3). I wish you good luck!!!
Author
Owner

@raphaelthegreat commented on GitHub (Sep 5, 2024):

Does the game progress further with this adjustment?

<!-- gh-comment-id:2331089003 --> @raphaelthegreat commented on GitHub (Sep 5, 2024): Does the game progress further with this adjustment?
Author
Owner

@StevenMiller123 commented on GitHub (Sep 5, 2024):

Yes, the game gets past this halt, but then immediately crashes from what appears to be an issue with sceKernelAvailableFlexibleMemorySize. These are the printed errors.

[Kernel.Vmm] <Info> memory_management.cpp:sceKernelAvailableFlexibleMemorySize:246: called size = 0xcaac000  
[Tty] <Info> libkernel.cpp:ps4__write:210: Code and Data section is too large. It is 17592186044416.016 and should be 73.000
[Tty] <Info> libkernel.cpp:ps4__write:210: Warning - RAM Cache is being disabled.

Here is a log with my fix applied, I modified sceKernelGetDirectMemorySize to print the returned size for debugging purposes.
Log: TLOU2 log.txt

I've also confirmed that the game requires the direct memory size to be the exact value I listed, and changing the size to slightly above or below the variable I listed causes that halt to come back.

<!-- gh-comment-id:2331357919 --> @StevenMiller123 commented on GitHub (Sep 5, 2024): Yes, the game gets past this halt, but then immediately crashes from what appears to be an issue with sceKernelAvailableFlexibleMemorySize. These are the printed errors. ``` [Kernel.Vmm] <Info> memory_management.cpp:sceKernelAvailableFlexibleMemorySize:246: called size = 0xcaac000 [Tty] <Info> libkernel.cpp:ps4__write:210: Code and Data section is too large. It is 17592186044416.016 and should be 73.000 [Tty] <Info> libkernel.cpp:ps4__write:210: Warning - RAM Cache is being disabled. ``` Here is a log with my fix applied, I modified sceKernelGetDirectMemorySize to print the returned size for debugging purposes. Log: [TLOU2 log.txt](https://github.com/user-attachments/files/16893181/TLOU2.log.txt) I've also confirmed that the game requires the direct memory size to be the exact value I listed, and changing the size to slightly above or below the variable I listed causes that halt to come back.
Author
Owner

@StevenMiller123 commented on GitHub (Sep 16, 2024):

Looking at logs from running the game on a base PS4, I think the issue is likely with how we handle flexible memory size assignments instead. I think the game might be trying to reduce the flexible memory size to increase dmem size, though I don't know how I would verify this, and I won't have access to my PS4s for another month or so.

<!-- gh-comment-id:2353231319 --> @StevenMiller123 commented on GitHub (Sep 16, 2024): Looking at logs from running the game on a base PS4, I think the issue is likely with how we handle flexible memory size assignments instead. I think the game might be trying to reduce the flexible memory size to increase dmem size, though I don't know how I would verify this, and I won't have access to my PS4s for another month or so.
Author
Owner

@Hermiten commented on GitHub (Nov 14, 2024):

Hey, can we have an update about this ? To put some labels and maybe report it on discord

<!-- gh-comment-id:2476040884 --> @Hermiten commented on GitHub (Nov 14, 2024): Hey, can we have an update about this ? To put some labels and maybe report it on discord
Author
Owner

@rmueller83 commented on GitHub (Dec 14, 2024):

@Hermiten still the same on e752f04cde

[Core] <Error> stubs.cpp:CommonStub:42: Stub: sceCoredumpRegisterCoredumpHandler (nid: 8zLSfEfW5AU) called, returning zero to 0x90025ff4e
[Kernel.Vmm] <Warning> memory.cpp:sceKernelGetDirectMemorySize:22: called
[Tty] <Info> logger.cpp:log_flush:60: [stdout] ******************************************************************************
[Tty] <Info> logger.cpp:log_flush:60: [stdout] ***      HALT: Direct memory sizes do not add up
[Tty] <Info> logger.cpp:log_flush:60: [stdout] ***
[Tty] <Info> logger.cpp:log_flush:60: [stdout] ***  Function: InitializeMemory
[Tty] <Info> logger.cpp:log_flush:60: [stdout] ***      File: common\common-main-ps4.cpp
[Tty] <Info> logger.cpp:log_flush:60: [stdout] ***      Line: 288
[Tty] <Info> logger.cpp:log_flush:60: [stdout] ***     Built:
[Tty] <Info> logger.cpp:log_flush:60: [stdout] ******************************************************************************

shad_log.txt

<!-- gh-comment-id:2543139532 --> @rmueller83 commented on GitHub (Dec 14, 2024): @Hermiten still the same on e752f04cde25941818e141cc933ffa380cc321e5 ``` [Core] <Error> stubs.cpp:CommonStub:42: Stub: sceCoredumpRegisterCoredumpHandler (nid: 8zLSfEfW5AU) called, returning zero to 0x90025ff4e [Kernel.Vmm] <Warning> memory.cpp:sceKernelGetDirectMemorySize:22: called [Tty] <Info> logger.cpp:log_flush:60: [stdout] ****************************************************************************** [Tty] <Info> logger.cpp:log_flush:60: [stdout] *** HALT: Direct memory sizes do not add up [Tty] <Info> logger.cpp:log_flush:60: [stdout] *** [Tty] <Info> logger.cpp:log_flush:60: [stdout] *** Function: InitializeMemory [Tty] <Info> logger.cpp:log_flush:60: [stdout] *** File: common\common-main-ps4.cpp [Tty] <Info> logger.cpp:log_flush:60: [stdout] *** Line: 288 [Tty] <Info> logger.cpp:log_flush:60: [stdout] *** Built: [Tty] <Info> logger.cpp:log_flush:60: [stdout] ****************************************************************************** ``` [shad_log.txt](https://github.com/user-attachments/files/18136275/shad_log.txt)
Author
Owner

@StevenMiller123 commented on GitHub (Dec 28, 2024):

Fixed by #1896

<!-- gh-comment-id:2564337120 --> @StevenMiller123 commented on GitHub (Dec 28, 2024): Fixed by #1896
Author
Owner

@nazzzzTLOU commented on GitHub (Feb 2, 2025):

Is this "case" closed? Tlou 2 is still crashing and I tried to convert the fixed log file into bin although I know it's impossible.
So I wanted to know if a fix has been found pls

<!-- gh-comment-id:2629505634 --> @nazzzzTLOU commented on GitHub (Feb 2, 2025): Is this "case" closed? Tlou 2 is still crashing and I tried to convert the fixed log file into bin although I know it's impossible. So I wanted to know if a fix has been found pls
Author
Owner

@StevenMiller123 commented on GitHub (Feb 2, 2025):

The specific issue I was reporting in this issue was fixed, the game is crashing on something else now.

<!-- gh-comment-id:2629506276 --> @StevenMiller123 commented on GitHub (Feb 2, 2025): The specific issue I was reporting in this issue was fixed, the game is crashing on something else now.
Author
Owner

@nazzzzTLOU commented on GitHub (Feb 2, 2025):

Have you found the issue? Or a hint to it? If not i hope it does,thanks for ur help man!!

<!-- gh-comment-id:2629507596 --> @nazzzzTLOU commented on GitHub (Feb 2, 2025): Have you found the issue? Or a hint to it? If not i hope it does,thanks for ur help man!!
Author
Owner

@StevenMiller123 commented on GitHub (Feb 2, 2025):

We know why it's crashing, but we haven't found a proper solution yet.
Either way, we've got a while before larger games start working, shadPS4 is still very early in development.

If you've got more questions, I recommend asking in the shadPS4 Discord server instead.

<!-- gh-comment-id:2629509729 --> @StevenMiller123 commented on GitHub (Feb 2, 2025): We know why it's crashing, but we haven't found a proper solution yet. Either way, we've got a while before larger games start working, shadPS4 is still very early in development. If you've got more questions, I recommend asking in the shadPS4 Discord server instead.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shadPS4#204
No description provided.