agc: keep the driver memory where macOS maps it (GTA V) #1454

Closed
github-bot wants to merge 2 commits from gh-pr/1454/head into gh-pr/1454/base
Owner

@⁠AN0DIN on GitHub · 2026-10-12 14:07 UTC · original
AN0DIN:pr/agc-macos-driver-base → main · +24 −6 · 2 files · 2 commits · closed without merging

Problem

On macOS, every title that initializes AGC now exits at boot. With GTA V (PPSA04263 01.010.002) on an Apple M5,
the log shows the driver block landing at out_addr = 0x0000007000000000, then:

Error: condition (reinterpret_cast<uint64_t>(address) != DriverDmemBase) is true in src/libs/agc.cpp

Since 165cd884 (agc: initialize function table in tracked driver memory), Gen5Driver::Initialize() maps the
driver block at the PS5 address DriverDmemBase (0x0fe0000000) and treats any other address as fatal. In the
macOS x86_64 guest layout, the system-reserved range ends at 0x0fbfffffff (HOST_SYSTEM_RESERVED_MAX in
memoryAddressSpace.inc), so the kernel cannot place the block there and returns the first free address of the user
area instead.

Change

  • On __APPLE__, Initialize() keeps the address the kernel returns (it only exits if the mapping returned no
    address), and builds the driver function table and its descriptor from that address instead of
    DriverDmemBase.
  • Other platforms keep the fixed address and the existing check: the base used there is the same value as before,
    since the check guarantees address == DriverDmemBase.

Note: #1399 changes the same function (it reserves the driver memory at startup) and keeps the fixed address, so
it does not cover this case; whichever lands second will need a small rebase.

Testing

  • macOS (Apple M5, x86_64 build under Rosetta 2, MoltenVK 1.4.2): build and ctest of this branch, 14/14 (the tests
    the macOS CI job runs).
  • In game, GTA V, boot only. On main the Apple GPU is rejected earlier at device selection, so both builds below
    are main plus #1083 (MoltenVK 1.4.x device features), one run each:
    • without this change: exits with the DriverDmemBase check above, driver block at 0x7000000000;
    • with this change: AGC initialization passes and the game reaches its first pipelines; it then stops on a
      separate, already known MoltenVK limitation (subgroup built-ins in vertex shaders), not related to this change.
    • With the other macOS fixes from my fork applied on top of this change, GTA V reaches the title screen, the menus
      and the Story mode prologue.
  • No unit test: the failure needs the guest kernel memory layout of a macOS host, which the existing tests do not set up.
  • Windows / Linux: not tested locally; the change only takes effect under __APPLE__.

AI assistance

An AI coding assistant (Claude Code) helped me find the cause, write the change and draft this description. I
reviewed the change and this text.

**@⁠AN0DIN** on GitHub · 2026-10-12 14:07 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1454) `AN0DIN:pr/agc-macos-driver-base` → `main` · +24 −6 · 2 files · 2 commits · closed without merging ### Problem On macOS, every title that initializes AGC now exits at boot. With GTA V (PPSA04263 01.010.002) on an Apple M5, the log shows the driver block landing at `out_addr = 0x0000007000000000`, then: Error: condition (reinterpret_cast<uint64_t>(address) != DriverDmemBase) is true in src/libs/agc.cpp Since 165cd884 (`agc: initialize function table in tracked driver memory`), `Gen5Driver::Initialize()` maps the driver block at the PS5 address `DriverDmemBase` (`0x0fe0000000`) and treats any other address as fatal. In the macOS x86_64 guest layout, the system-reserved range ends at `0x0fbfffffff` (`HOST_SYSTEM_RESERVED_MAX` in `memoryAddressSpace.inc`), so the kernel cannot place the block there and returns the first free address of the user area instead. ### Change - On `__APPLE__`, `Initialize()` keeps the address the kernel returns (it only exits if the mapping returned no address), and builds the driver function table and its descriptor from that address instead of `DriverDmemBase`. - Other platforms keep the fixed address and the existing check: the base used there is the same value as before, since the check guarantees `address == DriverDmemBase`. Note: #1399 changes the same function (it reserves the driver memory at startup) and keeps the fixed address, so it does not cover this case; whichever lands second will need a small rebase. ### Testing - macOS (Apple M5, x86_64 build under Rosetta 2, MoltenVK 1.4.2): build and ctest of this branch, 14/14 (the tests the macOS CI job runs). - In game, GTA V, boot only. On `main` the Apple GPU is rejected earlier at device selection, so both builds below are `main` plus #1083 (MoltenVK 1.4.x device features), one run each: - without this change: exits with the `DriverDmemBase` check above, driver block at `0x7000000000`; - with this change: AGC initialization passes and the game reaches its first pipelines; it then stops on a separate, already known MoltenVK limitation (subgroup built-ins in vertex shaders), not related to this change. - With the other macOS fixes from my fork applied on top of this change, GTA V reaches the title screen, the menus and the Story mode prologue. - No unit test: the failure needs the guest kernel memory layout of a macOS host, which the existing tests do not set up. - Windows / Linux: not tested locally; the change only takes effect under `__APPLE__`. ### AI assistance An AI coding assistant (Claude Code) helped me find the cause, write the change and draft this description. I reviewed the change and this text.
Since 165cd884 the AGC driver block is mapped at the PS5 address
0x0fe0000000 and anything else is fatal. On macOS x86_64 the guest
system-reserved range ends at 0x0fbfffffff, so the kernel places the
block in the user area (0x7000000000) and every AGC title exits at boot
(agc.cpp "address != DriverDmemBase"; seen with GTA V on Apple M5).

On macOS, accept the address the kernel returns and build the driver
function table from it; other platforms keep the fixed address.

Scope: macos
Co-Authored-By: Claude Opus 5.5 <[email protected]>
On macOS the driver block may no longer sit at 0x0fe0000000, so CheckAgcSystemTable now
looks the SceAgcDriver range up and reads the table from where it is mapped. Other platforms
still require the PS5 address.

Scope: macos
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:57:06 +00:00
github-bot closed this pull request 2026-11-26 09:57:06 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-12 14:18 UTC · original · edited 2026-10-17 08:10 UTC

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1c6322cc-a362-4481-b980-1e6cfc319414
📥 Commits

Reviewing files that changed from the base of the PR and between bde3b9fb71 and 2c355ae02f.

📒 Files selected for processing: 1
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

📝 Walkthrough

Gen5Driver::Initialize now accepts a non-null mapped address on macOS and uses it to calculate the DMEM table base. The AGC system table test discovers the SceAgcDriver mapping at runtime. Non-Apple platforms retain the fixed-address check.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 2c355

macOS can use the driver memory address selected by the kernel, while other platforms retain the fixed address. The test checks the discovered mapping and table layout; no concrete merge-blocking risk remains.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: preserving the driver memory address returned by macOS mapping for GTA V.
Description check Passed The description directly explains the macOS mapping failure, the platform-specific fix, testing results, and known limitations. It is fully related to the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 too large.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-12 14:18 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1454#issuecomment-6126127136) · edited 2026-10-17 08:10 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1454?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `1c6322cc-a362-4481-b980-1e6cfc319414` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between bde3b9fb71dbc316636f92da0bc8941358192385 and 2c355ae02f0303c9d0f5af1a1758957d060f3f01. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing: 1</strong></summary> <dl> <dd> * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> `Gen5Driver::Initialize` now accepts a non-null mapped address on macOS and uses it to calculate the DMEM table base. The AGC system table test discovers the `SceAgcDriver` mapping at runtime. Non-Apple platforms retain the fixed-address check. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"2c355ae02f0303c9d0f5af1a1758957d060f3f01" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>⚪ Minimal</strong> · up to <code>2c355</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `2c355` --> <!-- final_review_risk_coverage:{"sourceCommitId":"2c355ae02f0303c9d0f5af1a1758957d060f3f01","coveredCommitId":"2c355ae02f0303c9d0f5af1a1758957d060f3f01","kind":"reviewed"} --> macOS can use the driver memory address selected by the kernel, while other platforms retain the fixed address. The test checks the discovered mapping and table layout; no concrete merge-blocking risk remains. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-inconclusive-14-v2.svg" width="14" height="14" align="middle" alt="Inconclusive" title="Inconclusive"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 inconclusive</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :--------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Inconclusive](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-inconclusive.svg) | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 … | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: preserving the driver memory address returned by macOS mapping for GTA V. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the macOS mapping failure, the platform-specific fix, testing results, and known limitations. It is fully related to the changeset. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 too large.) **Resolution** Write docstrings for the functions missing them to satisfy the coverage threshold. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1454)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -4176,1 +4180,4 @@
EXIT_IF(address == nullptr);
#else
EXIT_IF(reinterpret_cast<uint64_t>(address) != DriverDmemBase);
#endif
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-12 14:18 UTC · original · edited 2026-10-17 08:06 UTC

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -eu
printf '%s\n' '--- test block ---'
nl -ba tests/ShaderRecompilerComputeTests.cpp | sed -n '42270,42345p'
printf '%s\n' '--- AGC mapping and table code ---'
nl -ba src/libs/agc.cpp | sed -n '4145,4210p'
printf '%s\n' '--- relevant test registration ---'
nl -ba CMakeLists.txt | sed -n '635,670p'
printf '%s\n' '--- macOS workflow selection ---'
nl -ba .github/workflows/build.yml | sed -n '195,220p'

Repository: KytyPS5/KytyPS5

Length of output: 12473


🏁 Script executed:

set -eu
printf '%s\n' '--- KernelVirtualQuery declarations and implementations ---'
rg -n -F --glob '*.{h,hpp,cpp,cxx}' -- 'KernelVirtualQuery' src tests include 2>/dev/null || true
printf '%s\n' '--- mapping address APIs and usages ---'
rg -n -F --glob '*.{h,hpp,cpp,cxx}' -- 'IsMapped(' src tests include 2>/dev/null || true
rg -n -F --glob '*.{h,hpp,cpp,cxx}' -- 'VirtualQueryInfo' src tests include 2>/dev/null || true
printf '%s\n' '--- AGC DMEM symbols and address consumers ---'
rg -n -F --glob '*.{h,hpp,cpp,cxx}' -- 'AgcDmemOffset' src tests include 2>/dev/null || true
rg -n -F --glob '*.{h,hpp,cpp,cxx}' -- 'DriverDmemBase' src tests include 2>/dev/null || true

Repository: KytyPS5/KytyPS5

Length of output: 7139


🏁 Script executed:

set -eu
printf '%s\n' '--- virtual query types ---'
nl -ba src/kernel/memory.h | sed -n '20,65p'
printf '%s\n' '--- direct-memory mapping implementation ---'
rg -n -F -- 'KernelMapNamedDirectMemory' src/kernel/memory.cpp src/kernel/memory.h
nl -ba src/kernel/memory.cpp | sed -n '3480,3715p'
printf '%s\n' '--- direct-memory test query helpers ---'
nl -ba tests/VirtualMemoryAllocationTests.cpp | sed -n '300,410p'

Repository: KytyPS5/KytyPS5

Length of output: 17146


🏁 Script executed:

set -eu
printf '%s\n' '--- VirtualRanges Query declaration and implementation ---'
rg -n -F -- 'Query(uint64_t' src
rg -n -F -- 'Query(' src/kernel | head -80
printf '%s\n' '--- flags=1 virtual-query callers ---'
rg -n -E -- 'KernelVirtualQuery\([^;]*,\s*1[),]' src tests || true
printf '%s\n' '--- mapping and range types ---'
rg -n -F -- 'class VirtualRanges' src/kernel
rg -n -F -- 'struct VirtualRanges' src/kernel

Repository: KytyPS5/KytyPS5

Length of output: 2884


🏁 Script executed:

set -eu
printf '%s\n' '--- VirtualRanges definition and Query ---'
nl -ba src/kernel/memory.cpp | sed -n '200,390p'
printf '%s\n' '--- flag-1 query caller ---'
nl -ba src/kernel/memory.cpp | sed -n '3260,3340p'

Repository: KytyPS5/KytyPS5

Length of output: 10123


🏁 Script executed:

set -eu
printf '%s\n' '--- direct-memory mapping path ---'
rg -n -F -- 'MapDirectMemory(' src/kernel/memory.cpp
rg -n -F -- 'FindGuestFreeRange' src/kernel/memory.cpp
nl -ba src/kernel/memory.cpp | sed -n '2460,2625p'
nl -ba src/kernel/memory.cpp | sed -n '3000,3275p'

Repository: KytyPS5/KytyPS5

Length of output: 20141


Derive the test base from the mapped SceAgcDriver range.

Gen5Driver::Initialize() can relocate the macOS mapping. CheckAgcSystemTable() still requires mapping.start == DriverDmemBase and reads the table at DriverDmemBase + 0x40000. The registered test can therefore fail on macOS before the descriptor checks. The macOS workflow builds this test but excludes it from its 14-test selection.

Find the SceAgcDriver range with KernelVirtualQuery(..., 1, ...), then derive driver_base and table_address from mapping.start.

Suggested fix
-  constexpr uint64_t driver_base = 0x0fe0000000ull;
-  constexpr uint64_t table_address = driver_base + 0x40000;
+  constexpr uint64_t driver_base_hint = 0x0fe0000000ull;
...
-  Libs::LibKernel::Memory::VirtualQueryInfo mapping{};
+  Libs::LibKernel::Memory::VirtualQueryInfo mapping{};
+  uint64_t query_address = driver_base_hint;
+  bool found_driver_mapping = false;
+  while (Libs::LibKernel::Memory::KernelVirtualQuery(
+             reinterpret_cast<void *>(query_address), 1, &mapping, sizeof(mapping)) == 0) {
+    if (std::strcmp(mapping.name, "SceAgcDriver") == 0) {
+      found_driver_mapping = true;
+      break;
+    }
+    if (mapping.end <= query_address) {
+      break;
+    }
+    query_address = mapping.end;
+  }
+  const auto driver_base = found_driver_mapping ? mapping.start : 0;
+  const auto table_address = driver_base + 0x40000;
   Require(name, "shared driver backing",
-          Libs::LibKernel::Memory::KernelVirtualQuery(reinterpret_cast<void *>(driver_base), 0,
-                                                 &mapping, sizeof(mapping)) == 0 &&
+          found_driver_mapping &&
               mapping.start == driver_base && mapping.end == driver_base + 0x200000 &&

✅ Addressed in commit 2c355ae

**@⁠coderabbitai[bot]** on GitHub · 2026-10-12 14:18 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1454#discussion_r4249047057) · edited 2026-10-17 08:06 UTC **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash set -eu printf '%s\n' '--- test block ---' nl -ba tests/ShaderRecompilerComputeTests.cpp | sed -n '42270,42345p' printf '%s\n' '--- AGC mapping and table code ---' nl -ba src/libs/agc.cpp | sed -n '4145,4210p' printf '%s\n' '--- relevant test registration ---' nl -ba CMakeLists.txt | sed -n '635,670p' printf '%s\n' '--- macOS workflow selection ---' nl -ba .github/workflows/build.yml | sed -n '195,220p' ``` Repository: KytyPS5/KytyPS5 Length of output: 12473 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- KernelVirtualQuery declarations and implementations ---' rg -n -F --glob '*.{h,hpp,cpp,cxx}' -- 'KernelVirtualQuery' src tests include 2>/dev/null || true printf '%s\n' '--- mapping address APIs and usages ---' rg -n -F --glob '*.{h,hpp,cpp,cxx}' -- 'IsMapped(' src tests include 2>/dev/null || true rg -n -F --glob '*.{h,hpp,cpp,cxx}' -- 'VirtualQueryInfo' src tests include 2>/dev/null || true printf '%s\n' '--- AGC DMEM symbols and address consumers ---' rg -n -F --glob '*.{h,hpp,cpp,cxx}' -- 'AgcDmemOffset' src tests include 2>/dev/null || true rg -n -F --glob '*.{h,hpp,cpp,cxx}' -- 'DriverDmemBase' src tests include 2>/dev/null || true ``` Repository: KytyPS5/KytyPS5 Length of output: 7139 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- virtual query types ---' nl -ba src/kernel/memory.h | sed -n '20,65p' printf '%s\n' '--- direct-memory mapping implementation ---' rg -n -F -- 'KernelMapNamedDirectMemory' src/kernel/memory.cpp src/kernel/memory.h nl -ba src/kernel/memory.cpp | sed -n '3480,3715p' printf '%s\n' '--- direct-memory test query helpers ---' nl -ba tests/VirtualMemoryAllocationTests.cpp | sed -n '300,410p' ``` Repository: KytyPS5/KytyPS5 Length of output: 17146 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- VirtualRanges Query declaration and implementation ---' rg -n -F -- 'Query(uint64_t' src rg -n -F -- 'Query(' src/kernel | head -80 printf '%s\n' '--- flags=1 virtual-query callers ---' rg -n -E -- 'KernelVirtualQuery\([^;]*,\s*1[),]' src tests || true printf '%s\n' '--- mapping and range types ---' rg -n -F -- 'class VirtualRanges' src/kernel rg -n -F -- 'struct VirtualRanges' src/kernel ``` Repository: KytyPS5/KytyPS5 Length of output: 2884 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- VirtualRanges definition and Query ---' nl -ba src/kernel/memory.cpp | sed -n '200,390p' printf '%s\n' '--- flag-1 query caller ---' nl -ba src/kernel/memory.cpp | sed -n '3260,3340p' ``` Repository: KytyPS5/KytyPS5 Length of output: 10123 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- direct-memory mapping path ---' rg -n -F -- 'MapDirectMemory(' src/kernel/memory.cpp rg -n -F -- 'FindGuestFreeRange' src/kernel/memory.cpp nl -ba src/kernel/memory.cpp | sed -n '2460,2625p' nl -ba src/kernel/memory.cpp | sed -n '3000,3275p' ``` Repository: KytyPS5/KytyPS5 Length of output: 20141 --- </details> **Derive the test base from the mapped `SceAgcDriver` range.** `Gen5Driver::Initialize()` can relocate the macOS mapping. `CheckAgcSystemTable()` still requires `mapping.start == DriverDmemBase` and reads the table at `DriverDmemBase + 0x40000`. The registered test can therefore fail on macOS before the descriptor checks. The macOS workflow builds this test but excludes it from its 14-test selection. Find the `SceAgcDriver` range with `KernelVirtualQuery(..., 1, ...)`, then derive `driver_base` and `table_address` from `mapping.start`. <details> <summary>Suggested fix</summary> ```diff - constexpr uint64_t driver_base = 0x0fe0000000ull; - constexpr uint64_t table_address = driver_base + 0x40000; + constexpr uint64_t driver_base_hint = 0x0fe0000000ull; ... - Libs::LibKernel::Memory::VirtualQueryInfo mapping{}; + Libs::LibKernel::Memory::VirtualQueryInfo mapping{}; + uint64_t query_address = driver_base_hint; + bool found_driver_mapping = false; + while (Libs::LibKernel::Memory::KernelVirtualQuery( + reinterpret_cast<void *>(query_address), 1, &mapping, sizeof(mapping)) == 0) { + if (std::strcmp(mapping.name, "SceAgcDriver") == 0) { + found_driver_mapping = true; + break; + } + if (mapping.end <= query_address) { + break; + } + query_address = mapping.end; + } + const auto driver_base = found_driver_mapping ? mapping.start : 0; + const auto table_address = driver_base + 0x40000; Require(name, "shared driver backing", - Libs::LibKernel::Memory::KernelVirtualQuery(reinterpret_cast<void *>(driver_base), 0, - &mapping, sizeof(mapping)) == 0 && + found_driver_mapping && mapping.start == driver_base && mapping.end == driver_base + 0x200000 && ``` </details> <!-- fingerprinting:phantom:medusa:serval --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:d27faa65376a650c8d5a68fb --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit 2c355ae
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-12 14:18 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d964e97b-5624-4952-81d6-04040d027cdc
📥 Commits

Reviewing files that changed from the base of the PR and between df5b9b92be and bde3b9fb71.

📒 Files selected for processing (1)
  • src/libs/agc.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-12 14:18 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1454#pullrequestreview-5492055733) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `d964e97b-5624-4952-81d6-04040d027cdc` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between df5b9b92be7dfd463b47756b707d6d356a9f0550 and bde3b9fb71dbc316636f92da0bc8941358192385. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/libs/agc.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=91934b9e-d7f2-4e91-be58-028a37bc08ed attempt=09630732-900d-4fd5-a27b-69f3c61df11f batch=1/1 -->
Author
Owner

@⁠AN0DIN on GitHub · 2026-10-17 08:06 UTC · original

Pushed 2c355ae for the CodeRabbit note: CheckAgcSystemTable no longer assumes 0x0fe0000000. It looks up the
SceAgcDriver range by name and reads the table from wherever it is mapped. Other platforms still require the
PS5 address.

Tested on macOS (Apple M5, Rosetta 2, MoltenVK 1.4.2): build OK, ctest 14/14 (the macOS CI selection), and the
test compiles. I could not run it: the Vulkan harness needs 64-bit buffer/shared atomics, which MoltenVK does not
expose, and CI builds shader_recompiler_compute_tests but does not run it. A local run on Windows or Linux would
confirm it.

**@⁠AN0DIN** on GitHub · 2026-10-17 08:06 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1454#issuecomment-6231540270) Pushed 2c355ae for the CodeRabbit note: `CheckAgcSystemTable` no longer assumes 0x0fe0000000. It looks up the `SceAgcDriver` range by name and reads the table from wherever it is mapped. Other platforms still require the PS5 address. Tested on macOS (Apple M5, Rosetta 2, MoltenVK 1.4.2): build OK, ctest 14/14 (the macOS CI selection), and the test compiles. I could not run it: the Vulkan harness needs 64-bit buffer/shared atomics, which MoltenVK does not expose, and CI builds `shader_recompiler_compute_tests` but does not run it. A local run on Windows or Linux would confirm it.
Author
Owner

@⁠Nmzik on GitHub · 2026-10-21 19:42 UTC · original

Duplicate of #1682.

**@⁠Nmzik** on GitHub · 2026-10-21 19:42 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1454#issuecomment-6324942585) Duplicate of #1682.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.