[PR #3655] [MERGED] Core: Memory code cleanup and further direct memory fixes #3635

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

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/3655
Author: @StevenMiller123
Created: 9/25/2025
Status: Merged
Merged: 9/26/2025
Merged by: @squidbus

Base: mainHead: memory-fixes


📝 Commits (10+)

  • a517a73 Remove mapped dmem type
  • dd70b5e Proper implementation for sceKernelMtypeprotect
  • 9c9e320 Apply memory type in sceKernelMemoryPoolCommit
  • 5e686a8 Organization
  • 596ea46 Iterator logic cleanup
  • 4b30cf2 Clang
  • 754334d Adjustments
  • 7e88d34 Properly account for behavior differences in MapDirectMemory2
  • 141c84d Clang
  • 72da141 Add execute permissions to physical backing

📊 Changes

6 files changed (+251 additions, -110 deletions)

View changed files

📝 src/core/address_space.cpp (+6 -5)
📝 src/core/libraries/kernel/memory.cpp (+85 -24)
📝 src/core/libraries/kernel/memory.h (+4 -5)
📝 src/core/memory.cpp (+150 -71)
📝 src/core/memory.h (+4 -4)
📝 src/core/module.cpp (+2 -1)

📄 Description

This PR changes some more logic, primarily related to direct memory handling and the dmem map.

  • Reimplemented MemoryManager::SetDirectMemoryType to search through VMAs to find the physical memory areas to update.
  • Updated sceKernelMtypeprotect to apply mtype using MemoryManager::SetDirectMemoryType.
  • Updated sceKernelMemoryPoolCommit to apply mtype during MemoryManager::PoolCommit.
  • Restored overlapping direct memory check, but properly restricted it to sceKernelMapDirectMemory2 calls.
  • Fixed detection of executable memory mappings in libkernel memory functions.
  • Fixed issues with backed executable mappings on Windows.
  • Fixed a variety of smaller things I've noticed while looking at memory code.

Everything I've changed appears to work fine on my end, but it would be good to have some other tests before merging.


🔄 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/3655 **Author:** [@StevenMiller123](https://github.com/StevenMiller123) **Created:** 9/25/2025 **Status:** ✅ Merged **Merged:** 9/26/2025 **Merged by:** [@squidbus](https://github.com/squidbus) **Base:** `main` ← **Head:** `memory-fixes` --- ### 📝 Commits (10+) - [`a517a73`](https://github.com/shadps4-emu/shadPS4/commit/a517a73bbedcb77aa02ed4d567bc574e8a05f33c) Remove mapped dmem type - [`dd70b5e`](https://github.com/shadps4-emu/shadPS4/commit/dd70b5e5573c1cbecf8dd911672b8391dec57410) Proper implementation for sceKernelMtypeprotect - [`9c9e320`](https://github.com/shadps4-emu/shadPS4/commit/9c9e32054ccfed17eac40682f1b90385a551b70e) Apply memory type in sceKernelMemoryPoolCommit - [`5e686a8`](https://github.com/shadps4-emu/shadPS4/commit/5e686a8903198d4933c7b6ee5cc1811a1c2920a8) Organization - [`596ea46`](https://github.com/shadps4-emu/shadPS4/commit/596ea466fad4186bb8b5075bd6d1bcc7f394c9c7) Iterator logic cleanup - [`4b30cf2`](https://github.com/shadps4-emu/shadPS4/commit/4b30cf2d0e0ba4f6c162bedf83d885227c1558b6) Clang - [`754334d`](https://github.com/shadps4-emu/shadPS4/commit/754334daa894cd283347d6db374dc0ad23561249) Adjustments - [`7e88d34`](https://github.com/shadps4-emu/shadPS4/commit/7e88d34f274250fb71d81aa1982296c1463d2525) Properly account for behavior differences in MapDirectMemory2 - [`141c84d`](https://github.com/shadps4-emu/shadPS4/commit/141c84dfc61a1eddd5668cb28a6ad1986accf707) Clang - [`72da141`](https://github.com/shadps4-emu/shadPS4/commit/72da141e095e541ba33f4e91feb5b68cd93b1b24) Add execute permissions to physical backing ### 📊 Changes **6 files changed** (+251 additions, -110 deletions) <details> <summary>View changed files</summary> 📝 `src/core/address_space.cpp` (+6 -5) 📝 `src/core/libraries/kernel/memory.cpp` (+85 -24) 📝 `src/core/libraries/kernel/memory.h` (+4 -5) 📝 `src/core/memory.cpp` (+150 -71) 📝 `src/core/memory.h` (+4 -4) 📝 `src/core/module.cpp` (+2 -1) </details> ### 📄 Description This PR changes some more logic, primarily related to direct memory handling and the dmem map. - Reimplemented `MemoryManager::SetDirectMemoryType` to search through VMAs to find the physical memory areas to update. - Updated `sceKernelMtypeprotect` to apply mtype using `MemoryManager::SetDirectMemoryType`. - Updated `sceKernelMemoryPoolCommit` to apply mtype during `MemoryManager::PoolCommit`. - Restored overlapping direct memory check, but properly restricted it to `sceKernelMapDirectMemory2` calls. - Fixed detection of executable memory mappings in libkernel memory functions. - Fixed issues with backed executable mappings on Windows. - Fixed a variety of smaller things I've noticed while looking at memory code. Everything I've changed appears to work fine on my end, but it would be good to have some other tests before merging. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:04:26 +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#3635
No description provided.