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