fix(svc): svcQueryMemory answers a free range as the whole gap, Inaccessible past the address space #1683

Merged
HumanBean merged 1 commit from rainy/Longshot:fix/svc-query-memory-free-gap into main 2026-11-19 07:16:34 +00:00
Contributor

Type: fix · Risk: low · Tested on: Linux (Omarchy, kernel 7.2.15; Intel Core Ultra 7 270K Plus; RTX 4090, driver 615.78.08) · Needs: a run on Windows, any GPU

TL;DR

When a program asked the console which memory sits at a free address, Longshot answered with one page. The real console answers with the whole free range around it, and past the end of the address space it answers with one inaccessible block. This PR answers the way the console does. A new game-free test fails on main and passes here. The full check suite on this branch has the same 40 failures as main, and one more pass. It also ran in the game on Linux.

Breakdown

  • Who it helps: mods and tools that list the game's memory by walking it region by region.
  • What was wrong: a free address was answered as one 4 KiB page, so a walk took one step per free page and never got far past the system region.
  • What changes: a free address is answered with the whole free range, and an address past the address space with one inaccessible block.
  • What does not change: the answers for mapped memory: the system region, the image, the heap and the thread's stack.
  • How it was checked: a new game-free test that fails on main and passes here, and python -I -B tests/run_all.py --jobs 8, which has the same 40 failures as main and one more pass.
  • What is still open: a run in the game on this branch.
  • Risk: low. The game asks this from 2 places of its own, and those now get the large free ranges a console gives them.

Why

A code mod, sloperinaGZ 0.0.8, on snaildev99's mods/module-gaps branch is what showed this. The kernel answers a memory query with the memory block that holds the address. The kernel merges adjacent free blocks, so a free address gets the whole free range. Past the address space it answers one Inaccessible block from the space's end to 2^64. Atmosphère's kernel reimplementation does this in KPageTableBase::QueryInfo and QueryInfoImpl in mesosphere's kern_k_page_table_base.cpp. Longshot answered a free address with its one page. Code that lists the mappings walks from address 0, stepping to base + size each time. With one page per step it needs about 16,000 steps per 64 MiB of free space. A walk with a step limit then stops in the free space after the system region and never reaches the image or the heap. The game itself calls this from 2 places. The tracker has no issue or PR for QueryMemory.

How to reproduce

Seen on: Linux (Omarchy, kernel 7.2.15; Intel Core Ultra 7 270K Plus; RTX 4090, driver 615.78.08). The answer itself does not depend on the GPU or driver.
Settings and switches: defaults
Steps: call svcQueryMemory on a free address, for example 0x07000000 just above the system region, from mod code or from the game-free test below run against main.
Expected: Free, base 0x07000000, size up to the start of the next mapping, the image.
Actual: Free, base 0x07000000, size 0x1000.

What changed

query_memory answers free memory with the whole gap and answers addresses past the address space as Inaccessible. Mapped regions answer as before.

  • svc: query_memory in host/hos_svc.c. An address at or above HOS_GUEST_SPACE, which is 1 << 39, gets base HOS_GUEST_SPACE, size 0 - HOS_GUEST_SPACE, state 0x10. A free address gets the range from the end of the nearest mapping below it to the start of the nearest mapping above it. The mappings are the system region, the image, the heap and the calling thread's stack.
  • tests: tests/test_query_memory_free.py cuts query_memory out of the source with tests/srccut.py and compiles it with a stub layout. It checks each gap from several addresses, the Inaccessible end, the four mapped regions, a walk from 0 that has to end in a few steps, a stack inside the heap and an empty heap.

Measurements

Nothing to measure. The change replaces one answer with another in a call the game makes from 2 places, and a timing would not show it.

Flags and settings

None

Testing

Tested: python -I -B tests/run_all.py --jobs 8 on Linux (Omarchy, kernel 7.2.15; Intel Core Ultra 7 270K Plus; RTX 4090, driver 615.78.08). main @ 2f1c0c9c: 685 passed, 40 failed, 97 skipped. this branch @ 2390b608: 686 passed, 40 failed, 97 skipped, 0 new failures compared by test name. The 40 failures also fail on main. They are:

Tests that also fail on main @ 2f1c0c9c in this environment
  • tests/test_bug_report_defaults.py
  • tests/test_bug_report.py
  • tests/test_capture_read_once.py
  • tests/test_crash_groups.py
  • tests/test_crash_record.py
  • tests/test_crt_options.py
  • tests/test_damage_debug_menu.py
  • tests/test_dev_packs.py
  • tests/test_display_startup_failure.py
  • tests/test_dlss_feature_size.py
  • tests/test_failed_compile_keeps_objects.py
  • tests/test_guest_imported.py
  • tests/test_hardware_report.py
  • tests/test_high_fps_fixes.py
  • tests/test_host_guest_writes.py
  • tests/test_hud_layout_row.py
  • tests/test_invalidate_quick.py
  • tests/test_libc_hooks.py
  • tests/test_link_path_comma.py
  • tests/test_linux_preflight.py
  • tests/test_linux_pressure.py
  • tests/test_linux_update.py
  • tests/test_log_open_failure.py
  • tests/test_missing_nup.py
  • tests/test_mods_size_table.py
  • tests/test_pending_guest_import.py
  • tests/test_pipeline_play_cache.py
  • tests/test_prepare_cache_save.py
  • tests/test_present_thread.py
  • tests/test_profiling_mode.py
  • tests/test_psychov35_fsr3_fg.py
  • tests/test_readback_timeout_source.py
  • tests/test_run_all_changed.py
  • tests/test_slow_frames.py
  • tests/test_song_note_cue.py
  • tests/test_switch_table.py
  • tests/test_upscaler_rows.py
  • tests/test_vcore_escape.py
  • tests/test_walk_key.py
  • tests/test_vbytes.py (timed out at 600 s)

With the fix's source file reverted to main, python -I -B tests/test_query_memory_free.py fails (FAIL:54 qb == 0 && qs == 0x01000000 ...). It passes on this branch. In the game, built from this branch on Linux with an RTX 4090: the game boots and plays as on main.

Not testable by hand: the free-gap walk that showed the bug can only be reached by a code mod. The game's own 2 call sites run in a normal play session, so the in-game run covers them. The game-free test stands in for the free-gap case.

Not tested: Windows (no build or run there) and other GPUs. The same change also ran in the game on snaildev99's mods/module-gaps branch, where a mod's memory walk reached the heap.

Must be tested:

  • Linux, any GPU: start the game on this branch, load a save, play for a few minutes and change areas, expecting no crash and no new svc lines in longshot_log.txt (by hand: the author, before this PR leaves WIP)
  • Windows, any GPU: the same steps, expecting the same result (Test Farm: @Beanstalk windows, start the game, load a save and change areas twice)

Risks

What could break: the game's 2 own call sites now see a large free range where they saw one page. A console answers them that way, so a problem would point to something else Longshot does differently.

Turning it off: revert the commit

Compatibility: Nothing changes

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what
    can't be run by hand is in Testing's Not testable by hand, with why.
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and
    in Risks.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • A game-free test added for the fix, failing on main and passing here.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
**Type:** fix · **Risk:** low · **Tested on:** Linux (Omarchy, kernel 7.2.15; Intel Core Ultra 7 270K Plus; RTX 4090, driver 615.78.08) · **Needs:** a run on Windows, any GPU ## TL;DR When a program asked the console which memory sits at a free address, Longshot answered with one page. The real console answers with the whole free range around it, and past the end of the address space it answers with one inaccessible block. This PR answers the way the console does. A new game-free test fails on main and passes here. The full check suite on this branch has the same 40 failures as main, and one more pass. It also ran in the game on Linux. ## Breakdown - **Who it helps:** mods and tools that list the game's memory by walking it region by region. - **What was wrong:** a free address was answered as one 4 KiB page, so a walk took one step per free page and never got far past the system region. - **What changes:** a free address is answered with the whole free range, and an address past the address space with one inaccessible block. - **What does not change:** the answers for mapped memory: the system region, the image, the heap and the thread's stack. - **How it was checked:** a new game-free test that fails on main and passes here, and `python -I -B tests/run_all.py --jobs 8`, which has the same 40 failures as main and one more pass. - **What is still open:** a run in the game on this branch. - **Risk:** low. The game asks this from 2 places of its own, and those now get the large free ranges a console gives them. ## Why A code mod, sloperinaGZ 0.0.8, on snaildev99's mods/module-gaps branch is what showed this. The kernel answers a memory query with the memory block that holds the address. The kernel merges adjacent free blocks, so a free address gets the whole free range. Past the address space it answers one Inaccessible block from the space's end to 2^64. Atmosphère's kernel reimplementation does this in `KPageTableBase::QueryInfo` and `QueryInfoImpl` in mesosphere's `kern_k_page_table_base.cpp`. Longshot answered a free address with its one page. Code that lists the mappings walks from address 0, stepping to base + size each time. With one page per step it needs about 16,000 steps per 64 MiB of free space. A walk with a step limit then stops in the free space after the system region and never reaches the image or the heap. The game itself calls this from 2 places. The tracker has no issue or PR for QueryMemory. ## How to reproduce **Seen on:** Linux (Omarchy, kernel 7.2.15; Intel Core Ultra 7 270K Plus; RTX 4090, driver 615.78.08). The answer itself does not depend on the GPU or driver. **Settings and switches:** defaults **Steps:** call svcQueryMemory on a free address, for example 0x07000000 just above the system region, from mod code or from the game-free test below run against main. **Expected:** Free, base 0x07000000, size up to the start of the next mapping, the image. **Actual:** Free, base 0x07000000, size 0x1000. ## What changed `query_memory` answers free memory with the whole gap and answers addresses past the address space as Inaccessible. Mapped regions answer as before. - svc: `query_memory` in `host/hos_svc.c`. An address at or above `HOS_GUEST_SPACE`, which is 1 << 39, gets base `HOS_GUEST_SPACE`, size `0 - HOS_GUEST_SPACE`, state 0x10. A free address gets the range from the end of the nearest mapping below it to the start of the nearest mapping above it. The mappings are the system region, the image, the heap and the calling thread's stack. - tests: `tests/test_query_memory_free.py` cuts `query_memory` out of the source with `tests/srccut.py` and compiles it with a stub layout. It checks each gap from several addresses, the Inaccessible end, the four mapped regions, a walk from 0 that has to end in a few steps, a stack inside the heap and an empty heap. ## Measurements Nothing to measure. The change replaces one answer with another in a call the game makes from 2 places, and a timing would not show it. ### Flags and settings None ## Testing **Tested:** `python -I -B tests/run_all.py --jobs 8` on Linux (Omarchy, kernel 7.2.15; Intel Core Ultra 7 270K Plus; RTX 4090, driver 615.78.08). main @ 2f1c0c9c: 685 passed, 40 failed, 97 skipped. this branch @ 2390b608: 686 passed, 40 failed, 97 skipped, 0 new failures compared by test name. The 40 failures also fail on main. They are: <details> <summary>Tests that also fail on main @ 2f1c0c9c in this environment</summary> - `tests/test_bug_report_defaults.py` - `tests/test_bug_report.py` - `tests/test_capture_read_once.py` - `tests/test_crash_groups.py` - `tests/test_crash_record.py` - `tests/test_crt_options.py` - `tests/test_damage_debug_menu.py` - `tests/test_dev_packs.py` - `tests/test_display_startup_failure.py` - `tests/test_dlss_feature_size.py` - `tests/test_failed_compile_keeps_objects.py` - `tests/test_guest_imported.py` - `tests/test_hardware_report.py` - `tests/test_high_fps_fixes.py` - `tests/test_host_guest_writes.py` - `tests/test_hud_layout_row.py` - `tests/test_invalidate_quick.py` - `tests/test_libc_hooks.py` - `tests/test_link_path_comma.py` - `tests/test_linux_preflight.py` - `tests/test_linux_pressure.py` - `tests/test_linux_update.py` - `tests/test_log_open_failure.py` - `tests/test_missing_nup.py` - `tests/test_mods_size_table.py` - `tests/test_pending_guest_import.py` - `tests/test_pipeline_play_cache.py` - `tests/test_prepare_cache_save.py` - `tests/test_present_thread.py` - `tests/test_profiling_mode.py` - `tests/test_psychov35_fsr3_fg.py` - `tests/test_readback_timeout_source.py` - `tests/test_run_all_changed.py` - `tests/test_slow_frames.py` - `tests/test_song_note_cue.py` - `tests/test_switch_table.py` - `tests/test_upscaler_rows.py` - `tests/test_vcore_escape.py` - `tests/test_walk_key.py` - `tests/test_vbytes.py` (timed out at 600 s) </details> With the fix's source file reverted to main, `python -I -B tests/test_query_memory_free.py` fails (`FAIL:54 qb == 0 && qs == 0x01000000 ...`). It passes on this branch. In the game, built from this branch on Linux with an RTX 4090: the game boots and plays as on main. **Not testable by hand:** the free-gap walk that showed the bug can only be reached by a code mod. The game's own 2 call sites run in a normal play session, so the in-game run covers them. The game-free test stands in for the free-gap case. **Not tested:** Windows (no build or run there) and other GPUs. The same change also ran in the game on snaildev99's mods/module-gaps branch, where a mod's memory walk reached the heap. **Must be tested:** - Linux, any GPU: start the game on this branch, load a save, play for a few minutes and change areas, expecting no crash and no new `svc` lines in `longshot_log.txt` (by hand: the author, before this PR leaves WIP) - Windows, any GPU: the same steps, expecting the same result (Test Farm: @Beanstalk windows, start the game, load a save and change areas twice) ## Risks **What could break:** the game's 2 own call sites now see a large free range where they saw one page. A console answers them that way, so a problem would point to something else Longshot does differently. **Turning it off:** revert the commit **Compatibility:** Nothing changes ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened.
fix(svc): svcQueryMemory answers a free range as the whole gap, Inaccessible past the address space
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 6s
Website / Website on Cloudflare (pull_request_target) Has been skipped
2390b60824
Free memory was answered one page at a time. The kernel answers the block
that holds the address, and free blocks are merged, so a free address gets
the whole free range around it; past the address space it answers one
Inaccessible block from the space's end to 2^64 (Atmosphere's mesosphere,
KPageTableBase::QueryInfo / QueryInfoImpl). Code that lists the mappings by
walking the address space region by region needed a step per free page and
never got far past the system region.

Free is now from the end of the mapping before the address (system region,
image, heap, the thread's stack) to the start of the one after it, and from
1 << 39 up Inaccessible (state 0x10) to the end. Mapped regions answer as
before. tests/test_query_memory_free.py cuts query_memory out of the source
and checks the gaps, the Inaccessible end, the mapped regions and a walk
from 0; it fails on main.

Assisted-by: Grok Bot
Author
Contributor

Tested in game: Linux (Omarchy, kernel 7.2.15), Intel Core Ultra 7 270K Plus, RTX 4090 driver 615.78.08, a build of this branch on v3.0.0-rc.8: the game boots and plays as on main.

Tested in game: Linux (Omarchy, kernel 7.2.15), Intel Core Ultra 7 270K Plus, RTX 4090 driver 615.78.08, a build of this branch on v3.0.0-rc.8: the game boots and plays as on main.
HumanBean left a comment

From the code and the evidence this looks ready to merge. The new answers match the kernel: mesosphere's KPageTableBase::QueryInfo gives one Inaccessible block from the end of the address space to 2^64, and a merged free block for a free address. The loop in query_memory gets each gap right. Regions with nothing in them are skipped, nested regions are handled (a stack inside the system region or the heap), and the size is never 0.

What the game sees. I read the game's own callers of svcQueryMemory, without running anything. The svc has two wrappers. The one in rtld never runs, because Longshot does rtld's work itself. The one in the SDK is called from about 25 places. These are the ones a normal session reaches:

  • nnosInitialize, the program-argument check. It queries x1, which hos_main.c passes as 0, and reads only the state ("is it Code?"). It got Free before and gets Free now, so nothing changes.
  • The ThreadManagerImplByHorizon constructor for the main thread. It queries its own frame, which falls in the calling thread's stack branch. That branch is unchanged.
  • nn::ro::FindModuleHeader, ProtectFullRelroForAllModules and nn::diag's backtrace query addresses in the image or on a stack. Those branches are unchanged.
  • SetMemoryPermissionImpl, SetMemoryAttributeImpl and IsMemoryLocked (through ExamineWholeAddressSpaceHasNoAttribute) step block by block. Over free memory they now take one step where they took one per page. svc 2 and 3 are no-ops here and the attribute is always 0, so the result is the same.
  • UserExceptionHandler and ro::GetExceptionInfo run only after a guest exception.

The one caller whose result really changes is AddressSpaceAllocator::CheckFreeSpace, which asks whether [addr, addr+size) lies inside one Free block. On main it said no to anything larger than a page. It now says yes. Its users are StackGuardManager::MapAtRandomAddress (alias stacks), the shared and transfer memory Map and RemoteRegionManager. They are not reached in play: the CreateThread HLE avoids MapAliasStack, and every one of them would next call svcMapMemory, svcMapSharedMemory or svcMapTransferMemory. Longshot implements none of those, and a64_svc's default case stops the run. On main they fail with no address space instead. So nothing in play changes, which fits the in-game run in the comments.

Suggestions (not blocking)

  • host/hos_svc.c:341: the gap only knows about the four regions. Memory Longshot hands out elsewhere still answers Free, and now as part of one large Free block: the address regions from hos_region_alloc (AllocateAddressRegion / AllocateMemoryPages, which grow down from 512 GB) and the VAMM pieces mapped with MapPhysicalMemory. On a console these are Normal. A mod walking the map, the case this PR is for, will skip the game's page-allocated memory. A CheckFreeSpace-style caller would also be told a live range is free. This was wrong before too (one Free page), and nothing in play hits it today. Two ways to settle it: say so in the comment, or answer hos_region_alloc's live ranges as Normal in a follow-up.
  • Description: "the game calls it from 2 places" is really the two svc wrappers. The list above is what actually reaches the svc in play. Also, the area/renderer label doesn't fit. This is host code.

Measurements: none, and none are needed. The change replaces the value of one answer and costs nothing per frame. The fix is shown by the new game-free test: the author reports it fails on main (FAIL:54) and passes here. Nothing was run for this review. The author ran the game on Linux with an RTX 4090. The answer doesn't depend on the GPU or the OS, and the code is plain portable C. The Windows run in Must be tested is a formality, not a gap.

Overlaps: PR 1542 also edits host/hos_svc.c, but at the start of a64_svc rather than in query_memory. They don't conflict, and either can merge first.

From the code and the evidence this looks ready to merge. The new answers match the kernel: mesosphere's `KPageTableBase::QueryInfo` gives one Inaccessible block from the end of the address space to 2^64, and a merged free block for a free address. The loop in `query_memory` gets each gap right. Regions with nothing in them are skipped, nested regions are handled (a stack inside the system region or the heap), and the size is never 0. **What the game sees.** I read the game's own callers of svcQueryMemory, without running anything. The svc has two wrappers. The one in rtld never runs, because Longshot does rtld's work itself. The one in the SDK is called from about 25 places. These are the ones a normal session reaches: - `nnosInitialize`, the program-argument check. It queries x1, which `hos_main.c` passes as 0, and reads only the state ("is it Code?"). It got Free before and gets Free now, so nothing changes. - The `ThreadManagerImplByHorizon` constructor for the main thread. It queries its own frame, which falls in the calling thread's stack branch. That branch is unchanged. - `nn::ro::FindModuleHeader`, `ProtectFullRelroForAllModules` and `nn::diag`'s backtrace query addresses in the image or on a stack. Those branches are unchanged. - `SetMemoryPermissionImpl`, `SetMemoryAttributeImpl` and `IsMemoryLocked` (through `ExamineWholeAddressSpaceHasNoAttribute`) step block by block. Over free memory they now take one step where they took one per page. svc 2 and 3 are no-ops here and the attribute is always 0, so the result is the same. - `UserExceptionHandler` and `ro::GetExceptionInfo` run only after a guest exception. The one caller whose result really changes is `AddressSpaceAllocator::CheckFreeSpace`, which asks whether `[addr, addr+size)` lies inside one Free block. On main it said no to anything larger than a page. It now says yes. Its users are `StackGuardManager::MapAtRandomAddress` (alias stacks), the shared and transfer memory `Map` and `RemoteRegionManager`. They are not reached in play: the `CreateThread` HLE avoids `MapAliasStack`, and every one of them would next call svcMapMemory, svcMapSharedMemory or svcMapTransferMemory. Longshot implements none of those, and `a64_svc`'s default case stops the run. On main they fail with no address space instead. So nothing in play changes, which fits the in-game run in the comments. **Suggestions (not blocking)** - `host/hos_svc.c:341`: the gap only knows about the four regions. Memory Longshot hands out elsewhere still answers Free, and now as part of one large Free block: the address regions from `hos_region_alloc` (`AllocateAddressRegion` / `AllocateMemoryPages`, which grow down from 512 GB) and the VAMM pieces mapped with MapPhysicalMemory. On a console these are Normal. A mod walking the map, the case this PR is for, will skip the game's page-allocated memory. A `CheckFreeSpace`-style caller would also be told a live range is free. This was wrong before too (one Free page), and nothing in play hits it today. Two ways to settle it: say so in the comment, or answer `hos_region_alloc`'s live ranges as Normal in a follow-up. - Description: "the game calls it from 2 places" is really the two svc wrappers. The list above is what actually reaches the svc in play. Also, the `area/renderer` label doesn't fit. This is host code. **Measurements:** none, and none are needed. The change replaces the value of one answer and costs nothing per frame. The fix is shown by the new game-free test: the author reports it fails on main (`FAIL:54`) and passes here. Nothing was run for this review. The author ran the game on Linux with an RTX 4090. The answer doesn't depend on the GPU or the OS, and the code is plain portable C. The Windows run in Must be tested is a formality, not a gap. **Overlaps:** [PR 1542](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1542) also edits `host/hos_svc.c`, but at the start of `a64_svc` rather than in `query_memory`. They don't conflict, and either can merge first.
@ -341,0 +341,4 @@
else { /* Free: the whole gap, from the end of the region before addr to the start of the one after it, as the kernel
answers (free blocks are merged). A walk over the address space region by region, base + size each step,
reaches every mapping in a few steps; at one page a step it never got past the system region */
const uint64_t lo[] = {HOS_SYSTEM_BASE, hos_image_base, HOS_HEAP_BASE, stack};
Owner

Nit: these four are all query_memory knows about. The ranges from hos_region_alloc (AllocateAddressRegion / AllocateMemoryPages, growing down from 512 GB) and the VAMM pieces from MapPhysicalMemory fall inside the gap after the heap, so they answer as part of one Free block. On a console they are Normal. Nothing in play depends on this today, but it's worth a word in the comment: a mod's map walk will skip that memory, and AddressSpaceAllocator::CheckFreeSpace would call a live range free.

Nit: these four are all `query_memory` knows about. The ranges from `hos_region_alloc` (`AllocateAddressRegion` / `AllocateMemoryPages`, growing down from 512 GB) and the VAMM pieces from MapPhysicalMemory fall inside the gap after the heap, so they answer as part of one Free block. On a console they are Normal. Nothing in play depends on this today, but it's worth a word in the comment: a mod's map walk will skip that memory, and `AddressSpaceAllocator::CheckFreeSpace` would call a live range free.
HumanBean deleted branch fix/svc-query-memory-free-gap 2026-11-19 07:16:35 +00:00
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 6s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1683
No description provided.