Skip to content

Commit

Permalink
lib_manager: llext_manager: Add const modifier to module manifest poi…
Browse files Browse the repository at this point in the history
…nters

To prevent unintentional modification of a loadable library manifest,
a const modifier has been added to all variables pointing to it.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
  • Loading branch information
softwarecki committed Mar 11, 2024
1 parent 30fd9df commit 61e877f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/include/sof/ipc/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct ipc_comp_dev;
const struct comp_driver *ipc4_get_comp_drv(int module_id);
struct comp_dev *ipc4_get_comp_dev(uint32_t comp_id);
int ipc4_add_comp_dev(struct comp_dev *dev);
const struct comp_driver *ipc4_get_drv(uint8_t *uuid);
const struct comp_driver *ipc4_get_drv(const uint8_t *uuid);
int ipc4_chain_manager_create(struct ipc4_chain_dma *cdma);
int ipc4_chain_dma_state(struct comp_dev *dev, struct ipc4_chain_dma *cdma);
int ipc4_create_chain_dma(struct ipc *ipc, struct ipc4_chain_dma *cdma);
Expand Down
6 changes: 3 additions & 3 deletions src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ int ipc4_chain_manager_create(struct ipc4_chain_dma *cdma)
const struct comp_driver *drv;
struct comp_dev *dev;

drv = ipc4_get_drv((uint8_t *)&uuid);
drv = ipc4_get_drv((const uint8_t *)&uuid);
if (!drv)
return -EINVAL;

Expand Down Expand Up @@ -864,7 +864,7 @@ int ipc4_process_on_core(uint32_t core, bool blocking)
return IPC4_SUCCESS;
}

const struct comp_driver *ipc4_get_drv(uint8_t *uuid)
const struct comp_driver *ipc4_get_drv(const uint8_t *uuid)
{
struct comp_driver_list *drivers = comp_drivers_get();
struct list_item *clist;
Expand Down Expand Up @@ -934,7 +934,7 @@ static const struct comp_driver *ipc4_library_get_drv(int module_id)
mod_uuid = &uuid_map[i];

if (mod_uuid->module_id == module_id)
return ipc4_get_drv((uint8_t *)&mod_uuid->uuid);
return ipc4_get_drv((const uint8_t *)&mod_uuid->uuid);
}

tr_err(&comp_tr, "ipc4_library_get_drv(): Unsupported module ID %#x\n", module_id);
Expand Down
12 changes: 6 additions & 6 deletions src/library_manager/lib_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ static int lib_manager_unload_libcode_modules(const uint32_t module_id,

static void __sparse_cache *lib_manager_get_instance_bss_address(uint32_t module_id,
uint32_t instance_id,
struct sof_man_module *mod)
const struct sof_man_module *mod)
{
uint32_t instance_bss_size =
mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length / mod->instance_max_count;
Expand All @@ -296,7 +296,7 @@ static void __sparse_cache *lib_manager_get_instance_bss_address(uint32_t module
}

static int lib_manager_allocate_module_instance(uint32_t module_id, uint32_t instance_id,
uint32_t is_pages, struct sof_man_module *mod)
uint32_t is_pages, const struct sof_man_module *mod)
{
uint32_t bss_size =
(mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length / mod->instance_max_count)
Expand Down Expand Up @@ -324,7 +324,7 @@ static int lib_manager_allocate_module_instance(uint32_t module_id, uint32_t ins
}

static int lib_manager_free_module_instance(uint32_t module_id, uint32_t instance_id,
struct sof_man_module *mod)
const struct sof_man_module *mod)
{
uint32_t bss_size =
(mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length / mod->instance_max_count)
Expand All @@ -337,7 +337,7 @@ static int lib_manager_free_module_instance(uint32_t module_id, uint32_t instanc
return sys_mm_drv_unmap_region((__sparse_force void *)va_base, bss_size);
}

static bool module_is_llext(struct sof_man_module *mod)
static inline bool module_is_llext(const struct sof_man_module *mod)
{
return mod->type.load_type == SOF_MAN_MOD_TYPE_LLEXT;
}
Expand All @@ -347,7 +347,7 @@ uintptr_t lib_manager_allocate_module(struct processing_module *proc,
const void *ipc_specific_config, const void **buildinfo)
{
struct sof_man_fw_desc *desc;
struct sof_man_module *mod;
const struct sof_man_module *mod;
const struct ipc4_base_module_cfg *base_cfg = ipc_specific_config;
int ret;
uint32_t module_id = IPC4_MOD_ID(ipc_config->id);
Expand Down Expand Up @@ -399,7 +399,7 @@ uintptr_t lib_manager_allocate_module(struct processing_module *proc,
int lib_manager_free_module(const uint32_t component_id)
{
struct sof_man_fw_desc *desc;
struct sof_man_module *mod;
const struct sof_man_module *mod;
const uint32_t module_id = IPC4_MOD_ID(component_id);
uint32_t entry_index = LIB_MANAGER_GET_MODULE_INDEX(module_id);
int ret;
Expand Down
12 changes: 6 additions & 6 deletions src/library_manager/llext_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static int llext_manager_load_data_from_storage(void __sparse_cache *vma, void *
return memcpy_s((__sparse_force void *)vma, size, s_addr, size);
}

static int llext_manager_load_module(uint32_t module_id, struct sof_man_module *mod,
static int llext_manager_load_module(uint32_t module_id, const struct sof_man_module *mod,
struct sof_man_fw_desc *desc)
{
struct lib_manager_mod_ctx *ctx = lib_manager_get_mod_ctx(module_id);
Expand Down Expand Up @@ -116,7 +116,7 @@ static int llext_manager_load_module(uint32_t module_id, struct sof_man_module *
return ret;
}

static int llext_manager_unload_module(uint32_t module_id, struct sof_man_module *mod,
static int llext_manager_unload_module(uint32_t module_id, const struct sof_man_module *mod,
struct sof_man_fw_desc *desc)
{
struct lib_manager_mod_ctx *ctx = lib_manager_get_mod_ctx(module_id);
Expand All @@ -136,13 +136,13 @@ static int llext_manager_unload_module(uint32_t module_id, struct sof_man_module
}

static void __sparse_cache *llext_manager_get_bss_address(uint32_t module_id,
struct sof_man_module *mod)
const struct sof_man_module *mod)
{
return (void __sparse_cache *)mod->segment[SOF_MAN_SEGMENT_BSS].v_base_addr;
}

static int llext_manager_allocate_module_bss(uint32_t module_id,
struct sof_man_module *mod)
const struct sof_man_module *mod)
{
struct lib_manager_mod_ctx *ctx = lib_manager_get_mod_ctx(module_id);
size_t bss_size = ctx->segment_size[SOF_MAN_SEGMENT_BSS];
Expand All @@ -158,7 +158,7 @@ static int llext_manager_allocate_module_bss(uint32_t module_id,
}

static int llext_manager_free_module_bss(uint32_t module_id,
struct sof_man_module *mod)
const struct sof_man_module *mod)
{
struct lib_manager_mod_ctx *ctx = lib_manager_get_mod_ctx(module_id);
size_t bss_size = ctx->segment_size[SOF_MAN_SEGMENT_BSS];
Expand Down Expand Up @@ -275,7 +275,7 @@ uintptr_t llext_manager_allocate_module(struct processing_module *proc,
int llext_manager_free_module(const uint32_t component_id)
{
struct sof_man_fw_desc *desc;
struct sof_man_module *mod;
const struct sof_man_module *mod;
const uint32_t module_id = IPC4_MOD_ID(component_id);
uint32_t entry_index = LIB_MANAGER_GET_MODULE_INDEX(module_id);
int ret;
Expand Down

0 comments on commit 61e877f

Please sign in to comment.