-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Common: Use Mach VM routines for memory mapping #11308
Conversation
MacOS does not support an equivalent of MAP_FIXED_NOREPLACE via mmap(), which means that our usage for allocating PCSX2's memory map is not thread-safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not super familiar with mach's memory management APIs but it seems reasonable (untested)
One part I do have a question about is the part that's just getting moved around, but since Edit: I'm apparently blindpthread_jit_write_protect_np
is per-thread while s_code_write_depth
is static, do/will we have something in place to make sure no two threads attempt to write code at the same time (e.g. ee and sw renderer)?
(Don't have to address it here/now, since it won't affect anyone on x86)
All good :) I've tested on Sonoma (M2 Pro) and it seems fine. The only potential issue is |
Sorry to say that, but this does not work on my 2014 MacBook Pro 13". It runs with Sonoma and Open Core Legacy Patcher. I do not know if this is an issue with Open Core Legacy Patcher, BUT PCSX2-v1.7.5849 introduces this feature, while PCSX2-v1.7.5847 runs flawlessly. |
Latest (1.7.5953) still works for me on a 15" MBP from 2014 running Big Sur. |
So, in Big Sur it works (your observation), in OCLP/Sonoma it doesn't (my observation). Anybody able to try if it works in vanilla Sonoma (Intel)? |
2019 MBP (Intel), macOS 14.4 (Sonoma), 1.7.5955 works for me. |
I guess as I run OCLP/Sonoma my system is out of support in this case and this error is irrelevant on regular systems. |
We had another user with a similar issue on a Ryzen hackintosh, check what SIP flags you have enabled, apparently some of them break this. |
here is what my Mac's OCLP/Sonoma state is like:
|
@jimjamyaha Can you check if #11734 helps? |
@TellowKrinkle #11734 works on my MacBook Pro 2014 Sonoma 14.6.1 OCLP. I just saw that you can set the SIP bits as you want before root-patching. What are these bits set like on a supported Mac with Sonoma? |
Description of Changes
MacOS does not support an equivalent of MAP_FIXED_NOREPLACE via mmap(), which means that our usage for allocating PCSX2's memory map is not thread-safe.
#11282 fixed this for Linux, this PR implements it for MacOS.
I'll follow up later with a signal handler tidy-up, that way we can skip compiling everything in the Linux/ directory on MacOS.
Rationale behind Changes
Preventing a race condition that can cause memory corruption in PCSX2 on startup, while it allocates its memory map.
Suggested Testing Steps
Make sure Mac builds still boot.
@TellowKrinkle I've tagged you for review in case you know anything about these system calls. Apple's documentation is all blank pages, I ended up using the published XNU source as a reference...