Skip to content

scripts: reset LLEXT VMA accumulators before each west build#10793

Open
lgirdwood wants to merge 1 commit into
thesofproject:mainfrom
lgirdwood:topic/vma-fix
Open

scripts: reset LLEXT VMA accumulators before each west build#10793
lgirdwood wants to merge 1 commit into
thesofproject:mainfrom
lgirdwood:topic/vma-fix

Conversation

@lgirdwood
Copy link
Copy Markdown
Member

llext_link_helper.py uses openmod_module_size and module_size as persistent counters to assign pre-linked VMAs to LLEXT ELFs. Running ninja more than once without a pristine build causes these files to accumulate across invocations. The second run doubles the counter values, placing all ELF VMAs outside the valid LLEXT virtual region [CONFIG_LIBRARY_BASE_ADDRESS, +CONFIG_LIBRARY_REGION_SIZE).

When pre_located=true the LLEXT loader uses the ELF sh_addr VMAs directly as physical load addresses. sys_mm_drv_map_region() silently fails for out-of-range addresses, so the module is never registered. The kernel then receives IPC4_MOD_NOT_INITIALIZED (error 104) for every module init IPC.

Reset both accumulator files to 0 before every west build invocation so VMA assignment always starts from CONFIG_LIBRARY_BASE_ADDRESS.

llext_link_helper.py uses openmod_module_size and module_size as
persistent counters to assign pre-linked VMAs to LLEXT ELFs.  Running
ninja more than once without a pristine build causes these files to
accumulate across invocations.  The second run doubles the counter
values, placing all ELF VMAs outside the valid LLEXT virtual region
[CONFIG_LIBRARY_BASE_ADDRESS, +CONFIG_LIBRARY_REGION_SIZE).

When pre_located=true the LLEXT loader uses the ELF sh_addr VMAs
directly as physical load addresses.  sys_mm_drv_map_region() silently
fails for out-of-range addresses, so the module is never registered.
The kernel then receives IPC4_MOD_NOT_INITIALIZED (error 104) for every
module init IPC.

Reset both accumulator files to 0 before every west build invocation so
VMA assignment always starts from CONFIG_LIBRARY_BASE_ADDRESS.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Copilot AI review requested due to automatic review settings May 20, 2026 15:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR prevents incorrect pre-linked LLEXT VMAs on incremental rebuilds by resetting the on-disk accumulator counters before each west build, ensuring VMA assignment restarts from CONFIG_LIBRARY_BASE_ADDRESS.

Changes:

  • Reset openmod_module_size and module_size accumulator files to 0 before invoking the build command.
  • Add inline documentation explaining the runtime failure mode prevented by the reset.

Comment on lines +990 to +992
for acc_file in ("openmod_module_size", "module_size"):
acc_path = zephyr_build_dir / acc_file
if acc_path.is_file():
for acc_file in ("openmod_module_size", "module_size"):
acc_path = zephyr_build_dir / acc_file
if acc_path.is_file():
acc_path.write_text("0\n")
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.

4 participants