* SearchFree adjustments
* Robust address validation
I've adjusted IsValidAddress to take in a size, and check whether the whole range is contained in vma map.
If no size is provided, the function reverts to the old form of address validation instead.
* Map around gaps
As is, this should work mostly.
Only remaining issue is adding logic to pass the "mapped regions" to the guest vma map (and make such logic cross-platform).
* Initialize vma_map using gaps
This should allow memory code to catch any issues from address space gaps, and prevent non-fixed mappings from jumping to a location that isn't actually available.
* Clang
* Fix compile
* Clang
* Fix compile again
* Set system_managed_base and system_managed_size based on
Many places in our code use system_managed_base as the minimum mappable address, ensure this fact remains the same on Windows to prevent potential bugs.
* Reduce address validation in SearchFree
Allows SearchFree to function when a certain Windows GPU driver goes and reserves the whole system managed area.
Since SearchFree is only called on flexible addresses, allowing this particular case, where addresses are in bounds, but there's not enough space to map, should be safe enough.
* Bump address space size further
To handle Madden NFL 16 (and any games like it)
* More thorough logging of available memory regions
Should help with spotting weirdness.
* Formatting fixes
* Clang
* Slight reduction of user space
Still large enough to handle EA's shenanigans, but small enough that Linux doesn't break.
* Assert on VirtualQuery failure
* Extra debugging information
* Further reduce user space
This will unfix most of EA's titles, but UFC will still work.
Older windows versions support the high addresses, but trying to actually use them causes significant performance issues.
* Extra debugging info
Just in case other testers still run into issues.
* Remove debug logging
* Revert user space increases
Technically this constant is still higher than before, but weird side effects of our old logic resulted in a max address somewhere around this in main.
* address_space: Support expanded virtual memory space on macOS.
Co-Authored-By: squidbus <175574877+squidbus@users.noreply.github.com>
* Move address space constants to address_space.cpp
This ensures that all code must use the calculated address space memory values instead of the constants, since the calculated values can differ based on the platform.
This does require slight modification to thread state and gnmdriver code, since both were already using these constants directly.
* Workaround Windows 10 limitations
If a Windows 10 device is detected, use a lower value for USER_MAX to prevent system-wide hangs in VirtualAlloc2 calls.
* Fix compile for Windows-Qt
* Move tessellation_factors_ring_addr initialization to sceGnmGetTheTessellationFactorRingBufferBaseAddress
* Set image base address on Windows
This seems to work fine on Windows 11, needs testing from Windows 10 due to the previously discussed bugs.
* Set Linux executable base to 0x700000000000
This allows Linux to map the full user space without any workarounds.
Co-Authored-By: Marcin Mikołajczyk <2052578+mikusp@users.noreply.github.com>
* Basic formatting changes
* Reduce USER_MAX on Linux
Seems like finding a reliable way to move shadPS4's position in memory is difficult, for now limit the user size so we aren't trying to overwrite ourselves.
* Move memory and address_space variables.
---------
Co-authored-by: squidbus <175574877+squidbus@users.noreply.github.com>
Co-authored-by: Marcin Mikołajczyk <2052578+mikusp@users.noreply.github.com>
* Fix module map addresses
Most modules are mapped starting at 0x800000000, with no gaps between mappings.
* Hardcode hardware accurate base address
Looking at our address space, all platforms will have this base address mapped, so there shouldn't be any problem in using it.
* Clang
* Swap module mapping to NoFlags, remove offset code
Since real hardware has no gap between module mappings, the Fixed flag is just an annoyance to work around, and has no impact on the actual mappings.
Swapping the module mappings to use flags NoFlags instead simplifies our code slightly.
* Fix module mapping names
On real hardware, the file extension is part of the mapping name. Easiest way to manage this is to swap the name to be `file.filename().string()` instead of `file.stem().string()`
* Fix patches
Completely missed this, whoops.
* translator: Implemtn f32 to f16 convert
* shader_recompiler: Add bit instructions
* shader_recompiler: More data share instructions
* shader_recompiler: Remove exec contexts, fix S_MOV_B64
* shader_recompiler: Split instruction parsing into categories
* shader_recompiler: Better BFS search
* shader_recompiler: Constant propagation pass for cmp_class_f32
* shader_recompiler: Partial readfirstlane implementation
* shader_recompiler: Stub readlane/writelane only for non-compute
* hack: Fix swizzle on RDR
* Will properly fix this when merging this
* clang format
* address_space: Bump user area size to full
* shader_recompiler: V_INTERP_MOV_F32
* Should work the same as spirv will emit flat decoration on demand
* kernel: Add MAP_OP_MAP_FLEXIBLE
* image_view: Attempt to apply storage swizzle on format
* vk_scheduler: Barrier attachments on renderpass end
* clang format
* liverpool: cs state backup
* shader_recompiler: More instructions and formats
* vector_alu: Proper V_MBCNT_U32_B32
* shader_recompiler: Port some dark souls things
* file_system: Implement sceKernelRename
* more formats
* clang format
* resource_tracking_pass: Back to assert
* translate: Tracedata
* kernel: Remove tracy lock
* Solves random crashes in Dark Souls
* code: Review comments
* Implement `sceKernelFtruncate` and `sceKernelUnlink`.
* Remove unused variable.
* Implement `sceKernelReserveVirtualRange`, misc fixes
* Fix `sceKernelReserveVirtualRange`.
* Add TODO on reserve
* Replace comment with assert.
* Add missing copyright header
* Add `UNREACHABLE` for `IOFile::Unlink`.
* Move NT API initialization out of the header
* Fix bug where files were always mapped as read only.
* `clang-format`
* video_core: Add a few missed things
* libkernel: More proper memory mapped files
* memory: Fix tessellation buffer mapping
* Cuphead work
* sceKernelPollSema fix
* clang format
* fixed ngs2 lle loading and rtc lib
* draft pthreads keys implementation
* fixed return codes
* return error code if sceKernelLoadStartModule module is invalid
* re-enabled system modules and disable debug in libs.h
* Improve linux support
* fix windows build
* kernel: Rework keys
---------
Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
* core: Split module code from linker
* linker: Properly implement thread local storage
* kernel: Fix a few memory functions
* kernel: Implement module loading
* Now it's easy to do anyway with new module rework