1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 2004 Tim J. Robbins 5 * Copyright (c) 2002 Doug Rabson 6 * Copyright (c) 2000 Marcel Moolenaar 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer 14 * in this position and unchanged. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #include <sys/cdefs.h> 34 __FBSDID("$FreeBSD$"); 35 36 #include "opt_compat.h" 37 38 #include <sys/param.h> 39 #include <sys/capsicum.h> 40 #include <sys/clock.h> 41 #include <sys/fcntl.h> 42 #include <sys/file.h> 43 #include <sys/imgact.h> 44 #include <sys/kernel.h> 45 #include <sys/limits.h> 46 #include <sys/lock.h> 47 #include <sys/malloc.h> 48 #include <sys/mman.h> 49 #include <sys/mutex.h> 50 #include <sys/priv.h> 51 #include <sys/proc.h> 52 #include <sys/reg.h> 53 #include <sys/resource.h> 54 #include <sys/resourcevar.h> 55 #include <sys/syscallsubr.h> 56 #include <sys/sysproto.h> 57 #include <sys/systm.h> 58 #include <sys/unistd.h> 59 #include <sys/wait.h> 60 61 #include <machine/frame.h> 62 #include <machine/md_var.h> 63 #include <machine/pcb.h> 64 #include <machine/psl.h> 65 #include <machine/segments.h> 66 #include <machine/specialreg.h> 67 #include <x86/ifunc.h> 68 69 #include <vm/pmap.h> 70 #include <vm/vm.h> 71 #include <vm/vm_map.h> 72 73 #include <security/audit/audit.h> 74 75 #include <compat/freebsd32/freebsd32_util.h> 76 #include <amd64/linux32/linux.h> 77 #include <amd64/linux32/linux32_proto.h> 78 #include <compat/linux/linux_emul.h> 79 #include <compat/linux/linux_fork.h> 80 #include <compat/linux/linux_ipc.h> 81 #include <compat/linux/linux_misc.h> 82 #include <compat/linux/linux_mmap.h> 83 #include <compat/linux/linux_signal.h> 84 #include <compat/linux/linux_util.h> 85 86 static void bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru); 87 88 struct l_old_select_argv { 89 l_int nfds; 90 l_uintptr_t readfds; 91 l_uintptr_t writefds; 92 l_uintptr_t exceptfds; 93 l_uintptr_t timeout; 94 } __packed; 95 96 static void 97 bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru) 98 { 99 100 lru->ru_utime.tv_sec = ru->ru_utime.tv_sec; 101 lru->ru_utime.tv_usec = ru->ru_utime.tv_usec; 102 lru->ru_stime.tv_sec = ru->ru_stime.tv_sec; 103 lru->ru_stime.tv_usec = ru->ru_stime.tv_usec; 104 lru->ru_maxrss = ru->ru_maxrss; 105 lru->ru_ixrss = ru->ru_ixrss; 106 lru->ru_idrss = ru->ru_idrss; 107 lru->ru_isrss = ru->ru_isrss; 108 lru->ru_minflt = ru->ru_minflt; 109 lru->ru_majflt = ru->ru_majflt; 110 lru->ru_nswap = ru->ru_nswap; 111 lru->ru_inblock = ru->ru_inblock; 112 lru->ru_oublock = ru->ru_oublock; 113 lru->ru_msgsnd = ru->ru_msgsnd; 114 lru->ru_msgrcv = ru->ru_msgrcv; 115 lru->ru_nsignals = ru->ru_nsignals; 116 lru->ru_nvcsw = ru->ru_nvcsw; 117 lru->ru_nivcsw = ru->ru_nivcsw; 118 } 119 120 int 121 linux_copyout_rusage(struct rusage *ru, void *uaddr) 122 { 123 struct l_rusage lru; 124 125 bsd_to_linux_rusage(ru, &lru); 126 127 return (copyout(&lru, uaddr, sizeof(struct l_rusage))); 128 } 129 130 int 131 linux_execve(struct thread *td, struct linux_execve_args *args) 132 { 133 struct image_args eargs; 134 char *path; 135 int error; 136 137 LCONVPATHEXIST(args->path, &path); 138 139 error = freebsd32_exec_copyin_args(&eargs, path, UIO_SYSSPACE, 140 args->argp, args->envp); 141 free(path, M_TEMP); 142 if (error == 0) 143 error = linux_common_execve(td, &eargs); 144 AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); 145 return (error); 146 } 147 148 CTASSERT(sizeof(struct l_iovec32) == 8); 149 150 int 151 linux32_copyinuio(struct l_iovec32 *iovp, l_ulong iovcnt, struct uio **uiop) 152 { 153 struct l_iovec32 iov32; 154 struct iovec *iov; 155 struct uio *uio; 156 uint32_t iovlen; 157 int error, i; 158 159 *uiop = NULL; 160 if (iovcnt > UIO_MAXIOV) 161 return (EINVAL); 162 iovlen = iovcnt * sizeof(struct iovec); 163 uio = malloc(iovlen + sizeof(*uio), M_IOV, M_WAITOK); 164 iov = (struct iovec *)(uio + 1); 165 for (i = 0; i < iovcnt; i++) { 166 error = copyin(&iovp[i], &iov32, sizeof(struct l_iovec32)); 167 if (error) { 168 free(uio, M_IOV); 169 return (error); 170 } 171 iov[i].iov_base = PTRIN(iov32.iov_base); 172 iov[i].iov_len = iov32.iov_len; 173 } 174 uio->uio_iov = iov; 175 uio->uio_iovcnt = iovcnt; 176 uio->uio_segflg = UIO_USERSPACE; 177 uio->uio_offset = -1; 178 uio->uio_resid = 0; 179 for (i = 0; i < iovcnt; i++) { 180 if (iov->iov_len > INT_MAX - uio->uio_resid) { 181 free(uio, M_IOV); 182 return (EINVAL); 183 } 184 uio->uio_resid += iov->iov_len; 185 iov++; 186 } 187 *uiop = uio; 188 return (0); 189 } 190 191 int 192 linux32_copyiniov(struct l_iovec32 *iovp32, l_ulong iovcnt, struct iovec **iovp, 193 int error) 194 { 195 struct l_iovec32 iov32; 196 struct iovec *iov; 197 uint32_t iovlen; 198 int i; 199 200 *iovp = NULL; 201 if (iovcnt > UIO_MAXIOV) 202 return (error); 203 iovlen = iovcnt * sizeof(struct iovec); 204 iov = malloc(iovlen, M_IOV, M_WAITOK); 205 for (i = 0; i < iovcnt; i++) { 206 error = copyin(&iovp32[i], &iov32, sizeof(struct l_iovec32)); 207 if (error) { 208 free(iov, M_IOV); 209 return (error); 210 } 211 iov[i].iov_base = PTRIN(iov32.iov_base); 212 iov[i].iov_len = iov32.iov_len; 213 } 214 *iovp = iov; 215 return(0); 216 217 } 218 219 int 220 linux_readv(struct thread *td, struct linux_readv_args *uap) 221 { 222 struct uio *auio; 223 int error; 224 225 error = linux32_copyinuio(uap->iovp, uap->iovcnt, &auio); 226 if (error) 227 return (error); 228 error = kern_readv(td, uap->fd, auio); 229 free(auio, M_IOV); 230 return (error); 231 } 232 233 int 234 linux_writev(struct thread *td, struct linux_writev_args *uap) 235 { 236 struct uio *auio; 237 int error; 238 239 error = linux32_copyinuio(uap->iovp, uap->iovcnt, &auio); 240 if (error) 241 return (error); 242 error = kern_writev(td, uap->fd, auio); 243 free(auio, M_IOV); 244 return (error); 245 } 246 247 struct l_ipc_kludge { 248 l_uintptr_t msgp; 249 l_long msgtyp; 250 } __packed; 251 252 int 253 linux_ipc(struct thread *td, struct linux_ipc_args *args) 254 { 255 256 switch (args->what & 0xFFFF) { 257 case LINUX_SEMOP: { 258 259 return (kern_semop(td, args->arg1, PTRIN(args->ptr), 260 args->arg2, NULL)); 261 } 262 case LINUX_SEMGET: { 263 struct linux_semget_args a; 264 265 a.key = args->arg1; 266 a.nsems = args->arg2; 267 a.semflg = args->arg3; 268 return (linux_semget(td, &a)); 269 } 270 case LINUX_SEMCTL: { 271 struct linux_semctl_args a; 272 int error; 273 274 a.semid = args->arg1; 275 a.semnum = args->arg2; 276 a.cmd = args->arg3; 277 error = copyin(PTRIN(args->ptr), &a.arg, sizeof(a.arg)); 278 if (error) 279 return (error); 280 return (linux_semctl(td, &a)); 281 } 282 case LINUX_SEMTIMEDOP: { 283 struct linux_semtimedop_args a; 284 285 a.semid = args->arg1; 286 a.tsops = PTRIN(args->ptr); 287 a.nsops = args->arg2; 288 a.timeout = PTRIN(args->arg5); 289 return (linux_semtimedop(td, &a)); 290 } 291 case LINUX_MSGSND: { 292 struct linux_msgsnd_args a; 293 294 a.msqid = args->arg1; 295 a.msgp = PTRIN(args->ptr); 296 a.msgsz = args->arg2; 297 a.msgflg = args->arg3; 298 return (linux_msgsnd(td, &a)); 299 } 300 case LINUX_MSGRCV: { 301 struct linux_msgrcv_args a; 302 303 a.msqid = args->arg1; 304 a.msgsz = args->arg2; 305 a.msgflg = args->arg3; 306 if ((args->what >> 16) == 0) { 307 struct l_ipc_kludge tmp; 308 int error; 309 310 if (args->ptr == 0) 311 return (EINVAL); 312 error = copyin(PTRIN(args->ptr), &tmp, sizeof(tmp)); 313 if (error) 314 return (error); 315 a.msgp = PTRIN(tmp.msgp); 316 a.msgtyp = tmp.msgtyp; 317 } else { 318 a.msgp = PTRIN(args->ptr); 319 a.msgtyp = args->arg5; 320 } 321 return (linux_msgrcv(td, &a)); 322 } 323 case LINUX_MSGGET: { 324 struct linux_msgget_args a; 325 326 a.key = args->arg1; 327 a.msgflg = args->arg2; 328 return (linux_msgget(td, &a)); 329 } 330 case LINUX_MSGCTL: { 331 struct linux_msgctl_args a; 332 333 a.msqid = args->arg1; 334 a.cmd = args->arg2; 335 a.buf = PTRIN(args->ptr); 336 return (linux_msgctl(td, &a)); 337 } 338 case LINUX_SHMAT: { 339 struct linux_shmat_args a; 340 l_uintptr_t addr; 341 int error; 342 343 a.shmid = args->arg1; 344 a.shmaddr = PTRIN(args->ptr); 345 a.shmflg = args->arg2; 346 error = linux_shmat(td, &a); 347 if (error != 0) 348 return (error); 349 addr = td->td_retval[0]; 350 error = copyout(&addr, PTRIN(args->arg3), sizeof(addr)); 351 td->td_retval[0] = 0; 352 return (error); 353 } 354 case LINUX_SHMDT: { 355 struct linux_shmdt_args a; 356 357 a.shmaddr = PTRIN(args->ptr); 358 return (linux_shmdt(td, &a)); 359 } 360 case LINUX_SHMGET: { 361 struct linux_shmget_args a; 362 363 a.key = args->arg1; 364 a.size = args->arg2; 365 a.shmflg = args->arg3; 366 return (linux_shmget(td, &a)); 367 } 368 case LINUX_SHMCTL: { 369 struct linux_shmctl_args a; 370 371 a.shmid = args->arg1; 372 a.cmd = args->arg2; 373 a.buf = PTRIN(args->ptr); 374 return (linux_shmctl(td, &a)); 375 } 376 default: 377 break; 378 } 379 380 return (EINVAL); 381 } 382 383 int 384 linux_old_select(struct thread *td, struct linux_old_select_args *args) 385 { 386 struct l_old_select_argv linux_args; 387 struct linux_select_args newsel; 388 int error; 389 390 error = copyin(args->ptr, &linux_args, sizeof(linux_args)); 391 if (error) 392 return (error); 393 394 newsel.nfds = linux_args.nfds; 395 newsel.readfds = PTRIN(linux_args.readfds); 396 newsel.writefds = PTRIN(linux_args.writefds); 397 newsel.exceptfds = PTRIN(linux_args.exceptfds); 398 newsel.timeout = PTRIN(linux_args.timeout); 399 return (linux_select(td, &newsel)); 400 } 401 402 int 403 linux_set_cloned_tls(struct thread *td, void *desc) 404 { 405 struct l_user_desc info; 406 struct pcb *pcb; 407 int error; 408 409 error = copyin(desc, &info, sizeof(struct l_user_desc)); 410 if (error) { 411 linux_msg(td, "set_cloned_tls copyin info failed!"); 412 } else { 413 /* We might copy out the entry_number as GUGS32_SEL. */ 414 info.entry_number = GUGS32_SEL; 415 error = copyout(&info, desc, sizeof(struct l_user_desc)); 416 if (error) 417 linux_msg(td, "set_cloned_tls copyout info failed!"); 418 419 pcb = td->td_pcb; 420 update_pcb_bases(pcb); 421 pcb->pcb_gsbase = (register_t)info.base_addr; 422 td->td_frame->tf_gs = GSEL(GUGS32_SEL, SEL_UPL); 423 } 424 425 return (error); 426 } 427 428 int 429 linux_set_upcall(struct thread *td, register_t stack) 430 { 431 432 if (stack) 433 td->td_frame->tf_rsp = stack; 434 435 /* 436 * The newly created Linux thread returns 437 * to the user space by the same path that a parent do. 438 */ 439 td->td_frame->tf_rax = 0; 440 return (0); 441 } 442 443 int 444 linux_mmap2(struct thread *td, struct linux_mmap2_args *args) 445 { 446 447 return (linux_mmap_common(td, PTROUT(args->addr), args->len, args->prot, 448 args->flags, args->fd, (uint64_t)(uint32_t)args->pgoff * 449 PAGE_SIZE)); 450 } 451 452 int 453 linux_mmap(struct thread *td, struct linux_mmap_args *args) 454 { 455 int error; 456 struct l_mmap_argv linux_args; 457 458 error = copyin(args->ptr, &linux_args, sizeof(linux_args)); 459 if (error) 460 return (error); 461 462 return (linux_mmap_common(td, linux_args.addr, linux_args.len, 463 linux_args.prot, linux_args.flags, linux_args.fd, 464 (uint32_t)linux_args.pgoff)); 465 } 466 467 int 468 linux_mprotect(struct thread *td, struct linux_mprotect_args *uap) 469 { 470 471 return (linux_mprotect_common(td, PTROUT(uap->addr), uap->len, uap->prot)); 472 } 473 474 int 475 linux_madvise(struct thread *td, struct linux_madvise_args *uap) 476 { 477 478 return (linux_madvise_common(td, PTROUT(uap->addr), uap->len, uap->behav)); 479 } 480 481 int 482 linux_iopl(struct thread *td, struct linux_iopl_args *args) 483 { 484 int error; 485 486 if (args->level < 0 || args->level > 3) 487 return (EINVAL); 488 if ((error = priv_check(td, PRIV_IO)) != 0) 489 return (error); 490 if ((error = securelevel_gt(td->td_ucred, 0)) != 0) 491 return (error); 492 td->td_frame->tf_rflags = (td->td_frame->tf_rflags & ~PSL_IOPL) | 493 (args->level * (PSL_IOPL / 3)); 494 495 return (0); 496 } 497 498 int 499 linux_sigaction(struct thread *td, struct linux_sigaction_args *args) 500 { 501 l_osigaction_t osa; 502 l_sigaction_t act, oact; 503 int error; 504 505 if (args->nsa != NULL) { 506 error = copyin(args->nsa, &osa, sizeof(l_osigaction_t)); 507 if (error) 508 return (error); 509 act.lsa_handler = osa.lsa_handler; 510 act.lsa_flags = osa.lsa_flags; 511 act.lsa_restorer = osa.lsa_restorer; 512 LINUX_SIGEMPTYSET(act.lsa_mask); 513 act.lsa_mask.__mask = osa.lsa_mask; 514 } 515 516 error = linux_do_sigaction(td, args->sig, args->nsa ? &act : NULL, 517 args->osa ? &oact : NULL); 518 519 if (args->osa != NULL && !error) { 520 osa.lsa_handler = oact.lsa_handler; 521 osa.lsa_flags = oact.lsa_flags; 522 osa.lsa_restorer = oact.lsa_restorer; 523 osa.lsa_mask = oact.lsa_mask.__mask; 524 error = copyout(&osa, args->osa, sizeof(l_osigaction_t)); 525 } 526 527 return (error); 528 } 529 530 /* 531 * Linux has two extra args, restart and oldmask. We don't use these, 532 * but it seems that "restart" is actually a context pointer that 533 * enables the signal to happen with a different register set. 534 */ 535 int 536 linux_sigsuspend(struct thread *td, struct linux_sigsuspend_args *args) 537 { 538 sigset_t sigmask; 539 l_sigset_t mask; 540 541 LINUX_SIGEMPTYSET(mask); 542 mask.__mask = args->mask; 543 linux_to_bsd_sigset(&mask, &sigmask); 544 return (kern_sigsuspend(td, sigmask)); 545 } 546 547 int 548 linux_pause(struct thread *td, struct linux_pause_args *args) 549 { 550 struct proc *p = td->td_proc; 551 sigset_t sigmask; 552 553 PROC_LOCK(p); 554 sigmask = td->td_sigmask; 555 PROC_UNLOCK(p); 556 return (kern_sigsuspend(td, sigmask)); 557 } 558 559 int 560 linux_gettimeofday(struct thread *td, struct linux_gettimeofday_args *uap) 561 { 562 struct timeval atv; 563 l_timeval atv32; 564 struct timezone rtz; 565 int error = 0; 566 567 if (uap->tp) { 568 microtime(&atv); 569 atv32.tv_sec = atv.tv_sec; 570 atv32.tv_usec = atv.tv_usec; 571 error = copyout(&atv32, uap->tp, sizeof(atv32)); 572 } 573 if (error == 0 && uap->tzp != NULL) { 574 rtz.tz_minuteswest = 0; 575 rtz.tz_dsttime = 0; 576 error = copyout(&rtz, uap->tzp, sizeof(rtz)); 577 } 578 return (error); 579 } 580 581 int 582 linux_settimeofday(struct thread *td, struct linux_settimeofday_args *uap) 583 { 584 l_timeval atv32; 585 struct timeval atv, *tvp; 586 struct timezone atz, *tzp; 587 int error; 588 589 if (uap->tp) { 590 error = copyin(uap->tp, &atv32, sizeof(atv32)); 591 if (error) 592 return (error); 593 atv.tv_sec = atv32.tv_sec; 594 atv.tv_usec = atv32.tv_usec; 595 tvp = &atv; 596 } else 597 tvp = NULL; 598 if (uap->tzp) { 599 error = copyin(uap->tzp, &atz, sizeof(atz)); 600 if (error) 601 return (error); 602 tzp = &atz; 603 } else 604 tzp = NULL; 605 return (kern_settimeofday(td, tvp, tzp)); 606 } 607 608 int 609 linux_getrusage(struct thread *td, struct linux_getrusage_args *uap) 610 { 611 struct rusage s; 612 int error; 613 614 error = kern_getrusage(td, uap->who, &s); 615 if (error != 0) 616 return (error); 617 if (uap->rusage != NULL) 618 error = linux_copyout_rusage(&s, uap->rusage); 619 return (error); 620 } 621 622 int 623 linux_set_thread_area(struct thread *td, 624 struct linux_set_thread_area_args *args) 625 { 626 struct l_user_desc info; 627 struct pcb *pcb; 628 int error; 629 630 error = copyin(args->desc, &info, sizeof(struct l_user_desc)); 631 if (error) 632 return (error); 633 634 /* 635 * Semantics of Linux version: every thread in the system has array 636 * of three TLS descriptors. 1st is GLIBC TLS, 2nd is WINE, 3rd unknown. 637 * This syscall loads one of the selected TLS decriptors with a value 638 * and also loads GDT descriptors 6, 7 and 8 with the content of 639 * the per-thread descriptors. 640 * 641 * Semantics of FreeBSD version: I think we can ignore that Linux has 642 * three per-thread descriptors and use just the first one. 643 * The tls_array[] is used only in [gs]et_thread_area() syscalls and 644 * for loading the GDT descriptors. We use just one GDT descriptor 645 * for TLS, so we will load just one. 646 * 647 * XXX: This doesn't work when a user space process tries to use more 648 * than one TLS segment. Comment in the Linux source says wine might 649 * do this. 650 */ 651 652 /* 653 * GLIBC reads current %gs and call set_thread_area() with it. 654 * We should let GUDATA_SEL and GUGS32_SEL proceed as well because 655 * we use these segments. 656 */ 657 switch (info.entry_number) { 658 case GUGS32_SEL: 659 case GUDATA_SEL: 660 case 6: 661 case -1: 662 info.entry_number = GUGS32_SEL; 663 break; 664 default: 665 return (EINVAL); 666 } 667 668 /* 669 * We have to copy out the GDT entry we use. 670 * 671 * XXX: What if a user space program does not check the return value 672 * and tries to use 6, 7 or 8? 673 */ 674 error = copyout(&info, args->desc, sizeof(struct l_user_desc)); 675 if (error) 676 return (error); 677 678 pcb = td->td_pcb; 679 update_pcb_bases(pcb); 680 pcb->pcb_gsbase = (register_t)info.base_addr; 681 update_gdt_gsbase(td, info.base_addr); 682 683 return (0); 684 } 685 686 void 687 bsd_to_linux_regset32(const struct reg32 *b_reg, 688 struct linux_pt_regset32 *l_regset) 689 { 690 691 l_regset->ebx = b_reg->r_ebx; 692 l_regset->ecx = b_reg->r_ecx; 693 l_regset->edx = b_reg->r_edx; 694 l_regset->esi = b_reg->r_esi; 695 l_regset->edi = b_reg->r_edi; 696 l_regset->ebp = b_reg->r_ebp; 697 l_regset->eax = b_reg->r_eax; 698 l_regset->ds = b_reg->r_ds; 699 l_regset->es = b_reg->r_es; 700 l_regset->fs = b_reg->r_fs; 701 l_regset->gs = b_reg->r_gs; 702 l_regset->orig_eax = b_reg->r_eax; 703 l_regset->eip = b_reg->r_eip; 704 l_regset->cs = b_reg->r_cs; 705 l_regset->eflags = b_reg->r_eflags; 706 l_regset->esp = b_reg->r_esp; 707 l_regset->ss = b_reg->r_ss; 708 } 709 710 int futex_xchgl_nosmap(int oparg, uint32_t *uaddr, int *oldval); 711 int futex_xchgl_smap(int oparg, uint32_t *uaddr, int *oldval); 712 DEFINE_IFUNC(, int, futex_xchgl, (int, uint32_t *, int *)) 713 { 714 715 return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ? 716 futex_xchgl_smap : futex_xchgl_nosmap); 717 } 718 719 int futex_addl_nosmap(int oparg, uint32_t *uaddr, int *oldval); 720 int futex_addl_smap(int oparg, uint32_t *uaddr, int *oldval); 721 DEFINE_IFUNC(, int, futex_addl, (int, uint32_t *, int *)) 722 { 723 724 return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ? 725 futex_addl_smap : futex_addl_nosmap); 726 } 727 728 int futex_orl_nosmap(int oparg, uint32_t *uaddr, int *oldval); 729 int futex_orl_smap(int oparg, uint32_t *uaddr, int *oldval); 730 DEFINE_IFUNC(, int, futex_orl, (int, uint32_t *, int *)) 731 { 732 733 return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ? 734 futex_orl_smap : futex_orl_nosmap); 735 } 736 737 int futex_andl_nosmap(int oparg, uint32_t *uaddr, int *oldval); 738 int futex_andl_smap(int oparg, uint32_t *uaddr, int *oldval); 739 DEFINE_IFUNC(, int, futex_andl, (int, uint32_t *, int *)) 740 { 741 742 return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ? 743 futex_andl_smap : futex_andl_nosmap); 744 } 745 746 int futex_xorl_nosmap(int oparg, uint32_t *uaddr, int *oldval); 747 int futex_xorl_smap(int oparg, uint32_t *uaddr, int *oldval); 748 DEFINE_IFUNC(, int, futex_xorl, (int, uint32_t *, int *)) 749 { 750 751 return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ? 752 futex_xorl_smap : futex_xorl_nosmap); 753 } 754