fix(linux): enter the guest entry on a main stack at the console's address #7532

Merged
hugodearaujo merged 13 commits from upstream-pr/7532 into main 2026-11-03 08:07:52 +00:00
hugodearaujo commented 2026-10-18 12:38:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-18T12:38:25Z.


What

On Linux the relinked executable entered the title's entry point on the host process stack, near the top of the address space (0x7ffc...). On the console a process's main thread stack sits inside the user area: a payload on a PS5 (FW 13.60) reports its main thread stack at 0x7eedfc000-0x7eeffc000 through pthread_attr_get_np, right above a worker thread's stack at 0x7eede8000-0x7eedf8000.

When the executable loads libkernel.prx, its Linux entry stub now calls EnterGuestMainStack_nid_no_patch (libkernel) through a GLOB_DAT slot, with the initial stack pointer and the entry point.

  • The helper maps the main stack in the guest arena so that it ends where the console's does (0x7eeffc000, moved by the arena's offset in ASan builds). Below it is a 16 KiB guard. Its size is the host's RLIMIT_STACK (8 MiB when unlimited, at most 1 GiB).
  • It calls the entry point there with the same arguments. sceKernelIsStack and the main thread's attributes report that range.
  • An executable that does not load libkernel.prx keeps the stub as it was.

#3965 does the same on Windows, with a helper in libc that is built only there.

Title

Assassin's Creed Mirage (PPSA13960, 01.007.000) first stops on main at a kevent read event, which #6343 implements. With #6343 applied, it stops with SIGSEGV on the main thread 6 s after start, with nothing in the log.

  • Its allocator finds the pool that owns a pointer through a table indexed by pointer >> 28 (eboot 0x570b9c1-0x570b9ec).
  • The main thread asks it about an object on its own stack. 0x7fffffff42c8 gives index 0x7ffff, so the lookup reads past the table and dereferences what it finds there (0x8232f00).
  • On the console the main thread's stack lies below 0x7eeffc000, which gives index 0x7e.

With this PR and #6343 it passes that point and goes through its start-up screens (photosensitivity warning, Ubisoft logo, intro video, disclaimer, autosave notice; screenshots from two runs) to the next unimplemented path:

AGC graphics: guest cube texture descriptor does not contain a multiple of 6 array slices (format 22, 128x128x7, type 11, tile 9, mips 0..0 of 1) (base array 0)

Tested

  • main f91137142e merged in (67658c0cbd): only the debt file conflicted, where main added an entry next to this PR's; both are kept. The same test set passes 93 of 93.

  • main a5939f10a8 merged in (003002a852): EntryStubBuilder.cpp conflicted with #12554, which checks the entry call's rel32 through SignedDistance so an entry point more than 2^63 away is rejected instead of wrapping. The resolution keeps this PR's stub (the lea/indirect call through the helper slot when there is one) and runs its shared appendRel32 through SignedDistance, so both rel32 fields get #12554's check; #12554's new test passes std::nullopt for the slot. The same test set as below passes 93 of 93.

  • main bb04a4f1ea merged in (7348d46be0): core/libs/prx/libkernel/CMakeLists.txt conflicted with #12126, which registers the macOS-only guest_main_stack_move test next to this PR's Linux-only guest_main_stack; both registrations are kept. With the same test set as below (ctest -j8 --output-on-failure), main bb04a4f1ea passes 91 of 91 and this head 93 of 93, the two extra tests being guest_main_stack and linux_main_stack_entry.

  • main 74acfad65b merged in (0c55cfcc6a), without conflicts: the overlaps with #7417's trace-import symbol, relocation and prologue in LinuxElfPatcher::Patch and with the entries #8061, #9059 and #9461 in docs/dev/debt/libkernel.md were already resolved in the earlier merge (both undefined symbols and both GLOB_DAT relocations are kept, the trace import's first, and the trace prologue falls through to this entry stub). The PR's own diff is unchanged.

  • PS5 (FW 13.60): a payload prints the address of a local in main, its pthread_attr_get_np stack range, a worker thread's range, and a malloc and an mmap address:

    MAIN|local=7eeffbcdc argv=7eeffbdb8 argc=1
    MAIN|attr init=0 get_np=0 getstack=0 stack=7eedfc000 size=0x200000 top=7eeffc000
    OTHER|malloc=880009c00 mmap=20001c000 main=200009310
    WORKER|local=7eedf7fbc
    WORKER|attr stack=7eede8000 size=0x10000 top=7eedf8000
    
  • Linux (Arch, kernel 7.2.11, GCC 16.2.1, Release), on main 74acfad65b and on this head, ctest -j8 --output-on-failure of guest_main_stack, linux_main_stack_entry, entry_stub, public_headers and its 64 compile batches, guest_kernel_is_stack, guest_kernel_stack_protect, guest_pthread_attr, guest_pthread_attr_stack, guest_pthread_stack, guest_pthread_start, guest_module_args and the linux_* relinker tests (linux_trace_imports among them): main passes 90 of 90 and this head 92 of 92, the two more being the new tests.

    • guest_main_stack enters a test entry through the helper and checks the argument; that sceKernelIsStack reports a range ending at 0x7eeffc000 that holds the entry's locals; the guard page below it; that a guest thread created there gets a separate stack; and that an entry over an existing guest mapping is refused and leaves the mapping as it was. With HostStackLimits as on main it fails at GuestMainStack.cpp:67, the check that the reported range ends at 0x7eeffc000.
    • linux_main_stack_entry relinks an executable that loads libkernel.prx and one that does not, and checks the stub and the imports of both. On Linux x86-64 it also runs the first with a test libkernel.prx whose helper calls the entry point; the entry exits with its argc plus 41. With the libkernel.prx check forced off, the first executable gets no DT_RELA entry for the helper's slot and the test fails (KeyError: 7 in helper_slots). entry_stub checks both stubs.
  • Full CTest with -j8, ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1 on the same machine (AMD Radeon RX 9070 XT, RADV GFX1201, Mesa 26.2.5): main 74acfad65b passes 2396 of 2431 tests and this head 2398 of 2433. On both, the same 34 tests are skipped and agc_driver_tessellation segfaults (#5444).

  • Reported by milescoviello on this PR (Linux, RTX 4070 Ti, main 750cf6cf48 with #12436): ProsperoCraft (PPSA99874 01.000.117), a Java launcher whose HotSpot runtime mprotects guard pages at the bottom of each thread's stack, aborts at start-up on the primordial thread (Native memory allocation (mprotect) failed to protect 49152 bytes), whose stack is the host process's. With this PR (head 0c55cfcc6a) the primordial thread gets past it, and with #9684 as well, which does the same for the threads the title creates, it runs the full 120 s.

  • Earlier heads, not repeated on this base:

    • On main 0d078f75d, each title relinked twice from the same ELF with the same options, with this PR's relinker (for A built with the libkernel.prx check forced off, so the stub is main's) and this PR's runtime libraries. Assassin's Creed Mirage, with #6343's Kqueue.cpp change: A stops with SIGSEGV 6 s after start, as on main; B reaches the cube texture error above 120 s after start. Hades (PPSA03355, 01.003.000), CONTROL Resonant (PPSA34547, 01.300.300), Alan Wake 2 (PPSA02572, 01.200.007) and ASTRO BOT (PPSA21567, 01.018.000) reach the same screens in A and B.
    • On main 137a8fab89 merged in (deec037e97), Assassin's Creed Mirage, 20 s runs: on main, 7 of 22 runs stop with SIGSEGV 3 s after start at eboot 0x570b9ec, and 12 of 12 with this PR get past start-up.
    • Windows Server 2025 VM, WinLibs GCC 15.2, Release, BUILD_TESTING=ON, on main 0d078f75d: of 1479 tests, 924 pass, 554 are skipped (the VM has no GPU) and guest_positioned_close fails, as it does intermittently on main there (5 of 30 runs). Windows does not use this stub.
  • tools/check_conventions.py --base origin/main passes and git diff --check is clean. Of the overlaps the earlier description discussed, #7417 and #6443 are merged and part of this base; #3965's head 8029f87e58 still merges with this branch without conflicts, and #7594 rebases after this one, as agreed on #7594.

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: PPSA13960 #7534
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4909147593 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7532). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-18T12:38:25Z. --- ### What On Linux the relinked executable entered the title's entry point on the host process stack, near the top of the address space (`0x7ffc...`). On the console a process's main thread stack sits inside the user area: a payload on a PS5 (FW 13.60) reports its main thread stack at `0x7eedfc000`-`0x7eeffc000` through `pthread_attr_get_np`, right above a worker thread's stack at `0x7eede8000`-`0x7eedf8000`. When the executable loads `libkernel.prx`, its Linux entry stub now calls `EnterGuestMainStack_nid_no_patch` (libkernel) through a `GLOB_DAT` slot, with the initial stack pointer and the entry point. - The helper maps the main stack in the guest arena so that it ends where the console's does (`0x7eeffc000`, moved by the arena's offset in ASan builds). Below it is a 16 KiB guard. Its size is the host's `RLIMIT_STACK` (8 MiB when unlimited, at most 1 GiB). - It calls the entry point there with the same arguments. `sceKernelIsStack` and the main thread's attributes report that range. - An executable that does not load `libkernel.prx` keeps the stub as it was. #3965 does the same on Windows, with a helper in libc that is built only there. ### Title Assassin's Creed Mirage (PPSA13960, 01.007.000) first stops on `main` at a kevent read event, which #6343 implements. With #6343 applied, it stops with SIGSEGV on the main thread 6 s after start, with nothing in the log. - Its allocator finds the pool that owns a pointer through a table indexed by `pointer >> 28` (eboot `0x570b9c1`-`0x570b9ec`). - The main thread asks it about an object on its own stack. `0x7fffffff42c8` gives index `0x7ffff`, so the lookup reads past the table and dereferences what it finds there (`0x8232f00`). - On the console the main thread's stack lies below `0x7eeffc000`, which gives index `0x7e`. With this PR and #6343 it passes that point and goes through its start-up screens (photosensitivity warning, Ubisoft logo, intro video, disclaimer, autosave notice; screenshots from two runs) to the next unimplemented path: ``` AGC graphics: guest cube texture descriptor does not contain a multiple of 6 array slices (format 22, 128x128x7, type 11, tile 9, mips 0..0 of 1) (base array 0) ``` ### Tested - **`main` f91137142e merged in** (67658c0cbd): only the debt file conflicted, where `main` added an entry next to this PR's; both are kept. The same test set passes 93 of 93. - **`main` a5939f10a8 merged in** (003002a852): `EntryStubBuilder.cpp` conflicted with #12554, which checks the entry call's rel32 through `SignedDistance` so an entry point more than 2^63 away is rejected instead of wrapping. The resolution keeps this PR's stub (the `lea`/indirect call through the helper slot when there is one) and runs its shared `appendRel32` through `SignedDistance`, so both rel32 fields get #12554's check; #12554's new test passes `std::nullopt` for the slot. The same test set as below passes 93 of 93. - **`main` bb04a4f1ea merged in** (7348d46be0): `core/libs/prx/libkernel/CMakeLists.txt` conflicted with #12126, which registers the macOS-only `guest_main_stack_move` test next to this PR's Linux-only `guest_main_stack`; both registrations are kept. With the same test set as below (`ctest -j8 --output-on-failure`), `main` bb04a4f1ea passes 91 of 91 and this head 93 of 93, the two extra tests being `guest_main_stack` and `linux_main_stack_entry`. - **`main` 74acfad65b merged in** (0c55cfcc6a), without conflicts: the overlaps with #7417's trace-import symbol, relocation and prologue in `LinuxElfPatcher::Patch` and with the entries #8061, #9059 and #9461 in `docs/dev/debt/libkernel.md` were already resolved in the earlier merge (both undefined symbols and both `GLOB_DAT` relocations are kept, the trace import's first, and the trace prologue falls through to this entry stub). The PR's own diff is unchanged. - PS5 (FW 13.60): a payload prints the address of a local in `main`, its `pthread_attr_get_np` stack range, a worker thread's range, and a `malloc` and an `mmap` address: ``` MAIN|local=7eeffbcdc argv=7eeffbdb8 argc=1 MAIN|attr init=0 get_np=0 getstack=0 stack=7eedfc000 size=0x200000 top=7eeffc000 OTHER|malloc=880009c00 mmap=20001c000 main=200009310 WORKER|local=7eedf7fbc WORKER|attr stack=7eede8000 size=0x10000 top=7eedf8000 ``` - Linux (Arch, kernel 7.2.11, GCC 16.2.1, Release), on `main` 74acfad65b and on this head, `ctest -j8 --output-on-failure` of `guest_main_stack`, `linux_main_stack_entry`, `entry_stub`, `public_headers` and its 64 compile batches, `guest_kernel_is_stack`, `guest_kernel_stack_protect`, `guest_pthread_attr`, `guest_pthread_attr_stack`, `guest_pthread_stack`, `guest_pthread_start`, `guest_module_args` and the `linux_*` relinker tests (`linux_trace_imports` among them): `main` passes 90 of 90 and this head 92 of 92, the two more being the new tests. - `guest_main_stack` enters a test entry through the helper and checks the argument; that `sceKernelIsStack` reports a range ending at `0x7eeffc000` that holds the entry's locals; the guard page below it; that a guest thread created there gets a separate stack; and that an entry over an existing guest mapping is refused and leaves the mapping as it was. With `HostStackLimits` as on `main` it fails at `GuestMainStack.cpp:67`, the check that the reported range ends at `0x7eeffc000`. - `linux_main_stack_entry` relinks an executable that loads `libkernel.prx` and one that does not, and checks the stub and the imports of both. On Linux x86-64 it also runs the first with a test `libkernel.prx` whose helper calls the entry point; the entry exits with its `argc` plus 41. With the `libkernel.prx` check forced off, the first executable gets no `DT_RELA` entry for the helper's slot and the test fails (`KeyError: 7` in `helper_slots`). `entry_stub` checks both stubs. - Full CTest with `-j8`, `ANYPS5_REQUIRE_VULKAN=1` and `ANYPS5_NO_SHADER_CACHE=1` on the same machine (AMD Radeon RX 9070 XT, RADV GFX1201, Mesa 26.2.5): `main` 74acfad65b passes 2396 of 2431 tests and this head 2398 of 2433. On both, the same 34 tests are skipped and `agc_driver_tessellation` segfaults (#5444). - Reported by milescoviello on this PR (Linux, RTX 4070 Ti, `main` 750cf6cf48 with #12436): ProsperoCraft (PPSA99874 01.000.117), a Java launcher whose HotSpot runtime `mprotect`s guard pages at the bottom of each thread's stack, aborts at start-up on the primordial thread (`Native memory allocation (mprotect) failed to protect 49152 bytes`), whose stack is the host process's. With this PR (head 0c55cfcc6a) the primordial thread gets past it, and with #9684 as well, which does the same for the threads the title creates, it runs the full 120 s. - Earlier heads, not repeated on this base: - On `main` `0d078f75d`, each title relinked twice from the same ELF with the same options, with this PR's relinker (for A built with the `libkernel.prx` check forced off, so the stub is `main`'s) and this PR's runtime libraries. Assassin's Creed Mirage, with #6343's `Kqueue.cpp` change: A stops with SIGSEGV 6 s after start, as on `main`; B reaches the cube texture error above 120 s after start. Hades (PPSA03355, 01.003.000), CONTROL Resonant (PPSA34547, 01.300.300), Alan Wake 2 (PPSA02572, 01.200.007) and ASTRO BOT (PPSA21567, 01.018.000) reach the same screens in A and B. - On `main` 137a8fab89 merged in (deec037e97), Assassin's Creed Mirage, 20 s runs: on `main`, 7 of 22 runs stop with SIGSEGV 3 s after start at eboot `0x570b9ec`, and 12 of 12 with this PR get past start-up. - Windows Server 2025 VM, WinLibs GCC 15.2, Release, `BUILD_TESTING=ON`, on `main` `0d078f75d`: of 1479 tests, 924 pass, 554 are skipped (the VM has no GPU) and `guest_positioned_close` fails, as it does intermittently on `main` there (5 of 30 runs). Windows does not use this stub. - `tools/check_conventions.py --base origin/main` passes and `git diff --check` is clean. Of the overlaps the earlier description discussed, #7417 and #6443 are merged and part of this base; #3965's head 8029f87e58 still merges with this branch without conflicts, and #7594 rebases after this one, as agreed on #7594. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA13960 #7534 - [x] GPUs tested: n/a - [x] AI-assisted: yes
oneandonlydean commented 2026-10-18 18:23:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T18:23:13Z.


Thanks, the design looks right, and the stub, the 16-byte alignment and the bounds query all check out. One small safety change before merge: EnterGuestMainStack maps the stack with DoMapAnon(&mapping, bytes, 3, GUEST_MAP_FIXED) and exclusive = false, so ReplaceFixedOverlap silently replaces anything already registered in [top - bytes, top). With a large RLIMIT_STACK (up to 1 GiB) that range reaches well below the console stack. Nothing should be there at entry, but a collision would be clobbered rather than reported. Could it pass exclusive = true, so an overlap fails with ENOMEM and a named error?

On order: as discussed on #7594, this lands first and #7594 rebases with its MXCSR set before call [rip+slot].

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6253481500 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7532#issuecomment-6253481500). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-18T18:23:13Z. --- Thanks, the design looks right, and the stub, the 16-byte alignment and the bounds query all check out. One small safety change before merge: `EnterGuestMainStack` maps the stack with `DoMapAnon(&mapping, bytes, 3, GUEST_MAP_FIXED)` and `exclusive = false`, so `ReplaceFixedOverlap` silently replaces anything already registered in `[top - bytes, top)`. With a large `RLIMIT_STACK` (up to 1 GiB) that range reaches well below the console stack. Nothing should be there at entry, but a collision would be clobbered rather than reported. Could it pass `exclusive = true`, so an overlap fails with ENOMEM and a named error? On order: as discussed on #7594, this lands first and #7594 rebases with its MXCSR set before `call [rip+slot]`.
simonbbby commented 2026-10-18 18:29:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-18T18:29:30Z.


I reproduced Dean's collision concern and tested the requested exclusive call locally on exact head 51e5eae15b432788ec554811a80c60ad74337e97. Ubuntu 24.04, kernel 7.0.0-38-generic, GCC 13.3, Release.

With soft RLIMIT_STACK=1 MiB, an external probe registers a 16 KiB RW anonymous guest mapping through DoMapAnon(..., exclusive=true), fills every dword with 0xa55a1234, then calls the real EnterGuestMainStack helper:

Existing sentinel page Submitted head Local exclusive-call proposal
Inside usable stack, at top - 0x10000 Enters; sentinel becomes zero Refuses; all 16 KiB and RW protection preserved
Inside guard, at top - 0x104000 Enters; page protection becomes 0 Refuses; all 16 KiB and RW protection preserved
Immediately below mapping, at top - 0x108000 Enters; sentinel preserved Same
No collision Enters Same

The local production change is only:

DoMapAnon(&mapping, bytes, 3, GUEST_MAP_FIXED, PS5_PAGE_SIZE, true)

Both refused cases report EnterGuestMainStack: cannot map the guest main stack before entry. This fits the mapping path: without exclusivity, the partial overlap reaches fixed-overlap replacement; with it, mutation.Overlaps returns ENOMEM before any replacement/protection change. The adjacent-page control rules out blanket refusal of nearby registered mappings.

Boundary/guard checks, on both the submitted head and the local proposal: an extension of GuestMainStack.cpp changes the soft limit after process startup and verifies these reported usable spans:

  • 1 MiB → 1 MiB; 3 MiB + 1 byte → 3 MiB + 16 KiB; 8 MiB → 8 MiB; 64 MiB → 64 MiB.
  • 2 GiB → 1 GiB; zero and unlimited → 8 MiB.

All 14 processes pass. Every reported upper bound is 0x7eeffc000; each run also forks a child with core dumps disabled/default SIGSEGV handling, and an actual read one byte below usable stack is terminated by SIGSEGV. The parent creates/joins a guest worker and keeps the original separate-stack assertions.

guest_main_stack, linux_main_stack_entry and entry_stub pass (3/3) with the proposal. Separately, restoring only the original HostStackLimits host-query behavior makes the stock test fail its upper-bound assertion at line 68. Restoring the exact PR source and rebuilding returns the three tests to passing.

I restored the submitted source; the worktree is clean. The exclusive call above is a tested local proposal, not a pushed change. Generated-input/runtime-helper checks only: no Mirage/title, Windows, ASan-offset or full-suite result.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6253544540 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7532#issuecomment-6253544540). Originally posted by [simonbbby](https://github.com/simonbbby) on 2026-10-18T18:29:30Z. --- I reproduced Dean's collision concern and tested the requested exclusive call locally on exact head `51e5eae15b432788ec554811a80c60ad74337e97`. Ubuntu 24.04, kernel `7.0.0-38-generic`, GCC 13.3, Release. With soft `RLIMIT_STACK=1 MiB`, an external probe registers a 16 KiB RW anonymous guest mapping through `DoMapAnon(..., exclusive=true)`, fills every dword with `0xa55a1234`, then calls the real `EnterGuestMainStack` helper: | Existing sentinel page | Submitted head | Local exclusive-call proposal | |---|---|---| | Inside usable stack, at `top - 0x10000` | Enters; sentinel becomes zero | Refuses; all 16 KiB and RW protection preserved | | Inside guard, at `top - 0x104000` | Enters; page protection becomes 0 | Refuses; all 16 KiB and RW protection preserved | | Immediately below mapping, at `top - 0x108000` | Enters; sentinel preserved | Same | | No collision | Enters | Same | The local production change is only: ```cpp DoMapAnon(&mapping, bytes, 3, GUEST_MAP_FIXED, PS5_PAGE_SIZE, true) ``` Both refused cases report `EnterGuestMainStack: cannot map the guest main stack` before entry. This fits the mapping path: without exclusivity, the partial overlap reaches fixed-overlap replacement; with it, `mutation.Overlaps` returns ENOMEM before any replacement/protection change. The adjacent-page control rules out blanket refusal of nearby registered mappings. **Boundary/guard checks, on both the submitted head and the local proposal:** an extension of `GuestMainStack.cpp` changes the soft limit after process startup and verifies these reported usable spans: - 1 MiB → 1 MiB; 3 MiB + 1 byte → 3 MiB + 16 KiB; 8 MiB → 8 MiB; 64 MiB → 64 MiB. - 2 GiB → 1 GiB; zero and unlimited → 8 MiB. All 14 processes pass. Every reported upper bound is `0x7eeffc000`; each run also forks a child with core dumps disabled/default SIGSEGV handling, and an actual read one byte below usable stack is terminated by SIGSEGV. The parent creates/joins a guest worker and keeps the original separate-stack assertions. `guest_main_stack`, `linux_main_stack_entry` and `entry_stub` pass (3/3) with the proposal. Separately, restoring only the original `HostStackLimits` host-query behavior makes the stock test fail its upper-bound assertion at line 68. Restoring the exact PR source and rebuilding returns the three tests to passing. I restored the submitted source; the worktree is clean. The exclusive call above is a tested local proposal, not a pushed change. Generated-input/runtime-helper checks only: no Mirage/title, Windows, ASan-offset or full-suite result.
hugodearaujo commented 2026-10-19 15:52:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-19T15:52:58Z.


@oneandonlydean Sorry for the slow reply, I missed this comment. Done in cdfddff83, on top of the existing head:

  • EnterGuestMainStack maps the stack with DoMapAnon(&mapping, bytes, 3, GUEST_MAP_FIXED, PS5_PAGE_SIZE, true), so an overlap returns ENOMEM before anything is replaced, and entry stops with EnterGuestMainStack: the guest main stack [low, top) overlaps a guest mapping. Any other mapping failure keeps the old message.
  • guest_main_stack has a case for it: it maps 16 KiB of flexible memory at top - 0x10000, fills it with a pattern, and checks that entry is refused with that message, that the page keeps its RW protection and its pattern, and that the normal entry still works once the page is unmapped. With the old non-exclusive call the case fails (entry goes ahead over the page).
  • The TechnicalDebt entry says an overlap stops the entry.

Linux (Arch, kernel 7.2.11, GCC 16.2.1, Release, RX 9070 XT with RADV, Mesa 26.2.5): full CTest 1439 of 1440, the failure being agc_driver_tessellation (#5444); guest_main_stack, linux_main_stack_entry and entry_stub pass.

@simonbbby Thanks for reproducing it and testing the exclusive call; the new case is your in-stack sentinel row.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6271357960 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7532#issuecomment-6271357960). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-19T15:52:58Z. --- @oneandonlydean Sorry for the slow reply, I missed this comment. Done in cdfddff83, on top of the existing head: - `EnterGuestMainStack` maps the stack with `DoMapAnon(&mapping, bytes, 3, GUEST_MAP_FIXED, PS5_PAGE_SIZE, true)`, so an overlap returns ENOMEM before anything is replaced, and entry stops with `EnterGuestMainStack: the guest main stack [low, top) overlaps a guest mapping`. Any other mapping failure keeps the old message. - `guest_main_stack` has a case for it: it maps 16 KiB of flexible memory at `top - 0x10000`, fills it with a pattern, and checks that entry is refused with that message, that the page keeps its RW protection and its pattern, and that the normal entry still works once the page is unmapped. With the old non-exclusive call the case fails (entry goes ahead over the page). - The TechnicalDebt entry says an overlap stops the entry. Linux (Arch, kernel 7.2.11, GCC 16.2.1, Release, RX 9070 XT with RADV, Mesa 26.2.5): full CTest 1439 of 1440, the failure being `agc_driver_tessellation` (#5444); `guest_main_stack`, `linux_main_stack_entry` and `entry_stub` pass. @simonbbby Thanks for reproducing it and testing the exclusive call; the new case is your in-stack sentinel row.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!7532
No description provided.