Skip to content

Commit dc27b42

Browse files
lyakhfabiobaltieri
authored andcommitted
llext: skip MMU flag adjustment for pre-located extensions
Extensions with the pre_located flag set, manage memory themselves, including MMU permissions. Skip any such adjustments in LLEXT core. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 828348e commit dc27b42

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

include/zephyr/llext/llext.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ struct llext {
125125
unsigned int sect_cnt;
126126
elf_shdr_t *sect_hdrs;
127127
bool sect_hdrs_on_heap;
128+
bool mmu_permissions_set;
128129
/** @endcond */
129130
};
130131

@@ -152,7 +153,8 @@ struct llext_load_param {
152153
* the memory buffer, when calculating relocation targets. It also
153154
* means, that the application will take care to place the extension at
154155
* those pre-defined addresses, so the LLEXT core doesn't have to do any
155-
* allocation and copying internally.
156+
* allocation and copying internally. Any MMU permission adjustment will
157+
* be done by the application too.
156158
*/
157159
bool pre_located;
158160

subsys/llext/llext_load.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,9 @@ int do_llext_load(struct llext_loader *ldr, struct llext *ext,
756756
goto out;
757757
}
758758

759-
llext_adjust_mmu_permissions(ext);
759+
if (!ldr_parm->pre_located) {
760+
llext_adjust_mmu_permissions(ext);
761+
}
760762

761763
out:
762764
/*

subsys/llext/llext_mem.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,16 @@ void llext_adjust_mmu_permissions(struct llext *ext)
220220
sys_cache_data_flush_range(addr, size);
221221
k_mem_update_flags(addr, size, flags);
222222
}
223+
224+
ext->mmu_permissions_set = true;
223225
#endif
224226
}
225227

226228
void llext_free_regions(struct llext *ext)
227229
{
228230
for (int i = 0; i < LLEXT_MEM_COUNT; i++) {
229231
#ifdef CONFIG_MMU
230-
if (ext->mem_size[i] != 0) {
232+
if (ext->mmu_permissions_set && ext->mem_size[i] != 0) {
231233
/* restore default RAM permissions */
232234
k_mem_update_flags(ext->mem[i],
233235
ROUND_UP(ext->mem_size[i], LLEXT_PAGE_SIZE),

0 commit comments

Comments
 (0)