Lines Matching +full:bad +full:- +full:key +full:- +full:1
4 * SPDX-License-Identifier: Apache-2.0
21 #include <zephyr/sys/libc-hooks.h>
25 #include <zephyr/linker/linker-defs.h>
44 * non-recursive. Rather than try to redesign as part of
55 /* On ARM & ARC MPU & RISC-V PMP we may have two different alignment requirement
86 /* -fdata-sections doesn't work right except in very recent in otype_to_str()
92 /* otype-to-str.h is generated automatically during build by in otype_to_str()
98 #include <zephyr/otype-to-str.h> in otype_to_str()
126 __ASSERT(obj->type == K_OBJ_THREAD_STACK_ELEMENT, in z_priv_stack_find()
127 "bad stack object"); in z_priv_stack_find()
129 return obj->data.stack_data->priv; in z_priv_stack_find()
136 * Note that dyn_obj->data is where the kernel object resides
196 #include <zephyr/otype-to-size.h> in obj_size_get()
228 k_spinlock_key_t key; in dyn_object_find() local
235 key = k_spin_lock(&lists_lock); in dyn_object_find()
238 if (node->kobj.name == obj) { in dyn_object_find()
247 k_spin_unlock(&lists_lock, key); in dyn_object_find()
279 *tidx = base + (idx - 1); in thread_idx_alloc()
284 _thread_idx_map[i] &= ~(BIT(idx - 1)); in thread_idx_alloc()
340 dyn->data = z_thread_aligned_alloc(DYN_OBJ_DATA_ALIGN_K_THREAD_STACK, in dynamic_object_create()
342 if (dyn->data == NULL) { in dynamic_object_create()
349 ((uint8_t *)dyn->data + adjusted_size - sizeof(*stack_data)); in dynamic_object_create()
350 stack_data->priv = (uint8_t *)dyn->data; in dynamic_object_create()
351 stack_data->size = adjusted_size; in dynamic_object_create()
352 dyn->kobj.data.stack_data = stack_data; in dynamic_object_create()
354 dyn->kobj.name = (void *)ROUND_UP( in dynamic_object_create()
355 ((uint8_t *)dyn->data + CONFIG_PRIVILEGED_STACK_SIZE), in dynamic_object_create()
358 dyn->kobj.name = dyn->data; in dynamic_object_create()
361 dyn->kobj.name = dyn->data; in dynamic_object_create()
362 dyn->kobj.data.stack_size = adjusted_size; in dynamic_object_create()
365 dyn->data = z_thread_aligned_alloc(align, obj_size_get(otype) + size); in dynamic_object_create()
366 if (dyn->data == NULL) { in dynamic_object_create()
367 k_free(dyn->data); in dynamic_object_create()
370 dyn->kobj.name = dyn->data; in dynamic_object_create()
373 dyn->kobj.type = otype; in dynamic_object_create()
374 dyn->kobj.flags = 0; in dynamic_object_create()
375 (void)memset(dyn->kobj.perms, 0, CONFIG_MAX_THREAD_BYTES); in dynamic_object_create()
377 k_spinlock_key_t key = k_spin_lock(&lists_lock); in dynamic_object_create() local
379 sys_dlist_append(&obj_list, &dyn->dobj_list); in dynamic_object_create()
380 k_spin_unlock(&lists_lock, key); in dynamic_object_create()
382 return &dyn->kobj; in dynamic_object_create()
402 LOG_ERR("bad object type %d requested", otype); in z_object_alloc()
434 zo->data.thread_id = tidx; in z_object_alloc()
445 zo->flags |= K_OBJ_FLAG_ALLOC; in z_object_alloc()
447 return zo->name; in z_object_alloc()
469 k_spinlock_key_t key = k_spin_lock(&objfree_lock); in k_object_free() local
473 sys_dlist_remove(&dyn->dobj_list); in k_object_free()
475 if (dyn->kobj.type == K_OBJ_THREAD) { in k_object_free()
476 thread_idx_free(dyn->kobj.data.thread_id); in k_object_free()
479 k_spin_unlock(&objfree_lock, key); in k_object_free()
482 k_free(dyn->data); in k_object_free()
496 /* The cast to pointer-to-non-const violates MISRA in k_object_find()
502 ret = &dyn->kobj; in k_object_find()
515 k_spinlock_key_t key = k_spin_lock(&lists_lock); in k_object_wordlist_foreach() local
518 func(&obj->kobj, context); in k_object_wordlist_foreach()
520 k_spin_unlock(&lists_lock, key); in k_object_wordlist_foreach()
531 return -1; in thread_index_get()
534 return ko->data.thread_id; in thread_index_get()
539 k_spinlock_key_t key = k_spin_lock(&obj_lock); in unref_check() local
541 sys_bitfield_clear_bit((mem_addr_t)&ko->perms, index); in unref_check()
544 if ((ko->flags & K_OBJ_FLAG_ALLOC) == 0U) { in unref_check()
556 if (ko->perms[i] != 0U) { in unref_check()
566 switch (ko->type) { in unref_check()
569 k_pipe_cleanup((struct k_pipe *)ko->name); in unref_check()
573 k_msgq_cleanup((struct k_msgq *)ko->name); in unref_check()
576 k_stack_cleanup((struct k_stack *)ko->name); in unref_check()
583 sys_dlist_remove(&dyn->dobj_list); in unref_check()
584 k_free(dyn->data); in unref_check()
588 k_spin_unlock(&obj_lock, key); in unref_check()
595 if (sys_bitfield_test_bit((mem_addr_t)&ko->perms, ctx->parent_id) && in wordlist_cb()
596 ((struct k_thread *)ko->name != ctx->parent)) { in wordlist_cb()
597 sys_bitfield_set_bit((mem_addr_t)&ko->perms, ctx->child_id); in wordlist_cb()
609 if ((ctx.parent_id != -1) && (ctx.child_id != -1)) { in k_thread_perms_inherit()
618 if (index != -1) { in k_thread_perms_set()
619 sys_bitfield_set_bit((mem_addr_t)&ko->perms, index); in k_thread_perms_set()
627 if (index != -1) { in k_thread_perms_clear()
628 sys_bitfield_clear_bit((mem_addr_t)&ko->perms, index); in k_thread_perms_clear()
644 if ((int)index != -1) { in k_thread_perms_all_clear()
653 if ((ko->flags & K_OBJ_FLAG_PUBLIC) != 0U) { in thread_perms_test()
654 return 1; in thread_perms_test()
658 if (index != -1) { in thread_perms_test()
659 return sys_bitfield_test_bit((mem_addr_t)&ko->perms, index); in thread_perms_test()
669 otype_to_str(ko->type), ko->name); in dump_permission_error()
670 LOG_HEXDUMP_ERR(ko->perms, sizeof(ko->perms), "permission bitmap"); in dump_permission_error()
677 case -EBADF: in k_object_dump_error()
683 otype_to_str(ko->type)); in k_object_dump_error()
686 case -EPERM: in k_object_dump_error()
689 case -EINVAL: in k_object_dump_error()
692 case -EADDRINUSE: in k_object_dump_error()
729 ko->flags |= K_OBJ_FLAG_PUBLIC; in k_object_access_all_grant()
737 ((otype != K_OBJ_ANY) && (ko->type != otype)))) { in k_object_validate()
738 return -EBADF; in k_object_validate()
745 return -EPERM; in k_object_validate()
751 if (unlikely((ko->flags & K_OBJ_FLAG_INITIALIZED) == 0U)) { in k_object_validate()
752 return -EINVAL; in k_object_validate()
756 if (unlikely((ko->flags & K_OBJ_FLAG_INITIALIZED) != 0U)) { in k_object_validate()
757 return -EADDRINUSE; in k_object_validate()
787 /* Allows non-initialization system calls to be made on this object */ in k_object_init()
788 ko->flags |= K_OBJ_FLAG_INITIALIZED; in k_object_init()
796 (void)memset(ko->perms, 0, sizeof(ko->perms)); in k_object_recycle()
798 ko->flags |= K_OBJ_FLAG_INITIALIZED; in k_object_recycle()
812 ko->flags &= ~K_OBJ_FLAG_INITIALIZED; in k_object_uninit()
879 if (size_add_overflow(actual_len, 1, &actual_len)) { in k_usermode_string_alloc_copy()
891 ret[actual_len - 1U] = '\0'; in k_usermode_string_alloc_copy()
913 if (size_add_overflow(actual_len, 1, &actual_len)) { in k_usermode_string_copy()
922 dst[actual_len - 1] = '\0'; in k_usermode_string_copy()
950 /* During pre-kernel init, z_sys_post_kernel == false, but in app_shmem_bss_zero()
952 * In post-kernel init, z_sys_post_kernel == true, in app_shmem_bss_zero()
956 if (((uint8_t *)region->bss_start >= (uint8_t *)_app_smem_pinned_start) && in app_shmem_bss_zero()
957 ((uint8_t *)region->bss_start < (uint8_t *)_app_smem_pinned_end)) { in app_shmem_bss_zero()
964 (void)memset(region->bss_start, 0, region->bss_size); in app_shmem_bss_zero()
997 LOG_ERR("Bad system call id %" PRIuPTR " invoked", bad_id); in handler_bad_syscall()