Skip to content

fix(libkernel): lay out user contexts as the console's getcontext writes them - #15794

Merged
oneandonlydean merged 7 commits into
boykopovar:mainfrom
root-over:fix/libkernel-console-ucontext-layout
Nov 7, 2026
Merged

oneandonlydean merged 7 commits into
boykopovar:mainfrom
root-over:fix/libkernel-console-ucontext-layout

Conversation

@root-over

Copy link
Copy Markdown
Contributor

What

Two catalog Xbox 360 ports by the same author, Naruto: Rise of a Ninja (PPSA99680) and Forza Horizon (PPSA99690), crash about 2 s after start on main with a jump to 0xa3/0xad.

Both build their fibers without makecontext (port patch, Fiber::Create):

  1. They call getcontext into a 2 KiB buffer.
  2. They store the entry stack at offset 0xf8, 0 at 0x88 and the entry function at 0xe0.
  3. They switch with swapcontext.

The same patch records what firmware 9.00 does: "getcontext reports mc_len=1152 and writes 1216 bytes".

That is the layout AnyPS5's exception path already uses (GuestUcontext in Exception.cpp): mcontext at 0x40, mc_rip at 0xe0, mc_rsp at 0xf8, sizeof(GuestMcontext) 0x480 (1152), uc_link at 0x4c0 (1216). getcontext, setcontext, swapcontext and makecontext instead used FreeBSD 11's layout: mcontext at 0x10, 800 bytes, mc_rip at 0xb0. So swapcontext resumed the fiber at getcontext's old return address, on a stack frame that had already returned. That frame's saved r13 had since been overwritten by a return address, and the next call *%r13 crashed. I traced it with gdb, single-stepping from the last pthread_mutex_unlock to the crash: getcontext at 0x4abf7d, swapcontext from 0x12a5e9a, then a second return at 0x4abf82.

Four commits:

  1. fix: UserMcontext and UserUcontext take the console layout:

    • lbrfrom, lbrto, aux1 and aux2 after mc_ownedfp;
    • an 832-byte mc_fpstate at mcontext + 0x100, still holding the 512-byte FXSAVE image at its start;
    • fsbase, gsbase, spare[6];
    • uc_link at 0x4c0.

    guest_user_context checks the new fields in place of mc_xfpustate.

  2. refactor: Exception.cpp uses UserMcontext/UserUcontext through aliases instead of its own copy of the same layout. No behaviour change.

  3. test: guest_user_context sets up a fiber the way the ports do, with raw offsets 0xf8/0x88/0xe0, and switches into it and back three times. It checks mc_len 1152 at 0x108 and that nothing is written from 0x4c0 on.

  4. docs: the debt entry gives the layout and its source, and keeps uc_stack at 0x4c8 (FreeBSD's order after uc_link) as not measured.

The previous layout came from the sizes PPSA99039 (EVO Player)'s OpenSSL ASYNC passes. EVO Player makes no getcontext/makecontext/swapcontext/setcontext call in its first 45 s (gdb breakpoints on all four), and still runs.

Tested

Ubuntu, kernel 7.0, GCC 15.2.0, Release.

Title main this PR
PPSA99680 Naruto: Rise of a Ninja SIGSEGV at 0xa3 after 2 s logs native fiber round-trip check: passed, then looks for /app0/game/naruto.module and exits 0 (no game data here)
PPSA99690 Forza Horizon SIGSEGV at 0xad after 2 s logs native fiber round-trip check: passed, then exits 0 the same way
PPSA99039 EVO Player alive at 30 s alive at 30 s

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: PPSA99680 and PPSA99690, no Game bring-up discussion yet (both get past their fiber self-check instead of crashing at start)
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line libkernel docs labels Nov 4, 2026
@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head d7d38c7 merged onto main b11c7bf · tested 2026-11-04 16:54 UTC · 27 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,769 passed · 14 failed (0 new, 12 also fail on main, 2 unstable on main) · 62 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,845 of 3,894 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 (1384 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.2 s, ⚠️ agc_driver_graphics_maps_fallback 119.3 s, ⚠️ agc_driver_graphics 108.0 s, ⚠️ public_headers 74.0 s, ⚠️ agc_driver_image_sample_unnormalized 46.0 s
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 8 of the last 10 main runs
agc_driver_two_sample_alpha_to_coverage_sample_mask_export: failed in 3 of the last 10 main runs
Failing on main too (12, not counted against this PR)
agc_driver_alpha_to_coverage_sample_mask_export
agc_driver_guest_memory_lifetime_direct
agc_driver_image_table
agc_driver_native_depth_bda_clear
agc_driver_native_depth_buffer_clear
agc_driver_native_depth_clears
agc_driver_native_multisample_depth
agc_driver_submit_progress
agc_submit_progress
agc_submit_progress_no_timeline
guest_mmap_executable
guest_socket_options_multicast
Validation IDs already present on main (8 IDs in 802 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (802 tests): agc_compute_pipeline_replay, agc_driver, agc_driver_address_draw_space_reuse, agc_driver_address_draw_space_reuse_held, agc_driver_address_draw_space_reuse_off, agc_driver_address_draw_space_reuse_transitions, agc_driver_address_draw_space_reuse_verify, agc_driver_address_passes, and 794 more
VUID-vkCmdCopyImage-srcImage-01548 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store_image_copy, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_partially_unmapped_plane, agc_driver_depth_plane_unmapped_plane, and 3 more
VUID-vkCmdCopyImage-srcImage-01551 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store_image_copy, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_partially_unmapped_plane, agc_driver_depth_plane_unmapped_plane, and 3 more
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
VUID-VkSamplerCreateInfo-addressModeU-01079 (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeU-parameter (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeV-parameter (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeW-parameter (1 test): agc_driver_image_gather_volume
Skipped (62)
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_copied_writer_label_order_drain: 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_storage_pending_key_refresh: skipped, refreshes over a pending key store are not testable here
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_net_ctl: skipped, the host has no IPv4 address
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_aftergp
Reproduce
git fetch origin d7d38c778685c6e024c3ff2c4c06732a90e96d88 b11c7bf84f5d2f636ff60166cc3371bd071e24d5
git checkout b11c7bf84f5d2f636ff60166cc3371bd071e24d5 && git merge --no-ff d7d38c778685c6e024c3ff2c4c06732a90e96d88
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.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 4, 2026
…tes them

getcontext, setcontext, swapcontext and makecontext used FreeBSD 11's
ucontext_t, with mcontext_t at 0x10 and 800 bytes long. The console's is
the layout the exception handler path already uses: mcontext_t at 0x40,
1152 bytes (mc_len 0x480), with lbrfrom, lbrto, aux1 and aux2 after
mc_ownedfp, an 832-byte mc_fpstate, and uc_link at 0x4c0. The Naruto: Rise
of a Ninja and Forza Horizon ports (PPSA99680, PPSA99690) read it so on
firmware 9.00: getcontext reports mc_len 1152 and writes 1216 bytes, and
their fibers set mc_rip at 0xe0, mc_rsp at 0xf8 and mc_rbp at 0x88 after
getcontext. Here swapcontext read mc_rip at 0xb0 instead, resumed the
fiber at getcontext's return address on a stack that had moved on, and
both titles crashed at start.

UserMcontext and UserUcontext now take that layout. getcontext still
copies the 512-byte FXSAVE image to the start of mc_fpstate and zeroes the
new fields; guest_user_context checks those fields in place of
mc_xfpustate and mc_xfpustate_len.
…tion path

Exception.cpp kept its own GuestMcontext and GuestUcontext, the layout
UserContext.hpp now has. It uses UserMcontext and UserUcontext through
aliases, so the exception handlers and getcontext/setcontext cannot drift
apart again. The static assertions on the offsets live in UserContext.hpp.
No behaviour changes.
The Naruto and Forza Horizon ports build their fibers without makecontext:
after getcontext they store the entry stack at offset 0xf8 (mc_rsp), 0 at
0x88 (mc_rbp) and the entry function at 0xe0 (mc_rip) of a 2 KiB buffer,
then switch with swapcontext. guest_user_context now does the same with
raw offsets, checks that getcontext reports mc_len 1152 at 0x108 and
writes nothing from uc_link at 0x4c0 on, and switches into the fiber and
back three times.
…s from

The getcontext entry described FreeBSD 11's layout, taken from the sizes
PPSA99039's OpenSSL ASYNC passes, and called the console's own layout
unverified. It now gives the layout the exception path and getcontext
share, the firmware 9.00 readings from the Naruto and Forza Horizon ports
behind it, and the part that is still not measured: uc_stack after
uc_link. PPSA99039 does not call these functions at start. The FXSAVE
entry names mc_lbrfrom, mc_lbrto, mc_aux1 and mc_aux2, which getcontext
leaves 0, in place of mc_xfpustate and mc_xfpustate_len, which the
console layout does not have.
@root-over
root-over force-pushed the fix/libkernel-console-ucontext-layout branch from d7d38c7 to 90c30d5 Compare November 5, 2026 08:00
@github-actions github-actions Bot added review queue Next in the maintainer review queue: checks pass, no open change request, no conflict and removed needs rebase Conflicts with main, rebase needed labels Nov 5, 2026

@BunnyFl BunnyFl 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.

@root-over looks right, and firmware 13.42's own makecontext agrees with the new layout.

Firmware 13.42

system/common/lib/libSceLibcInternal.sprx (SHA-256 a01795ab49df639dd40abd6194956ada062244826824ce486c9acab227bf5285), makecontext at 0x8de70, read to its return (disassembly only, not measured on a console):

8dee7: cmpq $0x480,0x108(%rdi)      ; mc_len must be 1152, at 0x40 + 0xc8
8def4: cmp  $0x6,%edx               ; at most 6 arguments
8def9: mov  0x4c8(%rdi),%rax        ; uc_stack.ss_sp
8df05: mov  0x4d0(%rdi),%rcx        ; uc_stack.ss_size
8df0c: cmp  $0x7ff,%rcx             ; must be above 0x7ff
8df15: movq $0x0,0x108(%rdi)        ; otherwise mc_len is cleared
8dfee: mov  %rdi,0x48(%rdi)         ; mc_rdi = ucp
8dffa: movq $0x0,0x88(%rdi)         ; mc_rbp = 0
8e00c: mov  %r14,0xf8(%rdi)         ; mc_rsp
8e013: mov  %rax,0xe0(%rdi)         ; mc_rip

system/common/lib/libkernel.sprx (SHA-256 4be40bf838a46e1ff83a1809960672526139b09dda6c4a6592cfeb485d29f243), swapcontext at 0xcad0, copies the context into a 0x500-byte stack buffer before the switch:

caef: mov $0x500,%edx

So mc_len 1152 at 0x108, mc_rip at 0xe0, mc_rsp at 0xf8 and sizeof(ucontext_t) 0x500 all match this PR's static_asserts. It also settles the one field the debt entry leaves open: uc_stack.ss_sp is at 0x4c8 and ss_size at 0x4d0 on 13.42, as you have them. You could cite that instead of "not measured" (non-blocking).

What I ran

Head 90c30d52be merged onto main 78e4248fea (clean merge), Windows 11, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON, test executables rebuilt. Your description says Windows wasn't built; this is a Windows run:

  • 10 tests: guest_user_context, guest_user_context_exit, guest_kernel_sys, guest_kernel_sys_swapcontext, guest_exception_handler, guest_raise_exception, guest_signals, guest_signal_handler_mask, guest_sce_v2_exceptions and fiber_contextless pass. register_context_capture, _restore and _threads aren't registered in this Windows build.
  • Negative control: main's UserContext.hpp and Exception.cpp with your GuestUserContext.cpp (its mc_xfpustate check put back so it compiles, CheckConsoleOffsets kept): guest_user_context aborts (0xc0000409). My log doesn't show which check stopped it.
  • check_conventions.py passes. pr_overlap.py --branch finds only shared lines, no shared exports, with #12682, #12688, #12700 and #12965, the four you named.

Approving.

AI-assisted: yes (Claude Code)

@TechLevelZero

Copy link
Copy Markdown
Contributor

❌ AMD GPU test: failed

PR head 90c30d5 merged onto main e772fb2 · tested 2026-11-05 16:03 UTC · 48 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,937 passed · 16 failed (1 new: 1 not compared, 10 also fail on main, 5 unstable on main) · 71 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 4,024 of 4,074 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 (1467 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.2 s, ⚠️ agc_driver_graphics_maps_fallback 96.6 s, ⚠️ agc_driver_graphics 94.8 s, ⚠️ agc_graphics_profile_draw 60.1 s, ⚠️ agc_driver_bda_device 48.7 s

Failing tests

This PR changes test files, so each failing test was also built and run on main with only the PR's test changes applied. ✅ there means the failure comes from the PR's other changes; ❌ means the test fails on main too, so this run does not show the PR caused it.

Test With this PR Same test on main e772fb2 (main + this PR's test changes only)
agc_graphics_profile_draw ❌ failed not compared: the PR's tests do not build without its other changes
agc_graphics_profile_draw: Timeout (also failed when re-run alone), assertion and diagnostics
ctest: Timeout

[guestmem] read 0 calls 0 MiB 0.0 s compare 0 calls 0 MiB 0.0 s write 0 calls 0 MiB 0.0 s write-changed 0 calls 0 MiB 0.0 s collect 0 calls 0 MiB 0.0 s verify 1 calls 0 MiB 0.0 s query 0 calls 0 MiB 0.0 s collect-memo hits 0, collect epochs 0 collect-dirty 0 tracker waits 0 / 0 | arena 0x10000+0xfbf
[textures] sampled created: 0 from storage images, 0 cleared on the GPU, 0 snapshots (0 snapshot reads over recorded writes inside cachedTexture, 0 storage-path fallbacks); stage-A records 0: 0 fast hits, 0 full lookups; storage images 0 hits, 0 created, 0 own-object refreshes; image tables 0 reused
[guestmem] read 102 calls 3 MiB 0.0 s compare 0 calls 0 MiB 0.0 s write 44 calls 0 MiB 0.0 s write-changed 15 calls 0 MiB 0.0 s collect 0 calls 0 MiB 0.0 s verify 1982 calls 98 MiB 0.0 s query 0 calls 0 MiB 0.0 s collect-memo hits 0, collect epochs 0 collect-dirty 0 tracker waits 0 / 213 | arena 0x1
[guestmem] read 135 calls 6 MiB 0.0 s compare 0 calls 0 MiB 0.0 s write 44 calls 0 MiB 0.0 s write-changed 15 calls 0 MiB 0.0 s collect 0 calls 0 MiB 0.0 s verify 110137 calls 598 MiB 0.2 s query 0 calls 0 MiB 0.0 s collect-memo hits 0, collect epochs 0 collect-dirty 0 tracker waits 0 / 74705 | aren
[bufferpool] small: 0 hits, 0 misses, 0 evictions, 0 retained (0 MiB); large: 0 hits, 0 misses, 0 evictions, 0 retained (0 MiB); device: 0 hits, 0 misses, 0 evictions, 0 retained (0 MiB of 512); images: 0 hits, 0 misses, 0 evictions, 0 retained (0 MiB of 128)
[buffers] image mirrors: 0 ranges (0.0 MiB, 0 writable, 0 heap 0.0 MiB), 0 address-based builds served, 0 descriptor sub-ranges bound, 0 sparse heaps bound, 0 rebuilds, 33637 refreshes: 0 blocks compared, 0 copied, 0 refresh syncs; heap refills 0, unwatched heaps 33637, 0 heap mirrors evicted for bu
[descriptors] layouts 0 hits / 0 created, sets 0 from 0 pools and 0 dedicated pools, samplers 0 hits / 0 created
[dcc] 54 scans, 0.0 MiB scanned, 0 memo hits, 0 flush syncs, 0.0 ms; uncompressed keys stored: 0 on the GPU (0 with an unaligned head or tail), 17 on the CPU; key proofs: 0 proved, 0 scanned, 0 unstable
Unstable on main (5, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_job_manager_compute_capacity: failed in 8 of the last 10 main runs
agc_driver_pipeline_journal: failed in 9 of the last 10 main runs
agc_driver_two_sample_alpha_to_coverage_sample_mask_export: failed in 5 of the last 10 main runs
agc_submit_progress: failed in 9 of the last 10 main runs
agc_submit_progress_no_timeline: failed in 9 of the last 10 main runs
Failing on main too (10, not counted against this PR)
agc_driver_alpha_to_coverage_sample_mask_export
agc_driver_guest_memory_lifetime_direct
agc_driver_image_table
agc_driver_native_depth_bda_clear
agc_driver_native_depth_buffer_clear
agc_driver_native_depth_clears
agc_driver_native_multisample_depth
agc_driver_submit_progress
guest_mmap_executable
guest_socket_options_multicast
Validated but not compared (65, not in the main baseline's validation pass)
guest_job_manager_worker_spin
public_headers
public_headers_compile_0
public_headers_compile_1
public_headers_compile_10
public_headers_compile_11
public_headers_compile_12
public_headers_compile_13
public_headers_compile_14
public_headers_compile_15
public_headers_compile_16
public_headers_compile_17
public_headers_compile_18
public_headers_compile_19
public_headers_compile_2
public_headers_compile_21
public_headers_compile_22
public_headers_compile_23
public_headers_compile_24
public_headers_compile_25
public_headers_compile_26
public_headers_compile_27
public_headers_compile_28
public_headers_compile_29
public_headers_compile_3
public_headers_compile_30
public_headers_compile_31
public_headers_compile_32
public_headers_compile_33
public_headers_compile_34
public_headers_compile_35
public_headers_compile_36
public_headers_compile_37
public_headers_compile_38
public_headers_compile_39
public_headers_compile_4
public_headers_compile_40
public_headers_compile_41
public_headers_compile_42
public_headers_compile_43
public_headers_compile_44
public_headers_compile_45
public_headers_compile_46
public_headers_compile_47
public_headers_compile_48
public_headers_compile_49
public_headers_compile_5
public_headers_compile_50
public_headers_compile_51
public_headers_compile_52
public_headers_compile_53
public_headers_compile_54
public_headers_compile_55
public_headers_compile_56
public_headers_compile_57
public_headers_compile_58
public_headers_compile_59
public_headers_compile_6
public_headers_compile_60
public_headers_compile_61
public_headers_compile_62
public_headers_compile_63
public_headers_compile_7
public_headers_compile_8
public_headers_compile_9
Validation IDs already present on main (4 IDs in 809 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (809 tests): agc_compute_pipeline_replay, agc_driver, agc_driver_address_draw_space_reuse, agc_driver_address_draw_space_reuse_held, agc_driver_address_draw_space_reuse_off, agc_driver_address_draw_space_reuse_transitions, agc_driver_address_draw_space_reuse_verify, agc_driver_address_passes, and 801 more
VUID-vkCmdCopyImage-srcImage-01548 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store_image_copy, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_partially_unmapped_plane, agc_driver_depth_plane_unmapped_plane, and 3 more
VUID-vkCmdCopyImage-srcImage-01551 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store_image_copy, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_partially_unmapped_plane, agc_driver_depth_plane_unmapped_plane, and 3 more
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
Skipped (71)
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_copied_writer_label_order_drain: 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_recorded_draw_staging: skipped, the device does not keep host imports write-watched, so the target is never resident
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_storage_pending_key_refresh: skipped, refreshes over a pending key store are not testable here
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_net_ctl: skipped, the host has no IPv4 address
guest_net_ctl_disconnected: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_device_capability: 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_host_resolution_disabled: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROL
Reproduce
git fetch origin 90c30d52bedf772d7f52789c6bbae4b3ded37378 e772fb25cc72ee5faf77847f06bbc69533016e82
git checkout e772fb25cc72ee5faf77847f06bbc69533016e82 && git merge --no-ff 90c30d52bedf772d7f52789c6bbae4b3ded37378
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
# the failing tests, on this merge and on main:
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc_graphics_profile_draw)$' --parallel 1 -V

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.

@BunnyFl

BunnyFl commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

@root-over correcting my comment here: I had suggested a cause for the agc_graphics_profile_draw timeout in TechLevelZero's AMD run without running the test, which I shouldn't have done.

What the bot's reports say: on this PR its one new failure is agc_graphics_profile_draw timing out at 60 s, not compared against main; on #14145's run against the same main e772fb2, the same test times out and also fails on main with only that PR's test changes. That doesn't show what happens with this PR's code. I'm running the test here on this PR and on main and will post the result.

AI-assisted: yes (Claude Code)

@BunnyFl

BunnyFl commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@root-over here is the agc_graphics_profile_draw run I said I'd post (cc @TechLevelZero, whose AMD run reported the timeout).

Head 90c30d52be merged onto main 6a337633c6 (merge a1d4076189, clean). Windows 11 Pro 10.0.26300, WinLibs GCC, AMD Radeon RX 9070 XT (Windows driver 32.0.32015.12012). Both runs used ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, with ctest -V, the test executable rebuilt for each run:

Tree agc_graphics_profile_draw VUID- ids layer-not-found lines
this PR merged onto main passed, 16.10 s none 0
the same merge with UserContext.hpp and Exception.cpp restored from main passed, 16.30 s none 0

One run of each. This doesn't reproduce the 60 s timeout from the bot's run (Linux, RX 6300, RADV) on this machine, and it doesn't tell us why the test timed out there; I have no Linux setup to run it on.

AI-assisted: yes (Claude Code)

@root-over

Copy link
Copy Markdown
Contributor Author

Linux RADV run of agc_graphics_profile_draw, for the timeout in the AMD bot's report (thanks @BunnyFl for the Windows run).

Head 90c30d52be merged onto main 8a64fc0d4b (clean), against main 8a64fc0d4b alone. Ubuntu, kernel 7.0, Ryzen 5 5625U iGPU (Vega, RADV RENOIR, Mesa 26.0.8), GCC 15.2.0, Release. ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R '^agc_graphics_profile_draw$' -V, with the test and libs rebuilt for each tree, three runs each:

Tree Result Time VUID- layer-not-found lines
this PR merged onto main passed ×3 13.10 s, 13.10 s, 13.35 s 0 0
main passed ×3 13.28 s, 13.24 s, 13.70 s 0 0

This does not reproduce the 60 s timeout on Linux and RADV either, and the time is the same with and without the change. The bot's run of #14145 against the same main e772fb2 timed out in this test too.

@github-actions github-actions Bot added review queue Next in the maintainer review queue: checks pass, no open change request, no conflict and removed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Nov 6, 2026
@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 core/libs/prx/libkernel/System/src/Exception.cpp
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 7804 docs/dev/debt/libkernel.md
PR 8592 core/libs/prx/libkernel/System/src/Exception.cpp
PR 9156 docs/dev/debt/libkernel.md
PR 9199 docs/dev/debt/libkernel.md
PR 9293 docs/dev/debt/libkernel.md
PR 9297 docs/dev/debt/libkernel.md
PR 9302 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 11628 core/libs/prx/libkernel/System/src/Exception.cpp
docs/dev/debt/libkernel.md
PR 11661 core/libs/prx/libkernel/System/src/Exception.cpp
docs/dev/debt/libkernel.md
PR 11689 core/libs/prx/libkernel/System/src/Exception.cpp
docs/dev/debt/libkernel.md
PR 11698 core/libs/prx/libkernel/System/src/Exception.cpp
docs/dev/debt/libkernel.md
PR 11896 docs/dev/debt/libkernel.md
PR 11939 docs/dev/debt/libkernel.md
PR 12130 core/libs/prx/libkernel/System/src/Exception.cpp
PR 12170 docs/dev/debt/libkernel.md
PR 12642 core/libs/prx/libkernel/System/src/Exception.cpp
PR 12682 core/libs/prx/libkernel/System/src/Exception.cpp
core/libs/tests/GuestUserContext.cpp
docs/dev/debt/libkernel.md
PR 12688 core/libs/prx/libkernel/System/src/Exception.cpp
core/libs/tests/GuestUserContext.cpp
docs/dev/debt/libkernel.md
PR 12700 core/libs/prx/libkernel/System/src/Exception.cpp
core/libs/tests/GuestUserContext.cpp
docs/dev/debt/libkernel.md
PR 12965 core/libs/prx/libkernel/System/src/Exception.cpp
core/libs/tests/GuestUserContext.cpp
docs/dev/debt/libkernel.md
PR 13560 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

@github-actions github-actions Bot removed the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 7, 2026

@gabichuuuuu gabichuuuuu 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.

A Windows check, and two notes on the debt entries.

On Windows 11 x64 (WinLibs GCC 15.2.0 r7 UCRT, Release, full build) I merged head 90c30d52 onto main c1e920e7 (clean merge) and ran ctest -R '^(guest_main_stack|guest_user_context|guest_.*exception|guest_.*unwind|guest_.*context)'. All 171 tests pass on main and with this PR, guest_user_context and guest_user_context_exit included.

In docs/dev/debt/libkernel.md:

  • The rewritten ksem entry drops its last clause, ksem_getvalue rejects an unwritable value pointer with EFAULT (14) via checked guest copy, as FreeBSD's sys_ksem_getvalue does through copyout. main still has it (L230), and it has nothing to do with this change.
  • The new entry gives FreeBSD's layout as mcontext at 0x10, which is right, since uc_sigmask is 16 bytes. The sceKernelRaiseException entry, which this PR does not touch, still says the handler's ucontext uses "FreeBSD's amd64 layout (16-byte sigmask, mcontext at 0x40, mc_rsp at 0xf8)". After this change, that is the console layout that getcontext shares, not FreeBSD's.

AI-assisted: yes.

@BunnyFl

BunnyFl commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

@root-over gabichuuuuu's two debt notes are right, and I missed the first one when I approved this head (cc @gabichuuuuu, thanks for catching it).

Both read at head 90c30d52be, against its merge base 1e24993fa3:

  • The ksem entry loses a clause this PR doesn't otherwise touch. git diff 1e24993fa3 90c30d52be -- docs/dev/debt/libkernel.md rewrites the ksem entry without its last clause. main 502288c2cf still has it, at docs/dev/debt/libkernel.md:230:

    ; ksem_getvalue rejects an unwritable value pointer with EFAULT (14) via checked guest copy, as FreeBSD's sys_ksem_getvalue does through copyout
    

    Could you put that clause back, as on main?

  • The sceKernelRaiseException entry still names the old layout. At this head, docs/dev/debt/libkernel.md:240 reads:

    builds the handler's ucontext with FreeBSD's amd64 layout (16-byte sigmask, mcontext at 0x40, mc_rsp at 0xf8)

    This PR's getcontext entry (docs/dev/debt/libkernel.md:223 at 90c30d52be) now gives mcontext at 0x40 and mc_rsp at 0xf8 as the exception handlers' ucontext_t, which getcontext shares. The sceKernelRaiseException entry could say the same instead of naming the old layout. Non-blocking.

My approval stands for the code; the ksem clause is the one fix I'd ask for.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot added the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 7, 2026
@root-over

Copy link
Copy Markdown
Contributor Author

@gabichuuuuu @BunnyFl thanks, both fixed on top of 90c30d52be, docs only:

  • 58489a0696 puts the ksem entry back as on main, ksem_getvalue EFAULT clause included. The clause was lost when I resolved the debt-file conflict in the last rebase.
  • 3cdd718c6c changes the sceKernelRaiseException entry from "FreeBSD's amd64 layout (16-byte sigmask, mcontext at 0x40, mc_rsp at 0xf8)" to "the console layout that getcontext shares (mcontext at 0x40, mc_rsp at 0xf8)".

The code is unchanged. I also rebuilt these commits rebased onto main 41614f0558 (Ubuntu 26.04, GCC 15.2.0, Ryzen 5 5625U / RADV RENOIR) and ran ctest -R '^(guest_main_stack|guest_user_context|guest_.*exception|guest_.*unwind|guest_.*context|guest_kernel_sys|.*ksem.*)': 197/197 pass, guest_user_context, guest_user_context_exit and guest_raise_exception included. The branch still merges cleanly into that main.

@BunnyFl

BunnyFl commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

@root-over thanks, both are fixed at 3cdd718c6c (cc @gabichuuuuu). I read the two commits against main:

  • 58489a0696: the ksem entry in docs/dev/debt/libkernel.md is now identical to main's, ksem_getvalue EFAULT clause included.
  • 3cdd718c6c: the sceKernelRaiseException entry (docs/dev/debt/libkernel.md:240 at 3cdd718c6c) now names the console layout that getcontext shares.

git diff 90c30d52be 3cdd718c6c changes only those two lines of docs/dev/debt/libkernel.md, so the code I approved at 90c30d52be is unchanged and my approval stands. I didn't re-run the tests at this head.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot removed the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 7, 2026
@oneandonlydean oneandonlydean self-assigned this Nov 7, 2026
The getcontext debt entry named two titles next to their ids. Debt docs
name PPSA ids only, so keep the ids.
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi @root-over, I pushed one small docs commit to your branch (3c14750, on top of 3cdd718; no force-push) so the PR can merge without another round.

In docs/dev/debt/libkernel.md (the getcontext/setcontext entry), the debt docs name title IDs only, so the sentence now refers to the ports of PPSA99680 and PPSA99690 without the game names. Nothing else changed; the code is as you wrote it. Thanks for the PR.

@oneandonlydean
oneandonlydean merged commit 142a252 into boykopovar:main Nov 7, 2026
12 checks passed
@root-over
root-over deleted the fix/libkernel-console-ucontext-layout branch November 8, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs libkernel unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants