| 712 | }; |
| 713 | |
| 714 | static int |
| 715 | linux_vsyscall(struct thread *td) |
| 716 | { |
| 717 | struct trapframe *frame; |
| 718 | uint64_t retqaddr; |
| 719 | int code, traced; |
| 720 | int error; |
| 721 | |
| 722 | frame = td->td_frame; |
| 723 | |
| 724 | /* Check %rip for vsyscall area. */ |
| 725 | if (__predict_true(frame->tf_rip < LINUX_VSYSCALL_START)) |
| 726 | return (EINVAL); |
| 727 | if ((frame->tf_rip & (LINUX_VSYSCALL_SZ - 1)) != 0) |
| 728 | return (EINVAL); |
| 729 | code = (frame->tf_rip - LINUX_VSYSCALL_START) / LINUX_VSYSCALL_SZ; |
| 730 | if (code >= nitems(linux_vsyscall_vector)) |
| 731 | return (EINVAL); |
| 732 | |
| 733 | /* |
| 734 | * vsyscall called as callq *(%rax), so we must |
| 735 | * use return address from %rsp and also fixup %rsp. |
| 736 | */ |
| 737 | error = copyin((void *)frame->tf_rsp, &retqaddr, sizeof(retqaddr)); |
| 738 | if (error) |
| 739 | return (error); |
| 740 | |
| 741 | frame->tf_rip = retqaddr; |
| 742 | frame->tf_rax = linux_vsyscall_vector[code]; |
| 743 | frame->tf_rsp += 8; |
| 744 | |
| 745 | traced = (frame->tf_flags & PSL_T); |
| 746 | |
| 747 | amd64_syscall(td, traced); |
| 748 | |
| 749 | return (0); |
| 750 | } |
| 751 | |
| 752 | struct sysentvec elf_linux_sysvec = { |
| 753 | .sv_size = LINUX_SYS_MAXSYSCALL, |
nothing calls this directly
no test coverage detected