libkernel: PS5X360 (PPSA50011) stops on a fixed sceKernelReserveVirtualRange below 0x200000000 (Linux: outside the guest address space arena; Windows: VirtualAlloc fixed failed) #10143

Closed
opened 2026-10-23 10:43:25 +00:00 by babyhuey · 0 comments
babyhuey commented 2026-10-23 10:43:25 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-23T10:43:25Z.


What happens

PS5X360 (PPSA50011, v1.0.2, a Xenia Canary port, source) stops during emulator setup on both host OSes, on a fixed sceKernelReserveVirtualRange below 0x200000000:

  • Linux (main b3e42bd1eb, lavapipe, Ubuntu 24.04 container), 5.3 s:
    [libc] unhandled exception 'St16invalid_argument' thrown from 0x7fe12c90a2d5
    terminate called after throwing an instance of 'std::invalid_argument'
      what():  fixed mapping is outside the guest address space arena
    
    This is the arena check in MapPlaced (DirectMemory.cpp, #if defined(__linux__)). With the address added to that message in a local build, the request is 0x10000+0x150000 with flags 0x10 (fixed).
  • Windows (main 513ca7e558, RTX 3080, Windows 11 26200), 11.1 s:
    terminate called after throwing an instance of 'std::system_error'
      what():  VirtualAlloc fixed failed: Attempt to access invalid address
    
    [memory] lines are printed only after a mapping succeeds, so the address isn't in the trace, but the sequence before it is the same as on Linux.

Why the title asks for these addresses

In the title's platform/ps5/memory_ps5.cpp (Reserve), when the kernel moves a reservation hint and the wanted range ends below 4 GiB, the title checks the range with sceKernelVirtualQuery and then asks for it again with sceKernelReserveVirtualRange(&at, bytes, 0x10, 0x4000). If that call returns non-zero, Reserve returns nullptr, so the title expects a failure code, not a fault:

    // The kernel moved the hint. Below 4 GiB, take a verified free range.
    if (wanted + bytes <= 0x100000000ull && RangeFree(wanted, bytes)) {
      at = reinterpret_cast<void*>(wanted);
      if (sceKernelReserveVirtualRange(&at, bytes, kFixed, kPage) == 0) {

The file's header says it was measured on hardware (FW 13.60). The port also moves Xenia's code cache below 2 GiB on the console (tools/prepare.py): "The console loads the title's libc at 0x80000000 ... the indirection table and the generated code move below 2 GiB, near the title's own code". Its generated code is at 0x40000000 and its indirection table at 0x80000000 - 0x30000000.

A local experiment

With DoReserveVirtual returning SCE_KERNEL_ERROR_EINVAL for a fixed request outside the arena (local only, Linux, lavapipe), the title gets past this stop and runs 25.8 s:

  • It probes fixed 0x150000-byte allocations at every 64 KiB from 0x10000 upward. Each fails and the title moves on ([X360] MEMORY alloc-fixed address=... result=ffffffff).
  • Then Xenia's code cache can't get its low ranges, and the title exits with its own error (main returned 4):
    !> Unable to allocate code cache indirection table
    !> This is likely because the 80000000-9FFFFFFF range is in use by some other system DLL
    !> Unable to allocate code cache generated code storage
    !> This is likely because the 40000000-4FFFFFFF range is in use by some other system DLL
    !> Setup: Cannot initalize processor!
    

Possible directions

  1. Return an error code (SCE_KERNEL_ERROR_EINVAL or ENOMEM?) from fixed reservations and mappings the host can't place, so the title's fallback runs instead of an abort. That alone doesn't get PS5X360 past setup.
  2. Let fixed reservations below 0x200000000 be placed when the host range is free (the title needs 0x40000000+0x10000000 and 0x50000000+0x20000000 at least). On Linux that range is normally free above the executable at 0x400000; on Windows the executable is at 0x140000000 by default.

Is (2) in scope for the arena, or should it start with (1)? I don't know what range the console allows for fixed reservations below 0x200000000, beyond what the title's comments say.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5996325679 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/10143). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-23T10:43:25Z. --- ### What happens PS5X360 (PPSA50011, v1.0.2, a Xenia Canary port, [source](https://github.com/BrinooTk/PS5X360)) stops during emulator setup on both host OSes, on a fixed `sceKernelReserveVirtualRange` below `0x200000000`: - **Linux** (`main` `b3e42bd1eb`, lavapipe, Ubuntu 24.04 container), 5.3 s: ```text [libc] unhandled exception 'St16invalid_argument' thrown from 0x7fe12c90a2d5 terminate called after throwing an instance of 'std::invalid_argument' what(): fixed mapping is outside the guest address space arena ``` This is the arena check in `MapPlaced` (`DirectMemory.cpp`, `#if defined(__linux__)`). With the address added to that message in a local build, the request is `0x10000+0x150000` with flags `0x10` (fixed). - **Windows** (`main` `513ca7e558`, RTX 3080, Windows 11 26200), 11.1 s: ```text terminate called after throwing an instance of 'std::system_error' what(): VirtualAlloc fixed failed: Attempt to access invalid address ``` `[memory]` lines are printed only after a mapping succeeds, so the address isn't in the trace, but the sequence before it is the same as on Linux. ### Why the title asks for these addresses In the title's `platform/ps5/memory_ps5.cpp` ([`Reserve`](https://github.com/BrinooTk/PS5X360/blob/0a178708ea2138413eea60eb7625496457455137/platform/ps5/memory_ps5.cpp#L87-L120)), when the kernel moves a reservation hint and the wanted range ends below 4 GiB, the title checks the range with `sceKernelVirtualQuery` and then asks for it again with `sceKernelReserveVirtualRange(&at, bytes, 0x10, 0x4000)`. If that call returns non-zero, `Reserve` returns `nullptr`, so the title expects a failure code, not a fault: ```cpp // The kernel moved the hint. Below 4 GiB, take a verified free range. if (wanted + bytes <= 0x100000000ull && RangeFree(wanted, bytes)) { at = reinterpret_cast<void*>(wanted); if (sceKernelReserveVirtualRange(&at, bytes, kFixed, kPage) == 0) { ``` The file's header says it was measured on hardware (FW 13.60). The port also moves Xenia's code cache below 2 GiB on the console ([`tools/prepare.py`](https://github.com/BrinooTk/PS5X360/blob/0a178708ea2138413eea60eb7625496457455137/tools/prepare.py#L175-L177)): "The console loads the title's libc at 0x80000000 ... the indirection table and the generated code move below 2 GiB, near the title's own code". Its generated code is at `0x40000000` and its indirection table at `0x80000000 - 0x30000000`. ### A local experiment With `DoReserveVirtual` returning `SCE_KERNEL_ERROR_EINVAL` for a fixed request outside the arena (local only, Linux, lavapipe), the title gets past this stop and runs 25.8 s: - It probes fixed `0x150000`-byte allocations at every 64 KiB from `0x10000` upward. Each fails and the title moves on (`[X360] MEMORY alloc-fixed address=... result=ffffffff`). - Then Xenia's code cache can't get its low ranges, and the title exits with its own error (`main returned 4`): ```text !> Unable to allocate code cache indirection table !> This is likely because the 80000000-9FFFFFFF range is in use by some other system DLL !> Unable to allocate code cache generated code storage !> This is likely because the 40000000-4FFFFFFF range is in use by some other system DLL !> Setup: Cannot initalize processor! ``` ### Possible directions 1. Return an error code (`SCE_KERNEL_ERROR_EINVAL` or `ENOMEM`?) from fixed reservations and mappings the host can't place, so the title's fallback runs instead of an abort. That alone doesn't get PS5X360 past setup. 2. Let fixed reservations below `0x200000000` be placed when the host range is free (the title needs `0x40000000+0x10000000` and `0x50000000+0x20000000` at least). On Linux that range is normally free above the executable at `0x400000`; on Windows the executable is at `0x140000000` by default. Is (2) in scope for the arena, or should it start with (1)? I don't know what range the console allows for fixed reservations below `0x200000000`, beyond what the title's comments say.
Sign in to join this conversation.
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#10143
No description provided.