diff options
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/imgact_aout.c | 1 | ||||
-rw-r--r-- | sys/kern/init_main.c | 1 | ||||
-rw-r--r-- | sys/kern/kern_environment.c | 38 | ||||
-rw-r--r-- | sys/kern/kern_linker.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_mib.c | 5 | ||||
-rw-r--r-- | sys/kern/kern_proc.c | 15 | ||||
-rw-r--r-- | sys/kern/kern_thread.c | 11 | ||||
-rw-r--r-- | sys/kern/makesyscalls.sh | 4 | ||||
-rw-r--r-- | sys/kern/subr_busdma_bufalloc.c | 4 |
9 files changed, 72 insertions, 13 deletions
diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c index edd5f5f..553dc04 100644 --- a/sys/kern/imgact_aout.c +++ b/sys/kern/imgact_aout.c @@ -100,6 +100,7 @@ struct sysentvec aout_sysvec = { .sv_syscallnames = syscallnames, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; #elif defined(__amd64__) diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 6cb5017..201680a 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -415,6 +415,7 @@ struct sysentvec null_sysvec = { .sv_syscallnames = NULL, .sv_schedtail = NULL, .sv_thread_detach = NULL, + .sv_trap = NULL, }; /* diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c index ff453cb..05c4f62 100644 --- a/sys/kern/kern_environment.c +++ b/sys/kern/kern_environment.c @@ -210,12 +210,44 @@ done: return (error); } +/* + * Populate the initial kernel environment. + * + * This is called very early in MD startup, either to provide a copy of the + * environment obtained from a boot loader, or to provide an empty buffer into + * which MD code can store an initial environment using kern_setenv() calls. + * + * If the global envmode is 1, the environment is initialized from the global + * static_env[], regardless of the arguments passed. This implements the env + * keyword described in config(5). In this case env_pos is set to env_len, + * causing kern_setenv() to return -1 (if len > 0) or panic (if len == 0) until + * the dynamic environment is available. The envmode and static_env variables + * are defined in env.c which is generated by config(8). + * + * If len is non-zero, the caller is providing an empty buffer. The caller will + * subsequently use kern_setenv() to add up to len bytes of initial environment + * before the dynamic environment is available. + * + * If len is zero, the caller is providing a pre-loaded buffer containing + * environment strings. Additional strings cannot be added until the dynamic + * environment is available. The memory pointed to must remain stable at least + * until sysinit runs init_dynamic_kenv(). If no initial environment is + * available from the boot loader, passing a NULL pointer allows the static_env + * to be installed if it is configured. + */ void init_static_kenv(char *buf, size_t len) { - kern_envp = buf; - env_len = len; - env_pos = 0; + + if (envmode == 1) { + kern_envp = static_env; + env_len = len; + env_pos = len; + } else { + kern_envp = buf; + env_len = len; + env_pos = 0; + } } /* diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index e379f5f..78eab87 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -71,6 +71,12 @@ SYSCTL_INT(_debug, OID_AUTO, kld_debug, CTLFLAG_RW | CTLFLAG_TUN, TUNABLE_INT("debug.kld_debug", &kld_debug); #endif +/* These variables are used by kernel debuggers to enumerate loaded files. */ +const int kld_off_address = offsetof(struct linker_file, address); +const int kld_off_filename = offsetof(struct linker_file, filename); +const int kld_off_pathname = offsetof(struct linker_file, pathname); +const int kld_off_next = offsetof(struct linker_file, link.tqe_next); + /* * static char *linker_search_path(const char *name, struct mod_depend * *verinfo); diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c index 0307791..ccecbc9 100644 --- a/sys/kern/kern_mib.c +++ b/sys/kern/kern_mib.c @@ -574,6 +574,11 @@ SYSCTL_INT(_debug_sizeof, OID_AUTO, buf, CTLFLAG_RD, SYSCTL_INT(_debug_sizeof, OID_AUTO, kinfo_proc, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, sizeof(struct kinfo_proc), "sizeof(struct kinfo_proc)"); +/* Used by kernel debuggers. */ +const int pcb_size = sizeof(struct pcb); +SYSCTL_INT(_debug_sizeof, OID_AUTO, pcb, CTLFLAG_RD, + SYSCTL_NULL_INT_PTR, sizeof(struct pcb), "sizeof(struct pcb)"); + /* XXX compatibility, remove for 6.0 */ #include <sys/imgact.h> #include <sys/imgact_elf.h> diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index c9b7ca3..6b60840 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -139,6 +139,21 @@ struct sx proctree_lock; struct mtx ppeers_lock; uma_zone_t proc_zone; +/* + * The offset of various fields in struct proc and struct thread. + * These are used by kernel debuggers to enumerate kernel threads and + * processes. + */ +const int proc_off_p_pid = offsetof(struct proc, p_pid); +const int proc_off_p_comm = offsetof(struct proc, p_comm); +const int proc_off_p_list = offsetof(struct proc, p_list); +const int proc_off_p_threads = offsetof(struct proc, p_threads); +const int thread_off_td_tid = offsetof(struct thread, td_tid); +const int thread_off_td_name = offsetof(struct thread, td_name); +const int thread_off_td_oncpu = offsetof(struct thread, td_oncpu); +const int thread_off_td_pcb = offsetof(struct thread, td_pcb); +const int thread_off_td_plist = offsetof(struct thread, td_plist); + int kstack_pages = KSTACK_PAGES; SYSCTL_INT(_kern, OID_AUTO, kstack_pages, CTLFLAG_RD, &kstack_pages, 0, "Kernel stack size in pages"); diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 96f68609ca..c85813b 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include <sys/sched.h> #include <sys/sleepqueue.h> #include <sys/selinfo.h> +#include <sys/syscallsubr.h> #include <sys/sysent.h> #include <sys/turnstile.h> #include <sys/ktr.h> @@ -885,7 +886,6 @@ thread_suspend_check(int return_instead) */ if ((p->p_flag & P_SINGLE_EXIT) && (p->p_singlethread != td)) { PROC_UNLOCK(p); - tidhash_remove(td); /* * Allow Linux emulation layer to do some work @@ -893,13 +893,8 @@ thread_suspend_check(int return_instead) */ if (__predict_false(p->p_sysent->sv_thread_detach != NULL)) (p->p_sysent->sv_thread_detach)(td); - - PROC_LOCK(p); - tdsigcleanup(td); - umtx_thread_exit(td); - PROC_SLOCK(p); - thread_stopped(p); - thread_exit(); + kern_thr_exit(td); + panic("stopped thread did not exit"); } PROC_SLOCK(p); diff --git a/sys/kern/makesyscalls.sh b/sys/kern/makesyscalls.sh index 8be4896..1d3af65 100644 --- a/sys/kern/makesyscalls.sh +++ b/sys/kern/makesyscalls.sh @@ -410,6 +410,10 @@ s/\$//g printf("\t\tuarg[%d] = (intptr_t) p->%s; /* %s */\n", \ i - 1, \ argname[i], arg) > systrace + else if (arg == "union l_semun") + printf("\t\tuarg[%d] = p->%s.buf; /* %s */\n", \ + i - 1, \ + argname[i], arg) > systrace else if (substr(arg, 1, 1) == "u" || arg == "size_t") printf("\t\tuarg[%d] = p->%s; /* %s */\n", \ i - 1, \ diff --git a/sys/kern/subr_busdma_bufalloc.c b/sys/kern/subr_busdma_bufalloc.c index b0b1ba8..c8980e1 100644 --- a/sys/kern/subr_busdma_bufalloc.c +++ b/sys/kern/subr_busdma_bufalloc.c @@ -94,8 +94,8 @@ busdma_bufalloc_create(const char *name, bus_size_t minimum_alignment, for (i = 0, bz = ba->buf_zones, cursize = ba->min_size; i < nitems(ba->buf_zones) && cursize <= MAX_ZONE_BUFSIZE; ++i, ++bz, cursize <<= 1) { - snprintf(bz->name, sizeof(bz->name), "dma %.10s %lu", - name, cursize); + snprintf(bz->name, sizeof(bz->name), "dma %.10s %ju", + name, (uintmax_t)cursize); bz->size = cursize; bz->umazone = uma_zcreate(bz->name, bz->size, NULL, NULL, NULL, NULL, bz->size - 1, zcreate_flags); |