Changeset ebb1489 in mainline for kernel/generic/src
- Timestamp:
- 2024-10-13T08:23:40Z (19 months ago)
- Parents:
- 2a0c827c (diff), b3b79981 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - git-author:
- boba-buba <120932204+boba-buba@…> (2024-10-13 08:23:40)
- git-committer:
- GitHub <noreply@…> (2024-10-13 08:23:40)
- Location:
- kernel/generic/src
- Files:
-
- 6 edited
-
lib/ubsan.c (modified) (2 diffs)
-
main/kinit.c (modified) (1 diff)
-
main/uinit.c (modified) (1 diff)
-
mm/malloc.c (modified) (1 diff)
-
proc/program.c (modified) (3 diffs)
-
proc/thread.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/lib/ubsan.c
r2a0c827c rebb1489 13 13 14 14 #define PRINTF(...) printf(__VA_ARGS__) 15 #define ubsan_panic() panic("... aborting ...")16 15 17 16 struct source_location { … … 115 114 void __ubsan_handle_builtin_unreachable(struct unreachable_data *data); 116 115 116 /* A real function for potential breakpoint location. */ 117 __attribute__((noinline)) 118 static void ubsan_panic(void) 119 { 120 panic("... aborting ..."); 121 } 122 117 123 static void print_loc(const char *func, struct source_location *loc) 118 124 { -
kernel/generic/src/main/kinit.c
r2a0c827c rebb1489 296 296 } 297 297 298 } else if (i == init.cnt - 1) { 299 /* 300 * Assume the last task is the RAM disk. 301 */ 298 } else if (str_cmp(name, "initrd.img") == 0) { 302 299 init_rd((void *) init.tasks[i].paddr, init.tasks[i].size); 303 300 } else { -
kernel/generic/src/main/uinit.c
r2a0c827c rebb1489 60 60 #endif 61 61 62 uspace_arg_t *uarg = arg; 63 uspace_arg_t local_uarg; 64 65 local_uarg.uspace_entry = uarg->uspace_entry; 66 local_uarg.uspace_stack = uarg->uspace_stack; 67 local_uarg.uspace_stack_size = uarg->uspace_stack_size; 68 local_uarg.uspace_uarg = uarg->uspace_uarg; 69 local_uarg.uspace_thread_function = USPACE_NULL; 70 local_uarg.uspace_thread_arg = USPACE_NULL; 71 62 uinit_arg_t *uarg = arg; 63 sysarg_t pc = uarg->pc; 64 sysarg_t sp = uarg->sp; 72 65 free(uarg); 73 66 74 userspace( &local_uarg);67 userspace(pc, sp); 75 68 } 76 69 -
kernel/generic/src/mm/malloc.c
r2a0c827c rebb1489 211 211 void *realloc(void *old_obj, size_t new_size) 212 212 { 213 if (new_size == 0) 214 new_size = 1; 215 213 216 if (!old_obj) 214 217 return malloc(new_size); -
kernel/generic/src/proc/program.c
r2a0c827c rebb1489 53 53 #include <syscall/copy.h> 54 54 #include <proc/program.h> 55 #include <userspace.h> 55 56 56 57 /** … … 72 73 errno_t program_create(as_t *as, uspace_addr_t entry_addr, char *name, program_t *prg) 73 74 { 74 uspace_arg_t *kernel_uarg = (uspace_arg_t *) 75 malloc(sizeof(uspace_arg_t)); 75 uinit_arg_t *kernel_uarg = malloc(sizeof(uinit_arg_t)); 76 76 if (!kernel_uarg) 77 77 return ENOMEM; … … 104 104 } 105 105 106 kernel_uarg->uspace_entry = entry_addr; 107 kernel_uarg->uspace_stack = virt; 108 kernel_uarg->uspace_stack_size = STACK_SIZE_USER; 109 kernel_uarg->uspace_thread_function = USPACE_NULL; 110 kernel_uarg->uspace_thread_arg = USPACE_NULL; 111 kernel_uarg->uspace_uarg = USPACE_NULL; 106 kernel_uarg->pc = entry_addr; 107 kernel_uarg->sp = arch_get_initial_sp(virt, STACK_SIZE_USER); 112 108 113 109 /* -
kernel/generic/src/proc/thread.c
r2a0c827c rebb1489 944 944 945 945 /** Process syscall to create new thread. 946 * 947 */ 948 sys_errno_t sys_thread_create(uspace_ptr_uspace_arg_t uspace_uarg, uspace_ptr_char uspace_name, 949 size_t name_len, uspace_ptr_thread_id_t uspace_thread_id) 946 * The started thread will have initial pc and sp set to the exact values passed 947 * to the syscall. The kernel will not touch any stack data below the stack 948 * pointer, but some architectures may require some space to be available 949 * for use above it. See userspace() in kernel, and <libarch/thread.h> in libc. 950 * 951 */ 952 sys_errno_t sys_thread_create(sysarg_t pc, sysarg_t sp, 953 uspace_ptr_char uspace_name, size_t name_len) 950 954 { 951 955 if (name_len > THREAD_NAME_BUFLEN - 1) … … 963 967 * In case of success, kernel_uarg will be freed in uinit(). 964 968 */ 965 uspace_arg_t *kernel_uarg = 966 (uspace_arg_t *) malloc(sizeof(uspace_arg_t)); 969 uinit_arg_t *kernel_uarg = malloc(sizeof(uinit_arg_t)); 967 970 if (!kernel_uarg) 968 971 return (sys_errno_t) ENOMEM; 969 972 970 rc = copy_from_uspace(kernel_uarg, uspace_uarg, sizeof(uspace_arg_t)); 971 if (rc != EOK) { 972 free(kernel_uarg); 973 return (sys_errno_t) rc; 974 } 973 kernel_uarg->pc = pc; 974 kernel_uarg->sp = sp; 975 976 // TODO: fix some unnecessary inconsistencies between architectures 975 977 976 978 thread_t *thread = thread_create(uinit, kernel_uarg, TASK, 977 979 THREAD_FLAG_USPACE | THREAD_FLAG_NOATTACH, namebuf); 978 if (thread) { 979 if (uspace_thread_id) { 980 rc = copy_to_uspace(uspace_thread_id, &thread->tid, 981 sizeof(thread->tid)); 982 if (rc != EOK) { 983 /* 984 * We have encountered a failure, but the thread 985 * has already been created. We need to undo its 986 * creation now. 987 */ 988 989 /* 990 * The new thread structure is initialized, but 991 * is still not visible to the system. 992 * We can safely deallocate it. 993 */ 994 slab_free(thread_cache, thread); 995 free(kernel_uarg); 996 997 return (sys_errno_t) rc; 998 } 999 } 980 if (!thread) { 981 free(kernel_uarg); 982 return (sys_errno_t) ENOMEM; 983 } 1000 984 1001 985 #ifdef CONFIG_UDEBUG 1002 /*1003 * Generate udebug THREAD_B event and attach the thread.1004 * This must be done atomically (with the debug locks held),1005 * otherwise we would either miss some thread or receive1006 * THREAD_B events for threads that already existed1007 * and could be detected with THREAD_READ before.1008 */1009 udebug_thread_b_event_attach(thread, TASK);986 /* 987 * Generate udebug THREAD_B event and attach the thread. 988 * This must be done atomically (with the debug locks held), 989 * otherwise we would either miss some thread or receive 990 * THREAD_B events for threads that already existed 991 * and could be detected with THREAD_READ before. 992 */ 993 udebug_thread_b_event_attach(thread, TASK); 1010 994 #else 1011 thread_attach(thread, TASK);995 thread_attach(thread, TASK); 1012 996 #endif 1013 thread_start(thread); 1014 thread_put(thread); 1015 1016 return 0; 1017 } else 1018 free(kernel_uarg); 1019 1020 return (sys_errno_t) ENOMEM; 997 thread_start(thread); 998 thread_put(thread); 999 1000 return (sys_errno_t) EOK; 1021 1001 } 1022 1002
Note:
See TracChangeset
for help on using the changeset viewer.
