Skip to content
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

Hotfix for shm->map_self() #9230

Merged
merged 1 commit into from Nov 8, 2020
Merged

Hotfix for shm->map_self() #9230

merged 1 commit into from Nov 8, 2020

Conversation

Nekotekina
Copy link
Member

Make sure mmap returns 64K-aligned results, as on Windows.
Does not affect Windows, but RPCS3 relies on this logic so need a little workaround.

Make sure mmap returns 64K-aligned results, as on Windows.
const u64 res64 = reinterpret_cast<u64>(::mmap(reinterpret_cast<void*>(ptr64), m_size + 0xe000, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0));

const u64 aligned = ::align(res64, 0x10000);
const auto result = ::mmap(reinterpret_cast<void*>(aligned), m_size, +prot, MAP_SHARED | MAP_FIXED, m_file, 0);
Copy link
Contributor

@elad335 elad335 Nov 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt this run in a loop? for cases where other thread just mmap on the same range inbetween. until second mmap call succeeds.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah nvm.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmap with MAP_FIXED flag just overwrites previous mapping, fully or partially.

@Nekotekina Nekotekina merged commit b05d12d into RPCS3:master Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants