diff --git a/zephyr/lib/vpage.c b/zephyr/lib/vpage.c index afc93035f3e1..a4d05dee0237 100644 --- a/zephyr/lib/vpage.c +++ b/zephyr/lib/vpage.c @@ -572,16 +572,18 @@ __cold static int vpage_init(void) k_mutex_init(&vpage_ctx.lock); - if (start + library_l2_size + CONFIG_MM_DRV_PAGE_SIZE <= l2_end) { + if (!IS_ENABLED(CONFIG_LLEXT_TYPE_ELF_RELOCATABLE) && + start + library_l2_size + CONFIG_MM_DRV_PAGE_SIZE <= l2_end) { /* virtual heap and library regions fit in L2, vpages get the rest */ end = l2_end - library_l2_size; } else { /* - * Small L2 (e.g. NVL-S): the virtual heap and library regions are only - * virtual address space backed on demand, so they need not fit in L2 - * together with the vpages. Use the virtual space up to the library - * region (or the end of virtual memory) and cap it below by the - * physical L2 left after the image, as vpages can never use more. + * Relocatable LLEXTs or small L2 (e.g. NVL-S / MTL with virtual heap): + * the virtual heap and library regions are only virtual address space + * backed on demand, so they need not fit in L2 together with the + * vpages. Use the virtual space up to the library region (or the end + * of virtual memory) and cap it below by the physical L2 left after + * the image, as vpages can never use more. * Using pages beyond physical L2 needs the Zephyr TLB driver to map * the uncached alias too, see * https://github.com/zephyrproject-rtos/zephyr/pull/122801