[userspace LL] LLEXT part of #10945 - #11112
Open
lyakh wants to merge 4 commits into
Open
Conversation
Move llext_manager_add_partition() and llext_manager_rm_partition() higher in the file for future use. No functional change. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
With userspace LL enabled module freeing runs in syscall contex on behalf of the userspace IPC thread. That thread doesn't have access to DRAM. Therefore we cannot call lib_manager_get_module_manifest() in that case. Use SRAM module data by calling llext_manager_mod_find() instead. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
lyakh
requested review from
dbaluta,
kv2019i,
lbetlej,
lgirdwood,
mmaka1 and
plbossart
as code owners
August 21, 2026 08:46
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extracts LLEXT-related userspace LL scheduling changes (from #10945) into the main SOF library manager flow, primarily by making LLEXT module identification available outside llext_manager.c and by adding temporary memory-domain partitioning to support LLEXT unload/unmap operations.
Changes:
- Exposes
llext_manager_mod_find()viasof/llext_manager.hand uses it inlib_manager_free_module()to route frees to the LLEXT manager when applicable. - Adds temporary mapping of ELF section-header inspection data during LLEXT module unload to support section-based unmapping.
- Refactors
CONFIG_USERSPACEpartition helper placement inllext_manager.c(moved earlier in file).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/library_manager/llext_manager.c | Adds/uses userspace memory-domain partition helpers during unload; exports llext_manager_mod_find() for external use. |
| src/library_manager/lib_manager.c | Routes module freeing to LLEXT manager based on llext_manager_mod_find() result. |
| src/include/sof/llext_manager.h | Declares llext_manager_mod_find() and adds a non-LLEXT stub macro for it. |
Suppressed comments (2)
src/library_manager/llext_manager.c:594
llext_manager_mod_find()can dereferencectx/ctx->modwhen they are NULL and can also readctx->mod[i - 1]whenctx->n_mod == 0. Additionally, whenidx < ctx->mod[0].start_idx, it currently returnsi - 1(wrap/underflow) rather than a clear-ENOENT. This function is now part of the public API, so it should defensively validate inputs and bounds.
int llext_manager_mod_find(const struct lib_manager_mod_ctx *ctx, unsigned int idx)
{
unsigned int i;
for (i = 0; i < ctx->n_mod; i++)
src/library_manager/llext_manager.c:422
llext_manager_rm_partition()is called unconditionally here, and its return value is ignored. This has the same compile-guard issue as the add call above, and a remove failure should be surfaced (at least by propagating intoerr).
llext_manager_rm_partition(zephyr_ll_mem_domain(), (uintptr_t)shdr, total,
K_MEM_PARTITION_P_RW_U_NA | XTENSA_MMU_CACHED_WB);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+385
to
+396
| unsigned int sect_cnt = llext_section_count(ext); | ||
| size_t total = sect_cnt * sizeof(elf_shdr_t); | ||
| const elf_shdr_t *shdr; | ||
|
|
||
| ret = llext_get_section_info(ldr, ext, 0, &shdr, NULL, NULL); | ||
| if (ret < 0) | ||
| return ret; | ||
|
|
||
| /* Temporarily map ELF section headers */ | ||
| llext_manager_add_partition(zephyr_ll_mem_domain(), (uintptr_t)shdr, total, | ||
| K_MEM_PARTITION_P_RW_U_NA | XTENSA_MMU_CACHED_WB); | ||
|
|
Comment on lines
1087
to
1091
| struct lib_manager_mod_ctx *ctx = lib_manager_get_mod_ctx(module_id); | ||
| uint32_t entry_index = LIB_MANAGER_GET_MODULE_INDEX(module_id); | ||
|
|
||
| if (entry_index >= desc->header.num_module_entries) { | ||
| tr_err(&lib_manager_tr, "Invalid driver index %u exceeds %d", | ||
| entry_index, desc->header.num_module_entries - 1); | ||
| return -ENOENT; | ||
| } | ||
|
|
||
| if (!ctx->mod) { | ||
| tr_err(&lib_manager_tr, "NULL module array: ID %#x ctx %p", component_id, ctx); |
Comment on lines
+429
to
+430
| if (llext_manager_mod_find(ctx, entry_index) >= 0) | ||
| return llext_manager_free_module(component_id); |
| #define llext_manager_free_module(component_id) 0 | ||
| #define llext_manager_add_library(module_id) 0 | ||
| #define llext_manager_add_domain(component_id, domain) 0 | ||
| #define llext_manager_mod_find(ctx, idx) -ENOENT |
llext_manager_unload_module() is called in a syscall context on behalf of the userspace IPC thread, so it doesn't have direct access to LLEXT module DRAM data. Map section headers temporarily for the duration of the function. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
llext_manager_free_module() cannot access DRAM when running with userspace LL enabled. Don't call lib_manager_get_library_manifest() to obtain the DRAM descriptor, needed to verify the entry index. The index is now verified by llext_manager_mod_find(). Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
kv2019i
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LLEXT related commits from #10945