From: guenther Date: Tue, 7 Dec 2021 17:51:04 +0000 (+0000) Subject: Continue to delete emulation support: we only have one sigcode and X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5a72e03e46ccd9c455c0f528063a5685a6fada00;p=openbsd Continue to delete emulation support: we only have one sigcode and sigobject. Just use the existing globals for the former and use a global for the latter. ok jsg@ kettenis@ --- diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c index aa789cc7057..40d19dfeb69 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.162 2021/12/07 04:19:24 guenther Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.163 2021/12/07 17:51:04 guenther Exp $ */ /* * Copyright (c) 1996 Per Fogelstrom @@ -104,7 +104,6 @@ int exec_elf_fixup(struct proc *, struct exec_package *); int elf_os_pt_note_name(Elf_Note *); int elf_os_pt_note(struct proc *, struct exec_package *, Elf_Ehdr *, int *); -extern char sigcode[], esigcode[], sigcoderet[]; #ifdef SYSCALL_DEBUG extern char *syscallnames[]; #endif @@ -136,9 +135,6 @@ struct emul emul_elf = { setregs, exec_elf_fixup, coredump_elf, - sigcode, - esigcode, - sigcoderet }; #define ELF_NOTE_NAME_OPENBSD 0x01 diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 15e4f928d30..8060a6e457a 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.310 2021/12/07 04:19:24 guenther Exp $ */ +/* $OpenBSD: init_main.c,v 1.311 2021/12/07 17:51:04 guenther Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -154,7 +154,6 @@ void timeout_proc_init(void); void pool_gc_pages(void *); void percpu_init(void); -extern char sigcode[], esigcode[], sigcoderet[]; #ifdef SYSCALL_DEBUG extern char *syscallnames[]; #endif @@ -173,9 +172,6 @@ struct emul emul_native = { setregs, NULL, /* fixup */ NULL, /* coredump */ - sigcode, - esigcode, - sigcoderet }; #ifdef DIAGNOSTIC diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index f3a8f641540..c3bbc5b178e 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exec.c,v 1.225 2021/12/07 04:19:24 guenther Exp $ */ +/* $OpenBSD: kern_exec.c,v 1.226 2021/12/07 17:51:04 guenther Exp $ */ /* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */ /*- @@ -67,6 +67,7 @@ #include +struct uvm_object *sigobject; /* shared sigcode object */ struct uvm_object *timekeep_object; struct timekeep *timekeep; @@ -80,7 +81,7 @@ const struct kmem_va_mode kv_exec = { /* * Map the shared signal code. */ -int exec_sigcode_map(struct process *, struct emul *); +int exec_sigcode_map(struct process *); /* * Map the shared timekeep page. @@ -691,7 +692,7 @@ sys_execve(struct proc *p, void *v, register_t *retval) #endif /* map the process's signal trampoline code */ - if (exec_sigcode_map(pr, pack.ep_emul)) + if (exec_sigcode_map(pr)) goto free_pack_abort; #ifdef __HAVE_EXEC_MD_MAP @@ -818,14 +819,15 @@ copyargs(struct exec_package *pack, struct ps_strings *arginfo, void *stack, } int -exec_sigcode_map(struct process *pr, struct emul *e) +exec_sigcode_map(struct process *pr) { + extern char sigcode[], esigcode[], sigcoderet[]; vsize_t sz; - sz = (vaddr_t)e->e_esigcode - (vaddr_t)e->e_sigcode; + sz = (vaddr_t)esigcode - (vaddr_t)sigcode; /* - * If we don't have a sigobject for this emulation, create one. + * If we don't have a sigobject yet, create one. * * sigobject is an anonymous memory object (just like SYSV shared * memory) that we keep a permanent reference to and that we map @@ -835,20 +837,20 @@ exec_sigcode_map(struct process *pr, struct emul *e) * Then we map it with PROT_READ|PROT_EXEC into the process just * the way sys_mmap would map it. */ - if (e->e_sigobject == NULL) { + if (sigobject == NULL) { extern int sigfillsiz; extern u_char sigfill[]; size_t off, left; vaddr_t va; int r; - e->e_sigobject = uao_create(sz, 0); - uao_reference(e->e_sigobject); /* permanent reference */ + sigobject = uao_create(sz, 0); + uao_reference(sigobject); /* permanent reference */ - if ((r = uvm_map(kernel_map, &va, round_page(sz), e->e_sigobject, + if ((r = uvm_map(kernel_map, &va, round_page(sz), sigobject, 0, 0, UVM_MAPFLAG(PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE, MAP_INHERIT_SHARE, MADV_RANDOM, 0)))) { - uao_detach(e->e_sigobject); + uao_detach(sigobject); return (ENOMEM); } @@ -858,23 +860,22 @@ exec_sigcode_map(struct process *pr, struct emul *e) memcpy((caddr_t)va + off, sigfill, chunk); left -= chunk; } - memcpy((caddr_t)va, e->e_sigcode, sz); + memcpy((caddr_t)va, sigcode, sz); uvm_unmap(kernel_map, va, va + round_page(sz)); } pr->ps_sigcode = 0; /* no hint */ - uao_reference(e->e_sigobject); + uao_reference(sigobject); if (uvm_map(&pr->ps_vmspace->vm_map, &pr->ps_sigcode, round_page(sz), - e->e_sigobject, 0, 0, UVM_MAPFLAG(PROT_READ | PROT_EXEC, + sigobject, 0, 0, UVM_MAPFLAG(PROT_READ | PROT_EXEC, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_INHERIT_COPY, MADV_RANDOM, UVM_FLAG_COPYONW | UVM_FLAG_SYSCALL))) { - uao_detach(e->e_sigobject); + uao_detach(sigobject); return (ENOMEM); } /* Calculate PC at point of sigreturn entry */ - pr->ps_sigcoderet = pr->ps_sigcode + - (pr->ps_emul->e_esigret - pr->ps_emul->e_sigcode); + pr->ps_sigcoderet = pr->ps_sigcode + (sigcoderet - sigcode); return (0); } diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 1f6b5b780dd..73bd2aa5bbc 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.319 2021/12/07 04:19:24 guenther Exp $ */ +/* $OpenBSD: proc.h,v 1.320 2021/12/07 17:51:04 guenther Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -105,10 +105,6 @@ struct emul { u_long, register_t *); int (*e_fixup)(struct proc *, struct exec_package *); int (*e_coredump)(struct proc *, void *cookie); - char *e_sigcode; /* Start of sigcode */ - char *e_esigcode; /* End of sigcode */ - char *e_esigret; /* sigaction RET position */ - struct uvm_object *e_sigobject; /* shared sigcode object */ }; /*