Skip to content

[userspace LL] LLEXT part of #10945 - #11112

Open
lyakh wants to merge 4 commits into
thesofproject:mainfrom
lyakh:llext
Open

[userspace LL] LLEXT part of #10945#11112
lyakh wants to merge 4 commits into
thesofproject:mainfrom
lyakh:llext

Conversation

@lyakh

@lyakh lyakh commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

LLEXT related commits from #10945

lyakh added 2 commits August 21, 2026 10:44
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>
Copilot AI lite review requested due to automatic review settings August 21, 2026 08:46

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.

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() via sof/llext_manager.h and uses it in lib_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_USERSPACE partition helper placement in llext_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 dereference ctx/ctx->mod when they are NULL and can also read ctx->mod[i - 1] when ctx->n_mod == 0. Additionally, when idx < ctx->mod[0].start_idx, it currently returns i - 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 into err).
	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 thread src/library_manager/llext_manager.c Outdated
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
lyakh added 2 commits August 21, 2026 12:17
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>
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.

3 participants