Skip to content

Commit

Permalink
llext fix Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski…
Browse files Browse the repository at this point in the history
…@linux.intel.com>
  • Loading branch information
softwarecki committed Apr 3, 2024
1 parent e2d4ee4 commit 97182d0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
3 changes: 3 additions & 0 deletions src/include/sof/lib_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ struct ipc_lib_msg {
struct list_item list;
};

struct sof_man_module_manifest;

struct lib_manager_mod_ctx {
void *base_addr;
const struct sof_man_module_manifest *mod_manifest;
size_t segment_size[3];
};

Expand Down
46 changes: 24 additions & 22 deletions src/library_manager/llext_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ static int llext_manager_link(struct sof_man_fw_desc *desc, struct sof_man_modul
struct lib_manager_mod_ctx *ctx = lib_manager_get_mod_ctx(module_id);
int ret = llext_load(&ebl.loader, mod->name, &md->llext, &ldr_parm);

if (ret < 0)
if (ret)
return ret;

mod->segment[SOF_MAN_SEGMENT_TEXT].v_base_addr = ebl.loader.sects[LLEXT_MEM_TEXT].sh_addr;
Expand Down Expand Up @@ -238,7 +238,6 @@ uintptr_t llext_manager_allocate_module(struct processing_module *proc,
uint32_t module_id = IPC4_MOD_ID(ipc_config->id);
uint32_t entry_index = LIB_MANAGER_GET_MODULE_INDEX(module_id);
struct lib_manager_mod_ctx *ctx = lib_manager_get_mod_ctx(module_id);
const struct sof_man_module_manifest *mod_manifest;
const struct sof_module_api_build_info *buildinfo;

tr_dbg(&lib_manager_tr, "llext_manager_allocate_module(): mod_id: %#x",
Expand All @@ -254,31 +253,34 @@ uintptr_t llext_manager_allocate_module(struct processing_module *proc,
mod = (struct sof_man_module *)((char *)desc + SOF_MAN_MODULE_OFFSET(entry_index));

ret = llext_manager_link(desc, mod, module_id, &proc->priv, (const void **)&buildinfo,
&mod_manifest);
if (ret < 0)
return 0;

/* Check if module is NOT native */
if (buildinfo->format != SOF_MODULE_API_BUILD_INFO_FORMAT ||
buildinfo->api_version_number.full != SOF_MODULE_API_CURRENT_VERSION) {
tr_err(&lib_manager_tr,
"llext_manager_allocate_module(): Unsupported module API version");
return -ENOEXEC;
}

/* Map .text and the rest as .data */
ret = llext_manager_load_module(module_id, mod);
&ctx->mod_manifest);
if (ret < 0)
return 0;

ret = llext_manager_allocate_module_bss(module_id, mod);
if (ret < 0) {
tr_err(&lib_manager_tr,
"llext_manager_allocate_module(): module allocation failed: %d", ret);
return 0;
if (!ret) {
/* First instance: check that the module is native */
if (buildinfo->format != SOF_MODULE_API_BUILD_INFO_FORMAT ||
buildinfo->api_version_number.full != SOF_MODULE_API_CURRENT_VERSION) {
tr_err(&lib_manager_tr,
"llext_manager_allocate_module(): Unsupported module API version");
return -ENOEXEC;
}

/* Map .text and the rest as .data */
ret = llext_manager_load_module(module_id, mod);
if (ret < 0)
return 0;

ret = llext_manager_allocate_module_bss(module_id, mod);
if (ret < 0) {
tr_err(&lib_manager_tr,
"llext_manager_allocate_module(): module allocation failed: %d",
ret);
return 0;
}
}

return mod_manifest->module.entry_point;
return ctx->mod_manifest->module.entry_point;
}

int llext_manager_free_module(const uint32_t component_id)
Expand Down

0 comments on commit 97182d0

Please sign in to comment.