[PR #2997] [MERGED] Core: More Memory Cleanup & Fixes #3137

Closed
opened 2026-02-27 22:02:35 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/2997
Author: @StevenMiller123
Created: 5/27/2025
Status: Merged
Merged: 5/29/2025
Merged by: @georgemoralis

Base: mainHead: memory-fixes-once-more


📝 Commits (10+)

📊 Changes

4 files changed (+189 additions, -177 deletions)

View changed files

📝 src/core/libraries/kernel/memory.cpp (+68 -38)
📝 src/core/libraries/kernel/memory.h (+9 -9)
📝 src/core/memory.cpp (+108 -120)
📝 src/core/memory.h (+4 -10)

📄 Description

The main change of this PR is completely removing our PoolReserve and Reserve functions in Core::Memory. Both of these functions were effectively re-implementations of MapMemory with minor changes, since all three functions are different uses of the mmap syscall.
Instead of constantly updating all three separately, it's easier to group all behavior in one function with additional checks where we need to behave slightly differently.

I've also added proper error handling in posix_mmap, added proper conditional rasterizer memory mapping logic based on protection values, and fixed a few other edge cases I've noticed in testing.

I'm opening this as a draft for now, as I need to make some more minor cleanup/style commits, and these changes need proper testing before any merges.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/2997 **Author:** [@StevenMiller123](https://github.com/StevenMiller123) **Created:** 5/27/2025 **Status:** ✅ Merged **Merged:** 5/29/2025 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `memory-fixes-once-more` --- ### 📝 Commits (10+) - [`1c0945e`](https://github.com/shadps4-emu/shadPS4/commit/1c0945e4ae0924c41e388b76d57a60b4c3c9d6cb) Only perform GPU memory mapping when GPU can access it - [`c59bb4f`](https://github.com/shadps4-emu/shadPS4/commit/c59bb4f1f1786dbd2b7a9152d0a6f878c3bdfe37) Reserve fixes - [`e205a7d`](https://github.com/shadps4-emu/shadPS4/commit/e205a7d993b0b3261045056d458c0c32f653d348) Better sceKernelMmap - [`2faa5ac`](https://github.com/shadps4-emu/shadPS4/commit/2faa5ac8a577ef9a8764be8b50ea933de4c61b40) Major refactor - [`f085265`](https://github.com/shadps4-emu/shadPS4/commit/f0852650cca310f5e22a2c76034889dbd379f059) Accurate phys_addr for non-direct mappings - [`55099c0`](https://github.com/shadps4-emu/shadPS4/commit/55099c0aac8ce1ab4c238a1fe7b34c1d4f7f9084) Properly handle GPU access rights - [`78a28a0`](https://github.com/shadps4-emu/shadPS4/commit/78a28a06b23db904e2d28eac56092fece5d58a6d) Update memory.cpp - [`fb7b90e`](https://github.com/shadps4-emu/shadPS4/commit/fb7b90e024ceaacab1d2ca3243a8678e7c439922) Update memory.h - [`3c734e7`](https://github.com/shadps4-emu/shadPS4/commit/3c734e7779295758f406fbd3bf1ba8382bd05f3d) Update memory.cpp - [`2c55d01`](https://github.com/shadps4-emu/shadPS4/commit/2c55d014c0efbdfadee4121b01e1dcf5af60e63d) Update memory.cpp ### 📊 Changes **4 files changed** (+189 additions, -177 deletions) <details> <summary>View changed files</summary> 📝 `src/core/libraries/kernel/memory.cpp` (+68 -38) 📝 `src/core/libraries/kernel/memory.h` (+9 -9) 📝 `src/core/memory.cpp` (+108 -120) 📝 `src/core/memory.h` (+4 -10) </details> ### 📄 Description The main change of this PR is completely removing our `PoolReserve` and `Reserve` functions in `Core::Memory`. Both of these functions were effectively re-implementations of `MapMemory` with minor changes, since all three functions are different uses of the `mmap` syscall. Instead of constantly updating all three separately, it's easier to group all behavior in one function with additional checks where we need to behave slightly differently. I've also added proper error handling in `posix_mmap`, added proper conditional rasterizer memory mapping logic based on protection values, and fixed a few other edge cases I've noticed in testing. I'm opening this as a draft for now, as I need to make some more minor cleanup/style commits, and these changes need proper testing before any merges. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:02:35 +03:00
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#3137
No description provided.