shadPS4/src
Stephen Miller 6477dc4f1e
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Core: Memory Fixes (#2872)
* Fix VirtualQuery behavior on low addresses.

* Fix VirtualQuery struct

Somewhere in our BitField and array use, the size of our VirtualQuery struct became larger than the struct used on real hardware.
Fixing this fixes some data corruption visible in the name parameter during my tests.

* Default name to anon

On real hardware, nameless mappings are given the name "anon:address" where address appears to be the address that made the memory call.
For simplicity sake, I'll stick to the name "anon" for now.

* Place an upper bound on returns from SearchFree

Right now, this upper bound is set based on the limitations of our GPU buffer cache and page table.
Someone with more experience in that area of code should probably fix that at some point.

* More anons

* Clang

* Fix name in sceKernelMapNamedDirectMemory

* strncpy instead of strcpy

Hardcoded the constant size for now, I need to review how real hardware behaves here to determine if anything else is necessary for this to be accurate.

* Fix name behavior

All memory naming functions restrict the name size to a 31 character limit, and return `ORBIS_KERNEL_ERROR_ENAMETOOLONG` if that limit is exceeded.
Since this value is constant for all functions involving names, I've defined it as a constant in kernel's memory.h, and used that in place of any hardcoded 32 character limits.

* Error logging

Hopefully this helps in catching the UFC regression?

* Increase address space upper bound

Probably needs heavy testing, especially on Mac/Windows.
This increases the address space, as needed to accommodate strange memory behaviors seen in UFC.

* VirtualQuery fix

Due to limitations of certain platforms, we initialize our vma_map with 3 separate free mappings.
As such, we need to use a while loop here to accurately query mappings with high addresses

* Fix mappings to high addresses

The PS4's GPU can only handle 40bit addresses. Our texture cache and buffer cache were designed around these limits, and mapping to higher addresses would cause segmentation faults and access violations.
To fix these crashes, only map to the GPU if the mapping is fully contained within the address space the GPU should access.
I'm open to suggestions on how to make this cleaner

* Revert "Increase address space upper bound"

This reverts commit 3d50eeeebb.

* Revert VirtualQuery while loop

Windows wasn't happy with this, again.
Will try to debug and properly fix this when I have a good chance.

* Fix asserts

FindVMA, due to the way it's programmed, never actually returns vma_map.end(), the furthest it ever returns is the last valid memory area. All those asserts we involving vma_map.end() never actually trigger due to this.
This commit removes redundant asserts, adds messages to asserts that were lacking them, and fixes all asserts designed to detect out of bounds memory accesses so they actually trigger.
I've also fixed some potential memory safety issues.

* Proper error behavior in QueryProtection

Might as well handle this properly while I'm here.

* Clang

* More information about ReserveVirtualRange results

Should help debug issues like the one in The Order: 1886 (CUSA00076)

* Fix assert message

* Update assert message

Extra space

* Fix my bug

Oh hey, finally something that's my fault.

* Fix rasterizer unmaps

Should use adjusted_size here, otherwise we could unmap too much.
Thanks to diegolix29 for spotting this.

* Fix edge case in MapMemory

Code comments explain everything.
This should fix some memory asserts.

* Fix fix

Avoid running the code path if it's unnecessary, since there are many additional edge cases to handle when the VMA map is small.

* Fix fix fix

Should prevent infinite loops, haven't tested properly yet though.

* Split logging for inputs and out_addr in ReserveVirtualRange

Addresses review comments.
2025-05-09 12:33:04 -07:00
..
common [Libs] Stubs sceSigninDialog (#2890) 2025-05-09 11:08:22 +03:00
core Core: Memory Fixes (#2872) 2025-05-09 12:33:04 -07:00
images misc: Few small fixes. (#2780) 2025-04-13 12:10:24 -07:00
imgui devtools: persist fsr configs (#2852) 2025-04-27 13:32:29 -03:00
input Fix incorrect calculation setting the center of the joysticks one value off causing stick drift in games that assume already corrected input values (#2760) 2025-04-07 13:58:00 -07:00
qt_gui New Crowdin updates (#2846) 2025-04-30 12:41:30 +03:00
shader_recompiler Adding opcode IMAGE_SAMPLE_B_O (#2894) 2025-05-09 09:01:34 -07:00
video_core gnm: Implement sceGnmDrawIndexIndirectMulti (#2889) 2025-05-09 10:04:37 -07:00
.clang-format chore: Make shadps4 REUSE compliant 2024-02-23 23:33:43 +02:00
emulator.cpp emulator: Fix log initialization order. (#2878) 2025-05-03 13:47:03 -07:00
emulator.h CLI: Add argument to pass an argument to the game (#2135) 2025-01-18 15:21:08 +03:00
main.cpp VideoOut event cleanup (#2849) 2025-04-27 09:04:17 +03:00
sdl_window.cpp build: Move versioning to CMake file. (#2752) 2025-04-07 12:22:51 +03:00
sdl_window.h Gui: Adding Pause button working, full screen button and labels to buttons on main window gui (#2634) 2025-03-26 23:50:52 +02:00
shadps4.qrc misc: Few small fixes. (#2780) 2025-04-13 12:10:24 -07:00
shadps4.rc [Windows] Adding Properties to the Executable (#2789) 2025-04-17 09:43:14 +03:00