refactor(agc): share the PROCMAP_QUERY lookup with GuestMemory #3454

Merged
GustavoGamarra95 merged 2 commits from upstream-pr/3454 into main 2026-10-11 11:45:42 +00:00
GustavoGamarra95 commented 2026-10-11 10:55:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by GustavoGamarra95 on 2026-10-11T10:55:59Z.


What

Follow-up to #3227, as suggested in its review: GuestMemory.cpp carried its own procmap_query fallback and a ProcMapsQueryFd that duplicated HostMapping::QueryFd. Both opened /proc/self/maps once, probed PROCMAP_QUERY and honoured APS5_NO_PROCMAP_QUERY.

  • HostMapping.hpp's fallback, used when the kernel headers lack PROCMAP_QUERY, now also defines PROCMAP_QUERY_VMA_READABLE and PROCMAP_QUERY_VMA_WRITABLE, which GuestMemory.cpp reads from the query result.
  • GuestMemory.cpp includes HostMapping.hpp and calls HostMapping::QueryFd. Its copy of the struct, the constants and the probe goes away (2 lines added, 46 removed). The queries and the fallback scan are unchanged.

Overlap: #1330 touches the same lines of GuestMemory.cpp (the struct and the probe), and #1810 touches a neighbouring line in describePages. Whichever lands later needs a small rebase.

Tested

Arch Linux, kernel 7.2.9, GCC 16.2.1, Release with -DANYPS5_ENABLE_SPIRV_TOOLS=ON, on main 74981fab, RTX 3050 Laptop:

  • ctest -R "^agc_|guest_sysmodule|unwind|module_info": 383/383 passed.
  • The guest memory, write-watch, copy and import tests, plus guest_sysmodule, with APS5_NO_PROCMAP_QUERY=1: 26/26 passed.
  • check_test_registration.py and check_conventions.py pass.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4818540786 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3454). Originally posted by [GustavoGamarra95](https://github.com/GustavoGamarra95) on 2026-10-11T10:55:59Z. --- ### What Follow-up to #3227, as suggested in its review: `GuestMemory.cpp` carried its own `procmap_query` fallback and a `ProcMapsQueryFd` that duplicated `HostMapping::QueryFd`. Both opened `/proc/self/maps` once, probed `PROCMAP_QUERY` and honoured `APS5_NO_PROCMAP_QUERY`. - `HostMapping.hpp`'s fallback, used when the kernel headers lack `PROCMAP_QUERY`, now also defines `PROCMAP_QUERY_VMA_READABLE` and `PROCMAP_QUERY_VMA_WRITABLE`, which `GuestMemory.cpp` reads from the query result. - `GuestMemory.cpp` includes `HostMapping.hpp` and calls `HostMapping::QueryFd`. Its copy of the struct, the constants and the probe goes away (2 lines added, 46 removed). The queries and the fallback scan are unchanged. Overlap: #1330 touches the same lines of `GuestMemory.cpp` (the struct and the probe), and #1810 touches a neighbouring line in `describePages`. Whichever lands later needs a small rebase. ### Tested Arch Linux, kernel 7.2.9, GCC 16.2.1, Release with `-DANYPS5_ENABLE_SPIRV_TOOLS=ON`, on `main` 74981fab, RTX 3050 Laptop: - `ctest -R "^agc_|guest_sysmodule|unwind|module_info"`: 383/383 passed. - The guest memory, write-watch, copy and import tests, plus `guest_sysmodule`, with `APS5_NO_PROCMAP_QUERY=1`: 26/26 passed. - `check_test_registration.py` and `check_conventions.py` pass. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-11 11:00:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T11:00:42Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1810 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp L591-592
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108323761 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3454#issuecomment-6108323761). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T11:00:42Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1810 | `core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp` [L591-592](https://github.com/boykopovar/AnyPS5/blob/97fbc7e629e139749a16f1763a875dc7690880db/core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp#L591-L592) | | |
adriadam10 commented 2026-10-11 11:45:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:45:39Z.


Checked the diff: the removed procmap_query struct, constants and ProcMapsQueryFd are identical to HostMapping::QueryFd and the fallback in HostMapping.hpp (same probe, same APS5_NO_PROCMAP_QUERY switch, same queries). Built the AgcDriver and libc scopes and ran the guest memory, write-watch and sysmodule tests; all pass. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108678150 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3454#issuecomment-6108678150). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T11:45:39Z. --- Checked the diff: the removed `procmap_query` struct, constants and `ProcMapsQueryFd` are identical to `HostMapping::QueryFd` and the fallback in `HostMapping.hpp` (same probe, same `APS5_NO_PROCMAP_QUERY` switch, same queries). Built the AgcDriver and libc scopes and ran the guest memory, write-watch and sysmodule tests; all pass. Merging.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!3454
No description provided.