git: e5e2c7ffa0f7 - stable/13 - Create sys/reg.h for the common code previously in machine/reg.h

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 12 May 2022 22:56:31 UTC
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=e5e2c7ffa0f7d9ba0874b95924f4d977b116f45b

commit e5e2c7ffa0f7d9ba0874b95924f4d977b116f45b
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2021-08-27 09:38:40 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-05-12 22:12:59 +0000

    Create sys/reg.h for the common code previously in machine/reg.h
    
    Move the common kernel function signatures from machine/reg.h to a new
    sys/reg.h. This is in preperation for adding PT_GETREGSET to ptrace(2).
    
    Reviewed by:    imp, markj
    Sponsored by:   DARPA, AFRL (original work)
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D19830
    
    (cherry picked from commit b792434150d66b9b2356fb9a7548f4c7f0a0f16c)
---
 sys/amd64/amd64/db_trace.c                         |  2 +-
 sys/amd64/amd64/exec_machdep.c                     |  2 +-
 sys/amd64/amd64/gdb_machdep.c                      |  2 +-
 sys/amd64/amd64/machdep.c                          |  2 +-
 sys/amd64/ia32/ia32_reg.c                          |  1 +
 sys/amd64/include/db_machdep.h                     |  1 -
 sys/amd64/linux/linux_ptrace.c                     |  1 -
 sys/amd64/linux32/linux32_machdep.c                |  2 +-
 sys/amd64/vmm/amd/svm.c                            |  2 +-
 sys/amd64/vmm/intel/vmx.c                          |  2 +-
 sys/arm/arm/debug_monitor.c                        |  2 +-
 sys/arm/arm/machdep_kdb.c                          |  2 +-
 sys/arm/include/reg.h                              |  9 ---
 sys/arm64/arm64/exec_machdep.c                     |  2 +-
 sys/arm64/arm64/machdep.c                          |  2 +-
 sys/arm64/include/reg.h                            | 20 -------
 sys/arm64/linux/linux_machdep.c                    |  1 +
 .../opensolaris/uts/intel/dtrace/fasttrap_isa.c    |  2 +-
 sys/cddl/dev/dtrace/aarch64/dtrace_isa.c           |  1 -
 sys/cddl/dev/dtrace/amd64/dtrace_isa.c             |  1 -
 sys/cddl/dev/dtrace/arm/dtrace_isa.c               |  1 -
 sys/cddl/dev/dtrace/mips/dtrace_isa.c              |  1 -
 sys/cddl/dev/dtrace/powerpc/dtrace_isa.c           |  1 -
 sys/cddl/dev/dtrace/riscv/dtrace_isa.c             |  1 -
 sys/ddb/db_run.c                                   |  1 +
 sys/fs/procfs/procfs_dbregs.c                      |  2 -
 sys/fs/procfs/procfs_fpregs.c                      |  2 -
 sys/fs/procfs/procfs_regs.c                        |  2 -
 sys/i386/i386/db_trace.c                           |  2 +-
 sys/i386/i386/exec_machdep.c                       |  2 +-
 sys/i386/i386/gdb_machdep.c                        |  2 +-
 sys/i386/i386/machdep.c                            |  2 +-
 sys/i386/include/db_machdep.h                      |  1 -
 sys/i386/linux/linux_ptrace.c                      |  1 -
 sys/kern/imgact_elf.c                              |  1 +
 sys/kern/kern_exec.c                               |  3 +-
 sys/kern/sys_process.c                             |  3 +-
 sys/mips/include/md_var.h                          |  2 +-
 sys/mips/include/reg.h                             | 16 -----
 sys/mips/mips/freebsd32_machdep.c                  |  2 +-
 sys/mips/mips/gdb_machdep.c                        |  1 -
 sys/mips/mips/machdep.c                            |  1 +
 sys/mips/mips/pm_machdep.c                         |  2 +-
 sys/mips/nlm/cms.c                                 |  1 -
 sys/mips/nlm/dev/net/xlpge.c                       |  1 -
 sys/powerpc/aim/aim_machdep.c                      |  1 -
 sys/powerpc/booke/booke_machdep.c                  |  1 -
 sys/powerpc/fpu/fpu_add.c                          |  1 -
 sys/powerpc/fpu/fpu_compare.c                      |  1 -
 sys/powerpc/fpu/fpu_div.c                          |  1 -
 sys/powerpc/fpu/fpu_emu.c                          |  1 -
 sys/powerpc/fpu/fpu_implode.c                      |  1 -
 sys/powerpc/fpu/fpu_mul.c                          |  1 -
 sys/powerpc/fpu/fpu_sqrt.c                         |  1 -
 sys/powerpc/fpu/fpu_subr.c                         |  1 -
 sys/powerpc/powerpc/elf32_machdep.c                |  2 +-
 sys/powerpc/powerpc/exec_machdep.c                 |  2 +-
 sys/powerpc/powerpc/gdb_machdep.c                  |  1 -
 sys/powerpc/powerpc/machdep.c                      |  2 +-
 sys/riscv/include/reg.h                            | 12 ----
 sys/riscv/riscv/exec_machdep.c                     |  2 +-
 sys/riscv/riscv/machdep.c                          |  2 +-
 sys/sys/reg.h                                      | 68 ++++++++++++++++++++++
 sys/x86/include/reg.h                              | 16 -----
 sys/x86/x86/dbreg.c                                |  1 +
 65 files changed, 100 insertions(+), 131 deletions(-)

diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c
index 4c569c456e92..037cae200e2e 100644
--- a/sys/amd64/amd64/db_trace.c
+++ b/sys/amd64/amd64/db_trace.c
@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/kdb.h>
 #include <sys/proc.h>
+#include <sys/reg.h>
 #include <sys/smp.h>
 #include <sys/stack.h>
 #include <sys/sysent.h>
@@ -38,7 +39,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/cpu.h>
 #include <machine/md_var.h>
 #include <machine/pcb.h>
-#include <machine/reg.h>
 #include <machine/stack.h>
 
 #include <vm/vm.h>
diff --git a/sys/amd64/amd64/exec_machdep.c b/sys/amd64/amd64/exec_machdep.c
index a4255c348212..0c2bebaea8f3 100644
--- a/sys/amd64/amd64/exec_machdep.c
+++ b/sys/amd64/amd64/exec_machdep.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 #include <sys/mutex.h>
 #include <sys/pcpu.h>
+#include <sys/reg.h>
 #include <sys/rwlock.h>
 #include <sys/signalvar.h>
 #ifdef SMP
@@ -90,7 +91,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/md_var.h>
 #include <machine/pcb.h>
 #include <machine/proc.h>
-#include <machine/reg.h>
 #include <machine/sigframe.h>
 #include <machine/specialreg.h>
 #include <machine/trap.h>
diff --git a/sys/amd64/amd64/gdb_machdep.c b/sys/amd64/amd64/gdb_machdep.c
index eb5ab525aa9c..02b76a35d7ae 100644
--- a/sys/amd64/amd64/gdb_machdep.c
+++ b/sys/amd64/amd64/gdb_machdep.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/kdb.h>
 #include <sys/kernel.h>
 #include <sys/proc.h>
+#include <sys/reg.h>
 #include <sys/signal.h>
 
 #include <machine/cpufunc.h>
@@ -42,7 +43,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/md_var.h>
 #include <machine/pcb.h>
 #include <machine/psl.h>
-#include <machine/reg.h>
 #include <machine/specialreg.h>
 #include <machine/trap.h>
 #include <machine/frame.h>
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 8a1da968cf02..cfe7e2518e58 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/pcpu.h>
 #include <sys/ptrace.h>
 #include <sys/reboot.h>
+#include <sys/reg.h>
 #include <sys/rwlock.h>
 #include <sys/sched.h>
 #include <sys/signalvar.h>
@@ -128,7 +129,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/pc/bios.h>
 #include <machine/pcb.h>
 #include <machine/proc.h>
-#include <machine/reg.h>
 #include <machine/sigframe.h>
 #include <machine/specialreg.h>
 #include <machine/trap.h>
diff --git a/sys/amd64/ia32/ia32_reg.c b/sys/amd64/ia32/ia32_reg.c
index f6333a65fb39..343d1564e1ff 100644
--- a/sys/amd64/ia32/ia32_reg.c
+++ b/sys/amd64/ia32/ia32_reg.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/namei.h>
 #include <sys/proc.h>
 #include <sys/procfs.h>
+#include <sys/reg.h>
 #include <sys/resourcevar.h>
 #include <sys/systm.h>
 #include <sys/signalvar.h>
diff --git a/sys/amd64/include/db_machdep.h b/sys/amd64/include/db_machdep.h
index c88c281ff9a6..102475f660a4 100644
--- a/sys/amd64/include/db_machdep.h
+++ b/sys/amd64/include/db_machdep.h
@@ -30,7 +30,6 @@
 #define	_MACHINE_DB_MACHDEP_H_
 
 #include <machine/frame.h>
-#include <machine/reg.h>
 #include <machine/trap.h>
 
 typedef	vm_offset_t	db_addr_t;	/* address - unsigned */
diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c
index 5fa7dafdf2c7..13bc0edd7c98 100644
--- a/sys/amd64/linux/linux_ptrace.c
+++ b/sys/amd64/linux/linux_ptrace.c
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/syscallsubr.h>
 
 #include <machine/pcb.h>
-#include <machine/reg.h>
 
 #include <amd64/linux/linux.h>
 #include <amd64/linux/linux_proto.h>
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c
index 1cfda5d60e13..7fa061f750c6 100644
--- a/sys/amd64/linux32/linux32_machdep.c
+++ b/sys/amd64/linux32/linux32_machdep.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mutex.h>
 #include <sys/priv.h>
 #include <sys/proc.h>
+#include <sys/reg.h>
 #include <sys/resource.h>
 #include <sys/resourcevar.h>
 #include <sys/syscallsubr.h>
@@ -61,7 +62,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/md_var.h>
 #include <machine/pcb.h>
 #include <machine/psl.h>
-#include <machine/reg.h>
 #include <machine/segments.h>
 #include <machine/specialreg.h>
 #include <x86/ifunc.h>
diff --git a/sys/amd64/vmm/amd/svm.c b/sys/amd64/vmm/amd/svm.c
index 0348c3335409..fbf11ec84084 100644
--- a/sys/amd64/vmm/amd/svm.c
+++ b/sys/amd64/vmm/amd/svm.c
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 #include <sys/pcpu.h>
 #include <sys/proc.h>
+#include <sys/reg.h>
 #include <sys/smr.h>
 #include <sys/sysctl.h>
 
@@ -47,7 +48,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/cpufunc.h>
 #include <machine/psl.h>
 #include <machine/md_var.h>
-#include <machine/reg.h>
 #include <machine/specialreg.h>
 #include <machine/smp.h>
 #include <machine/vmm.h>
diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c
index 7017e4b9077c..e7ced1b2c3fa 100644
--- a/sys/amd64/vmm/intel/vmx.c
+++ b/sys/amd64/vmm/intel/vmx.c
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 #include <sys/pcpu.h>
 #include <sys/proc.h>
+#include <sys/reg.h>
 #include <sys/smr.h>
 #include <sys/sysctl.h>
 
@@ -50,7 +51,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/psl.h>
 #include <machine/cpufunc.h>
 #include <machine/md_var.h>
-#include <machine/reg.h>
 #include <machine/segments.h>
 #include <machine/smp.h>
 #include <machine/specialreg.h>
diff --git a/sys/arm/arm/debug_monitor.c b/sys/arm/arm/debug_monitor.c
index 55b5f70b2397..b73249bedcf1 100644
--- a/sys/arm/arm/debug_monitor.c
+++ b/sys/arm/arm/debug_monitor.c
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/types.h>
 #include <sys/kdb.h>
 #include <sys/pcpu.h>
+#include <sys/reg.h>
 #include <sys/smp.h>
 #include <sys/systm.h>
 
@@ -44,7 +45,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/debug_monitor.h>
 #include <machine/kdb.h>
 #include <machine/pcb.h>
-#include <machine/reg.h>
 
 #include <ddb/ddb.h>
 #include <ddb/db_access.h>
diff --git a/sys/arm/arm/machdep_kdb.c b/sys/arm/arm/machdep_kdb.c
index 4dedb72edb22..b1f04c0832a1 100644
--- a/sys/arm/arm/machdep_kdb.c
+++ b/sys/arm/arm/machdep_kdb.c
@@ -35,10 +35,10 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/proc.h>
+#include <sys/reg.h>
 #include <sys/systm.h>
 
 #include <machine/cpu.h>
-#include <machine/reg.h>
 
 #ifdef DDB
 #include <ddb/ddb.h>
diff --git a/sys/arm/include/reg.h b/sys/arm/include/reg.h
index 494052f64732..4dc954816881 100644
--- a/sys/arm/include/reg.h
+++ b/sys/arm/include/reg.h
@@ -32,13 +32,4 @@ struct dbreg {
 	unsigned int dbg_wvr[ARM_WR_MAX]; /* Watchpoint Value Registers */
 };
 
-#ifdef _KERNEL
-int     fill_regs(struct thread *, struct reg *);
-int     set_regs(struct thread *, struct reg *);
-int     fill_fpregs(struct thread *, struct fpreg *);
-int     set_fpregs(struct thread *, struct fpreg *);
-int     fill_dbregs(struct thread *, struct dbreg *);
-int     set_dbregs(struct thread *, struct dbreg *);
-#endif
-
 #endif /* !MACHINE_REG_H */
diff --git a/sys/arm64/arm64/exec_machdep.c b/sys/arm64/arm64/exec_machdep.c
index 6a7fc64734e1..cc589731ae6a 100644
--- a/sys/arm64/arm64/exec_machdep.c
+++ b/sys/arm64/arm64/exec_machdep.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mutex.h>
 #include <sys/proc.h>
 #include <sys/ptrace.h>
+#include <sys/reg.h>
 #include <sys/rwlock.h>
 #include <sys/signalvar.h>
 #include <sys/syscallsubr.h>
@@ -54,7 +55,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/kdb.h>
 #include <machine/md_var.h>
 #include <machine/pcb.h>
-#include <machine/reg.h>
 
 #ifdef VFP
 #include <machine/vfp.h>
diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index 28105661c120..7b135a3623ba 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/proc.h>
 #include <sys/ptrace.h>
 #include <sys/reboot.h>
+#include <sys/reg.h>
 #include <sys/rwlock.h>
 #include <sys/sched.h>
 #include <sys/signalvar.h>
@@ -82,7 +83,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/metadata.h>
 #include <machine/md_var.h>
 #include <machine/pcb.h>
-#include <machine/reg.h>
 #include <machine/undefined.h>
 #include <machine/vmparam.h>
 
diff --git a/sys/arm64/include/reg.h b/sys/arm64/include/reg.h
index 9b954bd50b2b..bb151af55ba6 100644
--- a/sys/arm64/include/reg.h
+++ b/sys/arm64/include/reg.h
@@ -85,24 +85,4 @@ struct dbreg32 {
 
 #define	__HAVE_REG32
 
-#ifdef _KERNEL
-/*
- * XXX these interfaces are MI, so they should be declared in a MI place.
- */
-int	fill_regs(struct thread *, struct reg *);
-int	set_regs(struct thread *, struct reg *);
-int	fill_fpregs(struct thread *, struct fpreg *);
-int	set_fpregs(struct thread *, struct fpreg *);
-int	fill_dbregs(struct thread *, struct dbreg *);
-int	set_dbregs(struct thread *, struct dbreg *);
-#ifdef COMPAT_FREEBSD32
-int	fill_regs32(struct thread *, struct reg32 *);
-int	set_regs32(struct thread *, struct reg32 *);
-int	fill_fpregs32(struct thread *, struct fpreg32 *);
-int	set_fpregs32(struct thread *, struct fpreg32 *);
-int	fill_dbregs32(struct thread *, struct dbreg32 *);
-int	set_dbregs32(struct thread *, struct dbreg32 *);
-#endif
-#endif
-
 #endif /* !_MACHINE_REG_H_ */
diff --git a/sys/arm64/linux/linux_machdep.c b/sys/arm64/linux/linux_machdep.c
index c67c4aa6479a..23d9c6423b05 100644
--- a/sys/arm64/linux/linux_machdep.c
+++ b/sys/arm64/linux/linux_machdep.c
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/imgact.h>
 #include <sys/ktr.h>
 #include <sys/proc.h>
+#include <sys/reg.h>
 #include <sys/sdt.h>
 
 #include <security/audit/audit.h>
diff --git a/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c b/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
index 163a8fdd13fa..c40b4b94e38d 100644
--- a/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
+++ b/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
@@ -36,11 +36,11 @@
 #include <sys/types.h>
 #include <sys/dtrace_bsd.h>
 #include <sys/proc.h>
+#include <sys/reg.h>
 #include <sys/rmlock.h>
 #include <cddl/dev/dtrace/dtrace_cddl.h>
 #include <cddl/dev/dtrace/x86/regset.h>
 #include <machine/segments.h>
-#include <machine/reg.h>
 #include <machine/pcb.h>
 #include <machine/trap.h>
 #include <sys/sysmacros.h>
diff --git a/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c b/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c
index db47423e9d33..4a39fa7860cb 100644
--- a/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c
+++ b/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c
@@ -35,7 +35,6 @@
 
 #include <machine/frame.h>
 #include <machine/md_var.h>
-#include <machine/reg.h>
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
diff --git a/sys/cddl/dev/dtrace/amd64/dtrace_isa.c b/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
index 07a4103bd716..71b448a99c1c 100644
--- a/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
+++ b/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
@@ -35,7 +35,6 @@
 
 #include <machine/frame.h>
 #include <machine/md_var.h>
-#include <machine/reg.h>
 #include <machine/stack.h>
 #include <x86/ifunc.h>
 
diff --git a/sys/cddl/dev/dtrace/arm/dtrace_isa.c b/sys/cddl/dev/dtrace/arm/dtrace_isa.c
index 9bac37669a84..ede352e6b873 100644
--- a/sys/cddl/dev/dtrace/arm/dtrace_isa.c
+++ b/sys/cddl/dev/dtrace/arm/dtrace_isa.c
@@ -35,7 +35,6 @@
 
 #include <machine/frame.h>
 #include <machine/md_var.h>
-#include <machine/reg.h>
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
diff --git a/sys/cddl/dev/dtrace/mips/dtrace_isa.c b/sys/cddl/dev/dtrace/mips/dtrace_isa.c
index c09225c734b9..8d65012dadf0 100644
--- a/sys/cddl/dev/dtrace/mips/dtrace_isa.c
+++ b/sys/cddl/dev/dtrace/mips/dtrace_isa.c
@@ -35,7 +35,6 @@
 
 #include <machine/frame.h>
 #include <machine/md_var.h>
-#include <machine/reg.h>
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
diff --git a/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c b/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c
index a188eafa777d..cce1c907b5d8 100644
--- a/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c
+++ b/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c
@@ -39,7 +39,6 @@
 #include <machine/frame.h>
 #include <machine/md_var.h>
 #include <machine/psl.h>
-#include <machine/reg.h>
 #include <machine/stack.h>
 
 #include <vm/vm.h>
diff --git a/sys/cddl/dev/dtrace/riscv/dtrace_isa.c b/sys/cddl/dev/dtrace/riscv/dtrace_isa.c
index f8663b5bfeab..d42299abcd35 100644
--- a/sys/cddl/dev/dtrace/riscv/dtrace_isa.c
+++ b/sys/cddl/dev/dtrace/riscv/dtrace_isa.c
@@ -37,7 +37,6 @@
 
 #include <machine/frame.h>
 #include <machine/md_var.h>
-#include <machine/reg.h>
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
diff --git a/sys/ddb/db_run.c b/sys/ddb/db_run.c
index af99eb757609..c9ea87fca79c 100644
--- a/sys/ddb/db_run.c
+++ b/sys/ddb/db_run.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/param.h>
 #include <sys/kdb.h>
 #include <sys/proc.h>
+#include <sys/reg.h>
 #include <sys/systm.h>
 
 #include <machine/kdb.h>
diff --git a/sys/fs/procfs/procfs_dbregs.c b/sys/fs/procfs/procfs_dbregs.c
index 8d2206d2995c..acc0f7f8c5ac 100644
--- a/sys/fs/procfs/procfs_dbregs.c
+++ b/sys/fs/procfs/procfs_dbregs.c
@@ -54,8 +54,6 @@
 #include <sys/sysent.h>
 #include <sys/uio.h>
 
-#include <machine/reg.h>
-
 #include <fs/pseudofs/pseudofs.h>
 #include <fs/procfs/procfs.h>
 
diff --git a/sys/fs/procfs/procfs_fpregs.c b/sys/fs/procfs/procfs_fpregs.c
index 9675030df3c0..1118eb68dcbc 100644
--- a/sys/fs/procfs/procfs_fpregs.c
+++ b/sys/fs/procfs/procfs_fpregs.c
@@ -48,8 +48,6 @@
 #include <sys/sysent.h>
 #include <sys/uio.h>
 
-#include <machine/reg.h>
-
 #include <fs/pseudofs/pseudofs.h>
 #include <fs/procfs/procfs.h>
 
diff --git a/sys/fs/procfs/procfs_regs.c b/sys/fs/procfs/procfs_regs.c
index 032141a9e32e..703dad64a182 100644
--- a/sys/fs/procfs/procfs_regs.c
+++ b/sys/fs/procfs/procfs_regs.c
@@ -48,8 +48,6 @@
 #include <sys/sysent.h>
 #include <sys/uio.h>
 
-#include <machine/reg.h>
-
 #include <fs/pseudofs/pseudofs.h>
 #include <fs/procfs/procfs.h>
 
diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c
index 80ef0fe715d8..529b94b76cc4 100644
--- a/sys/i386/i386/db_trace.c
+++ b/sys/i386/i386/db_trace.c
@@ -31,13 +31,13 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/kdb.h>
 #include <sys/proc.h>
+#include <sys/reg.h>
 #include <sys/sysent.h>
 
 #include <machine/cpu.h>
 #include <machine/frame.h>
 #include <machine/md_var.h>
 #include <machine/pcb.h>
-#include <machine/reg.h>
 #include <machine/stack.h>
 
 #include <vm/vm.h>
diff --git a/sys/i386/i386/exec_machdep.c b/sys/i386/i386/exec_machdep.c
index 1f0a9a47a198..2223dd2a1efa 100644
--- a/sys/i386/i386/exec_machdep.c
+++ b/sys/i386/i386/exec_machdep.c
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mutex.h>
 #include <sys/pcpu.h>
 #include <sys/ptrace.h>
+#include <sys/reg.h>
 #include <sys/rwlock.h>
 #include <sys/signalvar.h>
 #include <sys/syscallsubr.h>
@@ -95,7 +96,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/pcb.h>
 #include <machine/pcb_ext.h>
 #include <machine/proc.h>
-#include <machine/reg.h>
 #include <machine/sigframe.h>
 #include <machine/specialreg.h>
 #include <machine/sysarch.h>
diff --git a/sys/i386/i386/gdb_machdep.c b/sys/i386/i386/gdb_machdep.c
index 7cb83d839fec..7523787da536 100644
--- a/sys/i386/i386/gdb_machdep.c
+++ b/sys/i386/i386/gdb_machdep.c
@@ -34,13 +34,13 @@ __FBSDID("$FreeBSD$");
 #include <sys/kdb.h>
 #include <sys/kernel.h>
 #include <sys/proc.h>
+#include <sys/reg.h>
 #include <sys/signal.h>
 
 #include <machine/endian.h>
 #include <machine/frame.h>
 #include <machine/gdb_machdep.h>
 #include <machine/pcb.h>
-#include <machine/reg.h>
 #include <machine/trap.h>
 
 #include <gdb/gdb.h>
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 227e7e07549b..22a40a4151c3 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/pcpu.h>
 #include <sys/ptrace.h>
 #include <sys/reboot.h>
+#include <sys/reg.h>
 #include <sys/rwlock.h>
 #include <sys/sched.h>
 #include <sys/signalvar.h>
@@ -129,7 +130,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/pcb.h>
 #include <machine/pcb_ext.h>
 #include <machine/proc.h>
-#include <machine/reg.h>
 #include <machine/sigframe.h>
 #include <machine/specialreg.h>
 #include <machine/sysarch.h>
diff --git a/sys/i386/include/db_machdep.h b/sys/i386/include/db_machdep.h
index 42f0f19d29a9..83daab106b82 100644
--- a/sys/i386/include/db_machdep.h
+++ b/sys/i386/include/db_machdep.h
@@ -30,7 +30,6 @@
 #define	_MACHINE_DB_MACHDEP_H_
 
 #include <machine/frame.h>
-#include <machine/reg.h>
 #include <machine/trap.h>
 
 typedef	vm_offset_t	db_addr_t;	/* address - unsigned */
diff --git a/sys/i386/linux/linux_ptrace.c b/sys/i386/linux/linux_ptrace.c
index 0c93d0266b87..d9e0ed50c750 100644
--- a/sys/i386/linux/linux_ptrace.c
+++ b/sys/i386/linux/linux_ptrace.c
@@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
 
 #include <machine/md_var.h>
 #include <machine/pcb.h>
-#include <machine/reg.h>
 
 #include <i386/linux/linux.h>
 #include <i386/linux/linux_proto.h>
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index b17141073fdf..939e0fe941b5 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/procfs.h>
 #include <sys/ptrace.h>
 #include <sys/racct.h>
+#include <sys/reg.h>
 #include <sys/resourcevar.h>
 #include <sys/rwlock.h>
 #include <sys/sbuf.h>
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 656de54cabc2..b001c413d6e7 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/priv.h>
 #include <sys/proc.h>
 #include <sys/ptrace.h>
+#include <sys/reg.h>
 #include <sys/resourcevar.h>
 #include <sys/rwlock.h>
 #include <sys/sched.h>
@@ -91,8 +92,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/pmckern.h>
 #endif
 
-#include <machine/reg.h>
-
 #include <security/audit/audit.h>
 #include <security/mac/mac_framework.h>
 
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index 267ffc3d8d50..8c5f795df691 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/limits.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
+#include <sys/reg.h>
 #include <sys/syscallsubr.h>
 #include <sys/sysent.h>
 #include <sys/sysproto.h>
@@ -54,8 +55,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/caprights.h>
 #include <sys/filedesc.h>
 
-#include <machine/reg.h>
-
 #include <security/audit/audit.h>
 
 #include <vm/vm.h>
diff --git a/sys/mips/include/md_var.h b/sys/mips/include/md_var.h
index 64cc2058f71b..138047a13b47 100644
--- a/sys/mips/include/md_var.h
+++ b/sys/mips/include/md_var.h
@@ -36,7 +36,7 @@
 #ifndef _MACHINE_MD_VAR_H_
 #define	_MACHINE_MD_VAR_H_
 
-#include <machine/reg.h>
+#include <machine/regnum.h>
 
 /*
  * Miscellaneous machine-dependent declarations.
diff --git a/sys/mips/include/reg.h b/sys/mips/include/reg.h
index a1f5aa4da23c..440b791bffc7 100644
--- a/sys/mips/include/reg.h
+++ b/sys/mips/include/reg.h
@@ -85,23 +85,7 @@ struct dbreg32 {
 #define __HAVE_REG32
 #endif
 
-#ifdef _KERNEL
-int	fill_fpregs(struct thread *, struct fpreg *);
-int	fill_regs(struct thread *, struct reg *);
-int	set_fpregs(struct thread *, struct fpreg *);
-int	set_regs(struct thread *, struct reg *);
-int	fill_dbregs(struct thread *, struct dbreg *);
-int	set_dbregs(struct thread *, struct dbreg *);
-#endif
-
 #ifdef COMPAT_FREEBSD32
-struct image_params;
-
-int	fill_regs32(struct thread *, struct reg32 *);
-int	set_regs32(struct thread *, struct reg32 *);
-int	fill_fpregs32(struct thread *, struct fpreg32 *);
-int	set_fpregs32(struct thread *, struct fpreg32 *);
-
 #define	fill_dbregs32(td, reg)	0
 #define	set_dbregs32(td, reg)	0
 #endif
diff --git a/sys/mips/mips/freebsd32_machdep.c b/sys/mips/mips/freebsd32_machdep.c
index b59ef995a4b2..710c7315de3c 100644
--- a/sys/mips/mips/freebsd32_machdep.c
+++ b/sys/mips/mips/freebsd32_machdep.c
@@ -48,6 +48,7 @@
 #include <sys/fcntl.h>
 #include <sys/sysent.h>
 #include <sys/imgact_elf.h>
+#include <sys/reg.h>
 #include <sys/syscall.h>
 #include <sys/syscallsubr.h>
 #include <sys/sysproto.h>
@@ -60,7 +61,6 @@
 
 #include <machine/cpuinfo.h>
 #include <machine/md_var.h>
-#include <machine/reg.h>
 #include <machine/sigframe.h>
 #include <machine/sysarch.h>
 #include <machine/tls.h>
diff --git a/sys/mips/mips/gdb_machdep.c b/sys/mips/mips/gdb_machdep.c
index 130a78f9eb87..4b999613d7f6 100644
--- a/sys/mips/mips/gdb_machdep.c
+++ b/sys/mips/mips/gdb_machdep.c
@@ -101,7 +101,6 @@
 
 #include <machine/gdb_machdep.h>
 #include <machine/pcb.h>
-#include <machine/reg.h>
 #include <machine/trap.h>
 
 #include <gdb/gdb.h>
diff --git a/sys/mips/mips/machdep.c b/sys/mips/mips/machdep.c
index fd0f83e5df98..ec0f3f31c254 100644
--- a/sys/mips/mips/machdep.c
+++ b/sys/mips/mips/machdep.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mbuf.h>
 #include <sys/msgbuf.h>
 #include <sys/reboot.h>
+#include <sys/reg.h>
 #include <sys/rwlock.h>
 #include <sys/sched.h>
 #include <sys/sysctl.h>
diff --git a/sys/mips/mips/pm_machdep.c b/sys/mips/mips/pm_machdep.c
index 8d8cf4e1023d..7a9db29b6ff6 100644
--- a/sys/mips/mips/pm_machdep.c
+++ b/sys/mips/mips/pm_machdep.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/sysent.h>
 #include <sys/proc.h>
+#include <sys/reg.h>
 #include <sys/signalvar.h>
 #include <sys/exec.h>
 #include <sys/ktr.h>
@@ -62,7 +63,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/uio.h>
 #include <machine/abi.h>
 #include <machine/cpuinfo.h>
-#include <machine/reg.h>
 #include <machine/md_var.h>
 #include <machine/sigframe.h>
 #include <machine/tls.h>
diff --git a/sys/mips/nlm/cms.c b/sys/mips/nlm/cms.c
index 32ee6e1c9546..4b6ad7c95db4 100644
--- a/sys/mips/nlm/cms.c
+++ b/sys/mips/nlm/cms.c
@@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysctl.h>
 #include <sys/malloc.h>
 
-#include <machine/reg.h>
 #include <machine/cpu.h>
 #include <machine/hwfunc.h>
 #include <machine/mips_opcode.h>
diff --git a/sys/mips/nlm/dev/net/xlpge.c b/sys/mips/nlm/dev/net/xlpge.c
index e9dadf83c7eb..20fe16048212 100644
--- a/sys/mips/nlm/dev/net/xlpge.c
+++ b/sys/mips/nlm/dev/net/xlpge.c
@@ -69,7 +69,6 @@ __FBSDID("$FreeBSD$");
 #include <vm/pmap.h>
 #include <vm/uma.h>
 
-#include <machine/reg.h>
 #include <machine/cpu.h>
 #include <machine/mips_opcode.h>
 #include <machine/asm.h>
diff --git a/sys/powerpc/aim/aim_machdep.c b/sys/powerpc/aim/aim_machdep.c
index bfbea09781a6..914296440104 100644
--- a/sys/powerpc/aim/aim_machdep.c
+++ b/sys/powerpc/aim/aim_machdep.c
@@ -118,7 +118,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/metadata.h>
 #include <machine/mmuvar.h>
 #include <machine/pcb.h>
-#include <machine/reg.h>
 #include <machine/sigframe.h>
 #include <machine/spr.h>
 #include <machine/trap.h>
diff --git a/sys/powerpc/booke/booke_machdep.c b/sys/powerpc/booke/booke_machdep.c
index 09396d854045..5db1a17fc243 100644
--- a/sys/powerpc/booke/booke_machdep.c
+++ b/sys/powerpc/booke/booke_machdep.c
@@ -122,7 +122,6 @@ __FBSDID("$FreeBSD$");
 
 #include <machine/cpu.h>
 #include <machine/kdb.h>
-#include <machine/reg.h>
 #include <machine/vmparam.h>
 #include <machine/spr.h>
 #include <machine/hid.h>
diff --git a/sys/powerpc/fpu/fpu_add.c b/sys/powerpc/fpu/fpu_add.c
index 6dd594ca0ec9..fdab0d8872ab 100644
--- a/sys/powerpc/fpu/fpu_add.c
+++ b/sys/powerpc/fpu/fpu_add.c
@@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$");
 
 #include <machine/fpu.h>
 #include <machine/ieeefp.h>
-#include <machine/reg.h>
 
 #include <powerpc/fpu/fpu_arith.h>
 #include <powerpc/fpu/fpu_emu.h>
diff --git a/sys/powerpc/fpu/fpu_compare.c b/sys/powerpc/fpu/fpu_compare.c
index 48d7c488ce8a..633d32dcc717 100644
--- a/sys/powerpc/fpu/fpu_compare.c
+++ b/sys/powerpc/fpu/fpu_compare.c
@@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 
 #include <machine/fpu.h>
-#include <machine/reg.h>
 
 #include <powerpc/fpu/fpu_arith.h>
 #include <powerpc/fpu/fpu_emu.h>
diff --git a/sys/powerpc/fpu/fpu_div.c b/sys/powerpc/fpu/fpu_div.c
index 5b625f640f13..7536d4aaa69e 100644
--- a/sys/powerpc/fpu/fpu_div.c
+++ b/sys/powerpc/fpu/fpu_div.c
@@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 
 #include <machine/fpu.h>
-#include <machine/reg.h>
 
 #include <powerpc/fpu/fpu_arith.h>
 #include <powerpc/fpu/fpu_emu.h>
diff --git a/sys/powerpc/fpu/fpu_emu.c b/sys/powerpc/fpu/fpu_emu.c
index 6c1b91fb9725..c8c1f0b4b7ee 100644
--- a/sys/powerpc/fpu/fpu_emu.c
+++ b/sys/powerpc/fpu/fpu_emu.c
@@ -93,7 +93,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/signalvar.h>
 
 #include <machine/fpu.h>
-#include <machine/reg.h>
 
 #include <powerpc/fpu/fpu_emu.h>
 #include <powerpc/fpu/fpu_extern.h>
diff --git a/sys/powerpc/fpu/fpu_implode.c b/sys/powerpc/fpu/fpu_implode.c
index 69a58bf79315..8ccf4b2f8243 100644
--- a/sys/powerpc/fpu/fpu_implode.c
+++ b/sys/powerpc/fpu/fpu_implode.c
@@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/fpu.h>
 #include <machine/ieee.h>
 #include <machine/ieeefp.h>
-#include <machine/reg.h>
 
 #include <powerpc/fpu/fpu_arith.h>
 #include <powerpc/fpu/fpu_emu.h>
diff --git a/sys/powerpc/fpu/fpu_mul.c b/sys/powerpc/fpu/fpu_mul.c
index 609b261492a4..336ddaee9607 100644
--- a/sys/powerpc/fpu/fpu_mul.c
+++ b/sys/powerpc/fpu/fpu_mul.c
@@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 
 #include <machine/fpu.h>
-#include <machine/reg.h>
 
 #include <powerpc/fpu/fpu_arith.h>
 #include <powerpc/fpu/fpu_emu.h>
diff --git a/sys/powerpc/fpu/fpu_sqrt.c b/sys/powerpc/fpu/fpu_sqrt.c
index e1f5bec9006f..5a95d7eae115 100644
--- a/sys/powerpc/fpu/fpu_sqrt.c
+++ b/sys/powerpc/fpu/fpu_sqrt.c
@@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 
 #include <machine/fpu.h>
-#include <machine/reg.h>
 
 #include <powerpc/fpu/fpu_arith.h>
 #include <powerpc/fpu/fpu_emu.h>
diff --git a/sys/powerpc/fpu/fpu_subr.c b/sys/powerpc/fpu/fpu_subr.c
index fc817a7ee587..fbe1bc70aa5a 100644
--- a/sys/powerpc/fpu/fpu_subr.c
+++ b/sys/powerpc/fpu/fpu_subr.c
@@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 
 #include <machine/fpu.h>
-#include <machine/reg.h>
 
 #include <powerpc/fpu/fpu_arith.h>
 #include <powerpc/fpu/fpu_emu.h>
diff --git a/sys/powerpc/powerpc/elf32_machdep.c b/sys/powerpc/powerpc/elf32_machdep.c
index 09a0cad8087f..993c55a3ce48 100644
--- a/sys/powerpc/powerpc/elf32_machdep.c
+++ b/sys/powerpc/powerpc/elf32_machdep.c
@@ -42,6 +42,7 @@
 #include <sys/sysent.h>
 #include <sys/imgact_elf.h>
 #include <sys/jail.h>
+#include <sys/reg.h>
 #include <sys/smp.h>
 #include <sys/syscall.h>
 #include <sys/sysctl.h>
@@ -56,7 +57,6 @@
 #include <machine/cpu.h>
 #include <machine/fpu.h>
 #include <machine/elf.h>
-#include <machine/reg.h>
 #include <machine/md_var.h>
 
 #include <powerpc/powerpc/elf_common.c>
diff --git a/sys/powerpc/powerpc/exec_machdep.c b/sys/powerpc/powerpc/exec_machdep.c
index 91cc9a98f7a7..ded419bf843d 100644
--- a/sys/powerpc/powerpc/exec_machdep.c
+++ b/sys/powerpc/powerpc/exec_machdep.c
@@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/lock.h>
 #include <sys/malloc.h>
 #include <sys/mutex.h>
+#include <sys/reg.h>
 #include <sys/signalvar.h>
 #include <sys/syscallsubr.h>
 #include <sys/syscall.h>
@@ -89,7 +90,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/elf.h>
 #include <machine/fpu.h>
 #include <machine/pcb.h>
-#include <machine/reg.h>
 #include <machine/sigframe.h>
 #include <machine/trap.h>
 #include <machine/vmparam.h>
diff --git a/sys/powerpc/powerpc/gdb_machdep.c b/sys/powerpc/powerpc/gdb_machdep.c
index a7f1de512e31..e334bd46375c 100644
*** 208 LINES SKIPPED ***