Skip to content

fix(libkernel): return EBADF from sceKernelAddAmprEvent for an equeue that is not live - #15884

Merged
oneandonlydean merged 7 commits into
boykopovar:mainfrom
zaryabzip:fix/kernel-ampr-event-bad-queue
Nov 7, 2026
Merged

oneandonlydean merged 7 commits into
boykopovar:mainfrom
zaryabzip:fix/kernel-ampr-event-bad-queue

Conversation

@zaryabzip

@zaryabzip zaryabzip commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What

sceKernelAddAmprEvent now returns EBADF (0x80020009) for an equeue that is not live, a null one included, as obSCEne's census measured. It ran in its own title (PPSA90000) on a PS5 with system software 12.40. The census logs the call by NID (bBfz7kMF2Ho, logged as 0x7ad80543eef3176c).

Equeue Console main
a stack address, not a live equeue 0x80020009 0
null 0x80020009 0

The same results came back in that log's sibling runs, report-20261013-184500.log and report-20261014-004800.log.

main returned 0 early for a null equeue. For any other equeue it dropped the EBADF that its own EqueueAddEvent_nid_postfix returns when the queue can't be pinned. Now the function returns that result, as sceKernelAddTimerEvent already does (guest_equeue_events checks sceKernelAddTimerEvent(0, …) == EBADF).

sceKernelAddAmprSystemEvent forwards to it, so it returns the same. That one wasn't probed, and the new debt entry says so.

Test. guest_equeue_events's Ampr case now also adds an event to the equeue it just deleted, and to a null equeue, expecting EBADF for both. The existing rows on live equeues keep returning 0, in this file and in GuestAmpr.cpp. On main the test fails at the deleted-equeue row.

Overlap: git merge-tree merges this cleanly with main and with the other open pull requests that touch these three files and merge with main. kallmek3nny's #14894, which rewrote the "kevent measurements" debt line right next to this PR's entry, merged on 11-07; ba04cfa234 merges main with it. The debt entry sits apart from the read-event entries that #10645 edits.

Tested

  • WSL2 and Windows, by me at de5d55a92f (comment):
    • WSL2: Ubuntu 24.04.5, GCC 13.3.0, Release, merged onto main 1e24993fa3. guest_equeue_events and the four guest_ampr_* tests pass.
    • Windows: Windows 11 Home 25H2, WinLibs GCC 15.2.0 r7, Release, the same merge. The same 5 tests pass.
    • --repeat until-fail:3 passes every round on both.
    • With Equeue.cpp from main, guest_equeue_events aborts on both: sceKernelAddAmprEvent on the deleted equeue returns 0.

Checked so far, on macOS (arm64, where no full build is possible):

  • Both changed files pass an x86-64 clang++ -fsyntax-only.
  • tools/check_conventions.py --base main passes.

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 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 (Claude Code)

… that is not live

obSCEne's PS5 run (system software 12.40) returned 0x80020009 for a null
equeue and for one that is not live; the host returned 0 for both,
dropping the EBADF its own add already reported.
@JJenkx

JJenkx commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Windows check of head de5d55a92f, merged onto main c3a5290c7d (b592c8ad93, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run this test on pull requests.

  • guest_equeue_events passes in 3 of 3 runs.

AI-assisted: yes.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head de5d55a merged onto main b611e63 · tested 2026-11-04 22:36 UTC · 18 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 3,030 passed · 8 failed (0 new, 7 also fail on main, 1 unstable on main) · 59 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 3,097 of 3,946 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (1074 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 121.1 s, ⚠️ agc_driver_graphics_maps_fallback 92.3 s, ⚠️ agc_driver_image_sample_unnormalized 68.5 s, ⚠️ agc_driver_lazy_resolved_abi 62.5 s, ⚠️ agc_driver_sdwa_move_selectors 43.7 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 9 of the last 10 main runs
Failing on main too (7, not counted against this PR)
agc_driver_image_gather_volume
agc_driver_image_table
agc_driver_native_depth_bda_clear
agc_driver_native_multisample_depth
agc_driver_submit_progress
agc_submit_progress
agc_submit_progress_no_timeline
Passed on retry (1, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)
agc_driver_sgpr_pattern_fill_keys: Failed in the parallel run; also passed only on retry in 7 other runs in the last 7 days
Validation IDs already present on main (4 IDs in 624 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (624 tests): agc_driver, agc_driver_address_draw_space_reuse, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, and 616 more
VUID-vkCmdCopyImage-srcImage-01548 (4 tests): agc_driver_depth_clear_hle, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (4 tests): agc_driver_depth_clear_hle, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
Skipped (59)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_gcn_display_present: skipped, no display: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
agc_driver_image_table_vouched_lookups: skipped, the device reports 4 of 4 host-imported pages written after a GPU read, so a watched imported table cannot be vouched for
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_driver_unit_shadow_budget: skipped, the device does not import watched host memory for unit shadows
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_idle_publish_wait: skipped, the device reports 4 of 4 host-imported pages written after a GPU read, so a forced watch of the import reads its submissions as CPU stores
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_shadowed_key_stores: skipped, the device imports no watched host memory under a unit shadow
agc_small_tiled_shadow_label: skipped, host imports are unavailable: the test block is not imported and watched
agc_storage_clear_hand_over: skipped, the device imports no watched host memory for the clear-key hand-over
agc_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip
Reproduce
git fetch origin de5d55a92f1dd377c0f28607c1764e4f1b7d6506 b611e634f7fc024f0c13e342d96de744448ef1d9
git checkout b611e634f7fc024f0c13e342d96de744448ef1d9 && git merge --no-ff de5d55a92f1dd377c0f28607c1764e4f1b7d6506
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 12 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 16 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@zaryabzip

Copy link
Copy Markdown
Contributor Author

Windows and WSL2 run at de5d55a92f, with the negative control. Both builds test the same merge onto main 1e24993fa3.

  • WSL2, Ubuntu 24.04.5 (kernel 6.18.54.1), GCC 13.3.0, Release:
    • Merged onto main 1e24993fa3, a clean merge.
    • ctest -R "guest_equeue_events|guest_ampr" runs 5 tests: guest_equeue_events and guest_ampr_div_and_buffer_size, _markers, _threads and _cpp_error.
    • All 5 pass, in each of the 3 rounds of --repeat until-fail:3 as well.
  • Windows 11 Home 25H2 (26200.9711), WinLibs GCC 15.2.0 r7 UCRT, Release:
    • The same merge onto 1e24993fa3 (the same tree).
    • The same 5 tests pass, in each of the 3 rounds as well.
  • Neither build has warnings in Equeue.cpp or GuestEqueueEvents.cpp.
  • Control (Equeue.cpp from main, this PR's test kept): guest_equeue_events aborts on both. The exit is 0xC0000409 on Windows and SIGABRT on Linux.
    • The failing check prints nothing, so on WSL2 I added a printout before that row (a local change, not part of the PR): main returns 0 from sceKernelAddAmprEvent(eq, 3, &udata) after sceKernelDeleteEqueue(eq), where the test expects SCE_KERNEL_ERROR_EBADF.

AI-assisted: yes (Claude Code)

…kernel-ampr-event-bad-queue

# Conflicts:
#	docs/dev/debt/libkernel.md
…kernel-ampr-event-bad-queue

# Conflicts:
#	docs/dev/debt/libkernel.md
…kernel-ampr-event-bad-queue

# Conflicts:
#	docs/dev/debt/libkernel.md
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

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 5021 docs/dev/debt/libkernel.md
PR 6149 docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 7088 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7135 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7447 docs/dev/debt/libkernel.md
PR 7464 docs/dev/debt/libkernel.md
PR 7492 core/libs/prx/libkernel/Equeue/Equeue.cpp
core/libs/tests/GuestEqueueEvents.cpp
PR 7804 docs/dev/debt/libkernel.md
PR 9156 docs/dev/debt/libkernel.md
PR 9199 docs/dev/debt/libkernel.md
PR 9293 core/libs/prx/libkernel/Equeue/Equeue.cpp
docs/dev/debt/libkernel.md
PR 9297 core/libs/prx/libkernel/Equeue/Equeue.cpp
docs/dev/debt/libkernel.md
PR 9302 core/libs/prx/libkernel/Equeue/Equeue.cpp
docs/dev/debt/libkernel.md
PR 9389 docs/dev/debt/libkernel.md
PR 9557 docs/dev/debt/libkernel.md
PR 9566 docs/dev/debt/libkernel.md
PR 9938 docs/dev/debt/libkernel.md
PR 10442 docs/dev/debt/libkernel.md
PR 11625 docs/dev/debt/libkernel.md
PR 11896 docs/dev/debt/libkernel.md
PR 12170 docs/dev/debt/libkernel.md
PR 12688 docs/dev/debt/libkernel.md
PR 12700 docs/dev/debt/libkernel.md
PR 12965 docs/dev/debt/libkernel.md
PR 14108 docs/dev/debt/libkernel.md
PR 14128 docs/dev/debt/libkernel.md
PR 14212 docs/dev/debt/libkernel.md
PR 14497 docs/dev/debt/libkernel.md
PR 14756 docs/dev/debt/libkernel.md
PR 15037 docs/dev/debt/libkernel.md
PR 15524 docs/dev/debt/libkernel.md
PR 15567 docs/dev/debt/libkernel.md
PR 15785 docs/dev/debt/libkernel.md
PR 16463 docs/dev/debt/libkernel.md

…kernel-ampr-event-bad-queue

# Conflicts:
#	docs/dev/debt/libkernel.md
@oneandonlydean oneandonlydean self-assigned this Nov 7, 2026
@oneandonlydean
oneandonlydean merged commit 9e47f0c into boykopovar:main Nov 7, 2026
13 of 14 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.

4 participants