Skip to content

PPU: Fix LVRX bad memory access #14499

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

Merged
merged 1 commit into from
Aug 17, 2023
Merged

PPU: Fix LVRX bad memory access #14499

merged 1 commit into from
Aug 17, 2023

Conversation

elad335
Copy link
Contributor

@elad335 elad335 commented Aug 17, 2023

  • LVRX puts zeroes into the destination register if the lower bits of address are all zeroes. This is because this instruction is used in unaligned loads and is supposed to be used in combination with LVLX by ORis the result. Now, it was unclear if on 0 address offset it actually dereferences memory so I tested it on realhw, and it didn't! loaded from nullptr just fine. To avoid a branch instruction for this fix to be detrimental for performance, address is selected between current instruction address and source address. Because current instruction address is assumed to be allocated memory.
    Whos knows, maybe this fixes some access violation in a game. (clear PPU cache if you want to test it)

@Whatcookie
Copy link
Member

What about the masked load intrinsics from LLVM? https://llvm.org/docs/LangRef.html#masked-vector-load-and-store-intrinsics

There are some masked load instructions in AVX2, and every instruction supports masked loads/stores with AVX-512, so LLVM should be able to choose something fast

@elad335
Copy link
Contributor Author

elad335 commented Aug 17, 2023

We discussed on it in private and we decided that due to giving up on atomicity this would not be used aside from AVX512 in the future. As the atomicity nature of these instructions is not known. (could be atomic for some offset values)

@elad335 elad335 added CPU Bugfix LLVM Related to LLVM instruction decoders labels Aug 17, 2023
@elad335 elad335 merged commit 8b212f2 into RPCS3:master Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix CPU LLVM Related to LLVM instruction decoders
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants