From owner-dev-commits-src-main@freebsd.org Thu Jun 10 11:53:24 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 08F29649CAE; Thu, 10 Jun 2021 11:53:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G12Rl6v5bz4YGd; Thu, 10 Jun 2021 11:53:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D57C56E79; Thu, 10 Jun 2021 11:53:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15ABrNx8018886; Thu, 10 Jun 2021 11:53:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15ABrNdB018885; Thu, 10 Jun 2021 11:53:23 GMT (envelope-from git) Date: Thu, 10 Jun 2021 11:53:23 GMT Message-Id: <202106101153.15ABrNdB018885@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: db4a1f331b73 - main - linux(4): Implement rt_sigtimedwait_time64 system call. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: db4a1f331b73eb821d5d9c3cbb478ad50223f023 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jun 2021 11:53:24 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=db4a1f331b73eb821d5d9c3cbb478ad50223f023 commit db4a1f331b73eb821d5d9c3cbb478ad50223f023 Author: Dmitry Chagin AuthorDate: 2021-06-10 11:51:30 +0000 Commit: Dmitry Chagin CommitDate: 2021-06-10 11:51:30 +0000 linux(4): Implement rt_sigtimedwait_time64 system call. It still does not work as intended, awaits D30675. MFC after: 2 weeks --- sys/amd64/linux32/linux32_dummy_machdep.c | 1 - sys/amd64/linux32/syscalls.master | 7 +++- sys/compat/linux/linux_signal.c | 70 +++++++++++++++++++++++-------- sys/i386/linux/linux_dummy_machdep.c | 1 - sys/i386/linux/syscalls.master | 7 +++- 5 files changed, 64 insertions(+), 22 deletions(-) diff --git a/sys/amd64/linux32/linux32_dummy_machdep.c b/sys/amd64/linux32/linux32_dummy_machdep.c index bfb4ff71e0b1..837496641311 100644 --- a/sys/amd64/linux32/linux32_dummy_machdep.c +++ b/sys/amd64/linux32/linux32_dummy_machdep.c @@ -79,5 +79,4 @@ DUMMY(recvmmsg_time64); DUMMY(mq_timedsend_time64); DUMMY(mq_timedreceive_time64); DUMMY(semtimedop_time64); -DUMMY(rt_sigtimedwait_time64); DUMMY(sched_rr_get_interval_time64); diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master index bf2778bb91fd..92c1c0e53cdc 100644 --- a/sys/amd64/linux32/syscalls.master +++ b/sys/amd64/linux32/syscalls.master @@ -2412,7 +2412,12 @@ int linux_semtimedop_time64(void); } 421 AUE_NULL STD { - int linux_rt_sigtimedwait_time64(void); + int linux_rt_sigtimedwait_time64( + l_sigset_t *mask, + l_siginfo_t *ptr, + struct l_timespec64 *timeout, + l_size_t sigsetsize + ); } 422 AUE_NULL STD { int linux_sys_futex_time64( diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c index 5310895cb92c..d0f1bb1c3b32 100644 --- a/sys/compat/linux/linux_signal.c +++ b/sys/compat/linux/linux_signal.c @@ -60,6 +60,9 @@ __FBSDID("$FreeBSD$"); static int linux_do_tkill(struct thread *td, struct thread *tdt, ksiginfo_t *ksi); static void sicode_to_lsicode(int si_code, int *lsi_code); +static int linux_common_rt_sigtimedwait(struct thread *, + l_sigset_t *, struct timespec *, l_siginfo_t *, + l_size_t); static void linux_to_bsd_sigaction(l_sigaction_t *lsa, struct sigaction *bsa) @@ -386,29 +389,14 @@ linux_rt_sigpending(struct thread *td, struct linux_rt_sigpending_args *args) return (copyout(&lset, args->set, args->sigsetsize)); } -/* - * MPSAFE - */ int linux_rt_sigtimedwait(struct thread *td, struct linux_rt_sigtimedwait_args *args) { - int error, sig; struct timespec ts, *tsa; struct l_timespec lts; - l_sigset_t lset; - sigset_t bset; - l_siginfo_t lsi; - ksiginfo_t ksi; - - if (args->sigsetsize != sizeof(l_sigset_t)) - return (EINVAL); - - if ((error = copyin(args->mask, &lset, sizeof(lset)))) - return (error); - linux_to_bsd_sigset(&lset, &bset); + int error; - tsa = NULL; if (args->timeout) { if ((error = copyin(args->timeout, <s, sizeof(lts)))) return (error); @@ -419,16 +407,38 @@ linux_rt_sigtimedwait(struct thread *td, } else tsa = NULL; + return (linux_common_rt_sigtimedwait(td, args->mask, tsa, + args->ptr, args->sigsetsize)); +} + +static int +linux_common_rt_sigtimedwait(struct thread *td, l_sigset_t *mask, + struct timespec *tsa, l_siginfo_t *ptr, l_size_t sigsetsize) +{ + int error, sig; + l_sigset_t lset; + sigset_t bset; + l_siginfo_t lsi; + ksiginfo_t ksi; + + if (sigsetsize != sizeof(l_sigset_t)) + return (EINVAL); + + if ((error = copyin(mask, &lset, sizeof(lset)))) + return (error); + linux_to_bsd_sigset(&lset, &bset); + + ksiginfo_init(&ksi); error = kern_sigtimedwait(td, bset, &ksi, tsa); if (error) return (error); sig = bsd_to_linux_signal(ksi.ksi_signo); - if (args->ptr) { + if (ptr) { memset(&lsi, 0, sizeof(lsi)); siginfo_to_lsiginfo(&ksi.ksi_info, &lsi, sig); - error = copyout(&lsi, args->ptr, sizeof(lsi)); + error = copyout(&lsi, ptr, sizeof(lsi)); } if (error == 0) td->td_retval[0] = sig; @@ -436,6 +446,30 @@ linux_rt_sigtimedwait(struct thread *td, return (error); } +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +int +linux_rt_sigtimedwait_time64(struct thread *td, + struct linux_rt_sigtimedwait_time64_args *args) +{ + struct timespec ts, *tsa; + struct l_timespec64 lts; + int error; + + if (args->timeout) { + if ((error = copyin(args->timeout, <s, sizeof(lts)))) + return (error); + error = linux_to_native_timespec64(&ts, <s); + if (error != 0) + return (error); + tsa = &ts; + } else + tsa = NULL; + + return (linux_common_rt_sigtimedwait(td, args->mask, tsa, + args->ptr, args->sigsetsize)); +} +#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ + int linux_kill(struct thread *td, struct linux_kill_args *args) { diff --git a/sys/i386/linux/linux_dummy_machdep.c b/sys/i386/linux/linux_dummy_machdep.c index 78503b9453ee..a349fab5b637 100644 --- a/sys/i386/linux/linux_dummy_machdep.c +++ b/sys/i386/linux/linux_dummy_machdep.c @@ -81,5 +81,4 @@ DUMMY(recvmmsg_time64); DUMMY(mq_timedsend_time64); DUMMY(mq_timedreceive_time64); DUMMY(semtimedop_time64); -DUMMY(rt_sigtimedwait_time64); DUMMY(sched_rr_get_interval_time64); diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master index d78f000530e3..c42d9af0058d 100644 --- a/sys/i386/linux/syscalls.master +++ b/sys/i386/linux/syscalls.master @@ -2430,7 +2430,12 @@ int linux_semtimedop_time64(void); } 421 AUE_NULL STD { - int linux_rt_sigtimedwait_time64(void); + int linux_rt_sigtimedwait_time64( + l_sigset_t *mask, + l_siginfo_t *ptr, + struct l_timespec64 *timeout, + l_size_t sigsetsize + ); } 422 AUE_NULL STD { int linux_sys_futex_time64(