Skip to content

test(libScePad): pin special-port zeroing in scePadGetExtControllerInformation - #21765

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
mrvlajnic:fix/libScePad-getExtControllerInformation-copyout
Nov 24, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
mrvlajnic:fix/libScePad-getExtControllerInformation-copyout

Conversation

@mrvlajnic

@mrvlajnic mrvlajnic commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What

Test-only change; the Export.cpp rename/restructure and the direct docs/dev/debt/libScePad.md edit from earlier revisions are dropped.

main already zeroes the special-port output through a checked GuestCopyOut_nid_no_patch of a 0x2c block, restores errno and returns PAD_ERROR_INVALID_ARG for an unwritable pointer, so this PR pins that behaviour in CheckExtControllerInformation (core/libs/tests/GuestPad.cpp):

  • opens special port 0x20000099, fills the 0x2c-byte output with 0x5a, and checks that a successful call zeroes exactly the first 0x2c bytes and leaves the tail untouched;
  • checks that 0x10 as the output pointer returns PAD_ERROR_INVALID_ARG and leaves errno at 71;
  • closes the port.

No implementation file changes; the debt files are untouched (a test-only PR makes no behavioural claim, and entries are edited only through fragments).

Tested

  • Rebased onto main 851212fb98; the whole diff is 10 added lines in core/libs/tests/GuestPad.cpp, and python tools/check_conventions.py --base origin/main --head HEAD passes.
  • The same test code ran green at the previous head cf3031bd85: @maskym reported guest_pad 3/3 on Windows 11 (i7-12700K, WinLibs GCC 15.2.0), @ycbuzi's full-suite runs passed on Windows Server 2022/2025, and @kiwe147 built it in a 30-PR batch on Windows 11.
  • Not rebuilt locally after the rebase: this machine's MSYS2 GCC 16.2.0 is missing libexec/gcc/.../cc1plus.exe, so no C++ compilation can run here. The added lines are byte-identical to the ones those runs exercised.
  • Not run on a PS5; the test pins host behaviour, and its assertions hold on unmodified main by construction (the negative control @PrivacyOnion ran is the same observation).

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed docs prx labels Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

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
PR 21127 core/libs/tests/GuestPad.cpp L440-441

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 13589 core/libs/tests/GuestPad.cpp

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@mrvlajnic two things before this can be reviewed. The Conventions check fails on the description: the ### What section is empty, AI-assisted is not answered yes or no, and Depends on needs #N or none. Please fill those from the template. The branch also conflicts with main in core/libs/prx/libScePad/Export.cpp, so it needs a rebase onto current main.

The change itself, a checked GuestCopyOut of the 0x2c zero block for scePadGetExtControllerInformation with errno kept and PAD_ERROR_INVALID_ARG for an unwritable pointer, is the same shape as the other pad fixes; I will review it once it builds.

@mrvlajnic
mrvlajnic force-pushed the fix/libScePad-getExtControllerInformation-copyout branch from 5370b8a to fad4cd0 Compare November 16, 2026 20:08

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against fad4cd08fe:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_pad_tests built cleanly.
  • CTest (guest_pad):
    1/1 Test #4620: guest_pad ........................   Passed    5.50 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: the tests still pass with the change reverted, so they do not cover it

Requesting changes for the points above.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 16, 2026
@maskym

maskym commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Windows result for head fad4cd08fe, merged alone into main 56c87adbdc (the PR's Tested section names no Windows run).

Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, BUILD_TESTING=ON, Ninja. main itself fails to compile one test on Windows at this commit (UploadCacheReadOnlyFlush.cpp:177, setenv; #19899 fixes it), so the tree was built with ninja -k 0. Microsoft Defender on this machine quarantines 34 AGC test executables as Trojan:Win64/ShellCode.MKA!MTB when they are linked (the case docs/dev/BUILD.md describes), so their objcopy step fails on both trees and those tests do not run here. This PR adds no other build failure.

guest_pad, the test this PR adds or extends, passes 3 of 3 runs. Not run on a PS5.

AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine.

@mrvlajnic
mrvlajnic force-pushed the fix/libScePad-getExtControllerInformation-copyout branch from fad4cd0 to cf3031b Compare November 18, 2026 09:15

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against cf3031bd85:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_pad_tests built cleanly.
  • CTest (guest_pad):
    1/1 Test #4814: guest_pad ........................   Passed    4.95 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: the tests still pass with the change reverted, so they do not cover it

Requesting changes for the points above.

@ycbuzi

ycbuzi commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Tested cf3031bd85 merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Windows Server 2022 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 99% tests passed, 3 tests failed out of 6204; 99% tests passed, 3 tests failed out of 6204. 3 of the failing tests fail on main too. run
  • Windows Server 2025 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 100% tests passed, 0 tests failed out of 6204; 100% tests passed, 0 tests failed out of 6204. run

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@maskym

maskym commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Retested head cf3031bd85 on Windows (the head moved since my earlier run), merged alone into main 168921678f.

Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, BUILD_TESTING=ON, Ninja. main itself fails to compile one test on Windows at this commit (UploadCacheReadOnlyFlush.cpp:177, setenv; #19899 fixes it), so the tree was built with ninja -k 0. This PR adds no other build failure.

guest_pad, the test this PR adds or extends, passes 3 of 3 runs. Not run on a PS5.

AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

I read the diff against main. In Export.cpp the change only renames zeroed to zero and restructures the return. Main already does a checked 0x2c GuestCopyOut of zeros, keeps errno, and returns INVALID_ARG on failure, so behaviour is identical and there is no game effect. The new tests pass with the change reverted (PrivacyOnion's negative control), and the body says "Tested: Not tested" while adding tests. Please drop the Export.cpp rename and restructure; the special-port test can stay if you want it as a pin of the existing behaviour, with the Tested line corrected. PR 5038 also touches libScePad Export.cpp and the debt doc, so please check it for overlap.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The change is sound at head cf3031bd8566bd22c1dd85bc5fd294248130e2cb; no checks were run, and the changed implementation, test, and documentation were read.

What I ran

No commands or tests were run. The PR description reports that it was not tested.

Results

Check Result Note
Code review passed All three changed files read
Tests not run No runtime behavior exercised

Findings

Blocking

None.

Non-blocking

None.

Sources

The special-handle path copies 0x2c zero bytes with GuestCopyOut_nid_no_patch, restores errno, and returns PAD_ERROR_INVALID_ARG if copying fails (core/libs/prx/libScePad/Export.cpp:291-296). The added test checks zeroing, preservation of trailing bytes, unwritable-pointer handling, and errno preservation (core/libs/tests/GuestPad.cpp:248-257).

Not verified

No tests or builds were run, and physical-console behavior was not verified. The prepared manifest lists three changed files, all included; each was read. No excluded files were provided for review.

To get this to a good state

Nothing is required.

@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head cf3031bd85, applied with git apply on main fd4aeed483 together with the other 29 PRs of one batch (#24576, #24603, #14196, #14527, #17718, #18671, #22753, #22792, #23503, #24245, #24480, #24553, #24714, #21236, #21987, #22030, #22107, #22397, #22571, #23158, #23816, #24067, #18401, #19101, #19398, #19657, #21563, #24584, #24628). All applied without conflicts and the whole tree built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. GPUs: NVIDIA GeForce RTX 3080 (driver 621.24) and the AMD Radeon iGPU of the CPU (gfx1036, driver 32.0.21036.18). No validation layer. iGPU run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="AMD Radeon", agc_/video tests only.

tests RTX 3080 iGPU
guest_pad, guest_pad_angular_velocity_deadband, guest_pad_angular_velocity_deadband_integration and 19 more (22 tests, matched by name to the test file this PR changes) all pass outside the iGPU subset

Whole batch: the full ctest -j 12 (6523 tests) on the RTX 3080 has 7 failing tests; the 4 that also fail on main fd4aeed483 are agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch, agc_storage_write_back_host_retile, and pr_overlap_names, which needs a newer Python than my 3.10. Intermittent in this run (pass when rerun alone, or known flaky): agc_driver_store_over_untracked, agc_driver_store_over_untracked, agc_storage_write_back_host_retile. Traced to other PRs of the batch, each by reverting it and testing again: #19101 (guest_video_out_window_margins_bounds); none is in this PR's area. Failing tests I could not trace to a single PR (reverting the likely candidates did not clear them): agc_driver_image_gather_lod. The 2125 agc_/video tests on the iGPU have 5 failing: agc_driver_image_gather_lod, agc_driver_stencil_plane_memory, agc_driver_store_over_untracked, agc_storage_write_back_host_retile, guest_video_out_window_margins_bounds (agc_driver_stencil_plane_memory also fails on main).

This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

@mrvlajnic
mrvlajnic force-pushed the fix/libScePad-getExtControllerInformation-copyout branch from cf3031b to 584cbec Compare November 22, 2026 00:08
@mrvlajnic mrvlajnic changed the title fix(libScePad): safely zero output in scePadGetExtControllerInformation test(libScePad): pin special-port zeroing in scePadGetExtControllerInformation Nov 22, 2026
@mrvlajnic

Copy link
Copy Markdown
Contributor Author

Reworked as a test-only PR at 584cbecc5c, rebased onto main 851212fb98:

  • Dropped the Export.cpp rename/restructure. main already does the checked GuestCopyOut_nid_no_patch of the 0x2c zero block, restores errno and returns PAD_ERROR_INVALID_ARG, so there was nothing to change.
  • Dropped the direct docs/dev/debt/libScePad.md edit; debt entries go through docs/dev/debt/changes/ fragments, and a test-only PR makes no behavioural claim to record.
  • Kept the special-port test as a pin of the existing behaviour: 10 added lines in CheckExtControllerInformation (core/libs/tests/GuestPad.cpp) covering the 0x2c zeroing, untouched tail, and the 0x10 unwritable case with errno preserved.
  • Corrected the Tested section: it now names the runs that exercised this exact test at cf3031bd85 (@maskym 3/3 guest_pad on Windows, @ycbuzi's full-suite runs, @kiwe147's 30-PR batch build) and states that I could not rebuild locally because this machine's MSYS2 GCC 16.2.0 is missing cc1plus.
  • Retitled fix(libScePad): ... to test(libScePad): pin special-port zeroing in scePadGetExtControllerInformation, since the PR no longer changes the implementation.

Overlap check: #5038 changes VR functions and a different debt entry, and #16288 adds a touchpad test earlier in the same file; neither touches scePadGetExtControllerInformation nor this test region, so nothing to rebase around.

Thanks to @PrivacyOnion for the negative control — it is now the point of the PR rather than a contradiction: the test pins what main already does.

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 584cbecc5c:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_pad_tests built cleanly.
  • CTest (guest_pad):
    1/1 Test #5201: guest_pad ........................   Passed    4.85 sec
    100% tests passed, 0 tests failed out of 1
    
  • Code reading:
    • Verified core/libs/tests/GuestPad.cpp:442-451 opens PAD_PORT_TYPE_SPECIAL (0x20000099), checks handle validity with Require(special > 0), and ensures cleanup with scePadClose_nid_postfix(special).
    • Verified 0x2c zero-fill assertion and verified that trailing bytes ([0x2c, extended.size()) remain untouched at sentinel value 0x5a in extended buffer.
    • Verified error-handling and errno preservation when passing unwritable guest pointer 0x10, returning PAD_ERROR_INVALID_ARG and preserving errno == 71.
    • Verified AGENTS.md compliance: no comments added, no debt file modifications needed for test-only PR, conventions gate passed.

Looks Good To Me

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The added test assertions match the implementation and existing coverage for special-port output zeroing and invalid guest pointers; no blocking defect was identified.

What I ran

Reviewed head 584cbecc5c4554bf4fc131375af3ed9aace0ef06; no commands or tests were run.

Results

Check Result Note
Diff and targeted code review passed One changed test file
Build and test execution not run No local execution performed

Findings

Blocking

None.

Non-blocking

None.

Not verified

The build, test suite, and platform-specific behavior were not verified. Read core/libs/tests/GuestPad.cpp, core/libs/prx/libScePad/Export.cpp, core/libs/tests/GuestPadControllerInfoCapabilitiesBounds.cpp, and core/libs/tests/GuestPadQueryGuestPointers.cpp. The bundle lists only core/libs/tests/GuestPad.cpp as reviewed; it was included in manifest.json. No excluded changed files were listed.

To get this to a good state

Nothing is required.

@oneandonlydean
oneandonlydean merged commit 8ce9a10 into boykopovar:main Nov 24, 2026
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants