2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2002 Doug Rabson
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
33 #include "opt_inet6.h"
34 #include "opt_ktrace.h"
36 #define __ELF_WORD_SIZE 32
38 #ifdef COMPAT_FREEBSD11
39 #define _WANT_FREEBSD11_KEVENT
42 #include <sys/param.h>
44 #include <sys/capsicum.h>
45 #include <sys/clock.h>
47 #include <sys/fcntl.h>
48 #include <sys/filedesc.h>
49 #include <sys/imgact.h>
51 #include <sys/kernel.h>
52 #include <sys/limits.h>
53 #include <sys/linker.h>
55 #include <sys/malloc.h>
56 #include <sys/file.h> /* Must come after sys/malloc.h */
57 #include <sys/imgact.h>
60 #include <sys/module.h>
61 #include <sys/mount.h>
62 #include <sys/mutex.h>
63 #include <sys/namei.h>
65 #include <sys/procctl.h>
66 #include <sys/ptrace.h>
67 #include <sys/reboot.h>
68 #include <sys/resource.h>
69 #include <sys/resourcevar.h>
70 #include <sys/selinfo.h>
71 #include <sys/eventvar.h> /* Must come after sys/selinfo.h */
72 #include <sys/pipe.h> /* Must come after sys/selinfo.h */
73 #include <sys/signal.h>
74 #include <sys/signalvar.h>
75 #include <sys/socket.h>
76 #include <sys/socketvar.h>
78 #include <sys/syscall.h>
79 #include <sys/syscallsubr.h>
80 #include <sys/sysctl.h>
81 #include <sys/sysent.h>
82 #include <sys/sysproto.h>
83 #include <sys/systm.h>
85 #include <sys/unistd.h>
86 #include <sys/ucontext.h>
88 #include <sys/vnode.h>
95 #include <sys/ktrace.h>
99 #include <netinet/in.h>
103 #include <vm/vm_param.h>
105 #include <vm/vm_map.h>
106 #include <vm/vm_object.h>
107 #include <vm/vm_extern.h>
109 #include <machine/cpu.h>
110 #include <machine/elf.h>
112 #include <machine/md_var.h>
115 #include <security/audit/audit.h>
117 #include <compat/freebsd32/freebsd32_util.h>
118 #include <compat/freebsd32/freebsd32.h>
119 #include <compat/freebsd32/freebsd32_ipc.h>
120 #include <compat/freebsd32/freebsd32_misc.h>
121 #include <compat/freebsd32/freebsd32_signal.h>
122 #include <compat/freebsd32/freebsd32_proto.h>
124 FEATURE(compat_freebsd_32bit, "Compatible with 32-bit FreeBSD");
126 struct ptrace_io_desc32 {
133 struct ptrace_sc_ret32 {
134 uint32_t sr_retval[2];
138 struct ptrace_vm_entry32 {
152 CTASSERT(sizeof(struct timeval32) == 8);
153 CTASSERT(sizeof(struct timespec32) == 8);
154 CTASSERT(sizeof(struct itimerval32) == 16);
155 CTASSERT(sizeof(struct bintime32) == 12);
157 CTASSERT(sizeof(struct statfs32) == 256);
159 CTASSERT(sizeof(struct rusage32) == 72);
161 CTASSERT(sizeof(struct sigaltstack32) == 12);
163 CTASSERT(sizeof(struct kevent32) == 56);
165 CTASSERT(sizeof(struct kevent32) == 64);
167 CTASSERT(sizeof(struct iovec32) == 8);
168 CTASSERT(sizeof(struct msghdr32) == 28);
170 CTASSERT(sizeof(struct stat32) == 208);
171 CTASSERT(sizeof(struct freebsd11_stat32) == 96);
173 CTASSERT(sizeof(struct sigaction32) == 24);
175 static int freebsd32_kevent_copyout(void *arg, struct kevent *kevp, int count);
176 static int freebsd32_kevent_copyin(void *arg, struct kevent *kevp, int count);
177 static int freebsd32_user_clock_nanosleep(struct thread *td, clockid_t clock_id,
178 int flags, const struct timespec32 *ua_rqtp, struct timespec32 *ua_rmtp);
181 freebsd32_rusage_out(const struct rusage *s, struct rusage32 *s32)
184 TV_CP(*s, *s32, ru_utime);
185 TV_CP(*s, *s32, ru_stime);
186 CP(*s, *s32, ru_maxrss);
187 CP(*s, *s32, ru_ixrss);
188 CP(*s, *s32, ru_idrss);
189 CP(*s, *s32, ru_isrss);
190 CP(*s, *s32, ru_minflt);
191 CP(*s, *s32, ru_majflt);
192 CP(*s, *s32, ru_nswap);
193 CP(*s, *s32, ru_inblock);
194 CP(*s, *s32, ru_oublock);
195 CP(*s, *s32, ru_msgsnd);
196 CP(*s, *s32, ru_msgrcv);
197 CP(*s, *s32, ru_nsignals);
198 CP(*s, *s32, ru_nvcsw);
199 CP(*s, *s32, ru_nivcsw);
203 freebsd32_wait4(struct thread *td, struct freebsd32_wait4_args *uap)
206 struct rusage32 ru32;
207 struct rusage ru, *rup;
209 if (uap->rusage != NULL)
213 error = kern_wait(td, uap->pid, &status, uap->options, rup);
216 if (uap->status != NULL)
217 error = copyout(&status, uap->status, sizeof(status));
218 if (uap->rusage != NULL && error == 0) {
219 freebsd32_rusage_out(&ru, &ru32);
220 error = copyout(&ru32, uap->rusage, sizeof(ru32));
226 freebsd32_wait6(struct thread *td, struct freebsd32_wait6_args *uap)
228 struct wrusage32 wru32;
229 struct __wrusage wru, *wrup;
230 struct siginfo32 si32;
231 struct __siginfo si, *sip;
234 if (uap->wrusage != NULL)
238 if (uap->info != NULL) {
240 bzero(sip, sizeof(*sip));
243 error = kern_wait6(td, uap->idtype, PAIR32TO64(id_t, uap->id),
244 &status, uap->options, wrup, sip);
247 if (uap->status != NULL)
248 error = copyout(&status, uap->status, sizeof(status));
249 if (uap->wrusage != NULL && error == 0) {
250 freebsd32_rusage_out(&wru.wru_self, &wru32.wru_self);
251 freebsd32_rusage_out(&wru.wru_children, &wru32.wru_children);
252 error = copyout(&wru32, uap->wrusage, sizeof(wru32));
254 if (uap->info != NULL && error == 0) {
255 siginfo_to_siginfo32 (&si, &si32);
256 error = copyout(&si32, uap->info, sizeof(si32));
261 #ifdef COMPAT_FREEBSD4
263 copy_statfs(struct statfs *in, struct statfs32 *out)
266 statfs_scale_blocks(in, INT32_MAX);
267 bzero(out, sizeof(*out));
268 CP(*in, *out, f_bsize);
269 out->f_iosize = MIN(in->f_iosize, INT32_MAX);
270 CP(*in, *out, f_blocks);
271 CP(*in, *out, f_bfree);
272 CP(*in, *out, f_bavail);
273 out->f_files = MIN(in->f_files, INT32_MAX);
274 out->f_ffree = MIN(in->f_ffree, INT32_MAX);
275 CP(*in, *out, f_fsid);
276 CP(*in, *out, f_owner);
277 CP(*in, *out, f_type);
278 CP(*in, *out, f_flags);
279 out->f_syncwrites = MIN(in->f_syncwrites, INT32_MAX);
280 out->f_asyncwrites = MIN(in->f_asyncwrites, INT32_MAX);
281 strlcpy(out->f_fstypename,
282 in->f_fstypename, MFSNAMELEN);
283 strlcpy(out->f_mntonname,
284 in->f_mntonname, min(MNAMELEN, FREEBSD4_MNAMELEN));
285 out->f_syncreads = MIN(in->f_syncreads, INT32_MAX);
286 out->f_asyncreads = MIN(in->f_asyncreads, INT32_MAX);
287 strlcpy(out->f_mntfromname,
288 in->f_mntfromname, min(MNAMELEN, FREEBSD4_MNAMELEN));
292 #ifdef COMPAT_FREEBSD4
294 freebsd4_freebsd32_getfsstat(struct thread *td,
295 struct freebsd4_freebsd32_getfsstat_args *uap)
297 struct statfs *buf, *sp;
298 struct statfs32 stat32;
299 size_t count, size, copycount;
302 count = uap->bufsize / sizeof(struct statfs32);
303 size = count * sizeof(struct statfs);
304 error = kern_getfsstat(td, &buf, size, &count, UIO_SYSSPACE, uap->mode);
308 while (copycount > 0 && error == 0) {
309 copy_statfs(sp, &stat32);
310 error = copyout(&stat32, uap->buf, sizeof(stat32));
318 td->td_retval[0] = count;
323 #ifdef COMPAT_FREEBSD10
325 freebsd10_freebsd32_pipe(struct thread *td,
326 struct freebsd10_freebsd32_pipe_args *uap) {
327 return (freebsd10_pipe(td, (struct freebsd10_pipe_args*)uap));
332 freebsd32_sigaltstack(struct thread *td,
333 struct freebsd32_sigaltstack_args *uap)
335 struct sigaltstack32 s32;
336 struct sigaltstack ss, oss, *ssp;
339 if (uap->ss != NULL) {
340 error = copyin(uap->ss, &s32, sizeof(s32));
343 PTRIN_CP(s32, ss, ss_sp);
344 CP(s32, ss, ss_size);
345 CP(s32, ss, ss_flags);
349 error = kern_sigaltstack(td, ssp, &oss);
350 if (error == 0 && uap->oss != NULL) {
351 PTROUT_CP(oss, s32, ss_sp);
352 CP(oss, s32, ss_size);
353 CP(oss, s32, ss_flags);
354 error = copyout(&s32, uap->oss, sizeof(s32));
360 * Custom version of exec_copyin_args() so that we can translate
364 freebsd32_exec_copyin_args(struct image_args *args, const char *fname,
365 enum uio_seg segflg, u_int32_t *argv, u_int32_t *envv)
371 bzero(args, sizeof(*args));
376 * Allocate demand-paged memory for the file name, argument, and
377 * environment strings.
379 error = exec_alloc_args(args);
384 * Copy the file name.
386 error = exec_args_add_fname(args, fname, segflg);
391 * extract arguments first
395 error = copyin(p32++, &arg, sizeof(arg));
401 error = exec_args_add_arg(args, argp, UIO_USERSPACE);
407 * extract environment strings
412 error = copyin(p32++, &arg, sizeof(arg));
418 error = exec_args_add_env(args, envp, UIO_USERSPACE);
427 exec_free_args(args);
432 freebsd32_execve(struct thread *td, struct freebsd32_execve_args *uap)
434 struct image_args eargs;
435 struct vmspace *oldvmspace;
438 error = pre_execve(td, &oldvmspace);
441 error = freebsd32_exec_copyin_args(&eargs, uap->fname, UIO_USERSPACE,
442 uap->argv, uap->envv);
444 error = kern_execve(td, &eargs, NULL, oldvmspace);
445 post_execve(td, error, oldvmspace);
446 AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
451 freebsd32_fexecve(struct thread *td, struct freebsd32_fexecve_args *uap)
453 struct image_args eargs;
454 struct vmspace *oldvmspace;
457 error = pre_execve(td, &oldvmspace);
460 error = freebsd32_exec_copyin_args(&eargs, NULL, UIO_SYSSPACE,
461 uap->argv, uap->envv);
464 error = kern_execve(td, &eargs, NULL, oldvmspace);
466 post_execve(td, error, oldvmspace);
467 AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
472 freebsd32_mknodat(struct thread *td, struct freebsd32_mknodat_args *uap)
475 return (kern_mknodat(td, uap->fd, uap->path, UIO_USERSPACE,
476 uap->mode, PAIR32TO64(dev_t, uap->dev)));
480 freebsd32_mprotect(struct thread *td, struct freebsd32_mprotect_args *uap)
485 #if defined(__amd64__)
486 if (i386_read_exec && (prot & PROT_READ) != 0)
489 return (kern_mprotect(td, (uintptr_t)PTRIN(uap->addr), uap->len,
494 freebsd32_mmap(struct thread *td, struct freebsd32_mmap_args *uap)
499 #if defined(__amd64__)
500 if (i386_read_exec && (prot & PROT_READ))
504 return (kern_mmap(td, (uintptr_t)uap->addr, uap->len, prot,
505 uap->flags, uap->fd, PAIR32TO64(off_t, uap->pos)));
508 #ifdef COMPAT_FREEBSD6
510 freebsd6_freebsd32_mmap(struct thread *td,
511 struct freebsd6_freebsd32_mmap_args *uap)
516 #if defined(__amd64__)
517 if (i386_read_exec && (prot & PROT_READ))
521 return (kern_mmap(td, (uintptr_t)uap->addr, uap->len, prot,
522 uap->flags, uap->fd, PAIR32TO64(off_t, uap->pos)));
527 freebsd32_setitimer(struct thread *td, struct freebsd32_setitimer_args *uap)
529 struct itimerval itv, oitv, *itvp;
530 struct itimerval32 i32;
533 if (uap->itv != NULL) {
534 error = copyin(uap->itv, &i32, sizeof(i32));
537 TV_CP(i32, itv, it_interval);
538 TV_CP(i32, itv, it_value);
542 error = kern_setitimer(td, uap->which, itvp, &oitv);
543 if (error || uap->oitv == NULL)
545 TV_CP(oitv, i32, it_interval);
546 TV_CP(oitv, i32, it_value);
547 return (copyout(&i32, uap->oitv, sizeof(i32)));
551 freebsd32_getitimer(struct thread *td, struct freebsd32_getitimer_args *uap)
553 struct itimerval itv;
554 struct itimerval32 i32;
557 error = kern_getitimer(td, uap->which, &itv);
558 if (error || uap->itv == NULL)
560 TV_CP(itv, i32, it_interval);
561 TV_CP(itv, i32, it_value);
562 return (copyout(&i32, uap->itv, sizeof(i32)));
566 freebsd32_select(struct thread *td, struct freebsd32_select_args *uap)
568 struct timeval32 tv32;
569 struct timeval tv, *tvp;
572 if (uap->tv != NULL) {
573 error = copyin(uap->tv, &tv32, sizeof(tv32));
576 CP(tv32, tv, tv_sec);
577 CP(tv32, tv, tv_usec);
582 * XXX Do pointers need PTRIN()?
584 return (kern_select(td, uap->nd, uap->in, uap->ou, uap->ex, tvp,
585 sizeof(int32_t) * 8));
589 freebsd32_pselect(struct thread *td, struct freebsd32_pselect_args *uap)
591 struct timespec32 ts32;
593 struct timeval tv, *tvp;
597 if (uap->ts != NULL) {
598 error = copyin(uap->ts, &ts32, sizeof(ts32));
601 CP(ts32, ts, tv_sec);
602 CP(ts32, ts, tv_nsec);
603 TIMESPEC_TO_TIMEVAL(&tv, &ts);
607 if (uap->sm != NULL) {
608 error = copyin(uap->sm, &set, sizeof(set));
615 * XXX Do pointers need PTRIN()?
617 error = kern_pselect(td, uap->nd, uap->in, uap->ou, uap->ex, tvp,
618 uset, sizeof(int32_t) * 8);
623 * Copy 'count' items into the destination list pointed to by uap->eventlist.
626 freebsd32_kevent_copyout(void *arg, struct kevent *kevp, int count)
628 struct freebsd32_kevent_args *uap;
629 struct kevent32 ks32[KQ_NEVENTS];
633 KASSERT(count <= KQ_NEVENTS, ("count (%d) > KQ_NEVENTS", count));
634 uap = (struct freebsd32_kevent_args *)arg;
636 for (i = 0; i < count; i++) {
637 CP(kevp[i], ks32[i], ident);
638 CP(kevp[i], ks32[i], filter);
639 CP(kevp[i], ks32[i], flags);
640 CP(kevp[i], ks32[i], fflags);
641 #if BYTE_ORDER == LITTLE_ENDIAN
642 ks32[i].data1 = kevp[i].data;
643 ks32[i].data2 = kevp[i].data >> 32;
645 ks32[i].data1 = kevp[i].data >> 32;
646 ks32[i].data2 = kevp[i].data;
648 PTROUT_CP(kevp[i], ks32[i], udata);
649 for (j = 0; j < nitems(kevp->ext); j++) {
651 #if BYTE_ORDER == LITTLE_ENDIAN
652 ks32[i].ext64[2 * j] = e;
653 ks32[i].ext64[2 * j + 1] = e >> 32;
655 ks32[i].ext64[2 * j] = e >> 32;
656 ks32[i].ext64[2 * j + 1] = e;
660 error = copyout(ks32, uap->eventlist, count * sizeof *ks32);
662 uap->eventlist += count;
667 * Copy 'count' items from the list pointed to by uap->changelist.
670 freebsd32_kevent_copyin(void *arg, struct kevent *kevp, int count)
672 struct freebsd32_kevent_args *uap;
673 struct kevent32 ks32[KQ_NEVENTS];
677 KASSERT(count <= KQ_NEVENTS, ("count (%d) > KQ_NEVENTS", count));
678 uap = (struct freebsd32_kevent_args *)arg;
680 error = copyin(uap->changelist, ks32, count * sizeof *ks32);
683 uap->changelist += count;
685 for (i = 0; i < count; i++) {
686 CP(ks32[i], kevp[i], ident);
687 CP(ks32[i], kevp[i], filter);
688 CP(ks32[i], kevp[i], flags);
689 CP(ks32[i], kevp[i], fflags);
690 kevp[i].data = PAIR32TO64(uint64_t, ks32[i].data);
691 PTRIN_CP(ks32[i], kevp[i], udata);
692 for (j = 0; j < nitems(kevp->ext); j++) {
693 #if BYTE_ORDER == LITTLE_ENDIAN
694 e = ks32[i].ext64[2 * j + 1];
696 e += ks32[i].ext64[2 * j];
698 e = ks32[i].ext64[2 * j];
700 e += ks32[i].ext64[2 * j + 1];
710 freebsd32_kevent(struct thread *td, struct freebsd32_kevent_args *uap)
712 struct timespec32 ts32;
713 struct timespec ts, *tsp;
714 struct kevent_copyops k_ops = {
716 .k_copyout = freebsd32_kevent_copyout,
717 .k_copyin = freebsd32_kevent_copyin,
720 struct kevent32 *eventlist = uap->eventlist;
725 error = copyin(uap->timeout, &ts32, sizeof(ts32));
728 CP(ts32, ts, tv_sec);
729 CP(ts32, ts, tv_nsec);
734 if (KTRPOINT(td, KTR_STRUCT_ARRAY))
735 ktrstructarray("kevent32", UIO_USERSPACE, uap->changelist,
736 uap->nchanges, sizeof(struct kevent32));
738 error = kern_kevent(td, uap->fd, uap->nchanges, uap->nevents,
741 if (error == 0 && KTRPOINT(td, KTR_STRUCT_ARRAY))
742 ktrstructarray("kevent32", UIO_USERSPACE, eventlist,
743 td->td_retval[0], sizeof(struct kevent32));
748 #ifdef COMPAT_FREEBSD11
750 freebsd32_kevent11_copyout(void *arg, struct kevent *kevp, int count)
752 struct freebsd11_freebsd32_kevent_args *uap;
753 struct kevent32_freebsd11 ks32[KQ_NEVENTS];
756 KASSERT(count <= KQ_NEVENTS, ("count (%d) > KQ_NEVENTS", count));
757 uap = (struct freebsd11_freebsd32_kevent_args *)arg;
759 for (i = 0; i < count; i++) {
760 CP(kevp[i], ks32[i], ident);
761 CP(kevp[i], ks32[i], filter);
762 CP(kevp[i], ks32[i], flags);
763 CP(kevp[i], ks32[i], fflags);
764 CP(kevp[i], ks32[i], data);
765 PTROUT_CP(kevp[i], ks32[i], udata);
767 error = copyout(ks32, uap->eventlist, count * sizeof *ks32);
769 uap->eventlist += count;
774 * Copy 'count' items from the list pointed to by uap->changelist.
777 freebsd32_kevent11_copyin(void *arg, struct kevent *kevp, int count)
779 struct freebsd11_freebsd32_kevent_args *uap;
780 struct kevent32_freebsd11 ks32[KQ_NEVENTS];
783 KASSERT(count <= KQ_NEVENTS, ("count (%d) > KQ_NEVENTS", count));
784 uap = (struct freebsd11_freebsd32_kevent_args *)arg;
786 error = copyin(uap->changelist, ks32, count * sizeof *ks32);
789 uap->changelist += count;
791 for (i = 0; i < count; i++) {
792 CP(ks32[i], kevp[i], ident);
793 CP(ks32[i], kevp[i], filter);
794 CP(ks32[i], kevp[i], flags);
795 CP(ks32[i], kevp[i], fflags);
796 CP(ks32[i], kevp[i], data);
797 PTRIN_CP(ks32[i], kevp[i], udata);
798 for (j = 0; j < nitems(kevp->ext); j++)
806 freebsd11_freebsd32_kevent(struct thread *td,
807 struct freebsd11_freebsd32_kevent_args *uap)
809 struct timespec32 ts32;
810 struct timespec ts, *tsp;
811 struct kevent_copyops k_ops = {
813 .k_copyout = freebsd32_kevent11_copyout,
814 .k_copyin = freebsd32_kevent11_copyin,
817 struct kevent32_freebsd11 *eventlist = uap->eventlist;
822 error = copyin(uap->timeout, &ts32, sizeof(ts32));
825 CP(ts32, ts, tv_sec);
826 CP(ts32, ts, tv_nsec);
831 if (KTRPOINT(td, KTR_STRUCT_ARRAY))
832 ktrstructarray("kevent32_freebsd11", UIO_USERSPACE,
833 uap->changelist, uap->nchanges,
834 sizeof(struct kevent32_freebsd11));
836 error = kern_kevent(td, uap->fd, uap->nchanges, uap->nevents,
839 if (error == 0 && KTRPOINT(td, KTR_STRUCT_ARRAY))
840 ktrstructarray("kevent32_freebsd11", UIO_USERSPACE,
841 eventlist, td->td_retval[0],
842 sizeof(struct kevent32_freebsd11));
849 freebsd32_gettimeofday(struct thread *td,
850 struct freebsd32_gettimeofday_args *uap)
853 struct timeval32 atv32;
859 CP(atv, atv32, tv_sec);
860 CP(atv, atv32, tv_usec);
861 error = copyout(&atv32, uap->tp, sizeof (atv32));
863 if (error == 0 && uap->tzp != NULL) {
864 rtz.tz_minuteswest = 0;
866 error = copyout(&rtz, uap->tzp, sizeof (rtz));
872 freebsd32_getrusage(struct thread *td, struct freebsd32_getrusage_args *uap)
878 error = kern_getrusage(td, uap->who, &s);
880 freebsd32_rusage_out(&s, &s32);
881 error = copyout(&s32, uap->rusage, sizeof(s32));
887 ptrace_lwpinfo_to32(const struct ptrace_lwpinfo *pl,
888 struct ptrace_lwpinfo32 *pl32)
891 bzero(pl32, sizeof(*pl32));
892 pl32->pl_lwpid = pl->pl_lwpid;
893 pl32->pl_event = pl->pl_event;
894 pl32->pl_flags = pl->pl_flags;
895 pl32->pl_sigmask = pl->pl_sigmask;
896 pl32->pl_siglist = pl->pl_siglist;
897 siginfo_to_siginfo32(&pl->pl_siginfo, &pl32->pl_siginfo);
898 strcpy(pl32->pl_tdname, pl->pl_tdname);
899 pl32->pl_child_pid = pl->pl_child_pid;
900 pl32->pl_syscall_code = pl->pl_syscall_code;
901 pl32->pl_syscall_narg = pl->pl_syscall_narg;
905 ptrace_sc_ret_to32(const struct ptrace_sc_ret *psr,
906 struct ptrace_sc_ret32 *psr32)
909 bzero(psr32, sizeof(*psr32));
910 psr32->sr_retval[0] = psr->sr_retval[0];
911 psr32->sr_retval[1] = psr->sr_retval[1];
912 psr32->sr_error = psr->sr_error;
916 freebsd32_ptrace(struct thread *td, struct freebsd32_ptrace_args *uap)
919 struct ptrace_io_desc piod;
920 struct ptrace_lwpinfo pl;
921 struct ptrace_vm_entry pve;
922 struct dbreg32 dbreg;
923 struct fpreg32 fpreg;
925 register_t args[nitems(td->td_sa.args)];
926 struct ptrace_sc_ret psr;
930 struct ptrace_io_desc32 piod;
931 struct ptrace_lwpinfo32 pl;
932 struct ptrace_vm_entry32 pve;
933 uint32_t args[nitems(td->td_sa.args)];
934 struct ptrace_sc_ret32 psr;
937 int data, error = 0, i;
939 AUDIT_ARG_PID(uap->pid);
940 AUDIT_ARG_CMD(uap->req);
941 AUDIT_ARG_VALUE(uap->data);
945 case PT_GET_EVENT_MASK:
950 if (uap->data > sizeof(r32.pl))
954 * Pass size of native structure in 'data'. Truncate
955 * if necessary to avoid siginfo.
958 if (uap->data < offsetof(struct ptrace_lwpinfo32, pl_siginfo) +
959 sizeof(struct siginfo32))
960 data = offsetof(struct ptrace_lwpinfo, pl_siginfo);
963 bzero(&r.reg, sizeof(r.reg));
966 bzero(&r.fpreg, sizeof(r.fpreg));
969 bzero(&r.dbreg, sizeof(r.dbreg));
972 error = copyin(uap->addr, &r.reg, sizeof(r.reg));
975 error = copyin(uap->addr, &r.fpreg, sizeof(r.fpreg));
978 error = copyin(uap->addr, &r.dbreg, sizeof(r.dbreg));
980 case PT_SET_EVENT_MASK:
981 if (uap->data != sizeof(r.ptevents))
984 error = copyin(uap->addr, &r.ptevents, uap->data);
987 error = copyin(uap->addr, &r32.piod, sizeof(r32.piod));
990 CP(r32.piod, r.piod, piod_op);
991 PTRIN_CP(r32.piod, r.piod, piod_offs);
992 PTRIN_CP(r32.piod, r.piod, piod_addr);
993 CP(r32.piod, r.piod, piod_len);
996 error = copyin(uap->addr, &r32.pve, sizeof(r32.pve));
1000 CP(r32.pve, r.pve, pve_entry);
1001 CP(r32.pve, r.pve, pve_timestamp);
1002 CP(r32.pve, r.pve, pve_start);
1003 CP(r32.pve, r.pve, pve_end);
1004 CP(r32.pve, r.pve, pve_offset);
1005 CP(r32.pve, r.pve, pve_prot);
1006 CP(r32.pve, r.pve, pve_pathlen);
1007 CP(r32.pve, r.pve, pve_fileid);
1008 CP(r32.pve, r.pve, pve_fsid);
1009 PTRIN_CP(r32.pve, r.pve, pve_path);
1018 error = kern_ptrace(td, uap->req, uap->pid, addr, data);
1024 CP(r.pve, r32.pve, pve_entry);
1025 CP(r.pve, r32.pve, pve_timestamp);
1026 CP(r.pve, r32.pve, pve_start);
1027 CP(r.pve, r32.pve, pve_end);
1028 CP(r.pve, r32.pve, pve_offset);
1029 CP(r.pve, r32.pve, pve_prot);
1030 CP(r.pve, r32.pve, pve_pathlen);
1031 CP(r.pve, r32.pve, pve_fileid);
1032 CP(r.pve, r32.pve, pve_fsid);
1033 error = copyout(&r32.pve, uap->addr, sizeof(r32.pve));
1036 CP(r.piod, r32.piod, piod_len);
1037 error = copyout(&r32.piod, uap->addr, sizeof(r32.piod));
1040 error = copyout(&r.reg, uap->addr, sizeof(r.reg));
1043 error = copyout(&r.fpreg, uap->addr, sizeof(r.fpreg));
1046 error = copyout(&r.dbreg, uap->addr, sizeof(r.dbreg));
1048 case PT_GET_EVENT_MASK:
1049 /* NB: The size in uap->data is validated in kern_ptrace(). */
1050 error = copyout(&r.ptevents, uap->addr, uap->data);
1053 ptrace_lwpinfo_to32(&r.pl, &r32.pl);
1054 error = copyout(&r32.pl, uap->addr, uap->data);
1056 case PT_GET_SC_ARGS:
1057 for (i = 0; i < nitems(r.args); i++)
1058 r32.args[i] = (uint32_t)r.args[i];
1059 error = copyout(r32.args, uap->addr, MIN(uap->data,
1063 ptrace_sc_ret_to32(&r.psr, &r32.psr);
1064 error = copyout(&r32.psr, uap->addr, MIN(uap->data,
1073 freebsd32_copyinuio(struct iovec32 *iovp, u_int iovcnt, struct uio **uiop)
1075 struct iovec32 iov32;
1082 if (iovcnt > UIO_MAXIOV)
1084 iovlen = iovcnt * sizeof(struct iovec);
1085 uio = malloc(iovlen + sizeof *uio, M_IOV, M_WAITOK);
1086 iov = (struct iovec *)(uio + 1);
1087 for (i = 0; i < iovcnt; i++) {
1088 error = copyin(&iovp[i], &iov32, sizeof(struct iovec32));
1093 iov[i].iov_base = PTRIN(iov32.iov_base);
1094 iov[i].iov_len = iov32.iov_len;
1097 uio->uio_iovcnt = iovcnt;
1098 uio->uio_segflg = UIO_USERSPACE;
1099 uio->uio_offset = -1;
1101 for (i = 0; i < iovcnt; i++) {
1102 if (iov->iov_len > INT_MAX - uio->uio_resid) {
1106 uio->uio_resid += iov->iov_len;
1114 freebsd32_readv(struct thread *td, struct freebsd32_readv_args *uap)
1119 error = freebsd32_copyinuio(uap->iovp, uap->iovcnt, &auio);
1122 error = kern_readv(td, uap->fd, auio);
1128 freebsd32_writev(struct thread *td, struct freebsd32_writev_args *uap)
1133 error = freebsd32_copyinuio(uap->iovp, uap->iovcnt, &auio);
1136 error = kern_writev(td, uap->fd, auio);
1142 freebsd32_preadv(struct thread *td, struct freebsd32_preadv_args *uap)
1147 error = freebsd32_copyinuio(uap->iovp, uap->iovcnt, &auio);
1150 error = kern_preadv(td, uap->fd, auio, PAIR32TO64(off_t,uap->offset));
1156 freebsd32_pwritev(struct thread *td, struct freebsd32_pwritev_args *uap)
1161 error = freebsd32_copyinuio(uap->iovp, uap->iovcnt, &auio);
1164 error = kern_pwritev(td, uap->fd, auio, PAIR32TO64(off_t,uap->offset));
1170 freebsd32_copyiniov(struct iovec32 *iovp32, u_int iovcnt, struct iovec **iovp,
1173 struct iovec32 iov32;
1179 if (iovcnt > UIO_MAXIOV)
1181 iovlen = iovcnt * sizeof(struct iovec);
1182 iov = malloc(iovlen, M_IOV, M_WAITOK);
1183 for (i = 0; i < iovcnt; i++) {
1184 error = copyin(&iovp32[i], &iov32, sizeof(struct iovec32));
1189 iov[i].iov_base = PTRIN(iov32.iov_base);
1190 iov[i].iov_len = iov32.iov_len;
1197 freebsd32_copyinmsghdr(struct msghdr32 *msg32, struct msghdr *msg)
1199 struct msghdr32 m32;
1202 error = copyin(msg32, &m32, sizeof(m32));
1205 msg->msg_name = PTRIN(m32.msg_name);
1206 msg->msg_namelen = m32.msg_namelen;
1207 msg->msg_iov = PTRIN(m32.msg_iov);
1208 msg->msg_iovlen = m32.msg_iovlen;
1209 msg->msg_control = PTRIN(m32.msg_control);
1210 msg->msg_controllen = m32.msg_controllen;
1211 msg->msg_flags = m32.msg_flags;
1216 freebsd32_copyoutmsghdr(struct msghdr *msg, struct msghdr32 *msg32)
1218 struct msghdr32 m32;
1221 m32.msg_name = PTROUT(msg->msg_name);
1222 m32.msg_namelen = msg->msg_namelen;
1223 m32.msg_iov = PTROUT(msg->msg_iov);
1224 m32.msg_iovlen = msg->msg_iovlen;
1225 m32.msg_control = PTROUT(msg->msg_control);
1226 m32.msg_controllen = msg->msg_controllen;
1227 m32.msg_flags = msg->msg_flags;
1228 error = copyout(&m32, msg32, sizeof(m32));
1233 #define FREEBSD32_ALIGNBYTES (sizeof(int) - 1)
1235 #define FREEBSD32_ALIGNBYTES (sizeof(long) - 1)
1237 #define FREEBSD32_ALIGN(p) \
1238 (((u_long)(p) + FREEBSD32_ALIGNBYTES) & ~FREEBSD32_ALIGNBYTES)
1239 #define FREEBSD32_CMSG_SPACE(l) \
1240 (FREEBSD32_ALIGN(sizeof(struct cmsghdr)) + FREEBSD32_ALIGN(l))
1242 #define FREEBSD32_CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \
1243 FREEBSD32_ALIGN(sizeof(struct cmsghdr)))
1246 freebsd32_cmsg_convert(const struct cmsghdr *cm, void *data, socklen_t datalen)
1250 struct timespec32 ts;
1251 struct timeval32 tv;
1252 struct bintime32 bt;
1263 switch (cm->cmsg_level) {
1265 switch (cm->cmsg_type) {
1267 TV_CP(*in, tmp32, tv);
1268 copylen = sizeof(tmp32.tv);
1272 BT_CP(*in, tmp32, bt);
1273 copylen = sizeof(tmp32.bt);
1278 TS_CP(*in, tmp32, ts);
1279 copylen = sizeof(tmp32.ts);
1293 KASSERT((datalen >= copylen), ("corrupted cmsghdr"));
1295 bcopy(&tmp32, data, copylen);
1300 freebsd32_copy_msg_out(struct msghdr *msg, struct mbuf *control)
1304 socklen_t clen, datalen, datalen_out, oldclen;
1307 int len, maxlen, copylen;
1311 len = msg->msg_controllen;
1312 maxlen = msg->msg_controllen;
1313 msg->msg_controllen = 0;
1315 ctlbuf = msg->msg_control;
1316 for (m = control; m != NULL && len > 0; m = m->m_next) {
1317 cm = mtod(m, struct cmsghdr *);
1319 while (cm != NULL) {
1320 if (sizeof(struct cmsghdr) > clen ||
1321 cm->cmsg_len > clen) {
1326 data = CMSG_DATA(cm);
1327 datalen = (caddr_t)cm + cm->cmsg_len - (caddr_t)data;
1328 datalen_out = freebsd32_cmsg_convert(cm, data, datalen);
1331 * Copy out the message header. Preserve the native
1332 * message size in case we need to inspect the message
1335 copylen = sizeof(struct cmsghdr);
1336 if (len < copylen) {
1337 msg->msg_flags |= MSG_CTRUNC;
1338 m_dispose_extcontrolm(m);
1341 oldclen = cm->cmsg_len;
1342 cm->cmsg_len = FREEBSD32_ALIGN(sizeof(struct cmsghdr)) +
1344 error = copyout(cm, ctlbuf, copylen);
1345 cm->cmsg_len = oldclen;
1349 ctlbuf += FREEBSD32_ALIGN(copylen);
1350 len -= FREEBSD32_ALIGN(copylen);
1352 copylen = datalen_out;
1353 if (len < copylen) {
1354 msg->msg_flags |= MSG_CTRUNC;
1355 m_dispose_extcontrolm(m);
1359 /* Copy out the message data. */
1360 error = copyout(data, ctlbuf, copylen);
1364 ctlbuf += FREEBSD32_ALIGN(copylen);
1365 len -= FREEBSD32_ALIGN(copylen);
1367 if (CMSG_SPACE(datalen) < clen) {
1368 clen -= CMSG_SPACE(datalen);
1369 cm = (struct cmsghdr *)
1370 ((caddr_t)cm + CMSG_SPACE(datalen));
1376 msg->msg_controllen +=
1377 FREEBSD32_CMSG_SPACE(datalen_out);
1380 if (len == 0 && m != NULL) {
1381 msg->msg_flags |= MSG_CTRUNC;
1382 m_dispose_extcontrolm(m);
1390 freebsd32_recvmsg(td, uap)
1392 struct freebsd32_recvmsg_args /* {
1394 struct msghdr32 *msg;
1399 struct msghdr32 m32;
1400 struct iovec *uiov, *iov;
1401 struct mbuf *control = NULL;
1402 struct mbuf **controlp;
1405 error = copyin(uap->msg, &m32, sizeof(m32));
1408 error = freebsd32_copyinmsghdr(uap->msg, &msg);
1411 error = freebsd32_copyiniov(PTRIN(m32.msg_iov), m32.msg_iovlen, &iov,
1415 msg.msg_flags = uap->flags;
1419 controlp = (msg.msg_control != NULL) ? &control : NULL;
1420 error = kern_recvit(td, uap->s, &msg, UIO_USERSPACE, controlp);
1424 if (control != NULL)
1425 error = freebsd32_copy_msg_out(&msg, control);
1427 msg.msg_controllen = 0;
1430 error = freebsd32_copyoutmsghdr(&msg, uap->msg);
1434 if (control != NULL) {
1436 m_dispose_extcontrolm(control);
1444 * Copy-in the array of control messages constructed using alignment
1445 * and padding suitable for a 32-bit environment and construct an
1446 * mbuf using alignment and padding suitable for a 64-bit kernel.
1447 * The alignment and padding are defined indirectly by CMSG_DATA(),
1448 * CMSG_SPACE() and CMSG_LEN().
1451 freebsd32_copyin_control(struct mbuf **mp, caddr_t buf, u_int buflen)
1455 void *in, *in1, *md;
1456 u_int msglen, outlen;
1459 if (buflen > MCLBYTES)
1462 in = malloc(buflen, M_TEMP, M_WAITOK);
1463 error = copyin(buf, in, buflen);
1468 * Make a pass over the input buffer to determine the amount of space
1469 * required for 64 bit-aligned copies of the control messages.
1473 while (buflen > 0) {
1474 if (buflen < sizeof(*cm)) {
1478 cm = (struct cmsghdr *)in1;
1479 if (cm->cmsg_len < FREEBSD32_ALIGN(sizeof(*cm))) {
1483 msglen = FREEBSD32_ALIGN(cm->cmsg_len);
1484 if (msglen > buflen || msglen < cm->cmsg_len) {
1490 in1 = (char *)in1 + msglen;
1491 outlen += CMSG_ALIGN(sizeof(*cm)) +
1492 CMSG_ALIGN(msglen - FREEBSD32_ALIGN(sizeof(*cm)));
1494 if (error == 0 && outlen > MCLBYTES) {
1496 * XXXMJ This implies that the upper limit on 32-bit aligned
1497 * control messages is less than MCLBYTES, and so we are not
1498 * perfectly compatible. However, there is no platform
1499 * guarantee that mbuf clusters larger than MCLBYTES can be
1507 m = m_get2(outlen, M_WAITOK, MT_CONTROL, 0);
1509 md = mtod(m, void *);
1512 * Make a second pass over input messages, copying them into the output
1516 while (outlen > 0) {
1517 /* Copy the message header and align the length field. */
1519 memcpy(cm, in1, sizeof(*cm));
1520 msglen = cm->cmsg_len - FREEBSD32_ALIGN(sizeof(*cm));
1521 cm->cmsg_len = CMSG_ALIGN(sizeof(*cm)) + msglen;
1523 /* Copy the message body. */
1524 in1 = (char *)in1 + FREEBSD32_ALIGN(sizeof(*cm));
1525 md = (char *)md + CMSG_ALIGN(sizeof(*cm));
1526 memcpy(md, in1, msglen);
1527 in1 = (char *)in1 + FREEBSD32_ALIGN(msglen);
1528 md = (char *)md + CMSG_ALIGN(msglen);
1529 KASSERT(outlen >= CMSG_ALIGN(sizeof(*cm)) + CMSG_ALIGN(msglen),
1530 ("outlen %u underflow, msglen %u", outlen, msglen));
1531 outlen -= CMSG_ALIGN(sizeof(*cm)) + CMSG_ALIGN(msglen);
1541 freebsd32_sendmsg(struct thread *td,
1542 struct freebsd32_sendmsg_args *uap)
1545 struct msghdr32 m32;
1547 struct mbuf *control = NULL;
1548 struct sockaddr *to = NULL;
1551 error = copyin(uap->msg, &m32, sizeof(m32));
1554 error = freebsd32_copyinmsghdr(uap->msg, &msg);
1557 error = freebsd32_copyiniov(PTRIN(m32.msg_iov), m32.msg_iovlen, &iov,
1562 if (msg.msg_name != NULL) {
1563 error = getsockaddr(&to, msg.msg_name, msg.msg_namelen);
1571 if (msg.msg_control) {
1572 if (msg.msg_controllen < sizeof(struct cmsghdr)) {
1577 error = freebsd32_copyin_control(&control, msg.msg_control,
1578 msg.msg_controllen);
1582 msg.msg_control = NULL;
1583 msg.msg_controllen = 0;
1586 error = kern_sendit(td, uap->s, &msg, uap->flags, control,
1597 freebsd32_recvfrom(struct thread *td,
1598 struct freebsd32_recvfrom_args *uap)
1604 if (uap->fromlenaddr) {
1605 error = copyin(PTRIN(uap->fromlenaddr), &msg.msg_namelen,
1606 sizeof(msg.msg_namelen));
1610 msg.msg_namelen = 0;
1613 msg.msg_name = PTRIN(uap->from);
1614 msg.msg_iov = &aiov;
1616 aiov.iov_base = PTRIN(uap->buf);
1617 aiov.iov_len = uap->len;
1618 msg.msg_control = NULL;
1619 msg.msg_flags = uap->flags;
1620 error = kern_recvit(td, uap->s, &msg, UIO_USERSPACE, NULL);
1621 if (error == 0 && uap->fromlenaddr)
1622 error = copyout(&msg.msg_namelen, PTRIN(uap->fromlenaddr),
1623 sizeof (msg.msg_namelen));
1628 freebsd32_settimeofday(struct thread *td,
1629 struct freebsd32_settimeofday_args *uap)
1631 struct timeval32 tv32;
1632 struct timeval tv, *tvp;
1633 struct timezone tz, *tzp;
1637 error = copyin(uap->tv, &tv32, sizeof(tv32));
1640 CP(tv32, tv, tv_sec);
1641 CP(tv32, tv, tv_usec);
1646 error = copyin(uap->tzp, &tz, sizeof(tz));
1652 return (kern_settimeofday(td, tvp, tzp));
1656 freebsd32_utimes(struct thread *td, struct freebsd32_utimes_args *uap)
1658 struct timeval32 s32[2];
1659 struct timeval s[2], *sp;
1662 if (uap->tptr != NULL) {
1663 error = copyin(uap->tptr, s32, sizeof(s32));
1666 CP(s32[0], s[0], tv_sec);
1667 CP(s32[0], s[0], tv_usec);
1668 CP(s32[1], s[1], tv_sec);
1669 CP(s32[1], s[1], tv_usec);
1673 return (kern_utimesat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
1678 freebsd32_lutimes(struct thread *td, struct freebsd32_lutimes_args *uap)
1680 struct timeval32 s32[2];
1681 struct timeval s[2], *sp;
1684 if (uap->tptr != NULL) {
1685 error = copyin(uap->tptr, s32, sizeof(s32));
1688 CP(s32[0], s[0], tv_sec);
1689 CP(s32[0], s[0], tv_usec);
1690 CP(s32[1], s[1], tv_sec);
1691 CP(s32[1], s[1], tv_usec);
1695 return (kern_lutimes(td, uap->path, UIO_USERSPACE, sp, UIO_SYSSPACE));
1699 freebsd32_futimes(struct thread *td, struct freebsd32_futimes_args *uap)
1701 struct timeval32 s32[2];
1702 struct timeval s[2], *sp;
1705 if (uap->tptr != NULL) {
1706 error = copyin(uap->tptr, s32, sizeof(s32));
1709 CP(s32[0], s[0], tv_sec);
1710 CP(s32[0], s[0], tv_usec);
1711 CP(s32[1], s[1], tv_sec);
1712 CP(s32[1], s[1], tv_usec);
1716 return (kern_futimes(td, uap->fd, sp, UIO_SYSSPACE));
1720 freebsd32_futimesat(struct thread *td, struct freebsd32_futimesat_args *uap)
1722 struct timeval32 s32[2];
1723 struct timeval s[2], *sp;
1726 if (uap->times != NULL) {
1727 error = copyin(uap->times, s32, sizeof(s32));
1730 CP(s32[0], s[0], tv_sec);
1731 CP(s32[0], s[0], tv_usec);
1732 CP(s32[1], s[1], tv_sec);
1733 CP(s32[1], s[1], tv_usec);
1737 return (kern_utimesat(td, uap->fd, uap->path, UIO_USERSPACE,
1742 freebsd32_futimens(struct thread *td, struct freebsd32_futimens_args *uap)
1744 struct timespec32 ts32[2];
1745 struct timespec ts[2], *tsp;
1748 if (uap->times != NULL) {
1749 error = copyin(uap->times, ts32, sizeof(ts32));
1752 CP(ts32[0], ts[0], tv_sec);
1753 CP(ts32[0], ts[0], tv_nsec);
1754 CP(ts32[1], ts[1], tv_sec);
1755 CP(ts32[1], ts[1], tv_nsec);
1759 return (kern_futimens(td, uap->fd, tsp, UIO_SYSSPACE));
1763 freebsd32_utimensat(struct thread *td, struct freebsd32_utimensat_args *uap)
1765 struct timespec32 ts32[2];
1766 struct timespec ts[2], *tsp;
1769 if (uap->times != NULL) {
1770 error = copyin(uap->times, ts32, sizeof(ts32));
1773 CP(ts32[0], ts[0], tv_sec);
1774 CP(ts32[0], ts[0], tv_nsec);
1775 CP(ts32[1], ts[1], tv_sec);
1776 CP(ts32[1], ts[1], tv_nsec);
1780 return (kern_utimensat(td, uap->fd, uap->path, UIO_USERSPACE,
1781 tsp, UIO_SYSSPACE, uap->flag));
1785 freebsd32_adjtime(struct thread *td, struct freebsd32_adjtime_args *uap)
1787 struct timeval32 tv32;
1788 struct timeval delta, olddelta, *deltap;
1792 error = copyin(uap->delta, &tv32, sizeof(tv32));
1795 CP(tv32, delta, tv_sec);
1796 CP(tv32, delta, tv_usec);
1800 error = kern_adjtime(td, deltap, &olddelta);
1801 if (uap->olddelta && error == 0) {
1802 CP(olddelta, tv32, tv_sec);
1803 CP(olddelta, tv32, tv_usec);
1804 error = copyout(&tv32, uap->olddelta, sizeof(tv32));
1809 #ifdef COMPAT_FREEBSD4
1811 freebsd4_freebsd32_statfs(struct thread *td, struct freebsd4_freebsd32_statfs_args *uap)
1813 struct statfs32 s32;
1817 sp = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK);
1818 error = kern_statfs(td, uap->path, UIO_USERSPACE, sp);
1820 copy_statfs(sp, &s32);
1821 error = copyout(&s32, uap->buf, sizeof(s32));
1828 #ifdef COMPAT_FREEBSD4
1830 freebsd4_freebsd32_fstatfs(struct thread *td, struct freebsd4_freebsd32_fstatfs_args *uap)
1832 struct statfs32 s32;
1836 sp = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK);
1837 error = kern_fstatfs(td, uap->fd, sp);
1839 copy_statfs(sp, &s32);
1840 error = copyout(&s32, uap->buf, sizeof(s32));
1847 #ifdef COMPAT_FREEBSD4
1849 freebsd4_freebsd32_fhstatfs(struct thread *td, struct freebsd4_freebsd32_fhstatfs_args *uap)
1851 struct statfs32 s32;
1856 if ((error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t))) != 0)
1858 sp = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK);
1859 error = kern_fhstatfs(td, fh, sp);
1861 copy_statfs(sp, &s32);
1862 error = copyout(&s32, uap->buf, sizeof(s32));
1870 freebsd32_pread(struct thread *td, struct freebsd32_pread_args *uap)
1873 return (kern_pread(td, uap->fd, uap->buf, uap->nbyte,
1874 PAIR32TO64(off_t, uap->offset)));
1878 freebsd32_pwrite(struct thread *td, struct freebsd32_pwrite_args *uap)
1881 return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte,
1882 PAIR32TO64(off_t, uap->offset)));
1887 ofreebsd32_lseek(struct thread *td, struct ofreebsd32_lseek_args *uap)
1890 return (kern_lseek(td, uap->fd, uap->offset, uap->whence));
1895 freebsd32_lseek(struct thread *td, struct freebsd32_lseek_args *uap)
1900 error = kern_lseek(td, uap->fd, PAIR32TO64(off_t, uap->offset),
1902 /* Expand the quad return into two parts for eax and edx */
1903 pos = td->td_uretoff.tdu_off;
1904 td->td_retval[RETVAL_LO] = pos & 0xffffffff; /* %eax */
1905 td->td_retval[RETVAL_HI] = pos >> 32; /* %edx */
1910 freebsd32_truncate(struct thread *td, struct freebsd32_truncate_args *uap)
1913 return (kern_truncate(td, uap->path, UIO_USERSPACE,
1914 PAIR32TO64(off_t, uap->length)));
1918 freebsd32_ftruncate(struct thread *td, struct freebsd32_ftruncate_args *uap)
1921 return (kern_ftruncate(td, uap->fd, PAIR32TO64(off_t, uap->length)));
1926 ofreebsd32_getdirentries(struct thread *td,
1927 struct ofreebsd32_getdirentries_args *uap)
1929 struct ogetdirentries_args ap;
1936 ap.count = uap->count;
1938 error = kern_ogetdirentries(td, &ap, &loff);
1941 error = copyout(&loff_cut, uap->basep, sizeof(int32_t));
1947 #if defined(COMPAT_FREEBSD11)
1949 freebsd11_freebsd32_getdirentries(struct thread *td,
1950 struct freebsd11_freebsd32_getdirentries_args *uap)
1956 error = freebsd11_kern_getdirentries(td, uap->fd, uap->buf, uap->count,
1960 if (uap->basep != NULL) {
1962 error = copyout(&base32, uap->basep, sizeof(int32_t));
1968 freebsd11_freebsd32_getdents(struct thread *td,
1969 struct freebsd11_freebsd32_getdents_args *uap)
1971 struct freebsd11_freebsd32_getdirentries_args ap;
1975 ap.count = uap->count;
1977 return (freebsd11_freebsd32_getdirentries(td, &ap));
1979 #endif /* COMPAT_FREEBSD11 */
1981 #ifdef COMPAT_FREEBSD6
1982 /* versions with the 'int pad' argument */
1984 freebsd6_freebsd32_pread(struct thread *td, struct freebsd6_freebsd32_pread_args *uap)
1987 return (kern_pread(td, uap->fd, uap->buf, uap->nbyte,
1988 PAIR32TO64(off_t, uap->offset)));
1992 freebsd6_freebsd32_pwrite(struct thread *td, struct freebsd6_freebsd32_pwrite_args *uap)
1995 return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte,
1996 PAIR32TO64(off_t, uap->offset)));
2000 freebsd6_freebsd32_lseek(struct thread *td, struct freebsd6_freebsd32_lseek_args *uap)
2005 error = kern_lseek(td, uap->fd, PAIR32TO64(off_t, uap->offset),
2007 /* Expand the quad return into two parts for eax and edx */
2008 pos = *(off_t *)(td->td_retval);
2009 td->td_retval[RETVAL_LO] = pos & 0xffffffff; /* %eax */
2010 td->td_retval[RETVAL_HI] = pos >> 32; /* %edx */
2015 freebsd6_freebsd32_truncate(struct thread *td, struct freebsd6_freebsd32_truncate_args *uap)
2018 return (kern_truncate(td, uap->path, UIO_USERSPACE,
2019 PAIR32TO64(off_t, uap->length)));
2023 freebsd6_freebsd32_ftruncate(struct thread *td, struct freebsd6_freebsd32_ftruncate_args *uap)
2026 return (kern_ftruncate(td, uap->fd, PAIR32TO64(off_t, uap->length)));
2028 #endif /* COMPAT_FREEBSD6 */
2038 freebsd32_do_sendfile(struct thread *td,
2039 struct freebsd32_sendfile_args *uap, int compat)
2041 struct sf_hdtr32 hdtr32;
2042 struct sf_hdtr hdtr;
2043 struct uio *hdr_uio, *trl_uio;
2045 cap_rights_t rights;
2046 struct iovec32 *iov32;
2047 off_t offset, sbytes;
2050 offset = PAIR32TO64(off_t, uap->offset);
2054 hdr_uio = trl_uio = NULL;
2056 if (uap->hdtr != NULL) {
2057 error = copyin(uap->hdtr, &hdtr32, sizeof(hdtr32));
2060 PTRIN_CP(hdtr32, hdtr, headers);
2061 CP(hdtr32, hdtr, hdr_cnt);
2062 PTRIN_CP(hdtr32, hdtr, trailers);
2063 CP(hdtr32, hdtr, trl_cnt);
2065 if (hdtr.headers != NULL) {
2066 iov32 = PTRIN(hdtr32.headers);
2067 error = freebsd32_copyinuio(iov32,
2068 hdtr32.hdr_cnt, &hdr_uio);
2071 #ifdef COMPAT_FREEBSD4
2073 * In FreeBSD < 5.0 the nbytes to send also included
2074 * the header. If compat is specified subtract the
2075 * header size from nbytes.
2078 if (uap->nbytes > hdr_uio->uio_resid)
2079 uap->nbytes -= hdr_uio->uio_resid;
2085 if (hdtr.trailers != NULL) {
2086 iov32 = PTRIN(hdtr32.trailers);
2087 error = freebsd32_copyinuio(iov32,
2088 hdtr32.trl_cnt, &trl_uio);
2094 AUDIT_ARG_FD(uap->fd);
2096 if ((error = fget_read(td, uap->fd,
2097 cap_rights_init(&rights, CAP_PREAD), &fp)) != 0)
2100 error = fo_sendfile(fp, uap->s, hdr_uio, trl_uio, offset,
2101 uap->nbytes, &sbytes, uap->flags, td);
2104 if (uap->sbytes != NULL)
2105 copyout(&sbytes, uap->sbytes, sizeof(off_t));
2109 free(hdr_uio, M_IOV);
2111 free(trl_uio, M_IOV);
2115 #ifdef COMPAT_FREEBSD4
2117 freebsd4_freebsd32_sendfile(struct thread *td,
2118 struct freebsd4_freebsd32_sendfile_args *uap)
2120 return (freebsd32_do_sendfile(td,
2121 (struct freebsd32_sendfile_args *)uap, 1));
2126 freebsd32_sendfile(struct thread *td, struct freebsd32_sendfile_args *uap)
2129 return (freebsd32_do_sendfile(td, uap, 0));
2133 copy_stat(struct stat *in, struct stat32 *out)
2136 CP(*in, *out, st_dev);
2137 CP(*in, *out, st_ino);
2138 CP(*in, *out, st_mode);
2139 CP(*in, *out, st_nlink);
2140 CP(*in, *out, st_uid);
2141 CP(*in, *out, st_gid);
2142 CP(*in, *out, st_rdev);
2143 TS_CP(*in, *out, st_atim);
2144 TS_CP(*in, *out, st_mtim);
2145 TS_CP(*in, *out, st_ctim);
2146 CP(*in, *out, st_size);
2147 CP(*in, *out, st_blocks);
2148 CP(*in, *out, st_blksize);
2149 CP(*in, *out, st_flags);
2150 CP(*in, *out, st_gen);
2151 TS_CP(*in, *out, st_birthtim);
2152 out->st_padding0 = 0;
2153 out->st_padding1 = 0;
2154 #ifdef __STAT32_TIME_T_EXT
2155 out->st_atim_ext = 0;
2156 out->st_mtim_ext = 0;
2157 out->st_ctim_ext = 0;
2158 out->st_btim_ext = 0;
2160 bzero(out->st_spare, sizeof(out->st_spare));
2165 copy_ostat(struct stat *in, struct ostat32 *out)
2168 bzero(out, sizeof(*out));
2169 CP(*in, *out, st_dev);
2170 CP(*in, *out, st_ino);
2171 CP(*in, *out, st_mode);
2172 CP(*in, *out, st_nlink);
2173 CP(*in, *out, st_uid);
2174 CP(*in, *out, st_gid);
2175 CP(*in, *out, st_rdev);
2176 out->st_size = MIN(in->st_size, INT32_MAX);
2177 TS_CP(*in, *out, st_atim);
2178 TS_CP(*in, *out, st_mtim);
2179 TS_CP(*in, *out, st_ctim);
2180 CP(*in, *out, st_blksize);
2181 CP(*in, *out, st_blocks);
2182 CP(*in, *out, st_flags);
2183 CP(*in, *out, st_gen);
2189 ofreebsd32_stat(struct thread *td, struct ofreebsd32_stat_args *uap)
2192 struct ostat32 sb32;
2195 error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE,
2199 copy_ostat(&sb, &sb32);
2200 error = copyout(&sb32, uap->ub, sizeof (sb32));
2206 freebsd32_fstat(struct thread *td, struct freebsd32_fstat_args *uap)
2212 error = kern_fstat(td, uap->fd, &ub);
2215 copy_stat(&ub, &ub32);
2216 error = copyout(&ub32, uap->ub, sizeof(ub32));
2222 ofreebsd32_fstat(struct thread *td, struct ofreebsd32_fstat_args *uap)
2225 struct ostat32 ub32;
2228 error = kern_fstat(td, uap->fd, &ub);
2231 copy_ostat(&ub, &ub32);
2232 error = copyout(&ub32, uap->ub, sizeof(ub32));
2238 freebsd32_fstatat(struct thread *td, struct freebsd32_fstatat_args *uap)
2244 error = kern_statat(td, uap->flag, uap->fd, uap->path, UIO_USERSPACE,
2248 copy_stat(&ub, &ub32);
2249 error = copyout(&ub32, uap->buf, sizeof(ub32));
2255 ofreebsd32_lstat(struct thread *td, struct ofreebsd32_lstat_args *uap)
2258 struct ostat32 sb32;
2261 error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path,
2262 UIO_USERSPACE, &sb, NULL);
2265 copy_ostat(&sb, &sb32);
2266 error = copyout(&sb32, uap->ub, sizeof (sb32));
2272 freebsd32_fhstat(struct thread *td, struct freebsd32_fhstat_args *uap)
2279 error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t));
2282 error = kern_fhstat(td, fh, &sb);
2285 copy_stat(&sb, &sb32);
2286 error = copyout(&sb32, uap->sb, sizeof (sb32));
2290 #if defined(COMPAT_FREEBSD11)
2291 extern int ino64_trunc_error;
2294 freebsd11_cvtstat32(struct stat *in, struct freebsd11_stat32 *out)
2297 CP(*in, *out, st_ino);
2298 if (in->st_ino != out->st_ino) {
2299 switch (ino64_trunc_error) {
2306 out->st_ino = UINT32_MAX;
2310 CP(*in, *out, st_nlink);
2311 if (in->st_nlink != out->st_nlink) {
2312 switch (ino64_trunc_error) {
2319 out->st_nlink = UINT16_MAX;
2323 out->st_dev = in->st_dev;
2324 if (out->st_dev != in->st_dev) {
2325 switch (ino64_trunc_error) {
2332 CP(*in, *out, st_mode);
2333 CP(*in, *out, st_uid);
2334 CP(*in, *out, st_gid);
2335 out->st_rdev = in->st_rdev;
2336 if (out->st_rdev != in->st_rdev) {
2337 switch (ino64_trunc_error) {
2344 TS_CP(*in, *out, st_atim);
2345 TS_CP(*in, *out, st_mtim);
2346 TS_CP(*in, *out, st_ctim);
2347 CP(*in, *out, st_size);
2348 CP(*in, *out, st_blocks);
2349 CP(*in, *out, st_blksize);
2350 CP(*in, *out, st_flags);
2351 CP(*in, *out, st_gen);
2352 TS_CP(*in, *out, st_birthtim);
2354 bzero((char *)&out->st_birthtim + sizeof(out->st_birthtim),
2355 sizeof(*out) - offsetof(struct freebsd11_stat32,
2356 st_birthtim) - sizeof(out->st_birthtim));
2361 freebsd11_freebsd32_stat(struct thread *td,
2362 struct freebsd11_freebsd32_stat_args *uap)
2365 struct freebsd11_stat32 sb32;
2368 error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE,
2372 error = freebsd11_cvtstat32(&sb, &sb32);
2374 error = copyout(&sb32, uap->ub, sizeof (sb32));
2379 freebsd11_freebsd32_fstat(struct thread *td,
2380 struct freebsd11_freebsd32_fstat_args *uap)
2383 struct freebsd11_stat32 sb32;
2386 error = kern_fstat(td, uap->fd, &sb);
2389 error = freebsd11_cvtstat32(&sb, &sb32);
2391 error = copyout(&sb32, uap->ub, sizeof (sb32));
2396 freebsd11_freebsd32_fstatat(struct thread *td,
2397 struct freebsd11_freebsd32_fstatat_args *uap)
2400 struct freebsd11_stat32 sb32;
2403 error = kern_statat(td, uap->flag, uap->fd, uap->path, UIO_USERSPACE,
2407 error = freebsd11_cvtstat32(&sb, &sb32);
2409 error = copyout(&sb32, uap->buf, sizeof (sb32));
2414 freebsd11_freebsd32_lstat(struct thread *td,
2415 struct freebsd11_freebsd32_lstat_args *uap)
2418 struct freebsd11_stat32 sb32;
2421 error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path,
2422 UIO_USERSPACE, &sb, NULL);
2425 error = freebsd11_cvtstat32(&sb, &sb32);
2427 error = copyout(&sb32, uap->ub, sizeof (sb32));
2432 freebsd11_freebsd32_fhstat(struct thread *td,
2433 struct freebsd11_freebsd32_fhstat_args *uap)
2436 struct freebsd11_stat32 sb32;
2440 error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t));
2443 error = kern_fhstat(td, fh, &sb);
2446 error = freebsd11_cvtstat32(&sb, &sb32);
2448 error = copyout(&sb32, uap->sb, sizeof (sb32));
2454 freebsd32___sysctl(struct thread *td, struct freebsd32___sysctl_args *uap)
2456 int error, name[CTL_MAXNAME];
2460 if (uap->namelen > CTL_MAXNAME || uap->namelen < 2)
2462 error = copyin(uap->name, name, uap->namelen * sizeof(int));
2466 error = fueword32(uap->oldlenp, &tmp);
2473 error = userland_sysctl(td, name, uap->namelen,
2474 uap->old, &oldlen, 1,
2475 uap->new, uap->newlen, &j, SCTL_MASK32);
2479 suword32(uap->oldlenp, j);
2484 freebsd32___sysctlbyname(struct thread *td,
2485 struct freebsd32___sysctlbyname_args *uap)
2491 if (uap->oldlenp != NULL) {
2492 error = fueword32(uap->oldlenp, &tmp);
2499 error = kern___sysctlbyname(td, uap->name, uap->namelen, uap->old,
2500 &oldlen, uap->new, uap->newlen, &rv, SCTL_MASK32, 1);
2503 if (uap->oldlenp != NULL)
2504 error = suword32(uap->oldlenp, rv);
2510 freebsd32_jail(struct thread *td, struct freebsd32_jail_args *uap)
2516 error = copyin(uap->jail, &version, sizeof(uint32_t));
2523 /* FreeBSD single IPv4 jails. */
2524 struct jail32_v0 j32_v0;
2526 bzero(&j, sizeof(struct jail));
2527 error = copyin(uap->jail, &j32_v0, sizeof(struct jail32_v0));
2530 CP(j32_v0, j, version);
2531 PTRIN_CP(j32_v0, j, path);
2532 PTRIN_CP(j32_v0, j, hostname);
2533 j.ip4s = htonl(j32_v0.ip_number); /* jail_v0 is host order */
2539 * Version 1 was used by multi-IPv4 jail implementations
2540 * that never made it into the official kernel.
2544 case 2: /* JAIL_API_VERSION */
2546 /* FreeBSD multi-IPv4/IPv6,noIP jails. */
2549 error = copyin(uap->jail, &j32, sizeof(struct jail32));
2552 CP(j32, j, version);
2553 PTRIN_CP(j32, j, path);
2554 PTRIN_CP(j32, j, hostname);
2555 PTRIN_CP(j32, j, jailname);
2558 PTRIN_CP(j32, j, ip4);
2559 PTRIN_CP(j32, j, ip6);
2564 /* Sci-Fi jails are not supported, sorry. */
2567 return (kern_jail(td, &j));
2571 freebsd32_jail_set(struct thread *td, struct freebsd32_jail_set_args *uap)
2576 /* Check that we have an even number of iovecs. */
2577 if (uap->iovcnt & 1)
2580 error = freebsd32_copyinuio(uap->iovp, uap->iovcnt, &auio);
2583 error = kern_jail_set(td, auio, uap->flags);
2589 freebsd32_jail_get(struct thread *td, struct freebsd32_jail_get_args *uap)
2591 struct iovec32 iov32;
2595 /* Check that we have an even number of iovecs. */
2596 if (uap->iovcnt & 1)
2599 error = freebsd32_copyinuio(uap->iovp, uap->iovcnt, &auio);
2602 error = kern_jail_get(td, auio, uap->flags);
2604 for (i = 0; i < uap->iovcnt; i++) {
2605 PTROUT_CP(auio->uio_iov[i], iov32, iov_base);
2606 CP(auio->uio_iov[i], iov32, iov_len);
2607 error = copyout(&iov32, uap->iovp + i, sizeof(iov32));
2616 freebsd32_sigaction(struct thread *td, struct freebsd32_sigaction_args *uap)
2618 struct sigaction32 s32;
2619 struct sigaction sa, osa, *sap;
2623 error = copyin(uap->act, &s32, sizeof(s32));
2626 sa.sa_handler = PTRIN(s32.sa_u);
2627 CP(s32, sa, sa_flags);
2628 CP(s32, sa, sa_mask);
2632 error = kern_sigaction(td, uap->sig, sap, &osa, 0);
2633 if (error == 0 && uap->oact != NULL) {
2634 s32.sa_u = PTROUT(osa.sa_handler);
2635 CP(osa, s32, sa_flags);
2636 CP(osa, s32, sa_mask);
2637 error = copyout(&s32, uap->oact, sizeof(s32));
2642 #ifdef COMPAT_FREEBSD4
2644 freebsd4_freebsd32_sigaction(struct thread *td,
2645 struct freebsd4_freebsd32_sigaction_args *uap)
2647 struct sigaction32 s32;
2648 struct sigaction sa, osa, *sap;
2652 error = copyin(uap->act, &s32, sizeof(s32));
2655 sa.sa_handler = PTRIN(s32.sa_u);
2656 CP(s32, sa, sa_flags);
2657 CP(s32, sa, sa_mask);
2661 error = kern_sigaction(td, uap->sig, sap, &osa, KSA_FREEBSD4);
2662 if (error == 0 && uap->oact != NULL) {
2663 s32.sa_u = PTROUT(osa.sa_handler);
2664 CP(osa, s32, sa_flags);
2665 CP(osa, s32, sa_mask);
2666 error = copyout(&s32, uap->oact, sizeof(s32));
2673 struct osigaction32 {
2682 ofreebsd32_sigaction(struct thread *td,
2683 struct ofreebsd32_sigaction_args *uap)
2685 struct osigaction32 s32;
2686 struct sigaction sa, osa, *sap;
2689 if (uap->signum <= 0 || uap->signum >= ONSIG)
2693 error = copyin(uap->nsa, &s32, sizeof(s32));
2696 sa.sa_handler = PTRIN(s32.sa_u);
2697 CP(s32, sa, sa_flags);
2698 OSIG2SIG(s32.sa_mask, sa.sa_mask);
2702 error = kern_sigaction(td, uap->signum, sap, &osa, KSA_OSIGSET);
2703 if (error == 0 && uap->osa != NULL) {
2704 s32.sa_u = PTROUT(osa.sa_handler);
2705 CP(osa, s32, sa_flags);
2706 SIG2OSIG(osa.sa_mask, s32.sa_mask);
2707 error = copyout(&s32, uap->osa, sizeof(s32));
2713 ofreebsd32_sigprocmask(struct thread *td,
2714 struct ofreebsd32_sigprocmask_args *uap)
2719 OSIG2SIG(uap->mask, set);
2720 error = kern_sigprocmask(td, uap->how, &set, &oset, SIGPROCMASK_OLD);
2721 SIG2OSIG(oset, td->td_retval[0]);
2726 ofreebsd32_sigpending(struct thread *td,
2727 struct ofreebsd32_sigpending_args *uap)
2729 struct proc *p = td->td_proc;
2733 siglist = p->p_siglist;
2734 SIGSETOR(siglist, td->td_siglist);
2736 SIG2OSIG(siglist, td->td_retval[0]);
2741 u_int32_t sv_handler;
2747 ofreebsd32_sigvec(struct thread *td,
2748 struct ofreebsd32_sigvec_args *uap)
2750 struct sigvec32 vec;
2751 struct sigaction sa, osa, *sap;
2754 if (uap->signum <= 0 || uap->signum >= ONSIG)
2758 error = copyin(uap->nsv, &vec, sizeof(vec));
2761 sa.sa_handler = PTRIN(vec.sv_handler);
2762 OSIG2SIG(vec.sv_mask, sa.sa_mask);
2763 sa.sa_flags = vec.sv_flags;
2764 sa.sa_flags ^= SA_RESTART;
2768 error = kern_sigaction(td, uap->signum, sap, &osa, KSA_OSIGSET);
2769 if (error == 0 && uap->osv != NULL) {
2770 vec.sv_handler = PTROUT(osa.sa_handler);
2771 SIG2OSIG(osa.sa_mask, vec.sv_mask);
2772 vec.sv_flags = osa.sa_flags;
2773 vec.sv_flags &= ~SA_NOCLDWAIT;
2774 vec.sv_flags ^= SA_RESTART;
2775 error = copyout(&vec, uap->osv, sizeof(vec));
2781 ofreebsd32_sigblock(struct thread *td,
2782 struct ofreebsd32_sigblock_args *uap)
2786 OSIG2SIG(uap->mask, set);
2787 kern_sigprocmask(td, SIG_BLOCK, &set, &oset, 0);
2788 SIG2OSIG(oset, td->td_retval[0]);
2793 ofreebsd32_sigsetmask(struct thread *td,
2794 struct ofreebsd32_sigsetmask_args *uap)
2798 OSIG2SIG(uap->mask, set);
2799 kern_sigprocmask(td, SIG_SETMASK, &set, &oset, 0);
2800 SIG2OSIG(oset, td->td_retval[0]);
2805 ofreebsd32_sigsuspend(struct thread *td,
2806 struct ofreebsd32_sigsuspend_args *uap)
2810 OSIG2SIG(uap->mask, mask);
2811 return (kern_sigsuspend(td, mask));
2820 ofreebsd32_sigstack(struct thread *td,
2821 struct ofreebsd32_sigstack_args *uap)
2823 struct sigstack32 s32;
2824 struct sigstack nss, oss;
2825 int error = 0, unss;
2827 if (uap->nss != NULL) {
2828 error = copyin(uap->nss, &s32, sizeof(s32));
2831 nss.ss_sp = PTRIN(s32.ss_sp);
2832 CP(s32, nss, ss_onstack);
2837 oss.ss_sp = td->td_sigstk.ss_sp;
2838 oss.ss_onstack = sigonstack(cpu_getstack(td));
2840 td->td_sigstk.ss_sp = nss.ss_sp;
2841 td->td_sigstk.ss_size = 0;
2842 td->td_sigstk.ss_flags |= (nss.ss_onstack & SS_ONSTACK);
2843 td->td_pflags |= TDP_ALTSTACK;
2845 if (uap->oss != NULL) {
2846 s32.ss_sp = PTROUT(oss.ss_sp);
2847 CP(oss, s32, ss_onstack);
2848 error = copyout(&s32, uap->oss, sizeof(s32));
2855 freebsd32_nanosleep(struct thread *td, struct freebsd32_nanosleep_args *uap)
2858 return (freebsd32_user_clock_nanosleep(td, CLOCK_REALTIME,
2859 TIMER_RELTIME, uap->rqtp, uap->rmtp));
2863 freebsd32_clock_nanosleep(struct thread *td,
2864 struct freebsd32_clock_nanosleep_args *uap)
2868 error = freebsd32_user_clock_nanosleep(td, uap->clock_id, uap->flags,
2869 uap->rqtp, uap->rmtp);
2870 return (kern_posix_error(td, error));
2874 freebsd32_user_clock_nanosleep(struct thread *td, clockid_t clock_id,
2875 int flags, const struct timespec32 *ua_rqtp, struct timespec32 *ua_rmtp)
2877 struct timespec32 rmt32, rqt32;
2878 struct timespec rmt, rqt;
2881 error = copyin(ua_rqtp, &rqt32, sizeof(rqt32));
2885 CP(rqt32, rqt, tv_sec);
2886 CP(rqt32, rqt, tv_nsec);
2888 error = kern_clock_nanosleep(td, clock_id, flags, &rqt, &rmt);
2889 if (error == EINTR && ua_rmtp != NULL && (flags & TIMER_ABSTIME) == 0) {
2890 CP(rmt, rmt32, tv_sec);
2891 CP(rmt, rmt32, tv_nsec);
2893 error2 = copyout(&rmt32, ua_rmtp, sizeof(rmt32));
2901 freebsd32_clock_gettime(struct thread *td,
2902 struct freebsd32_clock_gettime_args *uap)
2904 struct timespec ats;
2905 struct timespec32 ats32;
2908 error = kern_clock_gettime(td, uap->clock_id, &ats);
2910 CP(ats, ats32, tv_sec);
2911 CP(ats, ats32, tv_nsec);
2912 error = copyout(&ats32, uap->tp, sizeof(ats32));
2918 freebsd32_clock_settime(struct thread *td,
2919 struct freebsd32_clock_settime_args *uap)
2921 struct timespec ats;
2922 struct timespec32 ats32;
2925 error = copyin(uap->tp, &ats32, sizeof(ats32));
2928 CP(ats32, ats, tv_sec);
2929 CP(ats32, ats, tv_nsec);
2931 return (kern_clock_settime(td, uap->clock_id, &ats));
2935 freebsd32_clock_getres(struct thread *td,
2936 struct freebsd32_clock_getres_args *uap)
2939 struct timespec32 ts32;
2942 if (uap->tp == NULL)
2944 error = kern_clock_getres(td, uap->clock_id, &ts);
2946 CP(ts, ts32, tv_sec);
2947 CP(ts, ts32, tv_nsec);
2948 error = copyout(&ts32, uap->tp, sizeof(ts32));
2953 int freebsd32_ktimer_create(struct thread *td,
2954 struct freebsd32_ktimer_create_args *uap)
2956 struct sigevent32 ev32;
2957 struct sigevent ev, *evp;
2960 if (uap->evp == NULL) {
2964 error = copyin(uap->evp, &ev32, sizeof(ev32));
2967 error = convert_sigevent32(&ev32, &ev);
2971 error = kern_ktimer_create(td, uap->clock_id, evp, &id, -1);
2973 error = copyout(&id, uap->timerid, sizeof(int));
2975 kern_ktimer_delete(td, id);
2981 freebsd32_ktimer_settime(struct thread *td,
2982 struct freebsd32_ktimer_settime_args *uap)
2984 struct itimerspec32 val32, oval32;
2985 struct itimerspec val, oval, *ovalp;
2988 error = copyin(uap->value, &val32, sizeof(val32));
2992 ovalp = uap->ovalue != NULL ? &oval : NULL;
2993 error = kern_ktimer_settime(td, uap->timerid, uap->flags, &val, ovalp);
2994 if (error == 0 && uap->ovalue != NULL) {
2995 ITS_CP(oval, oval32);
2996 error = copyout(&oval32, uap->ovalue, sizeof(oval32));
3002 freebsd32_ktimer_gettime(struct thread *td,
3003 struct freebsd32_ktimer_gettime_args *uap)
3005 struct itimerspec32 val32;
3006 struct itimerspec val;
3009 error = kern_ktimer_gettime(td, uap->timerid, &val);
3012 error = copyout(&val32, uap->value, sizeof(val32));
3018 freebsd32_clock_getcpuclockid2(struct thread *td,
3019 struct freebsd32_clock_getcpuclockid2_args *uap)
3024 error = kern_clock_getcpuclockid2(td, PAIR32TO64(id_t, uap->id),
3025 uap->which, &clk_id);
3027 error = copyout(&clk_id, uap->clock_id, sizeof(clockid_t));
3032 freebsd32_thr_new(struct thread *td,
3033 struct freebsd32_thr_new_args *uap)
3035 struct thr_param32 param32;
3036 struct thr_param param;
3039 if (uap->param_size < 0 ||
3040 uap->param_size > sizeof(struct thr_param32))
3042 bzero(¶m, sizeof(struct thr_param));
3043 bzero(¶m32, sizeof(struct thr_param32));
3044 error = copyin(uap->param, ¶m32, uap->param_size);
3047 param.start_func = PTRIN(param32.start_func);
3048 param.arg = PTRIN(param32.arg);
3049 param.stack_base = PTRIN(param32.stack_base);
3050 param.stack_size = param32.stack_size;
3051 param.tls_base = PTRIN(param32.tls_base);
3052 param.tls_size = param32.tls_size;
3053 param.child_tid = PTRIN(param32.child_tid);
3054 param.parent_tid = PTRIN(param32.parent_tid);
3055 param.flags = param32.flags;
3056 param.rtp = PTRIN(param32.rtp);
3057 param.spare[0] = PTRIN(param32.spare[0]);
3058 param.spare[1] = PTRIN(param32.spare[1]);
3059 param.spare[2] = PTRIN(param32.spare[2]);
3061 return (kern_thr_new(td, ¶m));
3065 freebsd32_thr_suspend(struct thread *td, struct freebsd32_thr_suspend_args *uap)
3067 struct timespec32 ts32;
3068 struct timespec ts, *tsp;
3073 if (uap->timeout != NULL) {
3074 error = copyin((const void *)uap->timeout, (void *)&ts32,
3075 sizeof(struct timespec32));
3078 ts.tv_sec = ts32.tv_sec;
3079 ts.tv_nsec = ts32.tv_nsec;
3082 return (kern_thr_suspend(td, tsp));
3086 siginfo_to_siginfo32(const siginfo_t *src, struct siginfo32 *dst)
3088 bzero(dst, sizeof(*dst));
3089 dst->si_signo = src->si_signo;
3090 dst->si_errno = src->si_errno;
3091 dst->si_code = src->si_code;
3092 dst->si_pid = src->si_pid;
3093 dst->si_uid = src->si_uid;
3094 dst->si_status = src->si_status;
3095 dst->si_addr = (uintptr_t)src->si_addr;
3096 dst->si_value.sival_int = src->si_value.sival_int;
3097 dst->si_timerid = src->si_timerid;
3098 dst->si_overrun = src->si_overrun;
3101 #ifndef _FREEBSD32_SYSPROTO_H_
3102 struct freebsd32_sigqueue_args {
3105 /* union sigval32 */ int value;
3109 freebsd32_sigqueue(struct thread *td, struct freebsd32_sigqueue_args *uap)
3114 * On 32-bit ABIs, sival_int and sival_ptr are the same.
3115 * On 64-bit little-endian ABIs, the low bits are the same.
3116 * In 64-bit big-endian ABIs, sival_int overlaps with
3117 * sival_ptr's HIGH bits. We choose to support sival_int
3118 * rather than sival_ptr in this case as it seems to be
3121 bzero(&sv, sizeof(sv));
3122 sv.sival_int = uap->value;
3124 return (kern_sigqueue(td, uap->pid, uap->signum, &sv));
3128 freebsd32_sigtimedwait(struct thread *td, struct freebsd32_sigtimedwait_args *uap)
3130 struct timespec32 ts32;
3132 struct timespec *timeout;
3135 struct siginfo32 si32;
3139 error = copyin(uap->timeout, &ts32, sizeof(ts32));
3142 ts.tv_sec = ts32.tv_sec;
3143 ts.tv_nsec = ts32.tv_nsec;
3148 error = copyin(uap->set, &set, sizeof(set));
3152 error = kern_sigtimedwait(td, set, &ksi, timeout);
3157 siginfo_to_siginfo32(&ksi.ksi_info, &si32);
3158 error = copyout(&si32, uap->info, sizeof(struct siginfo32));
3162 td->td_retval[0] = ksi.ksi_signo;
3170 freebsd32_sigwaitinfo(struct thread *td, struct freebsd32_sigwaitinfo_args *uap)
3173 struct siginfo32 si32;
3177 error = copyin(uap->set, &set, sizeof(set));
3181 error = kern_sigtimedwait(td, set, &ksi, NULL);
3186 siginfo_to_siginfo32(&ksi.ksi_info, &si32);
3187 error = copyout(&si32, uap->info, sizeof(struct siginfo32));
3190 td->td_retval[0] = ksi.ksi_signo;
3195 freebsd32_cpuset_setid(struct thread *td,
3196 struct freebsd32_cpuset_setid_args *uap)
3199 return (kern_cpuset_setid(td, uap->which,
3200 PAIR32TO64(id_t, uap->id), uap->setid));
3204 freebsd32_cpuset_getid(struct thread *td,
3205 struct freebsd32_cpuset_getid_args *uap)
3208 return (kern_cpuset_getid(td, uap->level, uap->which,
3209 PAIR32TO64(id_t, uap->id), uap->setid));
3213 freebsd32_cpuset_getaffinity(struct thread *td,
3214 struct freebsd32_cpuset_getaffinity_args *uap)
3217 return (kern_cpuset_getaffinity(td, uap->level, uap->which,
3218 PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask));
3222 freebsd32_cpuset_setaffinity(struct thread *td,
3223 struct freebsd32_cpuset_setaffinity_args *uap)
3226 return (kern_cpuset_setaffinity(td, uap->level, uap->which,
3227 PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask));
3231 freebsd32_cpuset_getdomain(struct thread *td,
3232 struct freebsd32_cpuset_getdomain_args *uap)
3235 return (kern_cpuset_getdomain(td, uap->level, uap->which,
3236 PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, uap->policy));
3240 freebsd32_cpuset_setdomain(struct thread *td,
3241 struct freebsd32_cpuset_setdomain_args *uap)
3244 return (kern_cpuset_setdomain(td, uap->level, uap->which,
3245 PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, uap->policy));
3249 freebsd32_nmount(struct thread *td,
3250 struct freebsd32_nmount_args /* {
3252 unsigned int iovcnt;
3261 * Mount flags are now 64-bits. On 32-bit archtectures only
3262 * 32-bits are passed in, but from here on everything handles
3263 * 64-bit flags correctly.
3267 AUDIT_ARG_FFLAGS(flags);
3270 * Filter out MNT_ROOTFS. We do not want clients of nmount() in
3271 * userspace to set this flag, but we must filter it out if we want
3272 * MNT_UPDATE on the root file system to work.
3273 * MNT_ROOTFS should only be set by the kernel when mounting its
3276 flags &= ~MNT_ROOTFS;
3279 * check that we have an even number of iovec's
3280 * and that we have at least two options.
3282 if ((uap->iovcnt & 1) || (uap->iovcnt < 4))
3285 error = freebsd32_copyinuio(uap->iovp, uap->iovcnt, &auio);
3288 error = vfs_donmount(td, flags, auio);
3296 freebsd32_xxx(struct thread *td, struct freebsd32_xxx_args *uap)
3298 struct yyy32 *p32, s32;
3299 struct yyy *p = NULL, s;
3304 error = copyin(uap->zzz, &s32, sizeof(s32));
3310 error = kern_xxx(td, p);
3315 error = copyout(&s32, p32, sizeof(s32));
3322 syscall32_module_handler(struct module *mod, int what, void *arg)
3325 return (kern_syscall_module_handler(freebsd32_sysent, mod, what, arg));
3329 syscall32_helper_register(struct syscall_helper_data *sd, int flags)
3332 return (kern_syscall_helper_register(freebsd32_sysent, sd, flags));
3336 syscall32_helper_unregister(struct syscall_helper_data *sd)
3339 return (kern_syscall_helper_unregister(freebsd32_sysent, sd));
3343 freebsd32_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
3348 uintptr_t destp, ustringp;
3349 struct freebsd32_ps_strings *arginfo;
3350 char canary[sizeof(long) * 8];
3351 int32_t pagesizes32[MAXPAGESIZES];
3352 size_t execpath_len;
3353 int error, szsigcode;
3356 * Calculate string base and vector table pointers.
3357 * Also deal with signal trampoline code for this exec type.
3359 if (imgp->execpath != NULL && imgp->auxargs != NULL)
3360 execpath_len = strlen(imgp->execpath) + 1;
3363 arginfo = (struct freebsd32_ps_strings *)curproc->p_sysent->
3365 imgp->ps_strings = arginfo;
3366 if (imgp->proc->p_sysent->sv_sigcode_base == 0)
3367 szsigcode = *(imgp->proc->p_sysent->sv_szsigcode);
3370 destp = (uintptr_t)arginfo;
3375 if (szsigcode != 0) {
3377 destp = rounddown2(destp, sizeof(uint32_t));
3378 error = copyout(imgp->proc->p_sysent->sv_sigcode, (void *)destp,
3385 * Copy the image path for the rtld.
3387 if (execpath_len != 0) {
3388 destp -= execpath_len;
3389 imgp->execpathp = (void *)destp;
3390 error = copyout(imgp->execpath, imgp->execpathp, execpath_len);
3396 * Prepare the canary for SSP.
3398 arc4rand(canary, sizeof(canary), 0);
3399 destp -= sizeof(canary);
3400 imgp->canary = (void *)destp;
3401 error = copyout(canary, imgp->canary, sizeof(canary));
3404 imgp->canarylen = sizeof(canary);
3407 * Prepare the pagesizes array.
3409 for (i = 0; i < MAXPAGESIZES; i++)
3410 pagesizes32[i] = (uint32_t)pagesizes[i];
3411 destp -= sizeof(pagesizes32);
3412 destp = rounddown2(destp, sizeof(uint32_t));
3413 imgp->pagesizes = (void *)destp;
3414 error = copyout(pagesizes32, imgp->pagesizes, sizeof(pagesizes32));
3417 imgp->pagesizeslen = sizeof(pagesizes32);
3420 * Allocate room for the argument and environment strings.
3422 destp -= ARG_MAX - imgp->args->stringspace;
3423 destp = rounddown2(destp, sizeof(uint32_t));
3426 if (imgp->sysent->sv_stackgap != NULL)
3427 imgp->sysent->sv_stackgap(imgp, &destp);
3429 if (imgp->auxargs) {
3431 * Allocate room on the stack for the ELF auxargs
3432 * array. It has up to AT_COUNT entries.
3434 destp -= AT_COUNT * sizeof(Elf32_Auxinfo);
3435 destp = rounddown2(destp, sizeof(uint32_t));
3438 vectp = (uint32_t *)destp;
3441 * Allocate room for the argv[] and env vectors including the
3442 * terminating NULL pointers.
3444 vectp -= imgp->args->argc + 1 + imgp->args->envc + 1;
3447 * vectp also becomes our initial stack base
3449 *stack_base = (uintptr_t)vectp;
3451 stringp = imgp->args->begin_argv;
3452 argc = imgp->args->argc;
3453 envc = imgp->args->envc;
3455 * Copy out strings - arguments and environment.
3457 error = copyout(stringp, (void *)ustringp,
3458 ARG_MAX - imgp->args->stringspace);
3463 * Fill in "ps_strings" struct for ps, w, etc.
3466 if (suword32(&arginfo->ps_argvstr, (u_int32_t)(intptr_t)vectp) != 0 ||
3467 suword32(&arginfo->ps_nargvstr, argc) != 0)
3471 * Fill in argument portion of vector table.
3473 for (; argc > 0; --argc) {
3474 if (suword32(vectp++, ustringp) != 0)
3476 while (*stringp++ != 0)
3481 /* a null vector table pointer separates the argp's from the envp's */
3482 if (suword32(vectp++, 0) != 0)
3486 if (suword32(&arginfo->ps_envstr, (u_int32_t)(intptr_t)vectp) != 0 ||
3487 suword32(&arginfo->ps_nenvstr, envc) != 0)
3491 * Fill in environment portion of vector table.
3493 for (; envc > 0; --envc) {
3494 if (suword32(vectp++, ustringp) != 0)
3496 while (*stringp++ != 0)
3501 /* end of vector table is a null pointer */
3502 if (suword32(vectp, 0) != 0)
3505 if (imgp->auxargs) {
3507 error = imgp->sysent->sv_copyout_auxargs(imgp,
3517 freebsd32_kldstat(struct thread *td, struct freebsd32_kldstat_args *uap)
3519 struct kld_file_stat *stat;
3520 struct kld32_file_stat *stat32;
3523 if ((error = copyin(&uap->stat->version, &version, sizeof(version)))
3526 if (version != sizeof(struct kld32_file_stat_1) &&
3527 version != sizeof(struct kld32_file_stat))
3530 stat = malloc(sizeof(*stat), M_TEMP, M_WAITOK | M_ZERO);
3531 stat32 = malloc(sizeof(*stat32), M_TEMP, M_WAITOK | M_ZERO);
3532 error = kern_kldstat(td, uap->fileid, stat);
3534 bcopy(&stat->name[0], &stat32->name[0], sizeof(stat->name));
3535 CP(*stat, *stat32, refs);
3536 CP(*stat, *stat32, id);
3537 PTROUT_CP(*stat, *stat32, address);
3538 CP(*stat, *stat32, size);
3539 bcopy(&stat->pathname[0], &stat32->pathname[0],
3540 sizeof(stat->pathname));
3541 stat32->version = version;
3542 error = copyout(stat32, uap->stat, version);
3545 free(stat32, M_TEMP);
3550 freebsd32_posix_fallocate(struct thread *td,
3551 struct freebsd32_posix_fallocate_args *uap)
3555 error = kern_posix_fallocate(td, uap->fd,
3556 PAIR32TO64(off_t, uap->offset), PAIR32TO64(off_t, uap->len));
3557 return (kern_posix_error(td, error));
3561 freebsd32_posix_fadvise(struct thread *td,
3562 struct freebsd32_posix_fadvise_args *uap)
3566 error = kern_posix_fadvise(td, uap->fd, PAIR32TO64(off_t, uap->offset),
3567 PAIR32TO64(off_t, uap->len), uap->advice);
3568 return (kern_posix_error(td, error));
3572 convert_sigevent32(struct sigevent32 *sig32, struct sigevent *sig)
3575 CP(*sig32, *sig, sigev_notify);
3576 switch (sig->sigev_notify) {
3579 case SIGEV_THREAD_ID:
3580 CP(*sig32, *sig, sigev_notify_thread_id);
3583 CP(*sig32, *sig, sigev_signo);
3584 PTRIN_CP(*sig32, *sig, sigev_value.sival_ptr);
3587 CP(*sig32, *sig, sigev_notify_kqueue);
3588 CP(*sig32, *sig, sigev_notify_kevent_flags);
3589 PTRIN_CP(*sig32, *sig, sigev_value.sival_ptr);
3598 freebsd32_procctl(struct thread *td, struct freebsd32_procctl_args *uap)
3602 struct procctl_reaper_status rs;
3603 struct procctl_reaper_pids rp;
3604 struct procctl_reaper_kill rk;
3607 struct procctl_reaper_pids32 rp;
3609 int error, error1, flags, signum;
3611 if (uap->com >= PROC_PROCCTL_MD_MIN)
3612 return (cpu_procctl(td, uap->idtype, PAIR32TO64(id_t, uap->id),
3613 uap->com, PTRIN(uap->data)));
3617 case PROC_PROTMAX_CTL:
3619 case PROC_STACKGAP_CTL:
3620 case PROC_TRACE_CTL:
3621 case PROC_TRAPCAP_CTL:
3622 error = copyin(PTRIN(uap->data), &flags, sizeof(flags));
3627 case PROC_REAP_ACQUIRE:
3628 case PROC_REAP_RELEASE:
3629 if (uap->data != NULL)
3633 case PROC_REAP_STATUS:
3636 case PROC_REAP_GETPIDS:
3637 error = copyin(uap->data, &x32.rp, sizeof(x32.rp));
3640 CP(x32.rp, x.rp, rp_count);
3641 PTRIN_CP(x32.rp, x.rp, rp_pids);
3644 case PROC_REAP_KILL:
3645 error = copyin(uap->data, &x.rk, sizeof(x.rk));
3650 case PROC_ASLR_STATUS:
3651 case PROC_PROTMAX_STATUS:
3652 case PROC_STACKGAP_STATUS:
3653 case PROC_TRACE_STATUS:
3654 case PROC_TRAPCAP_STATUS:
3657 case PROC_PDEATHSIG_CTL:
3658 error = copyin(uap->data, &signum, sizeof(signum));
3663 case PROC_PDEATHSIG_STATUS:
3669 error = kern_procctl(td, uap->idtype, PAIR32TO64(id_t, uap->id),
3672 case PROC_REAP_STATUS:
3674 error = copyout(&x.rs, uap->data, sizeof(x.rs));
3676 case PROC_REAP_KILL:
3677 error1 = copyout(&x.rk, uap->data, sizeof(x.rk));
3681 case PROC_ASLR_STATUS:
3682 case PROC_PROTMAX_STATUS:
3683 case PROC_STACKGAP_STATUS:
3684 case PROC_TRACE_STATUS:
3685 case PROC_TRAPCAP_STATUS:
3687 error = copyout(&flags, uap->data, sizeof(flags));
3689 case PROC_PDEATHSIG_STATUS:
3691 error = copyout(&signum, uap->data, sizeof(signum));
3698 freebsd32_fcntl(struct thread *td, struct freebsd32_fcntl_args *uap)
3704 * Do unsigned conversion for arg when operation
3705 * interprets it as flags or pointer.
3707 case F_SETLK_REMOTE:
3716 tmp = (unsigned int)(uap->arg);
3722 return (kern_fcntl_freebsd(td, uap->fd, uap->cmd, tmp));
3726 freebsd32_ppoll(struct thread *td, struct freebsd32_ppoll_args *uap)
3728 struct timespec32 ts32;
3729 struct timespec ts, *tsp;
3733 if (uap->ts != NULL) {
3734 error = copyin(uap->ts, &ts32, sizeof(ts32));
3737 CP(ts32, ts, tv_sec);
3738 CP(ts32, ts, tv_nsec);
3742 if (uap->set != NULL) {
3743 error = copyin(uap->set, &set, sizeof(set));
3750 return (kern_poll(td, uap->fds, uap->nfds, tsp, ssp));
3754 freebsd32_sched_rr_get_interval(struct thread *td,
3755 struct freebsd32_sched_rr_get_interval_args *uap)
3758 struct timespec32 ts32;
3761 error = kern_sched_rr_get_interval(td, uap->pid, &ts);
3763 CP(ts, ts32, tv_sec);
3764 CP(ts, ts32, tv_nsec);
3765 error = copyout(&ts32, uap->interval, sizeof(ts32));
3771 freebsd32__umtx_op(struct thread *td, struct freebsd32__umtx_op_args *uap)
3774 return (kern__umtx_op(td, uap->obj, uap->op, uap->val, uap->uaddr,
3775 uap->uaddr2, &umtx_native_ops32));