Skip to content

llext_manager: get detached section addresses from the ELF buffer - #11352

Draft
kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:202610-llext-cold-fix
Draft

kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:202610-llext-cold-fix

Conversation

@kv2019i

@kv2019i kv2019i commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Detached sections, like .cold and .coldrodata, are not copied into their region but stay in the ELF buffer. llext_manager computed their addresses as the region address plus the section offset returned by llext_get_section_info(). This only worked by accident, while the region was used in place. Since Zephyr commit 181077caab27 ("llext: report no region offset for detached sections"), the offset for a detached section is (size_t)-1. The .cold partition is no longer added to the user memory domain and MMU flags are applied to the wrong pages. Calling a .cold function from a user thread then fails with EXCCAUSE 18 (instr fetch privilege), e.g. when the DRC module is loaded.

Use llext_peek() at the section's ELF file offset instead, matching what Zephyr llext itself does for detached sections. This also removes the section lookup loop in llext_manager_add_mod_domain().

@edersondisouza edersondisouza 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.

LGTM

size_t text_offset = 0, rodata_offset = 0;

shdr_cold.sh_size = 0;
shdr_coldrodata.sh_size = 0;

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.

Why remove this?

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.

Thanks @edersondisouza , you are right, the zero inits cannot be removed. I added them back to V2.

Detached sections, like .cold and .coldrodata, are not copied into
their region but stay in the ELF buffer. llext_manager computed their
addresses as the region address plus the section offset returned by
llext_get_section_info(). This only worked by accident, while the
region was used in place. Since Zephyr commit 181077caab27 ("llext:
report no region offset for detached sections"), the offset for a
detached section is (size_t)-1. The .cold partition is no longer added
to the user memory domain and MMU flags are applied to the wrong
pages. Calling a .cold function from a user thread then fails with
EXCCAUSE 18 (instr fetch privilege), e.g. when the DRC module is
loaded.

Use llext_peek() at the section's ELF file offset instead, matching
what Zephyr llext itself does for detached sections. This also
removes the section lookup loop in llext_manager_add_mod_domain().

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
@kv2019i
kv2019i force-pushed the 202610-llext-cold-fix branch from a3095b5 to a648cbe Compare October 26, 2026 08:59
@kv2019i

kv2019i commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator Author

I included the V2 version of this PR and submitted this as non-draft as part of #11355 .. let's merge this together with an Zephyr update.

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