Repository navigation
Conversation
|
@harajend fyi - pls let me know if this helps. |
There was a problem hiding this comment.
🟡 Changes recommended
Region boundary handling still has edge-case bugs, and the new regression test does not detect the original leak.
3 open findings
What changed in this PR
Fixes vpage sizing and allocation tracking, including NVL-S support.
Changes:
- Prevents virtual-region size underflow.
- Cleans up partially mapped pages and fixes out-of-order frees.
- Adds an out-of-order free boot test.
| File | Description |
|---|---|
zephyr/lib/vpage.c |
Updates region sizing, cleanup, and allocation tracking. |
zephyr/test/vpage.c |
Adds an out-of-order free regression test. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
6115723 to
b6f127a
Compare
PR 11303: test resultsRun date: 2026-10-21 17:14 UTC Tested commit: 81400fb02b5e15afd8849bd03c8941913067dde6 |
Tested commit This issue is not fixed. All playback/capture tests still fail on both Detailed analysis:CI failure: DSP firmware crash on NVL-S (regression vs. previously-reported bug)Tested commit Result: All playback/capture-dependent test cases fail on both boards with an Identical PC/backtrace/address on both boards → deterministic firmware bug, not This looks like a regression against a previously-filed bug, not a fixWe have an existing internal bug report ( In that prior report, the failure was graceful: With this PR, the same Hypothesis: this PR enables actually mapping/using the vpage region Suggested next stepPlease check the map-then-use ordering / error handling around |
| * Keep the elements dense: move the last in-use element (num_elems_in_use - 1) | ||
| * over the released one and clear the last slot. | ||
| */ | ||
| vpage_ctx.num_elems_in_use--; |
There was a problem hiding this comment.
This should be in a separate commit.
There was a problem hiding this comment.
Done, the free-tracking fix is now its own commit (with the boot test).
| if (!sys_mm_drv_page_phys_get(va, NULL)) | ||
| sys_mm_drv_unmap_page(va); | ||
| } | ||
|
|
There was a problem hiding this comment.
This should be a separate commit as well (or even a PR).
There was a problem hiding this comment.
Done, the rollback of partially mapped pages is now a separate commit.
| end = L2_VIRTUAL_SRAM_BASE + L2_VIRTUAL_SRAM_SIZE; | ||
| if (IS_ENABLED(CONFIG_LIBRARY_MANAGER) && CONFIG_LIBRARY_BASE_ADDRESS < end) | ||
| end = CONFIG_LIBRARY_BASE_ADDRESS; | ||
| } |
There was a problem hiding this comment.
This is rewriting the change in first commit? Why not make the correct fix in the first place?
There was a problem hiding this comment.
Agreed. The commits are restructured: the sizing logic is now written once in its final form in a single commit instead of rewriting an earlier one.
|
This PR fails without Zephyr zephyrproject-rtos/zephyr#122801 . @lgirdwood I pushed a minimal/subset of this PR as #11323 -> just fixes the overflow and limits SOF to what is safe to do with current version of Zephyr drivers. |
Will get Claude to respin once Zephyr part merged. |
vpages_free_and_unmap() moved velems[num_elems_in_use], which is one past the last in-use element, over the released slot. Freeing a non-last allocation therefore left the last element outside the in-use count, so the next allocation overwrote its tracking entry and that allocation could never be freed, leaking its virtual and physical pages. Decrement the count first so the real last element is moved. Add a boot test that frees allocations out of order and checks that the pages can be reused. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The mm driver maps page by page and leaves the pages already mapped, and their physical pages, in place when a later page fails, e.g. when physical L2 is exhausted. vpage then freed the virtual blocks without unmapping them, leaking physical L2. Unmap any page of the failed range that is still mapped before freeing the virtual blocks. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
vpage_init() computed the region size as an unsigned subtraction without checking that the image, virtual heap and library regions leave any L2 for vpages. On NVL-S (2MB L2) this underflows into a ~4GB region whose end wraps the 32-bit address space, so sys_mm_drv_map_region_safe() rejects every mapping with -EINVAL and every vpage_alloc() fails. The virtual heap and library regions are only virtual address space backed on demand, so they need not fit in L2 together with the vpages. When they fit, keep the existing layout. Otherwise place the vpage region after the virtual heap, end it at the library base address (or the end of virtual memory), and cap it by the physical L2 left after the image. If no page is left, log an error and leave vpages disabled; vpage_alloc() and vpage_free() then fail with -ENODEV. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Temporary: pull in "drivers: mm: intel_adsp: tlb: map uncached alias in the MMU" (zephyrproject-rtos/zephyr#122801), one commit on top of the currently pinned beeac475263e. Without it, coherent (uncached) accesses to vpages beyond the end of physical L2 fault on NVL-S. Drop this commit and bump the zephyr pin once the Zephyr PR is merged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
b6f127a to
81400fb
Compare
|
Respun onto current main (commits split per review) and added a DNM west.yml commit pinning zephyr to kv2019i's #122801 head (7280c15b8cff, one commit on top of the current pin) so CI picks up the uncached-alias fix via west. Will drop it and bump the pin when the Zephyr PR merges. Related: #11323 is the minimal subset. |



Fixes the NVL-S
vpage_alloc failed -22 ... total 1048294 free 1048294seen in the daily-nvl-s CI run, plus related vpage bugs. Respun as separate commits:velems[num_elems_in_use](one past the last element) was moved over the released slot, orphaning the last element and leaking its pages. Adds an out-of-order free boot test.Built for nvl-s (compile of vpage.c only with the new commits); not yet run on hardware - needs the CI run with the west.yml change. Draft.
🤖 Generated with Claude Code