EE Cache: Fix cache masking and support caching invalid physical addresses
Description of Changes
You are able to make TLB entries that point to invalid physical addresses. Because the cache is accessed before the physical write (obviously), the cache will still store data for these physical addresses. Once the cache data is evicted, curiously there is no bus error for addresses such as 0x70004000, so the data is silently discarded. Find my Own Way uses this method to create a "virtual scratchpad" of higher speed, temporary memory.
This implements correct behaviour (I have hardware tested an ELF), however, this sadly does not make Find My Own Way work without patching. Find My Own Way is one of those games that tend to deadlock the EE with cache enabled (for some other, unknown reason).
Rationale behind Changes
This is proper cache behaviour.
Suggested Testing Steps
Test games that require EE Cache (I'm sorry, I know it's slow :( ), make sure they still work. Also, if any game causes bus errors please try and test it with this PR and EE Cache enabled. This might be the fix required.
Going to look into properly locking cache lines.
@MrCK1 If you're going to accidentally mark the PR as ready, you could've put it back as a draft lol.
I've updated the PR, it's ready on my end. I'm confident I fixed find my own way. It's hard to know though, it's been running for 20 minutes at 1-3 FPS 🫠.
LGTM, maybe needs testing on linux to make sure the popcount thing doesn't explode :D
Tested on windows with find my own way + dead or alive with patches disabled
Did somebody say Linux? 👀