Skip to content

Commit 9f34d35

Browse files
mem: add initialization of virt memory region for loadable modules
This commit adds initialization of virtual memory region dedicated for loadable modules. This ensures no overlapping with other memory regions possible extension: check when a module is being loaded if it fits into the region Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
1 parent 15f900e commit 9f34d35

File tree

7 files changed

+29
-1
lines changed

7 files changed

+29
-1
lines changed

app/boards/intel_adsp_ace15_mtpm.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ CONFIG_WATCHDOG=y
8383
CONFIG_TIMESLICE_PER_THREAD=y
8484
CONFIG_THREAD_RUNTIME_STATS=y
8585
CONFIG_SCHED_THREAD_USAGE=y
86+
CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2
8687

8788
# Zephyr / device drivers
8889
CONFIG_CLOCK_CONTROL=y

app/boards/intel_adsp_ace20_lnl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ CONFIG_LLEXT_STORAGE_WRITABLE=y
6363
CONFIG_LLEXT_EXPERIMENTAL=y
6464
CONFIG_MODULES=y
6565
CONFIG_TIMING_FUNCTIONS=y
66+
CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2
6667

6768
# Zephyr / device drivers
6869
CONFIG_CLOCK_CONTROL=y

app/boards/intel_adsp_ace30_ptl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ CONFIG_LLEXT=y
6363
CONFIG_LLEXT_STORAGE_WRITABLE=y
6464
CONFIG_LLEXT_EXPERIMENTAL=y
6565
CONFIG_MODULES=y
66+
CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2
6667

6768
# Zephyr / device drivers
6869
CONFIG_CLOCK_CONTROL=y

app/boards/intel_adsp_ace30_wcl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ CONFIG_LLEXT=y
5050
CONFIG_LLEXT_STORAGE_WRITABLE=y
5151
CONFIG_LLEXT_EXPERIMENTAL=y
5252
CONFIG_MODULES=y
53+
CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2
5354

5455
# Zephyr / device drivers
5556
CONFIG_CLOCK_CONTROL=y

src/library_manager/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,10 @@ config LIBRARY_BASE_ADDRESS
5858
automatically but the beginning of that area is platform-specific and
5959
should be set by this option.
6060

61+
config LIBRARY_REGION_SIZE
62+
hex "Base address for memory, dedicated to loadable modules"
63+
default 0x100000
64+
help
65+
Size of the virtual memory region dedicated for loadable modules
66+
6167
endmenu

src/library_manager/llext_manager_dram.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
#include <rtos/alloc.h>
66

77
#include <sof/lib_manager.h>
8+
#include <sof/lib/regions_mm.h>
89
#include <ipc/topology.h>
910

1011
#include <zephyr/llext/buf_loader.h>
1112
#include <zephyr/llext/llext.h>
1213
#include <zephyr/llext/llext_internal.h>
1314
#include <zephyr/logging/log_ctrl.h>
15+
#include <adsp_memory_regions.h>
1416

1517
LOG_MODULE_DECLARE(lib_manager, CONFIG_SOF_LOG_LEVEL);
1618

@@ -331,3 +333,18 @@ int llext_manager_restore_from_dram(void)
331333

332334
return -ENOMEM;
333335
}
336+
337+
static int llext_memory_region_init(void)
338+
{
339+
int ret;
340+
341+
/* add a region for loadable libraries */
342+
ret = adsp_add_virtual_memory_region(CONFIG_LIBRARY_BASE_ADDRESS,
343+
CONFIG_LIBRARY_REGION_SIZE,
344+
VIRTUAL_REGION_LOADABLE_LIBRARIES_ATTR);
345+
346+
return ret;
347+
}
348+
349+
350+
SYS_INIT(llext_memory_region_init, POST_KERNEL, 1);

zephyr/include/sof/lib/regions_mm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
#include <zephyr/sys/mem_blocks.h>
1919

2020
/* Attributes for memory regions */
21-
#define VIRTUAL_REGION_SHARED_HEAP_ATTR 1U /*< region dedicated for shared virtual heap */
21+
#define VIRTUAL_REGION_SHARED_HEAP_ATTR 1U /*< region dedicated for shared virtual heap */
22+
#define VIRTUAL_REGION_LOADABLE_LIBRARIES_ATTR 2U /*< region dedicated for loadable libraries */
2223

2324
/* Dependency on ipc/topology.h created due to memory capability definitions
2425
* that are defined there

0 commit comments

Comments
 (0)