rcheevos: add PS3 memory map to consoleinfo.c - #545
Conversation
Add rc_memory_regions_playstation3 with four regions covering the full PS3 address space as defined in RPCS3 (vm.cpp g_locations): - Main RAM: 0x00000000-0x0FFFFFFF (256MB, preallocated) - User RAM (64K): 0x10000000-0x1FFFFFFF (lazy, sys_memory_allocate 64K) - Unused gap: 0x20000000-0x2FFFFFFF (declared UNUSED to preserve contiguity) - User RAM (1M): 0x30000000-0x3FFFFFFF (lazy, sys_memory_allocate 1M) Lazy regions return zeroed bytes via RPCS3 read_memory callback when not yet allocated, preventing rcheevos from permanently disabling achievements that reference unallocated memory at game load time. Reference: https://github.com/RPCS3/rpcs3/blob/master/rpcs3/Emu/Memory/vm.cpp
|
Note: AI tools were used to assist in development. All code was reviewed, tested, and verified manually before submission. |
Jamiras
left a comment
There was a problem hiding this comment.
I don't have sufficient understanding to validate the map itself, but the implementation is approved.
sys_rsx_context_allocate (called by cellGcmInit) reserves vm::rsx_context at 0x10000000 (256 MB) before any sys_memory_allocate call. User64K pool follows at 0x20000000 (512 MB hardcoded in sys_memory.cpp). User1M lands at 0x40000000. RSX context is fused with user64K[0] into a single 512 MB region since they are contiguous and game state is not expected in RSX space. References: - vm.cpp:1893 (_find_map scan from 0x10000000) - sys_rsx.cpp:272 (RSX context 256 MB reservation) - sys_memory.cpp:105 (user64K 512 MB hardcoded pool)
Jamiras
left a comment
There was a problem hiding this comment.
I'm still not confident that the map is correct, but have to assume it is as the author is more fluent with the target architecture.
That's an accurate, though unfortunate observation. RetroAchievements/RAIntegration#1314 excludes blocks from the search results if the read function returns 0 bytes read. But rc_client will also disable achievements if the read returns 0 bytes and it's not part of a pointer chain. Lines 5884 to 5896 in e871ef5 Since the memory isn't pre-distributed we can't just switch read functions after the game loads (use one before load to return dummy data saying the addresses are valid and one after load returning no data for unallocated regions). As a result, the search space will immediately be 1.3GB (256MBx5), which is the problem the above PR was trying to address. I wonder if we should allow |
There are actually two separate read callbacks in the RPCS3 integration: read_memory for rc_client and readBlock for RAIntegration. So the two concerns can be handled independently. read_memory already returns zeroed bytes with num_bytes for lazy unallocated regions, so rc_client sees a valid read and achievements aren't invalidated. No sentinel needed. // vm::try_access reads PS3 virtual memory; returns false for uncommitted lazy pages } For the search space, the block reader currently zero-fills unconditionally, which bypasses #1314. Fixing it to return 0 for fully unallocated blocks will let #1314 handle that side naturally. |
Adds rc_memory_regions_playstation3 to consoleinfo.c. Depends on #535
Memory regions
RSX context (0x10000000–0x1FFFFFFF) is GPU DMA memory allocated by sys_rsx_context_allocate before any sys_memory_allocate call. It is fused with the first half of the user64K pool into a single region since they are physically contiguous and game state is not expected in RSX context space.
Address mapping
RA addresses are a 1:1 map to RPCS3 virtual addresses. The RPCS3 read_memory callback returns zeroed bytes for lazy regions that have not yet been allocated, preventing rcheevos from permanently disabling achievements that reference unallocated memory at game load time.
References
_find_mapscan from 0x10000000: https://github.com/RPCS3/rpcs3/blob/a0bebfa5c/rpcs3/Emu/Memory/vm.cpp#L1893Tests
All tests pass (
make HAVE_HASH=1intest/).