Module Name: src
Committed By: pgoyette
Date: Sun Sep 23 11:23:47 UTC 2018
Modified Files:
src/sys/compat/netbsd32 [pgoyette-compat]: files.netbsd32 netbsd32.h
netbsd32_mod.c
src/sys/kern [pgoyette-compat]: kern_proc.c
src/sys/sys [pgoyette-compat]: compat_stub.h
Added Files:
src/sys/compat/netbsd32 [pgoyette-compat]: netbsd32_kern_proc.c
netbsd32_kern_proc.h
Log Message:
More work on kern_proc_32
To generate a diff of this commit:
cvs rdiff -u -r1.39.14.4 -r1.39.14.5 src/sys/compat/netbsd32/files.netbsd32
cvs rdiff -u -r1.116.2.10 -r1.116.2.11 src/sys/compat/netbsd32/netbsd32.h
cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/netbsd32/netbsd32_kern_proc.c \
src/sys/compat/netbsd32/netbsd32_kern_proc.h
cvs rdiff -u -r1.13.16.13 -r1.13.16.14 src/sys/compat/netbsd32/netbsd32_mod.c
cvs rdiff -u -r1.209.2.3 -r1.209.2.4 src/sys/kern/kern_proc.c
cvs rdiff -u -r1.1.2.35 -r1.1.2.36 src/sys/sys/compat_stub.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/compat/netbsd32/files.netbsd32
diff -u src/sys/compat/netbsd32/files.netbsd32:1.39.14.4 src/sys/compat/netbsd32/files.netbsd32:1.39.14.5
--- src/sys/compat/netbsd32/files.netbsd32:1.39.14.4 Wed Sep 12 04:35:22 2018
+++ src/sys/compat/netbsd32/files.netbsd32 Sun Sep 23 11:23:47 2018
@@ -1,4 +1,4 @@
-# $NetBSD: files.netbsd32,v 1.39.14.4 2018/09/12 04:35:22 pgoyette Exp $
+# $NetBSD: files.netbsd32,v 1.39.14.5 2018/09/23 11:23:47 pgoyette Exp $
#
# config file description for machine-independent netbsd32 compat code.
# included by ports that need it.
@@ -14,6 +14,7 @@ file compat/netbsd32/netbsd32_netbsd.c c
file compat/netbsd32/netbsd32_event.c compat_netbsd32
file compat/netbsd32/netbsd32_execve.c compat_netbsd32
file compat/netbsd32/netbsd32_fs.c compat_netbsd32
+file compat/netbsd32/netbsd32_kern_proc.c compat_netbsd32
file compat/netbsd32/netbsd32_ioctl.c compat_netbsd32
file compat/netbsd32/netbsd32_ipc.c compat_netbsd32
file compat/netbsd32/netbsd32_lwp.c compat_netbsd32
Index: src/sys/compat/netbsd32/netbsd32.h
diff -u src/sys/compat/netbsd32/netbsd32.h:1.116.2.10 src/sys/compat/netbsd32/netbsd32.h:1.116.2.11
--- src/sys/compat/netbsd32/netbsd32.h:1.116.2.10 Sun Sep 23 09:16:49 2018
+++ src/sys/compat/netbsd32/netbsd32.h Sun Sep 23 11:23:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32.h,v 1.116.2.10 2018/09/23 09:16:49 pgoyette Exp $ */
+/* $NetBSD: netbsd32.h,v 1.116.2.11 2018/09/23 11:23:47 pgoyette Exp $ */
/*
* Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
@@ -1181,6 +1181,13 @@ struct netbsd32_modctl_args;
MODULE_HOOK(compat32_80_modctl_hook,
(struct lwp *, const struct netbsd32_modctl_args *, register_t *));
+/*
+ * kern_proc compatability for netbsd32
+ */
+struct ps_strings;
+MODULE_HOOK2(kern_proc_32_hook, (struct proc *, struct ps_strings *),
+ (char **, size_t, vaddr_t *));
+
/*
* Finally, declare emul_netbsd32 as this is needed in lots of
* places when calling syscall_{,dis}establish()
Index: src/sys/compat/netbsd32/netbsd32_mod.c
diff -u src/sys/compat/netbsd32/netbsd32_mod.c:1.13.16.13 src/sys/compat/netbsd32/netbsd32_mod.c:1.13.16.14
--- src/sys/compat/netbsd32/netbsd32_mod.c:1.13.16.13 Tue Sep 18 23:03:54 2018
+++ src/sys/compat/netbsd32/netbsd32_mod.c Sun Sep 23 11:23:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_mod.c,v 1.13.16.13 2018/09/18 23:03:54 pgoyette Exp $ */
+/* $NetBSD: netbsd32_mod.c,v 1.13.16.14 2018/09/23 11:23:47 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.13.16.13 2018/09/18 23:03:54 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.13.16.14 2018/09/23 11:23:47 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_execfmt.h"
@@ -47,12 +47,14 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mod
#include <sys/module_hook.h>
#include <compat/netbsd32/netbsd32_sysctl.h>
+#include <compat/netbsd32/netbsd32_kern_proc.h>
#include <compat/netbsd32/netbsd32_exec.h>
#define ELF32_AUXSIZE (howmany(ELF_AUX_ENTRIES * sizeof(Aux32Info), \
sizeof(Elf32_Addr)) + MAXPATHLEN + ALIGN(1))
struct compat32_80_modctl_hook_t compat32_80_modctl_hook;
+struct kern_proc_32_hook_t kern_proc_32_hook;
# define DEPS1 "ksem,coredump,compat_util"
@@ -111,16 +113,19 @@ compat_netbsd32_modcmd(modcmd_t cmd, voi
if (error == 0) {
netbsd32_sysctl_init();
netbsd32_machdep_md_init();
+ kern_proc_32_init();
}
return error;
case MODULE_CMD_FINI:
netbsd32_machdep_md_fini();
netbsd32_sysctl_fini();
+ kern_proc_32_fini();
error = exec_remove(netbsd32_execsw,
__arraycount(netbsd32_execsw));
if (error) {
+ kern_proc_32_init();
netbsd32_sysctl_init();
netbsd32_machdep_md_init();
}
Index: src/sys/kern/kern_proc.c
diff -u src/sys/kern/kern_proc.c:1.209.2.3 src/sys/kern/kern_proc.c:1.209.2.4
--- src/sys/kern/kern_proc.c:1.209.2.3 Thu Sep 6 06:56:42 2018
+++ src/sys/kern/kern_proc.c Sun Sep 23 11:23:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_proc.c,v 1.209.2.3 2018/09/06 06:56:42 pgoyette Exp $ */
+/* $NetBSD: kern_proc.c,v 1.209.2.4 2018/09/23 11:23:47 pgoyette Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,18 +62,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.209.2.3 2018/09/06 06:56:42 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.209.2.4 2018/09/23 11:23:47 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_kstack.h"
#include "opt_maxuprc.h"
#include "opt_dtrace.h"
-#include "opt_compat_netbsd32.h"
-#endif
-
-#if defined(__HAVE_COMPAT_NETBSD32) && !defined(COMPAT_NETBSD32) \
- && !defined(_RUMPKERNEL)
-#define COMPAT_NETBSD32
#endif
#include <sys/param.h>
@@ -105,14 +99,11 @@ __KERNEL_RCSID(0, "$NetBSD: kern_proc.c,
#include <sys/sysctl.h>
#include <sys/exec.h>
#include <sys/cpu.h>
+#include <sys/compat_stub.h>
#include <uvm/uvm_extern.h>
#include <uvm/uvm.h>
-#ifdef COMPAT_NETBSD32
-#include <compat/netbsd32/netbsd32.h>
-#endif
-
/*
* Process lists.
*/
@@ -1862,25 +1853,26 @@ sysctl_doeproc(SYSCTLFN_ARGS)
return error;
}
+/*
+ * compat_netbsd32 hooks
+ */
+MODULE_CALL_HOOK_DECL(kern_proc_32_hook, f1,
+ (struct proc *p, struct ps_strings *s), (p, s), enosys());
+MODULE_CALL_HOOK(kern_proc_32_hook, f1,
+ (struct proc *p, struct ps_strings *s), (p, s), enosys());
+
+MODULE_CALL_HOOK_DECL(kern_proc_32_hook, f2,
+ (char **argv, size_t i, vaddr_t *base), (argv, i, base), enosys());
+MODULE_CALL_HOOK(kern_proc_32_hook, f2,
+ (char **argv, size_t i, vaddr_t *base), (argv, i, base), enosys());
+
int
copyin_psstrings(struct proc *p, struct ps_strings *arginfo)
{
-#ifdef COMPAT_NETBSD32
- if (p->p_flag & PK_32) {
- struct ps_strings32 arginfo32;
-
- int error = copyin_proc(p, (void *)p->p_psstrp, &arginfo32,
- sizeof(arginfo32));
- if (error)
- return error;
- arginfo->ps_argvstr = (void *)(uintptr_t)arginfo32.ps_argvstr;
- arginfo->ps_nargvstr = arginfo32.ps_nargvstr;
- arginfo->ps_envstr = (void *)(uintptr_t)arginfo32.ps_envstr;
- arginfo->ps_nenvstr = arginfo32.ps_nenvstr;
- return 0;
- }
-#endif
+ if (p->p_flag & PK_32)
+ return kern_proc_32_hook_f1_call(p, arginfo);
+
return copyin_proc(p, (void *)p->p_psstrp, arginfo, sizeof(*arginfo));
}
@@ -2089,14 +2081,9 @@ copy_procargs(struct proc *p, int oid, s
i = 0;
}
-#ifdef COMPAT_NETBSD32
- if (p->p_flag & PK_32) {
- netbsd32_charp *argv32;
-
- argv32 = (netbsd32_charp *)argv;
- base = (vaddr_t)NETBSD32PTR64(argv32[i++]);
- } else
-#endif
+ if (p->p_flag & PK_32)
+ (void)kern_proc_32_hook_f2_call(argv, i++, &base);
+ else
base = (vaddr_t)argv[i++];
loaded -= entry_len;
Index: src/sys/sys/compat_stub.h
diff -u src/sys/sys/compat_stub.h:1.1.2.35 src/sys/sys/compat_stub.h:1.1.2.36
--- src/sys/sys/compat_stub.h:1.1.2.35 Sun Sep 23 01:33:26 2018
+++ src/sys/sys/compat_stub.h Sun Sep 23 11:23:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.h,v 1.1.2.35 2018/09/23 01:33:26 pgoyette Exp $ */
+/* $NetBSD: compat_stub.h,v 1.1.2.36 2018/09/23 11:23:47 pgoyette Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -33,6 +33,7 @@
#define _SYS_COMPAT_STUB_H
#include <sys/module_hook.h>
+#include <sys/param.h>
/*
* Routine hooks for compat_50___sys_ntp_gettime
@@ -208,4 +209,11 @@ MODULE_HOOK(compat_modstat_80_hook, (int
*/
extern int kern_sig_43_pgid_mask;
+/*
+ * Hooks for kern_proc.c for netbsd32 compat
+ */
+struct ps_strings;
+MODULE_HOOK2(kern_proc_32_hook, (struct proc *, struct ps_strings *),
+ (char **, size_t, vaddr_t *));
+
#endif /* _SYS_COMPAT_STUB_H */
Added files:
Index: src/sys/compat/netbsd32/netbsd32_kern_proc.c
diff -u /dev/null src/sys/compat/netbsd32/netbsd32_kern_proc.c:1.1.2.1
--- /dev/null Sun Sep 23 11:23:47 2018
+++ src/sys/compat/netbsd32/netbsd32_kern_proc.c Sun Sep 23 11:23:47 2018
@@ -0,0 +1,158 @@
+/* $NetBSD: netbsd32_kern_proc.c,v 1.1.2.1 2018/09/23 11:23:47 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center, and by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)kern_proc.c 8.7 (Berkeley) 2/14/95
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_kern_proc.c,v 1.1.2.1 2018/09/23 11:23:47 pgoyette Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_kstack.h"
+#include "opt_maxuprc.h"
+#include "opt_dtrace.h"
+#include "opt_compat_netbsd32.h"
+#endif
+
+#if defined(__HAVE_COMPAT_NETBSD32) && !defined(COMPAT_NETBSD32) \
+ && !defined(_RUMPKERNEL)
+#define COMPAT_NETBSD32
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/resourcevar.h>
+#include <sys/buf.h>
+#include <sys/acct.h>
+#include <sys/wait.h>
+#include <sys/file.h>
+#include <ufs/ufs/quota.h>
+#include <sys/uio.h>
+#include <sys/pool.h>
+#include <sys/pset.h>
+#include <sys/mbuf.h>
+#include <sys/ioctl.h>
+#include <sys/tty.h>
+#include <sys/signalvar.h>
+#include <sys/ras.h>
+#include <sys/filedesc.h>
+#include <sys/syscall_stats.h>
+#include <sys/kauth.h>
+#include <sys/sleepq.h>
+#include <sys/atomic.h>
+#include <sys/kmem.h>
+#include <sys/namei.h>
+#include <sys/dtrace_bsd.h>
+#include <sys/sysctl.h>
+#include <sys/exec.h>
+#include <sys/cpu.h>
+
+#include <uvm/uvm_extern.h>
+#include <uvm/uvm.h>
+
+#include <compat/netbsd32/netbsd32.h>
+
+static int
+copyin_psstrings_32(struct proc *p, struct ps_strings *arginfo)
+{
+ struct ps_strings32 arginfo32;
+
+ int error = copyin_proc(p, (void *)p->p_psstrp, &arginfo32,
+ sizeof(arginfo32));
+ if (error)
+ return error;
+ arginfo->ps_argvstr = (void *)(uintptr_t)arginfo32.ps_argvstr;
+ arginfo->ps_nargvstr = arginfo32.ps_nargvstr;
+ arginfo->ps_envstr = (void *)(uintptr_t)arginfo32.ps_envstr;
+ arginfo->ps_nenvstr = arginfo32.ps_nenvstr;
+ return 0;
+}
+
+static int
+get_base32(char **argv, size_t i, vaddr_t *base)
+{
+
+ netbsd32_charp *argv32;
+
+ argv32 = (netbsd32_charp *)argv;
+ *base = (vaddr_t)NETBSD32PTR64(argv32[i]);
+
+ return 0;
+}
+
+MODULE_SET_HOOK2(kern_proc_32_hook, "kern_proc_32",
+ copyin_psstrings_32, get_base32);
+MODULE_UNSET_HOOK2(kern_proc_32_hook);
+
+void
+kern_proc_32_init(void)
+{
+
+ kern_proc_32_hook_set();
+}
+
+void
+kern_proc_32_fini(void)
+{
+
+ kern_proc_32_hook_unset();
+}
Index: src/sys/compat/netbsd32/netbsd32_kern_proc.h
diff -u /dev/null src/sys/compat/netbsd32/netbsd32_kern_proc.h:1.1.2.1
--- /dev/null Sun Sep 23 11:23:47 2018
+++ src/sys/compat/netbsd32/netbsd32_kern_proc.h Sun Sep 23 11:23:47 2018
@@ -0,0 +1,38 @@
+/* $NetBSD: netbsd32_kern_proc.h,v 1.1.2.1 2018/09/23 11:23:47 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software developed for The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _NETBSD32_KERN_PROC_H
+#define _NETBSD32_KERN_PROC_H
+
+void netbsd32_kern_proc_32_init(void);
+void netbsd32_kern_proc_32_fini(void);
+
+#endif /* !_NETBSD32_KERN_PROC_H */