diff --git a/sys/amd64/linux/linux.h b/sys/amd64/linux/linux.h
index 9080bcb36cbc..519b6bd200ac 100644
--- a/sys/amd64/linux/linux.h
+++ b/sys/amd64/linux/linux.h
@@ -1,465 +1,465 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
  * Copyright (c) 1994-1996 Søren Schmidt
  * All rights reserved.
  * Copyright (c) 2013 Dmitry Chagin <dchagin@FreeBSD.org>
  *
  * 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 AUTHOR 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 AUTHOR 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.
  *
  * $FreeBSD$
  */
 
 #ifndef _AMD64_LINUX_H_
 #define	_AMD64_LINUX_H_
 
 #include <sys/abi_compat.h>
 
 #include <compat/linux/linux.h>
 #include <amd64/linux/linux_syscall.h>
 
 #define	LINUX_LEGACY_SYSCALLS
 
 #define	LINUX_DTRACE	linuxulator
 
 /*
  * Provide a separate set of types for the Linux types.
  */
 typedef int32_t		l_int;
 typedef int64_t		l_long;
 typedef int16_t		l_short;
 typedef uint32_t	l_uint;
 typedef uint64_t	l_ulong;
 typedef uint16_t	l_ushort;
 
 typedef l_ulong		l_uintptr_t;
 typedef l_long		l_clock_t;
 typedef l_int		l_daddr_t;
 typedef l_ulong		l_dev_t;
 typedef l_uint		l_gid_t;
 typedef l_ushort	l_gid16_t;
 typedef l_uint		l_uid_t;
 typedef	l_ushort	l_uid16_t;
 typedef l_ulong		l_ino_t;
 typedef l_int		l_key_t;
 typedef l_long		l_loff_t;
 typedef l_uint		l_mode_t;
 typedef l_long		l_off_t;
 typedef l_int		l_pid_t;
 typedef l_ulong		l_size_t;
 typedef l_long		l_ssize_t;
 typedef l_long		l_suseconds_t;
 typedef l_long		l_time_t;
 typedef l_int		l_timer_t;
 typedef l_int		l_mqd_t;
 typedef l_size_t	l_socklen_t;
 typedef	l_ulong		l_fd_mask;
 
 typedef struct {
 	l_int		val[2];
 } l_fsid_t;
 
 typedef struct {
 	l_time_t	tv_sec;
 	l_suseconds_t	tv_usec;
 } l_timeval;
 
 #define	l_fd_set	fd_set
 
 /*
  * Miscellaneous
  */
 #define LINUX_AT_COUNT		20	/* Count of used aux entry types. */
 
 struct l___sysctl_args
 {
 	l_uintptr_t	name;
 	l_int		nlen;
 	l_uintptr_t	oldval;
 	l_uintptr_t	oldlenp;
 	l_uintptr_t	newval;
 	l_size_t	newlen;
 	l_ulong		__spare[4];
 };
 
 /* Resource limits */
 #define	LINUX_RLIMIT_CPU	0
 #define	LINUX_RLIMIT_FSIZE	1
 #define	LINUX_RLIMIT_DATA	2
 #define	LINUX_RLIMIT_STACK	3
 #define	LINUX_RLIMIT_CORE	4
 #define	LINUX_RLIMIT_RSS	5
 #define	LINUX_RLIMIT_NPROC	6
 #define	LINUX_RLIMIT_NOFILE	7
 #define	LINUX_RLIMIT_MEMLOCK	8
 #define	LINUX_RLIMIT_AS		9	/* Address space limit */
 
 #define	LINUX_RLIM_NLIMITS	10
 
 struct l_rlimit {
 	l_ulong		rlim_cur;
 	l_ulong		rlim_max;
 };
 
 /*
  * stat family of syscalls
  */
 struct l_timespec {
 	l_time_t	tv_sec;
 	l_long		tv_nsec;
 };
 
 struct l_newstat {
 	l_dev_t		st_dev;
 	l_ino_t		st_ino;
 	l_ulong		st_nlink;
 	l_uint		st_mode;
 	l_uid_t		st_uid;
 	l_gid_t		st_gid;
 	l_uint		__st_pad1;
 	l_dev_t		st_rdev;
 	l_off_t		st_size;
 	l_long		st_blksize;
 	l_long		st_blocks;
 	struct l_timespec	st_atim;
 	struct l_timespec	st_mtim;
 	struct l_timespec	st_ctim;
 	l_long		__unused1;
 	l_long		__unused2;
 	l_long		__unused3;
 };
 
 /* sigaction flags */
 #define	LINUX_SA_NOCLDSTOP	0x00000001
 #define	LINUX_SA_NOCLDWAIT	0x00000002
 #define	LINUX_SA_SIGINFO	0x00000004
 #define	LINUX_SA_RESTORER	0x04000000
 #define	LINUX_SA_ONSTACK	0x08000000
 #define	LINUX_SA_RESTART	0x10000000
 #define	LINUX_SA_INTERRUPT	0x20000000
 #define	LINUX_SA_NOMASK		0x40000000
 #define	LINUX_SA_ONESHOT	0x80000000
 
 /* sigprocmask actions */
 #define	LINUX_SIG_BLOCK		0
 #define	LINUX_SIG_UNBLOCK	1
 #define	LINUX_SIG_SETMASK	2
 
 /* sigaltstack */
 #define	LINUX_MINSIGSTKSZ	2048
 
 typedef void	(*l_handler_t)(l_int);
 
 typedef struct {
 	l_handler_t	lsa_handler;
 	l_ulong		lsa_flags;
 	l_uintptr_t	lsa_restorer;
 	l_sigset_t	lsa_mask;
 } l_sigaction_t;
 
 typedef struct {
 	l_uintptr_t	ss_sp;
 	l_int		ss_flags;
 	l_size_t	ss_size;
 } l_stack_t;
 
 struct l_fpstate {
 	u_int16_t cwd;
 	u_int16_t swd;
 	u_int16_t twd;
 	u_int16_t fop;
 	u_int64_t rip;
 	u_int64_t rdp;
 	u_int32_t mxcsr;
 	u_int32_t mxcsr_mask;
 	u_int32_t st_space[32];
 	u_int32_t xmm_space[64];
 	u_int32_t reserved2[24];
 };
 
 struct l_sigcontext {
 	l_ulong		sc_r8;
 	l_ulong		sc_r9;
 	l_ulong		sc_r10;
 	l_ulong		sc_r11;
 	l_ulong		sc_r12;
 	l_ulong		sc_r13;
 	l_ulong		sc_r14;
 	l_ulong		sc_r15;
 	l_ulong		sc_rdi;
 	l_ulong		sc_rsi;
 	l_ulong		sc_rbp;
 	l_ulong		sc_rbx;
 	l_ulong		sc_rdx;
 	l_ulong		sc_rax;
 	l_ulong		sc_rcx;
 	l_ulong		sc_rsp;
 	l_ulong		sc_rip;
 	l_ulong		sc_rflags;
 	l_ushort	sc_cs;
 	l_ushort	sc_gs;
 	l_ushort	sc_fs;
 	l_ushort	sc___pad0;
 	l_ulong		sc_err;
 	l_ulong		sc_trapno;
 	l_sigset_t	sc_mask;
 	l_ulong		sc_cr2;
 	struct l_fpstate *sc_fpstate;
 	l_ulong		sc_reserved1[8];
 };
 
 struct l_ucontext {
 	l_ulong		uc_flags;
 	l_uintptr_t	uc_link;
 	l_stack_t	uc_stack;
 	struct l_sigcontext	uc_mcontext;
 	l_sigset_t	uc_sigmask;
 };
 
 #define LINUX_SI_PREAMBLE_SIZE	(4 * sizeof(int))
 #define	LINUX_SI_MAX_SIZE	128
 #define	LINUX_SI_PAD_SIZE	((LINUX_SI_MAX_SIZE - \
 				    LINUX_SI_PREAMBLE_SIZE) / sizeof(l_int))
 typedef union l_sigval {
 	l_int		sival_int;
 	l_uintptr_t	sival_ptr;
 } l_sigval_t;
 
 typedef struct l_siginfo {
 	l_int		lsi_signo;
 	l_int		lsi_errno;
 	l_int		lsi_code;
 	union {
 		l_int	_pad[LINUX_SI_PAD_SIZE];
 
 		struct {
 			l_pid_t		_pid;
 			l_uid_t		_uid;
 		} _kill;
 
 		struct {
 			l_timer_t	_tid;
 			l_int		_overrun;
 			char		_pad[sizeof(l_uid_t) - sizeof(int)];
 			union l_sigval	_sigval;
 			l_uint		_sys_private;
 		} _timer;
 
 		struct {
 			l_pid_t		_pid;		/* sender's pid */
 			l_uid_t		_uid;		/* sender's uid */
 			union l_sigval	_sigval;
 		} _rt;
 
 		struct {
 			l_pid_t		_pid;		/* which child */
 			l_uid_t		_uid;		/* sender's uid */
 			l_int		_status;	/* exit code */
 			l_clock_t	_utime;
 			l_clock_t	_stime;
 		} _sigchld;
 
 		struct {
 			l_uintptr_t	_addr;	/* Faulting insn/memory ref. */
 		} _sigfault;
 
 		struct {
 			l_long		_band;	/* POLL_IN,POLL_OUT,POLL_MSG */
 			l_int		_fd;
 		} _sigpoll;
 	} _sifields;
 } l_siginfo_t;
 
 #define	lsi_pid		_sifields._kill._pid
 #define	lsi_uid		_sifields._kill._uid
 #define	lsi_tid		_sifields._timer._tid
 #define	lsi_overrun	_sifields._timer._overrun
 #define	lsi_sys_private	_sifields._timer._sys_private
 #define	lsi_status	_sifields._sigchld._status
 #define	lsi_utime	_sifields._sigchld._utime
 #define	lsi_stime	_sifields._sigchld._stime
 #define	lsi_value	_sifields._rt._sigval
 #define	lsi_int		_sifields._rt._sigval.sival_int
 #define	lsi_ptr		_sifields._rt._sigval.sival_ptr
 #define	lsi_addr	_sifields._sigfault._addr
 #define	lsi_band	_sifields._sigpoll._band
 #define	lsi_fd		_sifields._sigpoll._fd
 
 /*
  * We make the stack look like Linux expects it when calling a signal
  * handler, but use the BSD way of calling the handler and sigreturn().
  * This means that we need to pass the pointer to the handler too.
  * It is appended to the frame to not interfere with the rest of it.
  */
 
 struct l_rt_sigframe {
 	struct l_ucontext	sf_sc;
 	struct l_siginfo	sf_si;
 	l_handler_t		sf_handler;
 };
 
 /*
  * mount flags
  */
 #define	LINUX_MS_RDONLY		0x0001
 #define	LINUX_MS_NOSUID		0x0002
 #define	LINUX_MS_NODEV		0x0004
 #define	LINUX_MS_NOEXEC		0x0008
 #define	LINUX_MS_REMOUNT	0x0020
 
 /*
  * SystemV IPC defines
  */
 #define	LINUX_IPC_RMID		0
 #define	LINUX_IPC_SET		1
 #define	LINUX_IPC_STAT		2
 #define	LINUX_IPC_INFO		3
 
 #define	LINUX_SHM_LOCK		11
 #define	LINUX_SHM_UNLOCK	12
 #define	LINUX_SHM_STAT		13
 #define	LINUX_SHM_INFO		14
 
 #define	LINUX_SHM_RDONLY	0x1000
 #define	LINUX_SHM_RND		0x2000
 #define	LINUX_SHM_REMAP		0x4000
 
 /* semctl commands */
 #define	LINUX_GETPID		11
 #define	LINUX_GETVAL		12
 #define	LINUX_GETALL		13
 #define	LINUX_GETNCNT		14
 #define	LINUX_GETZCNT		15
 #define	LINUX_SETVAL		16
 #define	LINUX_SETALL		17
 #define	LINUX_SEM_STAT		18
 #define	LINUX_SEM_INFO		19
 
 union l_semun {
 	l_int		val;
 	l_uintptr_t	buf;
 	l_uintptr_t	array;
 	l_uintptr_t	__buf;
 	l_uintptr_t	__pad;
 };
 
 struct l_ifmap {
 	l_ulong		mem_start;
 	l_ulong		mem_end;
 	l_ushort	base_addr;
 	u_char		irq;
 	u_char		dma;
 	u_char		port;
 	/* 3 bytes spare */
 };
 
 struct l_ifreq {
 	union {
 		char	ifrn_name[LINUX_IFNAMSIZ];
 	} ifr_ifrn;
 
 	union {
 		struct l_sockaddr	ifru_addr;
 		struct l_sockaddr	ifru_dstaddr;
 		struct l_sockaddr	ifru_broadaddr;
 		struct l_sockaddr	ifru_netmask;
 		struct l_sockaddr	ifru_hwaddr;
 		l_short		ifru_flags[1];
 		l_int		ifru_ivalue;
 		l_int		ifru_mtu;
 		struct l_ifmap	ifru_map;
 		char		ifru_slave[LINUX_IFNAMSIZ];
 		l_uintptr_t	ifru_data;
 	} ifr_ifru;
 };
 
 #define	ifr_name	ifr_ifrn.ifrn_name	/* Interface name */
 #define	ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address */
 #define	ifr_ifindex	ifr_ifru.ifru_ivalue	/* Interface index */
 
 struct l_ifconf {
 	int	ifc_len;
 	union {
 		l_uintptr_t	ifcu_buf;
 		l_uintptr_t	ifcu_req;
 	} ifc_ifcu;
 };
 
 #define	ifc_buf		ifc_ifcu.ifcu_buf
 #define	ifc_req		ifc_ifcu.ifcu_req
 
 #define LINUX_ARCH_SET_GS		0x1001
 #define LINUX_ARCH_SET_FS		0x1002
 #define LINUX_ARCH_GET_FS		0x1003
 #define LINUX_ARCH_GET_GS		0x1004
 #define LINUX_ARCH_CET_STATUS		0x3001
 
 #define	linux_copyout_rusage(r, u)	copyout(r, u, sizeof(*r))
 
 /* robust futexes */
 struct linux_robust_list {
 	l_uintptr_t			next;
 };
 
 struct linux_robust_list_head {
 	struct linux_robust_list	list;
 	l_long				futex_offset;
 	l_uintptr_t			pending_list;
 };
 
 /* This corresponds to 'struct user_regs_struct' in Linux. */
 struct linux_pt_regset {
 	l_ulong	r15;
 	l_ulong	r14;
 	l_ulong	r13;
 	l_ulong	r12;
 	l_ulong	rbp;
 	l_ulong	rbx;
 	l_ulong	r11;
 	l_ulong	r10;
 	l_ulong	r9;
 	l_ulong	r8;
 	l_ulong	rax;
 	l_ulong	rcx;
 	l_ulong	rdx;
 	l_ulong	rsi;
 	l_ulong	rdi;
 	l_ulong	orig_rax;
 	l_ulong	rip;
 	l_ulong	cs;
 	l_ulong	eflags;
 	l_ulong	rsp;
 	l_ulong	ss;
 	l_ulong fs_base;
 	l_ulong gs_base;
 	l_ulong ds;
 	l_ulong es;
 	l_ulong fs;
 	l_ulong gs;
 };
 
 struct reg;
 
-void	bsd_to_linux_regset(struct reg *b_reg,
+void	bsd_to_linux_regset(const struct reg *b_reg,
 	    struct linux_pt_regset *l_regset);
 
 #endif /* !_AMD64_LINUX_H_ */
diff --git a/sys/amd64/linux/linux_machdep.c b/sys/amd64/linux/linux_machdep.c
index dc6b6140f60c..c34d98e86d0b 100644
--- a/sys/amd64/linux/linux_machdep.c
+++ b/sys/amd64/linux/linux_machdep.c
@@ -1,332 +1,332 @@
 /*-
  * Copyright (c) 2004 Tim J. Robbins
  * Copyright (c) 2002 Doug Rabson
  * Copyright (c) 2000 Marcel Moolenaar
  * All rights reserved.
  * Copyright (c) 2013 Dmitry Chagin <dchagin@FreeBSD.org>
  *
  * 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
  *    in this position and unchanged.
  * 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. The name of the author may not be used to endorse or promote products
  *    derived from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
  */
 
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/capsicum.h>
 #include <sys/clock.h>
 #include <sys/dirent.h>
 #include <sys/fcntl.h>
 #include <sys/file.h>
 #include <sys/filedesc.h>
 #include <sys/imgact.h>
 #include <sys/kernel.h>
 #include <sys/ktr.h>
 #include <sys/limits.h>
 #include <sys/lock.h>
 #include <sys/malloc.h>
 #include <sys/mman.h>
 #include <sys/mutex.h>
 #include <sys/priv.h>
 #include <sys/proc.h>
 #include <sys/resource.h>
 #include <sys/resourcevar.h>
 #include <sys/sched.h>
 #include <sys/syscallsubr.h>
 #include <sys/sysproto.h>
 #include <sys/systm.h>
 #include <sys/unistd.h>
 #include <sys/vnode.h>
 #include <sys/wait.h>
 
 #include <security/mac/mac_framework.h>
 
 #include <ufs/ufs/extattr.h>
 #include <ufs/ufs/quota.h>
 #include <ufs/ufs/ufsmount.h>
 
 #include <machine/frame.h>
 #include <machine/md_var.h>
 #include <machine/pcb.h>
 #include <machine/psl.h>
 #include <machine/segments.h>
 #include <machine/specialreg.h>
 
 #include <vm/pmap.h>
 #include <vm/vm.h>
 #include <vm/vm_extern.h>
 #include <vm/vm_kern.h>
 #include <vm/vm_map.h>
 
 #include <x86/ifunc.h>
 #include <x86/reg.h>
 #include <x86/sysarch.h>
 
 #include <security/audit/audit.h>
 
 #include <amd64/linux/linux.h>
 #include <amd64/linux/linux_proto.h>
 #include <compat/linux/linux_emul.h>
 #include <compat/linux/linux_file.h>
 #include <compat/linux/linux_fork.h>
 #include <compat/linux/linux_ipc.h>
 #include <compat/linux/linux_misc.h>
 #include <compat/linux/linux_mmap.h>
 #include <compat/linux/linux_signal.h>
 #include <compat/linux/linux_util.h>
 
 int
 linux_execve(struct thread *td, struct linux_execve_args *args)
 {
 	struct image_args eargs;
 	char *path;
 	int error;
 
 	LINUX_CTR(execve);
 
 	if (!LUSECONVPATH(td)) {
 		error = exec_copyin_args(&eargs, args->path, UIO_USERSPACE,
 		    args->argp, args->envp);
 	} else {
 		LCONVPATHEXIST(td, args->path, &path);
 		error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, args->argp,
 		    args->envp);
 		LFREEPATH(path);
 	}
 	if (error == 0)
 		error = linux_common_execve(td, &eargs);
 	AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
 	return (error);
 }
 
 int
 linux_set_upcall(struct thread *td, register_t stack)
 {
 
 	if (stack)
 		td->td_frame->tf_rsp = stack;
 
 	/*
 	 * The newly created Linux thread returns
 	 * to the user space by the same path that a parent does.
 	 */
 	td->td_frame->tf_rax = 0;
 	return (0);
 }
 
 int
 linux_mmap2(struct thread *td, struct linux_mmap2_args *args)
 {
 
 	return (linux_mmap_common(td, args->addr, args->len, args->prot,
 		args->flags, args->fd, args->pgoff));
 }
 
 int
 linux_mprotect(struct thread *td, struct linux_mprotect_args *uap)
 {
 
 	return (linux_mprotect_common(td, uap->addr, uap->len, uap->prot));
 }
 
 int
 linux_madvise(struct thread *td, struct linux_madvise_args *uap)
 {
 
 	return (linux_madvise_common(td, uap->addr, uap->len, uap->behav));
 }
 
 int
 linux_iopl(struct thread *td, struct linux_iopl_args *args)
 {
 	int error;
 
 	LINUX_CTR(iopl);
 
 	if (args->level > 3)
 		return (EINVAL);
 	if ((error = priv_check(td, PRIV_IO)) != 0)
 		return (error);
 	if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
 		return (error);
 	td->td_frame->tf_rflags = (td->td_frame->tf_rflags & ~PSL_IOPL) |
 	    (args->level * (PSL_IOPL / 3));
 
 	return (0);
 }
 
 int
 linux_pause(struct thread *td, struct linux_pause_args *args)
 {
 	struct proc *p = td->td_proc;
 	sigset_t sigmask;
 
 	LINUX_CTR(pause);
 
 	PROC_LOCK(p);
 	sigmask = td->td_sigmask;
 	PROC_UNLOCK(p);
 	return (kern_sigsuspend(td, sigmask));
 }
 
 int
 linux_arch_prctl(struct thread *td, struct linux_arch_prctl_args *args)
 {
 	unsigned long long cet[3];
 	struct pcb *pcb;
 	int error;
 
 	pcb = td->td_pcb;
 	LINUX_CTR2(arch_prctl, "0x%x, %p", args->code, args->addr);
 
 	switch (args->code) {
 	case LINUX_ARCH_SET_GS:
 		if (args->addr < VM_MAXUSER_ADDRESS) {
 			update_pcb_bases(pcb);
 			pcb->pcb_gsbase = args->addr;
 			td->td_frame->tf_gs = _ugssel;
 			error = 0;
 		} else
 			error = EPERM;
 		break;
 	case LINUX_ARCH_SET_FS:
 		if (args->addr < VM_MAXUSER_ADDRESS) {
 			update_pcb_bases(pcb);
 			pcb->pcb_fsbase = args->addr;
 			td->td_frame->tf_fs = _ufssel;
 			error = 0;
 		} else
 			error = EPERM;
 		break;
 	case LINUX_ARCH_GET_FS:
 		error = copyout(&pcb->pcb_fsbase, PTRIN(args->addr),
 		    sizeof(args->addr));
 		break;
 	case LINUX_ARCH_GET_GS:
 		error = copyout(&pcb->pcb_gsbase, PTRIN(args->addr),
 		    sizeof(args->addr));
 		break;
 	case LINUX_ARCH_CET_STATUS:
 		memset(cet, 0, sizeof(cet));
 		error = copyout(&cet, PTRIN(args->addr), sizeof(cet));
 		break;
 	default:
 		linux_msg(td, "unsupported arch_prctl code %#x", args->code);
 		error = EINVAL;
 	}
 	return (error);
 }
 
 int
 linux_set_cloned_tls(struct thread *td, void *desc)
 {
 	struct pcb *pcb;
 
 	if ((uint64_t)desc >= VM_MAXUSER_ADDRESS)
 		return (EPERM);
 
 	pcb = td->td_pcb;
 	update_pcb_bases(pcb);
 	pcb->pcb_fsbase = (register_t)desc;
 	td->td_frame->tf_fs = _ufssel;
 
 	return (0);
 }
 
 int futex_xchgl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
 int futex_xchgl_smap(int oparg, uint32_t *uaddr, int *oldval);
 DEFINE_IFUNC(, int, futex_xchgl, (int, uint32_t *, int *))
 {
 
 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
 	    futex_xchgl_smap : futex_xchgl_nosmap);
 }
 
 int futex_addl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
 int futex_addl_smap(int oparg, uint32_t *uaddr, int *oldval);
 DEFINE_IFUNC(, int, futex_addl, (int, uint32_t *, int *))
 {
 
 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
 	    futex_addl_smap : futex_addl_nosmap);
 }
 
 int futex_orl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
 int futex_orl_smap(int oparg, uint32_t *uaddr, int *oldval);
 DEFINE_IFUNC(, int, futex_orl, (int, uint32_t *, int *))
 {
 
 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
 	    futex_orl_smap : futex_orl_nosmap);
 }
 
 int futex_andl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
 int futex_andl_smap(int oparg, uint32_t *uaddr, int *oldval);
 DEFINE_IFUNC(, int, futex_andl, (int, uint32_t *, int *))
 {
 
 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
 	    futex_andl_smap : futex_andl_nosmap);
 }
 
 int futex_xorl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
 int futex_xorl_smap(int oparg, uint32_t *uaddr, int *oldval);
 DEFINE_IFUNC(, int, futex_xorl, (int, uint32_t *, int *))
 {
 
 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
 	    futex_xorl_smap : futex_xorl_nosmap);
 }
 
 void
-bsd_to_linux_regset(struct reg *b_reg, struct linux_pt_regset *l_regset)
+bsd_to_linux_regset(const struct reg *b_reg, struct linux_pt_regset *l_regset)
 {
 
 	l_regset->r15 = b_reg->r_r15;
 	l_regset->r14 = b_reg->r_r14;
 	l_regset->r13 = b_reg->r_r13;
 	l_regset->r12 = b_reg->r_r12;
 	l_regset->rbp = b_reg->r_rbp;
 	l_regset->rbx = b_reg->r_rbx;
 	l_regset->r11 = b_reg->r_r11;
 	l_regset->r10 = b_reg->r_r10;
 	l_regset->r9 = b_reg->r_r9;
 	l_regset->r8 = b_reg->r_r8;
 	l_regset->rax = b_reg->r_rax;
 	l_regset->rcx = b_reg->r_rcx;
 	l_regset->rdx = b_reg->r_rdx;
 	l_regset->rsi = b_reg->r_rsi;
 	l_regset->rdi = b_reg->r_rdi;
 	l_regset->orig_rax = b_reg->r_rax;
 	l_regset->rip = b_reg->r_rip;
 	l_regset->cs = b_reg->r_cs;
 	l_regset->eflags = b_reg->r_rflags;
 	l_regset->rsp = b_reg->r_rsp;
 	l_regset->ss = b_reg->r_ss;
 	l_regset->fs_base = 0;
 	l_regset->gs_base = 0;
 	l_regset->ds = b_reg->r_ds;
 	l_regset->es = b_reg->r_es;
 	l_regset->fs = b_reg->r_fs;
 	l_regset->gs = b_reg->r_gs;
 }
diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h
index 8d7a36eedee9..f1f877181e47 100644
--- a/sys/amd64/linux32/linux.h
+++ b/sys/amd64/linux32/linux.h
@@ -1,640 +1,640 @@
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
  * Copyright (c) 2004 Tim J. Robbins
  * Copyright (c) 2001 Doug Rabson
  * Copyright (c) 1994-1996 Søren Schmidt
  * 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
  *    in this position and unchanged.
  * 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. The name of the author may not be used to endorse or promote products
  *    derived from this software without specific prior written permission
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
  *
  * $FreeBSD$
  */
 
 #ifndef _AMD64_LINUX_H_
 #define	_AMD64_LINUX_H_
 
 #include <sys/abi_compat.h>
 
 #include <compat/linux/linux.h>
 #include <amd64/linux32/linux32_syscall.h>
 
 #define	LINUX_LEGACY_SYSCALLS
 
 #define	LINUX_DTRACE	linuxulator32
 
 #define	LINUX32_MAXDSIZ		(512 * 1024 * 1024)	/* 512MB */
 #define	LINUX32_MAXSSIZ		(64 * 1024 * 1024)	/* 64MB */
 #define	LINUX32_MAXVMEM		0			/* Unlimited */
 
 /*
  * Provide a separate set of types for the Linux types.
  */
 typedef int		l_int;
 typedef int32_t		l_long;
 typedef int64_t		l_longlong;
 typedef short		l_short;
 typedef unsigned int	l_uint;
 typedef uint32_t	l_ulong;
 typedef uint64_t	l_ulonglong;
 typedef unsigned short	l_ushort;
 
 typedef l_ulong		l_uintptr_t;
 typedef l_long		l_clock_t;
 typedef l_int		l_daddr_t;
 typedef l_ushort	l_dev_t;
 typedef l_uint		l_gid_t;
 typedef l_ushort	l_gid16_t;
 typedef l_ulong		l_ino_t;
 typedef l_int		l_key_t;
 typedef l_longlong	l_loff_t;
 typedef l_ushort	l_mode_t;
 typedef l_long		l_off_t;
 typedef l_int		l_pid_t;
 typedef l_uint		l_size_t;
 typedef l_long		l_suseconds_t;
 typedef l_long		l_time_t;
 typedef l_longlong	l_time64_t;
 typedef l_uint		l_uid_t;
 typedef l_ushort	l_uid16_t;
 typedef l_int		l_timer_t;
 typedef l_int		l_mqd_t;
 typedef	l_ulong		l_fd_mask;
 
 typedef struct {
 	l_int		val[2];
 } l_fsid_t;
 
 typedef struct {
 	l_time_t	tv_sec;
 	l_suseconds_t	tv_usec;
 } l_timeval;
 
 #define	l_fd_set	fd_set
 
 /*
  * Miscellaneous
  */
 #define	LINUX_AT_COUNT		21	/* Count of used aux entry types.
 					 * Keep this synchronized with
 					 * linux_fixup_elf() code.
 					 */
 struct l___sysctl_args
 {
 	l_uintptr_t	name;
 	l_int		nlen;
 	l_uintptr_t	oldval;
 	l_uintptr_t	oldlenp;
 	l_uintptr_t	newval;
 	l_size_t	newlen;
 	l_ulong		__spare[4];
 };
 
 /* Resource limits */
 #define	LINUX_RLIMIT_CPU	0
 #define	LINUX_RLIMIT_FSIZE	1
 #define	LINUX_RLIMIT_DATA	2
 #define	LINUX_RLIMIT_STACK	3
 #define	LINUX_RLIMIT_CORE	4
 #define	LINUX_RLIMIT_RSS	5
 #define	LINUX_RLIMIT_NPROC	6
 #define	LINUX_RLIMIT_NOFILE	7
 #define	LINUX_RLIMIT_MEMLOCK	8
 #define	LINUX_RLIMIT_AS		9	/* Address space limit */
 
 #define	LINUX_RLIM_NLIMITS	10
 
 struct l_rlimit {
 	l_ulong rlim_cur;
 	l_ulong rlim_max;
 };
 
 struct l_rusage {
 	l_timeval ru_utime;
 	l_timeval ru_stime;
 	l_long	ru_maxrss;
 	l_long	ru_ixrss;
 	l_long	ru_idrss;
 	l_long	ru_isrss;
 	l_long	ru_minflt;
 	l_long	ru_majflt;
 	l_long	ru_nswap;
 	l_long	ru_inblock;
 	l_long	ru_oublock;
 	l_long	ru_msgsnd;
 	l_long	ru_msgrcv;
 	l_long	ru_nsignals;
 	l_long	ru_nvcsw;
 	l_long	ru_nivcsw;
 };
 
 struct l_mmap_argv {
 	l_uintptr_t	addr;
 	l_size_t	len;
 	l_int		prot;
 	l_int		flags;
 	l_int		fd;
 	l_ulong		pgoff;
 };
 
 /*
  * stat family of syscalls
  */
 struct l_timespec {
 	l_time_t	tv_sec;
 	l_long		tv_nsec;
 };
 
 /* __kernel_timespec */
 struct l_timespec64 {
 	l_time64_t	tv_sec;
 	l_longlong	tv_nsec;
 };
 
 struct l_newstat {
 	l_ushort	st_dev;
 	l_ushort	__pad1;
 	l_ulong		st_ino;
 	l_ushort	st_mode;
 	l_ushort	st_nlink;
 	l_ushort	st_uid;
 	l_ushort	st_gid;
 	l_ushort	st_rdev;
 	l_ushort	__pad2;
 	l_ulong		st_size;
 	l_ulong		st_blksize;
 	l_ulong		st_blocks;
 	struct l_timespec	st_atim;
 	struct l_timespec	st_mtim;
 	struct l_timespec	st_ctim;
 	l_ulong		__unused4;
 	l_ulong		__unused5;
 };
 
 struct l_stat {
 	l_ushort	st_dev;
 	l_ulong		st_ino;
 	l_ushort	st_mode;
 	l_ushort	st_nlink;
 	l_ushort	st_uid;
 	l_ushort	st_gid;
 	l_ushort	st_rdev;
 	l_long		st_size;
 	struct l_timespec	st_atim;
 	struct l_timespec	st_mtim;
 	struct l_timespec	st_ctim;
 	l_long		st_blksize;
 	l_long		st_blocks;
 	l_ulong		st_flags;
 	l_ulong		st_gen;
 };
 
 struct l_stat64 {
 	l_ushort	st_dev;
 	u_char		__pad0[10];
 	l_ulong		__st_ino;
 	l_uint		st_mode;
 	l_uint		st_nlink;
 	l_ulong		st_uid;
 	l_ulong		st_gid;
 	l_ushort	st_rdev;
 	u_char		__pad3[10];
 	l_longlong	st_size;
 	l_ulong		st_blksize;
 	l_ulong		st_blocks;
 	l_ulong		__pad4;
 	struct l_timespec	st_atim;
 	struct l_timespec	st_mtim;
 	struct l_timespec	st_ctim;
 	l_ulonglong	st_ino;
 } __packed;
 
 struct l_statfs64 {
 	l_int		f_type;
 	l_int		f_bsize;
 	uint64_t	f_blocks;
 	uint64_t	f_bfree;
 	uint64_t	f_bavail;
 	uint64_t	f_files;
 	uint64_t	f_ffree;
 	l_fsid_t	f_fsid;
 	l_int		f_namelen;
 	l_int		f_frsize;
 	l_int		f_flags;
 	l_int		f_spare[4];
 } __packed;
 
 /* sigaction flags */
 #define	LINUX_SA_NOCLDSTOP	0x00000001
 #define	LINUX_SA_NOCLDWAIT	0x00000002
 #define	LINUX_SA_SIGINFO	0x00000004
 #define	LINUX_SA_RESTORER	0x04000000
 #define	LINUX_SA_ONSTACK	0x08000000
 #define	LINUX_SA_RESTART	0x10000000
 #define	LINUX_SA_INTERRUPT	0x20000000
 #define	LINUX_SA_NOMASK		0x40000000
 #define	LINUX_SA_ONESHOT	0x80000000
 
 /* sigprocmask actions */
 #define	LINUX_SIG_BLOCK		0
 #define	LINUX_SIG_UNBLOCK	1
 #define	LINUX_SIG_SETMASK	2
 
 /* sigaltstack */
 #define	LINUX_MINSIGSTKSZ	2048
 
 typedef l_uintptr_t l_handler_t;
 typedef l_ulong	l_osigset_t;
 
 typedef struct {
 	l_handler_t	lsa_handler;
 	l_osigset_t	lsa_mask;
 	l_ulong		lsa_flags;
 	l_uintptr_t	lsa_restorer;
 } l_osigaction_t;
 
 typedef struct {
 	l_handler_t	lsa_handler;
 	l_ulong		lsa_flags;
 	l_uintptr_t	lsa_restorer;
 	l_sigset_t	lsa_mask;
 } __packed l_sigaction_t;
 
 typedef struct {
 	l_uintptr_t	ss_sp;
 	l_int		ss_flags;
 	l_size_t	ss_size;
 } l_stack_t;
 
 /* The Linux sigcontext, pretty much a standard 386 trapframe. */
 struct l_sigcontext {
 	l_uint		sc_gs;
 	l_uint		sc_fs;
 	l_uint		sc_es;
 	l_uint		sc_ds;
 	l_uint		sc_edi;
 	l_uint		sc_esi;
 	l_uint		sc_ebp;
 	l_uint		sc_esp;
 	l_uint		sc_ebx;
 	l_uint		sc_edx;
 	l_uint		sc_ecx;
 	l_uint		sc_eax;
 	l_uint		sc_trapno;
 	l_uint		sc_err;
 	l_uint		sc_eip;
 	l_uint		sc_cs;
 	l_uint		sc_eflags;
 	l_uint		sc_esp_at_signal;
 	l_uint		sc_ss;
 	l_uint		sc_387;
 	l_uint		sc_mask;
 	l_uint		sc_cr2;
 };
 
 struct l_ucontext {
 	l_ulong		uc_flags;
 	l_uintptr_t	uc_link;
 	l_stack_t	uc_stack;
 	struct l_sigcontext	uc_mcontext;
 	l_sigset_t	uc_sigmask;
 } __packed;
 
 #define	LINUX_SI_MAX_SIZE	128
 #define	LINUX_SI_PAD_SIZE	((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3)
 
 typedef union l_sigval {
 	l_int		sival_int;
 	l_uintptr_t	sival_ptr;
 } l_sigval_t;
 
 typedef struct l_siginfo {
 	l_int		lsi_signo;
 	l_int		lsi_errno;
 	l_int		lsi_code;
 	union {
 		l_int	_pad[LINUX_SI_PAD_SIZE];
 
 		struct {
 			l_pid_t		_pid;
 			l_uid_t		_uid;
 		} _kill;
 
 		struct {
 			l_timer_t	_tid;
 			l_int		_overrun;
 			char		_pad[sizeof(l_uid_t) - sizeof(l_int)];
 			l_sigval_t	_sigval;
 			l_int		_sys_private;
 		} _timer;
 
 		struct {
 			l_pid_t		_pid;		/* sender's pid */
 			l_uid_t		_uid;		/* sender's uid */
 			l_sigval_t	_sigval;
 		} _rt;
 
 		struct {
 			l_pid_t		_pid;		/* which child */
 			l_uid_t		_uid;		/* sender's uid */
 			l_int		_status;	/* exit code */
 			l_clock_t	_utime;
 			l_clock_t	_stime;
 		} _sigchld;
 
 		struct {
 			l_uintptr_t	_addr;	/* Faulting insn/memory ref. */
 		} _sigfault;
 
 		struct {
 			l_long		_band;	/* POLL_IN,POLL_OUT,POLL_MSG */
 			l_int		_fd;
 		} _sigpoll;
 	} _sifields;
 } l_siginfo_t;
 
 #define	lsi_pid		_sifields._kill._pid
 #define	lsi_uid		_sifields._kill._uid
 #define	lsi_tid		_sifields._timer._tid
 #define	lsi_overrun	_sifields._timer._overrun
 #define	lsi_sys_private	_sifields._timer._sys_private
 #define	lsi_status	_sifields._sigchld._status
 #define	lsi_utime	_sifields._sigchld._utime
 #define	lsi_stime	_sifields._sigchld._stime
 #define	lsi_value	_sifields._rt._sigval
 #define	lsi_int		_sifields._rt._sigval.sival_int
 #define	lsi_ptr		_sifields._rt._sigval.sival_ptr
 #define	lsi_addr	_sifields._sigfault._addr
 #define	lsi_band	_sifields._sigpoll._band
 #define	lsi_fd		_sifields._sigpoll._fd
 
 struct l_fpreg {
 	u_int16_t	significand[4];
 	u_int16_t	exponent;
 };
 
 struct l_fpxreg {
 	u_int16_t	significand[4];
 	u_int16_t	exponent;
 	u_int16_t	padding[3];
 };
 
 struct l_xmmreg {
 	u_int32_t	element[4];
 };
 
 struct l_fpstate {
 	/* Regular FPU environment */
 	u_int32_t		cw;
 	u_int32_t		sw;
 	u_int32_t		tag;
 	u_int32_t		ipoff;
 	u_int32_t		cssel;
 	u_int32_t		dataoff;
 	u_int32_t		datasel;
 	struct l_fpreg		_st[8];
 	u_int16_t		status;
 	u_int16_t		magic;		/* 0xffff = regular FPU data */
 
 	/* FXSR FPU environment */
 	u_int32_t		_fxsr_env[6];	/* env is ignored. */
 	u_int32_t		mxcsr;
 	u_int32_t		reserved;
 	struct l_fpxreg		_fxsr_st[8];	/* reg data is ignored. */
 	struct l_xmmreg		_xmm[8];
 	u_int32_t		padding[56];
 };
 
 /*
  * We make the stack look like Linux expects it when calling a signal
  * handler, but use the BSD way of calling the handler and sigreturn().
  * This means that we need to pass the pointer to the handler too.
  * It is appended to the frame to not interfere with the rest of it.
  */
 struct l_sigframe {
 	l_int			sf_sig;
 	struct l_sigcontext	sf_sc;
 	struct l_fpstate	sf_fpstate;
 	l_uint			sf_extramask[1];
 	l_handler_t		sf_handler;
 };
 
 struct l_rt_sigframe {
 	l_int			sf_sig;
 	l_uintptr_t		sf_siginfo;
 	l_uintptr_t		sf_ucontext;
 	l_siginfo_t		sf_si;
 	struct l_ucontext	sf_sc;
 	l_handler_t		sf_handler;
 } __packed;
 
 /*
  * arch specific open/fcntl flags
  */
 #define	LINUX_F_GETLK64		12
 #define	LINUX_F_SETLK64		13
 #define	LINUX_F_SETLKW64	14
 
 union l_semun {
 	l_int		val;
 	l_uintptr_t	buf;
 	l_uintptr_t	array;
 	l_uintptr_t	__buf;
 	l_uintptr_t	__pad;
 };
 
 struct l_ifmap {
 	l_ulong		mem_start;
 	l_ulong		mem_end;
 	l_ushort	base_addr;
 	u_char		irq;
 	u_char		dma;
 	u_char		port;
 	/* 3 bytes spare */
 };
 
 struct l_ifreq {
 	union {
 		char	ifrn_name[LINUX_IFNAMSIZ];
 	} ifr_ifrn;
 
 	union {
 		struct l_sockaddr	ifru_addr;
 		struct l_sockaddr	ifru_dstaddr;
 		struct l_sockaddr	ifru_broadaddr;
 		struct l_sockaddr	ifru_netmask;
 		struct l_sockaddr	ifru_hwaddr;
 		l_short		ifru_flags[1];
 		l_int		ifru_ivalue;
 		l_int		ifru_mtu;
 		struct l_ifmap	ifru_map;
 		char		ifru_slave[LINUX_IFNAMSIZ];
 		l_uintptr_t	ifru_data;
 	} ifr_ifru;
 };
 
 #define	ifr_name	ifr_ifrn.ifrn_name	/* Interface name */
 #define	ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address */
 #define	ifr_ifindex	ifr_ifru.ifru_ivalue	/* Interface index */
 
 struct l_ifconf {
 	int	ifc_len;
 	union {
 		l_uintptr_t	ifcu_buf;
 		l_uintptr_t	ifcu_req;
 	} ifc_ifcu;
 };
 
 #define	ifc_buf		ifc_ifcu.ifcu_buf
 #define	ifc_req		ifc_ifcu.ifcu_req
 
 struct l_user_desc {
 	l_uint		entry_number;
 	l_uint		base_addr;
 	l_uint		limit;
 	l_uint		seg_32bit:1;
 	l_uint		contents:2;
 	l_uint		read_exec_only:1;
 	l_uint		limit_in_pages:1;
 	l_uint		seg_not_present:1;
 	l_uint		useable:1;
 };
 
 #define	LINUX_LOWERWORD	0x0000ffff
 
 /*
  * Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h.
  * These convert Linux user space descriptor to machine one.
  */
 #define	LINUX_LDT_entry_a(info)					\
 	((((info)->base_addr & LINUX_LOWERWORD) << 16) |	\
 	((info)->limit & LINUX_LOWERWORD))
 
 #define	LINUX_ENTRY_B_READ_EXEC_ONLY	9
 #define	LINUX_ENTRY_B_CONTENTS		10
 #define	LINUX_ENTRY_B_SEG_NOT_PRESENT	15
 #define	LINUX_ENTRY_B_BASE_ADDR		16
 #define	LINUX_ENTRY_B_USEABLE		20
 #define	LINUX_ENTRY_B_SEG32BIT		22
 #define	LINUX_ENTRY_B_LIMIT		23
 
 #define	LINUX_LDT_entry_b(info)							\
 	(((info)->base_addr & 0xff000000) |					\
 	((info)->limit & 0xf0000) |						\
 	((info)->contents << LINUX_ENTRY_B_CONTENTS) |				\
 	(((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) |	\
 	(((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) |		\
 	(((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) |	\
 	((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) |				\
 	((info)->useable << LINUX_ENTRY_B_USEABLE) |				\
 	((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000)
 
 #define	LINUX_LDT_empty(info)		\
 	((info)->base_addr == 0 &&	\
 	(info)->limit == 0 &&		\
 	(info)->contents == 0 &&	\
 	(info)->seg_not_present == 1 &&	\
 	(info)->read_exec_only == 1 &&	\
 	(info)->seg_32bit == 0 &&	\
 	(info)->limit_in_pages == 0 &&	\
 	(info)->useable == 0)
 
 /*
  * Macros for converting segments.
  * They do the same as those in arch/i386/kernel/process.c in Linux.
  */
 #define	LINUX_GET_BASE(desc)				\
 	((((desc)->a >> 16) & LINUX_LOWERWORD) |	\
 	(((desc)->b << 16) & 0x00ff0000) |		\
 	((desc)->b & 0xff000000))
 
 #define	LINUX_GET_LIMIT(desc)			\
 	(((desc)->a & LINUX_LOWERWORD) |	\
 	((desc)->b & 0xf0000))
 
 #define	LINUX_GET_32BIT(desc)		\
 	(((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1)
 #define	LINUX_GET_CONTENTS(desc)	\
 	(((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3)
 #define	LINUX_GET_WRITABLE(desc)	\
 	(((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1)
 #define	LINUX_GET_LIMIT_PAGES(desc)	\
 	(((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1)
 #define	LINUX_GET_PRESENT(desc)		\
 	(((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1)
 #define	LINUX_GET_USEABLE(desc)		\
 	(((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1)
 
 struct iovec;
 struct uio;
 
 struct l_iovec32 {
 	uint32_t	iov_base;
 	l_size_t	iov_len;
 };
 
 int linux32_copyiniov(struct l_iovec32 *iovp32, l_ulong iovcnt,
 			    struct iovec **iovp, int error);
 int linux32_copyinuio(struct l_iovec32 *iovp, l_ulong iovcnt,
 			    struct uio **uiop);
 int linux_copyout_rusage(struct rusage *ru, void *uaddr);
 
 /* robust futexes */
 struct linux_robust_list {
 	l_uintptr_t			next;
 };
 
 struct linux_robust_list_head {
 	struct linux_robust_list	list;
 	l_long				futex_offset;
 	l_uintptr_t			pending_list;
 };
 
 /* This corresponds to 'struct user_regs_struct32' in Linux. */
 struct linux_pt_regset32 {
 	l_uint ebx;
 	l_uint ecx;
 	l_uint edx;
 	l_uint esi;
 	l_uint edi;
 	l_uint ebp;
 	l_uint eax;
 	l_uint ds;
 	l_uint es;
 	l_uint fs;
 	l_uint gs;
 	l_uint orig_eax;
 	l_uint eip;
 	l_uint cs;
 	l_uint eflags;
 	l_uint esp;
 	l_uint ss;
 };
 
 struct reg32;
 
-void	bsd_to_linux_regset32(struct reg32 *b_reg,
+void	bsd_to_linux_regset32(const struct reg32 *b_reg,
 	    struct linux_pt_regset32 *l_regset);
 
 #endif /* !_AMD64_LINUX_H_ */
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c
index 5801fac7f126..86f7bdc918d8 100644
--- a/sys/amd64/linux32/linux32_machdep.c
+++ b/sys/amd64/linux32/linux32_machdep.c
@@ -1,746 +1,747 @@
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
  * Copyright (c) 2004 Tim J. Robbins
  * Copyright (c) 2002 Doug Rabson
  * Copyright (c) 2000 Marcel Moolenaar
  * 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
  *    in this position and unchanged.
  * 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. The name of the author may not be used to endorse or promote products
  *    derived from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
  */
 
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
 #include "opt_compat.h"
 
 #include <sys/param.h>
 #include <sys/capsicum.h>
 #include <sys/clock.h>
 #include <sys/fcntl.h>
 #include <sys/file.h>
 #include <sys/imgact.h>
 #include <sys/kernel.h>
 #include <sys/limits.h>
 #include <sys/lock.h>
 #include <sys/malloc.h>
 #include <sys/mman.h>
 #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>
 #include <sys/sysproto.h>
 #include <sys/systm.h>
 #include <sys/unistd.h>
 #include <sys/wait.h>
 
 #include <machine/frame.h>
 #include <machine/md_var.h>
 #include <machine/pcb.h>
 #include <machine/psl.h>
 #include <machine/segments.h>
 #include <machine/specialreg.h>
 #include <x86/ifunc.h>
 
 #include <vm/pmap.h>
 #include <vm/vm.h>
 #include <vm/vm_map.h>
 
 #include <security/audit/audit.h>
 
 #include <compat/freebsd32/freebsd32_util.h>
 #include <amd64/linux32/linux.h>
 #include <amd64/linux32/linux32_proto.h>
 #include <compat/linux/linux_emul.h>
 #include <compat/linux/linux_fork.h>
 #include <compat/linux/linux_ipc.h>
 #include <compat/linux/linux_misc.h>
 #include <compat/linux/linux_mmap.h>
 #include <compat/linux/linux_signal.h>
 #include <compat/linux/linux_util.h>
 
 static void	bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru);
 
 struct l_old_select_argv {
 	l_int		nfds;
 	l_uintptr_t	readfds;
 	l_uintptr_t	writefds;
 	l_uintptr_t	exceptfds;
 	l_uintptr_t	timeout;
 } __packed;
 
 static void
 bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru)
 {
 
 	lru->ru_utime.tv_sec = ru->ru_utime.tv_sec;
 	lru->ru_utime.tv_usec = ru->ru_utime.tv_usec;
 	lru->ru_stime.tv_sec = ru->ru_stime.tv_sec;
 	lru->ru_stime.tv_usec = ru->ru_stime.tv_usec;
 	lru->ru_maxrss = ru->ru_maxrss;
 	lru->ru_ixrss = ru->ru_ixrss;
 	lru->ru_idrss = ru->ru_idrss;
 	lru->ru_isrss = ru->ru_isrss;
 	lru->ru_minflt = ru->ru_minflt;
 	lru->ru_majflt = ru->ru_majflt;
 	lru->ru_nswap = ru->ru_nswap;
 	lru->ru_inblock = ru->ru_inblock;
 	lru->ru_oublock = ru->ru_oublock;
 	lru->ru_msgsnd = ru->ru_msgsnd;
 	lru->ru_msgrcv = ru->ru_msgrcv;
 	lru->ru_nsignals = ru->ru_nsignals;
 	lru->ru_nvcsw = ru->ru_nvcsw;
 	lru->ru_nivcsw = ru->ru_nivcsw;
 }
 
 int
 linux_copyout_rusage(struct rusage *ru, void *uaddr)
 {
 	struct l_rusage lru;
 
 	bsd_to_linux_rusage(ru, &lru);
 
 	return (copyout(&lru, uaddr, sizeof(struct l_rusage)));
 }
 
 int
 linux_execve(struct thread *td, struct linux_execve_args *args)
 {
 	struct image_args eargs;
 	char *path;
 	int error;
 
 	LCONVPATHEXIST(td, args->path, &path);
 
 	error = freebsd32_exec_copyin_args(&eargs, path, UIO_SYSSPACE,
 	    args->argp, args->envp);
 	free(path, M_TEMP);
 	if (error == 0)
 		error = linux_common_execve(td, &eargs);
 	AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
 	return (error);
 }
 
 CTASSERT(sizeof(struct l_iovec32) == 8);
 
 int
 linux32_copyinuio(struct l_iovec32 *iovp, l_ulong iovcnt, struct uio **uiop)
 {
 	struct l_iovec32 iov32;
 	struct iovec *iov;
 	struct uio *uio;
 	uint32_t iovlen;
 	int error, i;
 
 	*uiop = NULL;
 	if (iovcnt > UIO_MAXIOV)
 		return (EINVAL);
 	iovlen = iovcnt * sizeof(struct iovec);
 	uio = malloc(iovlen + sizeof(*uio), M_IOV, M_WAITOK);
 	iov = (struct iovec *)(uio + 1);
 	for (i = 0; i < iovcnt; i++) {
 		error = copyin(&iovp[i], &iov32, sizeof(struct l_iovec32));
 		if (error) {
 			free(uio, M_IOV);
 			return (error);
 		}
 		iov[i].iov_base = PTRIN(iov32.iov_base);
 		iov[i].iov_len = iov32.iov_len;
 	}
 	uio->uio_iov = iov;
 	uio->uio_iovcnt = iovcnt;
 	uio->uio_segflg = UIO_USERSPACE;
 	uio->uio_offset = -1;
 	uio->uio_resid = 0;
 	for (i = 0; i < iovcnt; i++) {
 		if (iov->iov_len > INT_MAX - uio->uio_resid) {
 			free(uio, M_IOV);
 			return (EINVAL);
 		}
 		uio->uio_resid += iov->iov_len;
 		iov++;
 	}
 	*uiop = uio;
 	return (0);
 }
 
 int
 linux32_copyiniov(struct l_iovec32 *iovp32, l_ulong iovcnt, struct iovec **iovp,
     int error)
 {
 	struct l_iovec32 iov32;
 	struct iovec *iov;
 	uint32_t iovlen;
 	int i;
 
 	*iovp = NULL;
 	if (iovcnt > UIO_MAXIOV)
 		return (error);
 	iovlen = iovcnt * sizeof(struct iovec);
 	iov = malloc(iovlen, M_IOV, M_WAITOK);
 	for (i = 0; i < iovcnt; i++) {
 		error = copyin(&iovp32[i], &iov32, sizeof(struct l_iovec32));
 		if (error) {
 			free(iov, M_IOV);
 			return (error);
 		}
 		iov[i].iov_base = PTRIN(iov32.iov_base);
 		iov[i].iov_len = iov32.iov_len;
 	}
 	*iovp = iov;
 	return(0);
 
 }
 
 int
 linux_readv(struct thread *td, struct linux_readv_args *uap)
 {
 	struct uio *auio;
 	int error;
 
 	error = linux32_copyinuio(uap->iovp, uap->iovcnt, &auio);
 	if (error)
 		return (error);
 	error = kern_readv(td, uap->fd, auio);
 	free(auio, M_IOV);
 	return (error);
 }
 
 int
 linux_writev(struct thread *td, struct linux_writev_args *uap)
 {
 	struct uio *auio;
 	int error;
 
 	error = linux32_copyinuio(uap->iovp, uap->iovcnt, &auio);
 	if (error)
 		return (error);
 	error = kern_writev(td, uap->fd, auio);
 	free(auio, M_IOV);
 	return (error);
 }
 
 struct l_ipc_kludge {
 	l_uintptr_t msgp;
 	l_long msgtyp;
 } __packed;
 
 int
 linux_ipc(struct thread *td, struct linux_ipc_args *args)
 {
 
 	switch (args->what & 0xFFFF) {
 	case LINUX_SEMOP: {
 		struct linux_semop_args a;
 
 		a.semid = args->arg1;
 		a.tsops = PTRIN(args->ptr);
 		a.nsops = args->arg2;
 		return (linux_semop(td, &a));
 	}
 	case LINUX_SEMGET: {
 		struct linux_semget_args a;
 
 		a.key = args->arg1;
 		a.nsems = args->arg2;
 		a.semflg = args->arg3;
 		return (linux_semget(td, &a));
 	}
 	case LINUX_SEMCTL: {
 		struct linux_semctl_args a;
 		int error;
 
 		a.semid = args->arg1;
 		a.semnum = args->arg2;
 		a.cmd = args->arg3;
 		error = copyin(PTRIN(args->ptr), &a.arg, sizeof(a.arg));
 		if (error)
 			return (error);
 		return (linux_semctl(td, &a));
 	}
 	case LINUX_MSGSND: {
 		struct linux_msgsnd_args a;
 
 		a.msqid = args->arg1;
 		a.msgp = PTRIN(args->ptr);
 		a.msgsz = args->arg2;
 		a.msgflg = args->arg3;
 		return (linux_msgsnd(td, &a));
 	}
 	case LINUX_MSGRCV: {
 		struct linux_msgrcv_args a;
 
 		a.msqid = args->arg1;
 		a.msgsz = args->arg2;
 		a.msgflg = args->arg3;
 		if ((args->what >> 16) == 0) {
 			struct l_ipc_kludge tmp;
 			int error;
 
 			if (args->ptr == 0)
 				return (EINVAL);
 			error = copyin(PTRIN(args->ptr), &tmp, sizeof(tmp));
 			if (error)
 				return (error);
 			a.msgp = PTRIN(tmp.msgp);
 			a.msgtyp = tmp.msgtyp;
 		} else {
 			a.msgp = PTRIN(args->ptr);
 			a.msgtyp = args->arg5;
 		}
 		return (linux_msgrcv(td, &a));
 	}
 	case LINUX_MSGGET: {
 		struct linux_msgget_args a;
 
 		a.key = args->arg1;
 		a.msgflg = args->arg2;
 		return (linux_msgget(td, &a));
 	}
 	case LINUX_MSGCTL: {
 		struct linux_msgctl_args a;
 
 		a.msqid = args->arg1;
 		a.cmd = args->arg2;
 		a.buf = PTRIN(args->ptr);
 		return (linux_msgctl(td, &a));
 	}
 	case LINUX_SHMAT: {
 		struct linux_shmat_args a;
 		l_uintptr_t addr;
 		int error;
 
 		a.shmid = args->arg1;
 		a.shmaddr = PTRIN(args->ptr);
 		a.shmflg = args->arg2;
 		error = linux_shmat(td, &a);
 		if (error != 0)
 			return (error);
 		addr = td->td_retval[0];
 		error = copyout(&addr, PTRIN(args->arg3), sizeof(addr));
 		td->td_retval[0] = 0;
 		return (error);
 	}
 	case LINUX_SHMDT: {
 		struct linux_shmdt_args a;
 
 		a.shmaddr = PTRIN(args->ptr);
 		return (linux_shmdt(td, &a));
 	}
 	case LINUX_SHMGET: {
 		struct linux_shmget_args a;
 
 		a.key = args->arg1;
 		a.size = args->arg2;
 		a.shmflg = args->arg3;
 		return (linux_shmget(td, &a));
 	}
 	case LINUX_SHMCTL: {
 		struct linux_shmctl_args a;
 
 		a.shmid = args->arg1;
 		a.cmd = args->arg2;
 		a.buf = PTRIN(args->ptr);
 		return (linux_shmctl(td, &a));
 	}
 	default:
 		break;
 	}
 
 	return (EINVAL);
 }
 
 int
 linux_old_select(struct thread *td, struct linux_old_select_args *args)
 {
 	struct l_old_select_argv linux_args;
 	struct linux_select_args newsel;
 	int error;
 
 	error = copyin(args->ptr, &linux_args, sizeof(linux_args));
 	if (error)
 		return (error);
 
 	newsel.nfds = linux_args.nfds;
 	newsel.readfds = PTRIN(linux_args.readfds);
 	newsel.writefds = PTRIN(linux_args.writefds);
 	newsel.exceptfds = PTRIN(linux_args.exceptfds);
 	newsel.timeout = PTRIN(linux_args.timeout);
 	return (linux_select(td, &newsel));
 }
 
 int
 linux_set_cloned_tls(struct thread *td, void *desc)
 {
 	struct l_user_desc info;
 	struct pcb *pcb;
 	int error;
 
 	error = copyin(desc, &info, sizeof(struct l_user_desc));
 	if (error) {
 		linux_msg(td, "set_cloned_tls copyin info failed!");
 	} else {
 		/* We might copy out the entry_number as GUGS32_SEL. */
 		info.entry_number = GUGS32_SEL;
 		error = copyout(&info, desc, sizeof(struct l_user_desc));
 		if (error)
 			linux_msg(td, "set_cloned_tls copyout info failed!");
 
 		pcb = td->td_pcb;
 		update_pcb_bases(pcb);
 		pcb->pcb_gsbase = (register_t)info.base_addr;
 		td->td_frame->tf_gs = GSEL(GUGS32_SEL, SEL_UPL);
 	}
 
 	return (error);
 }
 
 int
 linux_set_upcall(struct thread *td, register_t stack)
 {
 
 	if (stack)
 		td->td_frame->tf_rsp = stack;
 
 	/*
 	 * The newly created Linux thread returns
 	 * to the user space by the same path that a parent do.
 	 */
 	td->td_frame->tf_rax = 0;
 	return (0);
 }
 
 int
 linux_mmap2(struct thread *td, struct linux_mmap2_args *args)
 {
 
 	return (linux_mmap_common(td, PTROUT(args->addr), args->len, args->prot,
 		args->flags, args->fd, (uint64_t)(uint32_t)args->pgoff *
 		PAGE_SIZE));
 }
 
 int
 linux_mmap(struct thread *td, struct linux_mmap_args *args)
 {
 	int error;
 	struct l_mmap_argv linux_args;
 
 	error = copyin(args->ptr, &linux_args, sizeof(linux_args));
 	if (error)
 		return (error);
 
 	return (linux_mmap_common(td, linux_args.addr, linux_args.len,
 	    linux_args.prot, linux_args.flags, linux_args.fd,
 	    (uint32_t)linux_args.pgoff));
 }
 
 int
 linux_mprotect(struct thread *td, struct linux_mprotect_args *uap)
 {
 
 	return (linux_mprotect_common(td, PTROUT(uap->addr), uap->len, uap->prot));
 }
 
 int
 linux_madvise(struct thread *td, struct linux_madvise_args *uap)
 {
 
 	return (linux_madvise_common(td, PTROUT(uap->addr), uap->len, uap->behav));
 }
 
 int
 linux_iopl(struct thread *td, struct linux_iopl_args *args)
 {
 	int error;
 
 	if (args->level < 0 || args->level > 3)
 		return (EINVAL);
 	if ((error = priv_check(td, PRIV_IO)) != 0)
 		return (error);
 	if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
 		return (error);
 	td->td_frame->tf_rflags = (td->td_frame->tf_rflags & ~PSL_IOPL) |
 	    (args->level * (PSL_IOPL / 3));
 
 	return (0);
 }
 
 int
 linux_sigaction(struct thread *td, struct linux_sigaction_args *args)
 {
 	l_osigaction_t osa;
 	l_sigaction_t act, oact;
 	int error;
 
 	if (args->nsa != NULL) {
 		error = copyin(args->nsa, &osa, sizeof(l_osigaction_t));
 		if (error)
 			return (error);
 		act.lsa_handler = osa.lsa_handler;
 		act.lsa_flags = osa.lsa_flags;
 		act.lsa_restorer = osa.lsa_restorer;
 		LINUX_SIGEMPTYSET(act.lsa_mask);
 		act.lsa_mask.__mask = osa.lsa_mask;
 	}
 
 	error = linux_do_sigaction(td, args->sig, args->nsa ? &act : NULL,
 	    args->osa ? &oact : NULL);
 
 	if (args->osa != NULL && !error) {
 		osa.lsa_handler = oact.lsa_handler;
 		osa.lsa_flags = oact.lsa_flags;
 		osa.lsa_restorer = oact.lsa_restorer;
 		osa.lsa_mask = oact.lsa_mask.__mask;
 		error = copyout(&osa, args->osa, sizeof(l_osigaction_t));
 	}
 
 	return (error);
 }
 
 /*
  * Linux has two extra args, restart and oldmask.  We don't use these,
  * but it seems that "restart" is actually a context pointer that
  * enables the signal to happen with a different register set.
  */
 int
 linux_sigsuspend(struct thread *td, struct linux_sigsuspend_args *args)
 {
 	sigset_t sigmask;
 	l_sigset_t mask;
 
 	LINUX_SIGEMPTYSET(mask);
 	mask.__mask = args->mask;
 	linux_to_bsd_sigset(&mask, &sigmask);
 	return (kern_sigsuspend(td, sigmask));
 }
 
 int
 linux_pause(struct thread *td, struct linux_pause_args *args)
 {
 	struct proc *p = td->td_proc;
 	sigset_t sigmask;
 
 	PROC_LOCK(p);
 	sigmask = td->td_sigmask;
 	PROC_UNLOCK(p);
 	return (kern_sigsuspend(td, sigmask));
 }
 
 int
 linux_gettimeofday(struct thread *td, struct linux_gettimeofday_args *uap)
 {
 	struct timeval atv;
 	l_timeval atv32;
 	struct timezone rtz;
 	int error = 0;
 
 	if (uap->tp) {
 		microtime(&atv);
 		atv32.tv_sec = atv.tv_sec;
 		atv32.tv_usec = atv.tv_usec;
 		error = copyout(&atv32, uap->tp, sizeof(atv32));
 	}
 	if (error == 0 && uap->tzp != NULL) {
 		rtz.tz_minuteswest = 0;
 		rtz.tz_dsttime = 0;
 		error = copyout(&rtz, uap->tzp, sizeof(rtz));
 	}
 	return (error);
 }
 
 int
 linux_settimeofday(struct thread *td, struct linux_settimeofday_args *uap)
 {
 	l_timeval atv32;
 	struct timeval atv, *tvp;
 	struct timezone atz, *tzp;
 	int error;
 
 	if (uap->tp) {
 		error = copyin(uap->tp, &atv32, sizeof(atv32));
 		if (error)
 			return (error);
 		atv.tv_sec = atv32.tv_sec;
 		atv.tv_usec = atv32.tv_usec;
 		tvp = &atv;
 	} else
 		tvp = NULL;
 	if (uap->tzp) {
 		error = copyin(uap->tzp, &atz, sizeof(atz));
 		if (error)
 			return (error);
 		tzp = &atz;
 	} else
 		tzp = NULL;
 	return (kern_settimeofday(td, tvp, tzp));
 }
 
 int
 linux_getrusage(struct thread *td, struct linux_getrusage_args *uap)
 {
 	struct rusage s;
 	int error;
 
 	error = kern_getrusage(td, uap->who, &s);
 	if (error != 0)
 		return (error);
 	if (uap->rusage != NULL)
 		error = linux_copyout_rusage(&s, uap->rusage);
 	return (error);
 }
 
 int
 linux_set_thread_area(struct thread *td,
     struct linux_set_thread_area_args *args)
 {
 	struct l_user_desc info;
 	struct pcb *pcb;
 	int error;
 
 	error = copyin(args->desc, &info, sizeof(struct l_user_desc));
 	if (error)
 		return (error);
 
 	/*
 	 * Semantics of Linux version: every thread in the system has array
 	 * of three TLS descriptors. 1st is GLIBC TLS, 2nd is WINE, 3rd unknown.
 	 * This syscall loads one of the selected TLS decriptors with a value
 	 * and also loads GDT descriptors 6, 7 and 8 with the content of
 	 * the per-thread descriptors.
 	 *
 	 * Semantics of FreeBSD version: I think we can ignore that Linux has
 	 * three per-thread descriptors and use just the first one.
 	 * The tls_array[] is used only in [gs]et_thread_area() syscalls and
 	 * for loading the GDT descriptors. We use just one GDT descriptor
 	 * for TLS, so we will load just one.
 	 *
 	 * XXX: This doesn't work when a user space process tries to use more
 	 * than one TLS segment. Comment in the Linux source says wine might
 	 * do this.
 	 */
 
 	/*
 	 * GLIBC reads current %gs and call set_thread_area() with it.
 	 * We should let GUDATA_SEL and GUGS32_SEL proceed as well because
 	 * we use these segments.
 	 */
 	switch (info.entry_number) {
 	case GUGS32_SEL:
 	case GUDATA_SEL:
 	case 6:
 	case -1:
 		info.entry_number = GUGS32_SEL;
 		break;
 	default:
 		return (EINVAL);
 	}
 
 	/*
 	 * We have to copy out the GDT entry we use.
 	 *
 	 * XXX: What if a user space program does not check the return value
 	 * and tries to use 6, 7 or 8?
 	 */
 	error = copyout(&info, args->desc, sizeof(struct l_user_desc));
 	if (error)
 		return (error);
 
 	pcb = td->td_pcb;
 	update_pcb_bases(pcb);
 	pcb->pcb_gsbase = (register_t)info.base_addr;
 	update_gdt_gsbase(td, info.base_addr);
 
 	return (0);
 }
 
 void
-bsd_to_linux_regset32(struct reg32 *b_reg, struct linux_pt_regset32 *l_regset)
+bsd_to_linux_regset32(const struct reg32 *b_reg,
+    struct linux_pt_regset32 *l_regset)
 {
 
 	l_regset->ebx = b_reg->r_ebx;
 	l_regset->ecx = b_reg->r_ecx;
 	l_regset->edx = b_reg->r_edx;
 	l_regset->esi = b_reg->r_esi;
 	l_regset->edi = b_reg->r_edi;
 	l_regset->ebp = b_reg->r_ebp;
 	l_regset->eax = b_reg->r_eax;
 	l_regset->ds = b_reg->r_ds;
 	l_regset->es = b_reg->r_es;
 	l_regset->fs = b_reg->r_fs;
 	l_regset->gs = b_reg->r_gs;
 	l_regset->orig_eax = b_reg->r_eax;
 	l_regset->eip = b_reg->r_eip;
 	l_regset->cs = b_reg->r_cs;
 	l_regset->eflags = b_reg->r_eflags;
 	l_regset->esp = b_reg->r_esp;
 	l_regset->ss = b_reg->r_ss;
 }
 
 int futex_xchgl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
 int futex_xchgl_smap(int oparg, uint32_t *uaddr, int *oldval);
 DEFINE_IFUNC(, int, futex_xchgl, (int, uint32_t *, int *))
 {
 
 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
 	    futex_xchgl_smap : futex_xchgl_nosmap);
 }
 
 int futex_addl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
 int futex_addl_smap(int oparg, uint32_t *uaddr, int *oldval);
 DEFINE_IFUNC(, int, futex_addl, (int, uint32_t *, int *))
 {
 
 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
 	    futex_addl_smap : futex_addl_nosmap);
 }
 
 int futex_orl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
 int futex_orl_smap(int oparg, uint32_t *uaddr, int *oldval);
 DEFINE_IFUNC(, int, futex_orl, (int, uint32_t *, int *))
 {
 
 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
 	    futex_orl_smap : futex_orl_nosmap);
 }
 
 int futex_andl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
 int futex_andl_smap(int oparg, uint32_t *uaddr, int *oldval);
 DEFINE_IFUNC(, int, futex_andl, (int, uint32_t *, int *))
 {
 
 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
 	    futex_andl_smap : futex_andl_nosmap);
 }
 
 int futex_xorl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
 int futex_xorl_smap(int oparg, uint32_t *uaddr, int *oldval);
 DEFINE_IFUNC(, int, futex_xorl, (int, uint32_t *, int *))
 {
 
 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
 	    futex_xorl_smap : futex_xorl_nosmap);
 }
diff --git a/sys/arm64/linux/linux.h b/sys/arm64/linux/linux.h
index b5273498a5aa..5e4bf3ae0680 100644
--- a/sys/arm64/linux/linux.h
+++ b/sys/arm64/linux/linux.h
@@ -1,328 +1,328 @@
 /*-
  * Copyright (c) 1994-1996 Søren Schmidt
  * Copyright (c) 2013 Dmitry Chagin <dchagin@FreeBSD.org>
  * Copyright (c) 2018 Turing Robotic Industries Inc.
  *
  * 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 AUTHOR 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 AUTHOR 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.
  */
 
 /*
  * $FreeBSD$
  */
 #ifndef _ARM64_LINUX_H_
 #define	_ARM64_LINUX_H_
 
 #include <sys/abi_compat.h>
 
 #include <compat/linux/linux.h>
 #include <arm64/linux/linux_syscall.h>
 
 #define	LINUX_DTRACE	linuxulator
 
 /* Provide a separate set of types for the Linux types */
 typedef int32_t		l_int;
 typedef int64_t		l_long;
 typedef int16_t		l_short;
 typedef uint32_t	l_uint;
 typedef uint64_t	l_ulong;
 typedef uint16_t	l_ushort;
 
 typedef l_ulong		l_uintptr_t;
 typedef l_long		l_clock_t;
 typedef l_int		l_daddr_t;
 typedef l_ulong		l_dev_t;
 typedef l_uint		l_gid_t;
 typedef l_ushort	l_gid16_t;	/* XXX */
 typedef l_uint		l_uid_t;
 typedef l_ushort	l_uid16_t;	/* XXX */
 typedef l_ulong		l_ino_t;
 typedef l_int		l_key_t;
 typedef l_long		l_loff_t;
 typedef l_uint		l_mode_t;
 typedef l_long		l_off_t;
 typedef l_int		l_pid_t;
 typedef l_ulong		l_size_t;
 typedef l_long		l_suseconds_t;
 typedef l_long		l_time_t;
 typedef l_int		l_timer_t;	/* XXX */
 typedef l_int		l_mqd_t;
 typedef l_ulong		l_fd_mask;
 
 typedef struct {
 	l_int		val[2];
 } l_fsid_t;
 
 typedef struct {
 	l_time_t	tv_sec;
 	l_suseconds_t	tv_usec;
 } l_timeval;
 
 #define	l_fd_set	fd_set
 
 /* Miscellaneous */
 #define	LINUX_AT_COUNT		20
 
 struct l___sysctl_args
 {
 	l_uintptr_t	name;
 	l_int		nlen;
 	l_uintptr_t	oldval;
 	l_uintptr_t	oldlenp;
 	l_uintptr_t	newval;
 	l_uintptr_t	newlen;
 	l_ulong		__spare[4];
 };
 
 /* Resource limits */
 #define	LINUX_RLIMIT_CPU	0
 #define	LINUX_RLIMIT_FSIZE	1
 #define	LINUX_RLIMIT_DATA	2
 #define	LINUX_RLIMIT_STACK	3
 #define	LINUX_RLIMIT_CORE	4
 #define	LINUX_RLIMIT_RSS	5
 #define	LINUX_RLIMIT_NPROC	6
 #define	LINUX_RLIMIT_NOFILE	7
 #define	LINUX_RLIMIT_MEMLOCK	8
 #define	LINUX_RLIMIT_AS		9	/* Address space limit */
 
 #define	LINUX_RLIM_NLIMITS	10
 
 struct l_rlimit {
 	l_ulong		rlim_cur;
 	l_ulong		rlim_max;
 };
 
 /* stat family of syscalls */
 struct l_timespec {
 	l_time_t	tv_sec;
 	l_long		tv_nsec;
 };
 
 #define	LINUX_O_DIRECTORY	000040000	/* Must be a directory */
 #define	LINUX_O_NOFOLLOW	000100000	/* Do not follow links */
 #define	LINUX_O_DIRECT		000200000	/* Direct disk access hint */
 #define	LINUX_O_LARGEFILE	000400000
 
 struct l_newstat {
 	l_dev_t		st_dev;
 	l_ino_t		st_ino;
 	l_uint		st_mode;
 	l_uint		st_nlink;
 
 	l_uid_t		st_uid;
 	l_gid_t		st_gid;
 
 	l_dev_t		st_rdev;
 	l_ulong		__st_pad1;
 	l_off_t		st_size;
 	l_int		st_blksize;
 	l_int		__st_pad2;
 	l_long		st_blocks;
 
 	struct l_timespec	st_atim;
 	struct l_timespec	st_mtim;
 	struct l_timespec	st_ctim;
 	l_uint		__unused1;
 	l_uint		__unused2;
 };
 
 /* sigaction flags */
 #define	LINUX_SA_NOCLDSTOP	0x00000001
 #define	LINUX_SA_NOCLDWAIT	0x00000002
 #define	LINUX_SA_SIGINFO	0x00000004
 #define	LINUX_SA_RESTORER	0x04000000
 #define	LINUX_SA_ONSTACK	0x08000000
 #define	LINUX_SA_RESTART	0x10000000
 #define	LINUX_SA_INTERRUPT	0x20000000	/* XXX */
 #define	LINUX_SA_NOMASK		0x40000000	/* SA_NODEFER */
 #define	LINUX_SA_ONESHOT	0x80000000	/* SA_RESETHAND */
 
 /* sigprocmask actions */
 #define	LINUX_SIG_BLOCK		0
 #define	LINUX_SIG_UNBLOCK	1
 #define	LINUX_SIG_SETMASK	2
 
 /* sigaltstack */
 #define	LINUX_MINSIGSTKSZ	2048		/* XXX */
 
 typedef void	(*l_handler_t)(l_int);
 
 typedef struct {
 	l_handler_t	lsa_handler;
 	l_ulong		lsa_flags;
 	l_uintptr_t	lsa_restorer;
 	l_sigset_t	lsa_mask;
 } l_sigaction_t;				/* XXX */
 
 typedef struct {
 	l_uintptr_t	ss_sp;
 	l_int		ss_flags;
 	l_size_t	ss_size;
 } l_stack_t;
 
 #define	LINUX_SI_PREAMBLE_SIZE	(4 * sizeof(int))
 #define	LINUX_SI_MAX_SIZE	128
 #define	LINUX_SI_PAD_SIZE	((LINUX_SI_MAX_SIZE - \
 				    LINUX_SI_PREAMBLE_SIZE) / sizeof(l_int))
 typedef union l_sigval {
 	l_int		sival_int;
 	l_uintptr_t	sival_ptr;
 } l_sigval_t;
 
 typedef struct l_siginfo {
 	l_int		lsi_signo;
 	l_int		lsi_errno;
 	l_int		lsi_code;
 	union {
 		l_int	_pad[LINUX_SI_PAD_SIZE];
 
 		struct {
 			l_pid_t		_pid;
 			l_uid_t		_uid;
 		} _kill;
 
 		struct {
 			l_timer_t	_tid;
 			l_int		_overrun;
 			char		_pad[sizeof(l_uid_t) - sizeof(int)];
 			union l_sigval	_sigval;
 			l_uint		_sys_private;
 		} _timer;
 
 		struct {
 			l_pid_t		_pid;		/* sender's pid */
 			l_uid_t		_uid;		/* sender's uid */
 			union l_sigval	_sigval;
 		} _rt;
 
 		struct {
 			l_pid_t		_pid;		/* which child */
 			l_uid_t		_uid;		/* sender's uid */
 			l_int		_status;	/* exit code */
 			l_clock_t	_utime;
 			l_clock_t	_stime;
 		} _sigchld;
 
 		struct {
 			l_uintptr_t	_addr;	/* Faulting insn/memory ref. */
 		} _sigfault;
 
 		struct {
 			l_long		_band;	/* POLL_IN,POLL_OUT,POLL_MSG */
 			l_int		_fd;
 		} _sigpoll;
 	} _sifields;
 } l_siginfo_t;
 
 #define	lsi_pid		_sifields._kill._pid
 #define	lsi_uid		_sifields._kill._uid
 #define	lsi_tid		_sifields._timer._tid
 #define	lsi_overrun	_sifields._timer._overrun
 #define	lsi_sys_private	_sifields._timer._sys_private
 #define	lsi_status	_sifields._sigchld._status
 #define	lsi_utime	_sifields._sigchld._utime
 #define	lsi_stime	_sifields._sigchld._stime
 #define	lsi_value	_sifields._rt._sigval
 #define	lsi_int		_sifields._rt._sigval.sival_int
 #define	lsi_ptr		_sifields._rt._sigval.sival_ptr
 #define	lsi_addr	_sifields._sigfault._addr
 #define	lsi_band	_sifields._sigpoll._band
 #define	lsi_fd		_sifields._sigpoll._fd
 
 /*
  * This structure is different from the one used by Linux,
  * but it doesn't matter - it's not user-accessible.  We need
  * it instead of the native one because of l_siginfo.
  */
 struct l_sigframe {
 	struct l_siginfo	sf_si;
 	ucontext_t		sf_uc;
 };
 
 union l_semun {
 	l_int		val;
 	l_uintptr_t	buf;
 	l_uintptr_t	array;
 	l_uintptr_t	__buf;
 	l_uintptr_t	__pad;
 };
 
 struct l_ifmap {
 	l_ulong		mem_start;
 	l_ulong		mem_end;
 	l_ushort	base_addr;
 	u_char		irq;
 	u_char		dma;
 	u_char		port;
 	/* 3 bytes spare*/
 };
 
 struct l_ifreq {
 	union {
 		char	ifrn_name[LINUX_IFNAMSIZ];
 	} ifr_ifrn;
 
 	union {
 		struct l_sockaddr	ifru_addr;
 		struct l_sockaddr	ifru_dstaddr;
 		struct l_sockaddr	ifru_broadaddr;
 		struct l_sockaddr	ifru_netmask;
 		struct l_sockaddr	ifru_hwaddr;
 		l_short		ifru_flags[1];
 		l_int		ifru_ivalue;
 		l_int		ifru_mtu;
 		struct l_ifmap	ifru_map;
 		char		ifru_slave[LINUX_IFNAMSIZ];
 		l_uintptr_t	ifru_data;
 	} ifr_ifru;
 };
 
 #define	ifr_name	ifr_ifrn.ifrn_name	/* Interface name */
 #define	ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address */
 #define	ifr_ifindex	ifr_ifru.ifru_ivalue	/* Interface index */
 
 #define	linux_copyout_rusage(r, u)	copyout(r, u, sizeof(*r))
 
 /* robust futexes */
 struct linux_robust_list {
 	l_uintptr_t			next;
 };
 
 struct linux_robust_list_head {
 	struct linux_robust_list	list;
 	l_long				futex_offset;
 	l_uintptr_t			pending_list;
 };
 
 struct linux_pt_regset {
 	l_ulong x[31];
 	l_ulong sp;
 	l_ulong pc;
 	l_ulong cpsr;
 };
 
 struct reg;
 
-void	bsd_to_linux_regset(struct reg *b_reg,
+void	bsd_to_linux_regset(const struct reg *b_reg,
 	    struct linux_pt_regset *l_regset);
 
 #endif /* _ARM64_LINUX_H_ */
diff --git a/sys/arm64/linux/linux_machdep.c b/sys/arm64/linux/linux_machdep.c
index fae5bd11653b..c874f86a5f0c 100644
--- a/sys/arm64/linux/linux_machdep.c
+++ b/sys/arm64/linux/linux_machdep.c
@@ -1,147 +1,147 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
  * Copyright (c) 2018 Turing Robotic Industries Inc.
  * Copyright (c) 2000 Marcel Moolenaar
  *
  * 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 AUTHOR 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 AUTHOR 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.
  *
  * $FreeBSD$
  */
 
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/fcntl.h>
 #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>
 
 #include <arm64/linux/linux.h>
 #include <arm64/linux/linux_proto.h>
 #include <compat/linux/linux_dtrace.h>
 #include <compat/linux/linux_emul.h>
 #include <compat/linux/linux_fork.h>
 #include <compat/linux/linux_misc.h>
 #include <compat/linux/linux_mmap.h>
 #include <compat/linux/linux_util.h>
 
 /* DTrace init */
 LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE);
 
 /* DTrace probes */
 LIN_SDT_PROBE_DEFINE0(machdep, linux_mmap2, todo);
 
 /*
  * LINUXTODO: deduplicate; linux_execve is common across archs, except that on
  * amd64 compat linuxulator it calls freebsd32_exec_copyin_args.
  */
 int
 linux_execve(struct thread *td, struct linux_execve_args *uap)
 {
 	struct image_args eargs;
 	char *path;
 	int error;
 
 	if (!LUSECONVPATH(td)) {
 		error = exec_copyin_args(&eargs, uap->path, UIO_USERSPACE,
 		    uap->argp, uap->envp);
 	} else {
 		LCONVPATHEXIST(td, uap->path, &path);
 		error = exec_copyin_args(&eargs, path, UIO_SYSSPACE,
 		    uap->argp, uap->envp);
 		LFREEPATH(path);
 	}
 	if (error == 0)
 		error = linux_common_execve(td, &eargs);
 	AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
 	return (error);
 }
 
 int
 linux_set_upcall(struct thread *td, register_t stack)
 {
 
 	if (stack)
 		td->td_frame->tf_sp = stack;
 
 	/*
 	 * The newly created Linux thread returns
 	 * to the user space by the same path that a parent does.
 	 */
 	td->td_frame->tf_x[0] = 0;
 	return (0);
 }
 
 /* LINUXTODO: deduplicate arm64 linux_mmap2 */
 int
 linux_mmap2(struct thread *td, struct linux_mmap2_args *uap)
 {
 
 	LIN_SDT_PROBE0(machdep, linux_mmap2, todo);
 	return (linux_mmap_common(td, PTROUT(uap->addr), uap->len, uap->prot,
 	    uap->flags, uap->fd, uap->pgoff));
 }
 
 int
 linux_mprotect(struct thread *td, struct linux_mprotect_args *uap)
 {
 
 	return (linux_mprotect_common(td, PTROUT(uap->addr), uap->len,
 	    uap->prot));
 }
 
 int
 linux_madvise(struct thread *td, struct linux_madvise_args *uap)
 {
 
 	return (linux_madvise_common(td, PTROUT(uap->addr), uap->len, uap->behav));
 }
 
 int
 linux_set_cloned_tls(struct thread *td, void *desc)
 {
 
 	if ((uint64_t)desc >= VM_MAXUSER_ADDRESS)
 		return (EPERM);
 
 	return (cpu_set_user_tls(td, desc));
 }
 
 void
-bsd_to_linux_regset(struct reg *b_reg, struct linux_pt_regset *l_regset)
+bsd_to_linux_regset(const struct reg *b_reg, struct linux_pt_regset *l_regset)
 {
 
 	KASSERT(sizeof(l_regset->x) == sizeof(b_reg->x) + sizeof(l_ulong),
 	    ("%s: size mismatch\n", __func__));
 	memcpy(l_regset->x, b_reg->x, sizeof(b_reg->x));
 
 	l_regset->x[30] = b_reg->lr;
 	l_regset->sp = b_reg->sp;
 	l_regset->pc = b_reg->elr;
 	l_regset->cpsr = b_reg->spsr;
 }