Skip to content

zephyr: vpage: add checks against invalid vpage config - #11323

Open
kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:202610-vpage-init-fix
Open

kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:202610-vpage-init-fix

Conversation

@kv2019i

@kv2019i kv2019i commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

The calculation of 'remaining_ram' ended up overflowing if the configuration did not allow for enough space for vpage region. Catch this case and disable vpage safely.

Also add a separate check to ensure vpage is not allocated beyond physical memory. This is a temporary limitation as Zephyr TLB driver only maps the cached alias when a page is mapped at runtime, and this leads to faults when vpage is used via a coherent alias (leading to e.g. "EXCCAUSE 29 (store prohibited)").

Co-developed-by: Liam Girdwood liam.r.girdwood@linux.intel.com

The calculation of 'remaining_ram' ended up overflowing if
the configuration did not allow for enough space for vpage
region. Catch this case and disable vpage safely.

Also add a separate check to ensure vpage is not allocated beyond
physical memory. This is a temporary limitation as Zephyr TLB
driver only maps the cached alias when a page is mapped at runtime,
and this leads to faults when vpage is used via a coherent alias
(leading to e.g. "EXCCAUSE 29 (store prohibited)").

Co-developed-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
@kv2019i
kv2019i requested review from lgirdwood and a balanced review from Copilot October 20, 2026 11:10
@kv2019i

kv2019i commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

FYI @lgirdwood @harajend This PR is a subset/alternative to #11303 . Tested on target hardware and passes the test.

Additionally, with #11322 vpage can be enabled again on this target.

Copilot AI 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.

🟡 Changes recommended

The fallback can discard an in-L2 library reservation and register overlapping vpage memory.

1 open issue
What changed in this PR

Adds configuration checks to Zephyr’s vpage allocator to prevent size underflow and keep mappings within physical L2 memory.

Changes:

  • Reject allocation and free operations when no vpage region exists.
  • Validate available space before registering the region.
File Description
zephyr/​lib/​vpage.c Adds region-availability guards and initialization bounds checks.

Review effort: Balanced

Comment thread zephyr/lib/vpage.c
* physical L2 size for now until support is added to
* Zephyr mm_drv_intel_adsp_mtl_tlb.c and friends
*/
end = l2_end;
Comment thread zephyr/lib/vpage.c
/*
* TODO: on demand mapping currently only supports
* cached mappings, so we need to limit vpages to
* physical L2 size for now until support is added to

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related Zephyr PR to address this limitation zephyrproject-rtos/zephyr#122801

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants