From f8d4d26bff434e03c888f9c6c117210009c2ffdb Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Tue, 7 May 2019 14:41:22 +0200
Subject: [PATCH] kernel: Stop including <sys/user.h> from kernel code.

---
 sys/dev/disk/iscsi/initiator/isc_soc.c   | 1 -
 sys/kern/imgact_aout.c                   | 2 --
 sys/kern/init_main.c                     | 1 -
 sys/kern/kern_exec.c                     | 1 -
 sys/kern/kern_exit.c                     | 1 -
 sys/kern/kern_proc.c                     | 2 +-
 sys/kern/sys_process.c                   | 2 --
 sys/kern/sys_vmm.c                       | 5 ++++-
 sys/platform/pc64/x86_64/db_trace.c      | 2 --
 sys/platform/pc64/x86_64/machdep.c       | 3 +--
 sys/platform/pc64/x86_64/mp_machdep.c    | 1 -
 sys/platform/pc64/x86_64/mptable.c       | 1 -
 sys/platform/pc64/x86_64/pmap.c          | 1 -
 sys/platform/pc64/x86_64/tls.c           | 2 +-
 sys/platform/vkernel64/platform/pmap.c   | 2 +-
 sys/platform/vkernel64/x86_64/cpu_regs.c | 4 ++--
 sys/platform/vkernel64/x86_64/db_trace.c | 2 --
 sys/platform/vkernel64/x86_64/tls.c      | 2 +-
 sys/vfs/procfs/procfs_mem.c              | 1 -
 sys/vm/vm_glue.c                         | 4 +---
 20 files changed, 12 insertions(+), 28 deletions(-)

diff --git a/sys/dev/disk/iscsi/initiator/isc_soc.c b/sys/dev/disk/iscsi/initiator/isc_soc.c
index 12e91a15f7..45c988159d 100644
--- a/sys/dev/disk/iscsi/initiator/isc_soc.c
+++ b/sys/dev/disk/iscsi/initiator/isc_soc.c
@@ -50,7 +50,6 @@
 #include <sys/kthread.h>
 #include <sys/syslog.h>
 #include <sys/mbuf.h>
-#include <sys/user.h>
 #include <sys/eventhandler.h>
 #include <sys/socketops.h>
 
diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c
index 047e3d4238..9a2939b2d1 100644
--- a/sys/kern/imgact_aout.c
+++ b/sys/kern/imgact_aout.c
@@ -24,7 +24,6 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/kern/imgact_aout.c,v 1.59.2.5 2001/11/03 01:41:08 ps Exp $
- * $DragonFly: src/sys/kern/imgact_aout.c,v 1.14 2007/02/01 10:33:25 corecode Exp $
  */
 
 #include <sys/param.h>
@@ -52,7 +51,6 @@
 #include <vm/pmap.h>
 #include <vm/vm_map.h>
 #include <vm/vm_object.h>
-#include <sys/user.h>
 
 static int	exec_aout_imgact (struct image_params *imgp);
 
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 991c29eebb..98ebac21df 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -72,7 +72,6 @@
 #include <vm/pmap.h>
 #include <vm/vm_map.h>
 #include <vm/vm_extern.h>
-#include <sys/user.h>
 #include <sys/copyright.h>
 
 int vfs_mountroot_devfs(void);
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index d0391e9540..69dbb217c5 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -67,7 +67,6 @@
 #include <vm/vnode_pager.h>
 #include <vm/vm_pager.h>
 
-#include <sys/user.h>
 #include <sys/reg.h>
 
 #include <sys/objcache.h>
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index a382fe5e6d..9728111c62 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -68,7 +68,6 @@
 #include <vm/pmap.h>
 #include <vm/vm_map.h>
 #include <vm/vm_extern.h>
-#include <sys/user.h>
 
 #include <sys/refcount.h>
 #include <sys/spinlock2.h>
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index f83f1d6b6e..ffca0d73e5 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -44,9 +44,9 @@
 #include <sys/exec.h>
 #include <vm/vm.h>
 #include <sys/lock.h>
+#include <sys/kinfo.h>
 #include <vm/pmap.h>
 #include <vm/vm_map.h>
-#include <sys/user.h>
 #include <machine/smp.h>
 
 #include <sys/refcount.h>
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index ebde7620e8..4bc74d49d1 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -29,7 +29,6 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/kern/sys_process.c,v 1.51.2.6 2003/01/08 03:06:45 kan Exp $
- * $DragonFly: src/sys/kern/sys_process.c,v 1.30 2007/02/19 01:14:23 corecode Exp $
  */
 
 #include <sys/param.h>
@@ -47,7 +46,6 @@
 #include <vm/vm_map.h>
 #include <vm/vm_page.h>
 
-#include <sys/user.h>
 #include <vfs/procfs/procfs.h>
 
 #include <sys/thread2.h>
diff --git a/sys/kern/sys_vmm.c b/sys/kern/sys_vmm.c
index a4241d2686..202727da74 100644
--- a/sys/kern/sys_vmm.c
+++ b/sys/kern/sys_vmm.c
@@ -36,7 +36,6 @@
 #include <sys/systm.h>
 #include <sys/sysproto.h>
 #include <sys/proc.h>
-#include <sys/user.h>
 #include <sys/wait.h>
 #include <sys/vmm.h>
 
@@ -44,7 +43,11 @@
 #include <sys/spinlock2.h>
 
 #include <machine/cpu.h>
+#include <machine/pmap.h>
 #include <machine/vmm.h>
+#include <machine/vmparam.h>
+
+#include <vm/vm_map.h>
 
 /*
  * vmm guest system call:
diff --git a/sys/platform/pc64/x86_64/db_trace.c b/sys/platform/pc64/x86_64/db_trace.c
index 4200a8d503..b0e93574a3 100644
--- a/sys/platform/pc64/x86_64/db_trace.c
+++ b/sys/platform/pc64/x86_64/db_trace.c
@@ -74,8 +74,6 @@
 #include <ddb/ddb.h>
 #include <dlfcn.h>	/* DLL */
 
-#include <sys/user.h>
-
 #include <ddb/db_access.h>
 #include <ddb/db_sym.h>
 #include <ddb/db_variables.h>
diff --git a/sys/platform/pc64/x86_64/machdep.c b/sys/platform/pc64/x86_64/machdep.c
index 7fea86a970..e1352547f8 100644
--- a/sys/platform/pc64/x86_64/machdep.c
+++ b/sys/platform/pc64/x86_64/machdep.c
@@ -86,7 +86,6 @@
 #include <sys/mplock2.h>
 #include <sys/mutex2.h>
 
-#include <sys/user.h>
 #include <sys/exec.h>
 #include <sys/cons.h>
 
@@ -103,7 +102,7 @@
 #include <machine/md_var.h>
 #include <machine/metadata.h>
 #include <machine/pc/bios.h>
-#include <machine/pcb_ext.h>		/* pcb.h included via sys/user.h */
+#include <machine/pcb_ext.h>
 #include <machine/globaldata.h>		/* CPU_prvspace */
 #include <machine/smp.h>
 #include <machine/cputypes.h>
diff --git a/sys/platform/pc64/x86_64/mp_machdep.c b/sys/platform/pc64/x86_64/mp_machdep.c
index 6eef7760e5..bff8b83894 100644
--- a/sys/platform/pc64/x86_64/mp_machdep.c
+++ b/sys/platform/pc64/x86_64/mp_machdep.c
@@ -46,7 +46,6 @@
 #include <vm/vm_extern.h>
 #include <sys/lock.h>
 #include <vm/vm_map.h>
-#include <sys/user.h>
 
 #include <machine/smp.h>
 #include <machine_base/apic/apicreg.h>
diff --git a/sys/platform/pc64/x86_64/mptable.c b/sys/platform/pc64/x86_64/mptable.c
index 141a1d79f9..aaf8fd7f13 100644
--- a/sys/platform/pc64/x86_64/mptable.c
+++ b/sys/platform/pc64/x86_64/mptable.c
@@ -45,7 +45,6 @@
 #include <vm/vm_extern.h>
 #include <sys/lock.h>
 #include <vm/vm_map.h>
-#include <sys/user.h>
 
 #include <machine/smp.h>
 #include <machine_base/isa/isa_intr.h>
diff --git a/sys/platform/pc64/x86_64/pmap.c b/sys/platform/pc64/x86_64/pmap.c
index 92d4051a55..1e2e05dad9 100644
--- a/sys/platform/pc64/x86_64/pmap.c
+++ b/sys/platform/pc64/x86_64/pmap.c
@@ -78,7 +78,6 @@
 #include <vm/vm_pager.h>
 #include <vm/vm_zone.h>
 
-#include <sys/user.h>
 #include <sys/thread2.h>
 #include <sys/spinlock2.h>
 #include <vm/vm_page2.h>
diff --git a/sys/platform/pc64/x86_64/tls.c b/sys/platform/pc64/x86_64/tls.c
index 36dec4cb5d..12214539d2 100644
--- a/sys/platform/pc64/x86_64/tls.c
+++ b/sys/platform/pc64/x86_64/tls.c
@@ -50,7 +50,7 @@
 #include <machine/specialreg.h>
 #include <machine/segments.h>
 #include <machine/md_var.h>
-#include <machine/pcb_ext.h>		/* pcb.h included via sys/user.h */
+#include <machine/pcb_ext.h>
 #include <machine/globaldata.h>		/* CPU_prvspace */
 #include <machine/smp.h>
 #include <machine/pcb.h>
diff --git a/sys/platform/vkernel64/platform/pmap.c b/sys/platform/vkernel64/platform/pmap.c
index 2ea876631a..bbb370dc44 100644
--- a/sys/platform/vkernel64/platform/pmap.c
+++ b/sys/platform/vkernel64/platform/pmap.c
@@ -72,7 +72,6 @@
 #include <vm/vm_pager.h>
 #include <vm/vm_zone.h>
 
-#include <sys/user.h>
 #include <sys/thread2.h>
 #include <sys/spinlock2.h>
 #include <vm/vm_page2.h>
@@ -82,6 +81,7 @@
 #include <machine/specialreg.h>
 #include <machine/smp.h>
 #include <machine/globaldata.h>
+#include <machine/pcb.h>
 #include <machine/pmap.h>
 #include <machine/pmap_inval.h>
 
diff --git a/sys/platform/vkernel64/x86_64/cpu_regs.c b/sys/platform/vkernel64/x86_64/cpu_regs.c
index ccc91acec7..5dccd0484a 100644
--- a/sys/platform/vkernel64/x86_64/cpu_regs.c
+++ b/sys/platform/vkernel64/x86_64/cpu_regs.c
@@ -76,7 +76,6 @@
 #include <sys/thread2.h>
 #include <sys/mplock2.h>
 
-#include <sys/user.h>
 #include <sys/exec.h>
 #include <sys/cons.h>
 
@@ -86,7 +85,8 @@
 #include <machine/clock.h>
 #include <machine/specialreg.h>
 #include <machine/md_var.h>
-#include <machine/pcb_ext.h>		/* pcb.h included via sys/user.h */
+#include <machine/pcb.h>
+#include <machine/pcb_ext.h>
 #include <machine/globaldata.h>		/* CPU_prvspace */
 #include <machine/smp.h>
 #include <machine/cputypes.h>
diff --git a/sys/platform/vkernel64/x86_64/db_trace.c b/sys/platform/vkernel64/x86_64/db_trace.c
index 79a4636ec3..be669e7085 100644
--- a/sys/platform/vkernel64/x86_64/db_trace.c
+++ b/sys/platform/vkernel64/x86_64/db_trace.c
@@ -74,8 +74,6 @@
 #include <ddb/ddb.h>
 #include <dlfcn.h>	/* DLL */
 
-#include <sys/user.h>
-
 #include <ddb/db_access.h>
 #include <ddb/db_sym.h>
 #include <ddb/db_variables.h>
diff --git a/sys/platform/vkernel64/x86_64/tls.c b/sys/platform/vkernel64/x86_64/tls.c
index a520ccc086..a4d91d18c1 100644
--- a/sys/platform/vkernel64/x86_64/tls.c
+++ b/sys/platform/vkernel64/x86_64/tls.c
@@ -49,7 +49,7 @@
 #include <machine/specialreg.h>
 #include <machine/segments.h>
 #include <machine/md_var.h>
-#include <machine/pcb_ext.h>		/* pcb.h included via sys/user.h */
+#include <machine/pcb_ext.h>
 #include <machine/globaldata.h>		/* CPU_prvspace */
 #include <machine/smp.h>
 #include <machine/pcb.h>
diff --git a/sys/vfs/procfs/procfs_mem.c b/sys/vfs/procfs/procfs_mem.c
index 9922069fa9..1d28c57cae 100644
--- a/sys/vfs/procfs/procfs_mem.c
+++ b/sys/vfs/procfs/procfs_mem.c
@@ -56,7 +56,6 @@
 #include <vm/vm_kern.h>
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
-#include <sys/user.h>
 #include <sys/ptrace.h>
 
 #include <machine/vmm.h>
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c
index 072b5fce56..9c81d18a77 100644
--- a/sys/vm/vm_glue.c
+++ b/sys/vm/vm_glue.c
@@ -81,13 +81,11 @@
 #include <vm/pmap.h>
 #include <vm/vm_map.h>
 #include <vm/vm_page.h>
+#include <vm/vm_page2.h>
 #include <vm/vm_pageout.h>
 #include <vm/vm_kern.h>
 #include <vm/vm_extern.h>
 
-#include <sys/user.h>
-#include <vm/vm_page2.h>
-
 /*
  * THIS MUST BE THE LAST INITIALIZATION ITEM!!!
  *
-- 
2.21.0

