Lines Matching +full:permission +full:- +full:flags

5  * SPDX-License-Identifier: Apache-2.0
38 ext->mem_parts[mem_idx].start = start; in llext_init_mem_part()
39 ext->mem_parts[mem_idx].size = len; in llext_init_mem_part()
43 ext->mem_parts[mem_idx].attr = K_MEM_PARTITION_P_RX_U_RX; in llext_init_mem_part()
47 ext->mem_parts[mem_idx].attr = K_MEM_PARTITION_P_RW_U_RW; in llext_init_mem_part()
50 ext->mem_parts[mem_idx].attr = K_MEM_PARTITION_P_RO_U_RO; in llext_init_mem_part()
66 if (!ldr->sects[mem_idx].sh_size) { in llext_copy_section()
69 ext->mem_size[mem_idx] = ldr->sects[mem_idx].sh_size; in llext_copy_section()
72 if (ldr->sects[mem_idx].sh_type != SHT_NOBITS) { in llext_copy_section()
74 ext->mem[mem_idx] = llext_peek(ldr, ldr->sects[mem_idx].sh_offset); in llext_copy_section()
75 if (ext->mem[mem_idx]) { in llext_copy_section()
76 llext_init_mem_part(ext, mem_idx, (uintptr_t)ext->mem[mem_idx], in llext_copy_section()
77 ldr->sects[mem_idx].sh_size); in llext_copy_section()
78 ext->mem_on_heap[mem_idx] = false; in llext_copy_section()
81 } else if (ldr_parm && ldr_parm->pre_located) { in llext_copy_section()
84 * we add a check to make it future-proof in llext_copy_section()
86 ext->mem[mem_idx] = NULL; in llext_copy_section()
87 ext->mem_on_heap[mem_idx] = false; in llext_copy_section()
92 if (ldr_parm && ldr_parm->pre_located) { in llext_copy_section()
93 return -EFAULT; in llext_copy_section()
98 * we are after that we can assign memory permission bits on. in llext_copy_section()
101 const uintptr_t sect_alloc = ROUND_UP(ldr->sects[mem_idx].sh_size, LLEXT_PAGE_SIZE); in llext_copy_section()
106 while (sect_alloc < ldr->sects[mem_idx].sh_size) { in llext_copy_section()
112 ext->mem[mem_idx] = llext_aligned_alloc(sect_align, sect_alloc); in llext_copy_section()
113 if (!ext->mem[mem_idx]) { in llext_copy_section()
114 return -ENOMEM; in llext_copy_section()
117 ext->alloc_size += sect_alloc; in llext_copy_section()
119 llext_init_mem_part(ext, mem_idx, (uintptr_t)ext->mem[mem_idx], in llext_copy_section()
122 if (ldr->sects[mem_idx].sh_type == SHT_NOBITS) { in llext_copy_section()
123 memset(ext->mem[mem_idx], 0, ldr->sects[mem_idx].sh_size); in llext_copy_section()
125 ret = llext_seek(ldr, ldr->sects[mem_idx].sh_offset); in llext_copy_section()
130 ret = llext_read(ldr, ext->mem[mem_idx], ldr->sects[mem_idx].sh_size); in llext_copy_section()
136 ext->mem_on_heap[mem_idx] = true; in llext_copy_section()
141 llext_free(ext->mem[mem_idx]); in llext_copy_section()
142 ext->mem[mem_idx] = NULL; in llext_copy_section()
162 if (ext->mem[mem_idx]) { in llext_copy_regions()
181 uint32_t flags; in llext_adjust_mmu_permissions() local
184 addr = ext->mem[mem_idx]; in llext_adjust_mmu_permissions()
185 size = ROUND_UP(ext->mem_size[mem_idx], LLEXT_PAGE_SIZE); in llext_adjust_mmu_permissions()
192 flags = K_MEM_PERM_EXEC; in llext_adjust_mmu_permissions()
199 flags = 0; in llext_adjust_mmu_permissions()
205 k_mem_update_flags(addr, size, flags); in llext_adjust_mmu_permissions()
214 if (ext->mem_size[i] != 0) { in llext_free_regions()
216 k_mem_update_flags(ext->mem[i], in llext_free_regions()
217 ROUND_UP(ext->mem_size[i], LLEXT_PAGE_SIZE), in llext_free_regions()
221 if (ext->mem_on_heap[i]) { in llext_free_regions()
223 llext_free(ext->mem[i]); in llext_free_regions()
224 ext->mem[i] = NULL; in llext_free_regions()
235 if (ext->mem_size[i] == 0) { in llext_add_domain()
238 ret = k_mem_domain_add_partition(domain, &ext->mem_parts[i]); in llext_add_domain()
248 return -ENOSYS; in llext_add_domain()