From nobody Fri Jun 17 19:39:44 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7599C85C4BF; Fri, 17 Jun 2022 19:39:45 +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 4LPqB90Kxgz3RCW; Fri, 17 Jun 2022 19:39:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YVjQdA5g0bvgedSq4w0F8u/OdNWKZmzRly/qMQAc3UQ=; b=DuNyBf/Ib/qfJDQnrgo5qQIc7rphThizxGCy2J8M88/ymABVnkQa83DIVfwDRTWoAfGoM+ L2/11cemeCYRMrtXBVyEZo27vy6Wo0YD3Hq96usP+tpEVXmjqZZQvMMKqcNtQGVZvnhahe yi+rb7JqsYHbclct1+4I0h5kJXg1MkSaqqRPPZucElZzXIQDlJYL+RuaRa5ZXW8TZXUNVA HtA7wOjHnOXXXlXOpZblA5T8Wtbvf6t7fHiMuZ2GEPBQlbHlf4ywKQSM4/fuV+zWoweG89 9l7Krbf1nHrTCGtXtUzBj288EagMSX7z2KODiYVWlqfE59qBx0htq7ZqSlMS9g== 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 C1EE325C9A; Fri, 17 Jun 2022 19:39:44 +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 25HJdie2016413; Fri, 17 Jun 2022 19:39:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJdiEt016412; Fri, 17 Jun 2022 19:39:44 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:39:44 GMT Message-Id: <202206171939.25HJdiEt016412@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: eea4b5db7184 - stable/13 - linux(4): Implement timerfd_settime64 syscall. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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/stable/13 X-Git-Reftype: branch X-Git-Commit: eea4b5db7184f08b753009f246add9b5e7a8f253 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YVjQdA5g0bvgedSq4w0F8u/OdNWKZmzRly/qMQAc3UQ=; b=NBCg/d0Xdm4BN1XMy0Yz/Yv2j+jdlb3yxhiaaMAmVAkzgPFnK/xARp67etILmhMdIq3on9 e8ntKQ2ssJDF1ECwhmYucvazsk8ffqxa7WC+AYNblpmlzwc+m0hDvHJUEP6BDBX56iTjhh 7PrT5qedDh5WF00ohgP2SD29kr3nv5BnvLttDS8g95RAEPDNKkUeRwkw7b2dSv4ka6I5Hb SrHBceBsaEQNsN5KNew7SL7XwkTQ1DMpuRPjDwCHHfm76BMxZDHkBfsj28gmKzR4uEyUKa 9qgT2f4r57DBelXPs5DsESjTUOnfbdQ7HBOyz+e2lHwo+CW6vzQLrC0bA9fQxQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494785; a=rsa-sha256; cv=none; b=uro2ekvElyuqBpH/CXEWEzwMLCLhD0TLfcr45LIHHmqnnywiwyicX7/aB7ctNctkl++5iJ OSj9m3DsbqjuUcwJXXeu8/K0b32cz3bmhxbIwi1eiksCsZIU1mpPZlanXxGhVuQYhGGfPw AQMLdVOlb6RdL5Z5rzZFwvVC92r9fQ4T2QUDpwrFvPztT51XApO7mXvmB0l87d+Pe6xA4u jsV4yYT4Rqswxb/m00vChW72GczdaOXiGn7EEmwtlM7OU7BDLWQLGV+2oSeNqE3BpRHJ3e NKt7urVOFbMbPifTkWcIDcPcHWTFlLm4AEg/aoR/ZbHBRtTqdVCduQcb60iU1A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=eea4b5db7184f08b753009f246add9b5e7a8f253 commit eea4b5db7184f08b753009f246add9b5e7a8f253 Author: Dmitry Chagin AuthorDate: 2022-05-04 10:06:50 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:34:31 +0000 linux(4): Implement timerfd_settime64 syscall. MFC after: 2weeks (cherry picked from commit b1f0b08d932005a574411c829422e81223df14da) --- sys/amd64/linux32/linux32_dummy_machdep.c | 1 - sys/compat/linux/linux_event.c | 84 ++++++++++++++++++++++--------- sys/i386/linux/linux_dummy_machdep.c | 1 - 3 files changed, 60 insertions(+), 26 deletions(-) diff --git a/sys/amd64/linux32/linux32_dummy_machdep.c b/sys/amd64/linux32/linux32_dummy_machdep.c index 7dbc3352b07d..6b264e2891f1 100644 --- a/sys/amd64/linux32/linux32_dummy_machdep.c +++ b/sys/amd64/linux32/linux32_dummy_machdep.c @@ -69,7 +69,6 @@ DUMMY(arch_prctl); /* Linux 5.0: */ DUMMY(clock_adjtime64); DUMMY(timerfd_gettime64); -DUMMY(timerfd_settime64); DUMMY(io_pgetevents_time64); DUMMY(recvmmsg_time64); DUMMY(mq_timedsend_time64); diff --git a/sys/compat/linux/linux_event.c b/sys/compat/linux/linux_event.c index 7d4d3d678e26..f3191c910013 100644 --- a/sys/compat/linux/linux_event.c +++ b/sys/compat/linux/linux_event.c @@ -933,28 +933,20 @@ out: return (error); } -int -linux_timerfd_settime(struct thread *td, struct linux_timerfd_settime_args *args) +static int +linux_timerfd_settime_common(struct thread *td, int fd, int flags, + struct itimerspec *nts, struct itimerspec *oval) { - struct l_itimerspec lots; - struct itimerspec nts, ots; struct timespec cts, ts; struct timerfd *tfd; struct timeval tv; struct file *fp; int error; - if ((args->flags & ~LINUX_TFD_SETTIME_FLAGS) != 0) + if ((flags & ~LINUX_TFD_SETTIME_FLAGS) != 0) return (EINVAL); - error = copyin(args->new_value, &lots, sizeof(lots)); - if (error != 0) - return (error); - error = linux_to_native_itimerspec(&nts, &lots); - if (error != 0) - return (error); - - error = fget(td, args->fd, &cap_write_rights, &fp); + error = fget(td, fd, &cap_write_rights, &fp); if (error != 0) return (error); tfd = fp->f_data; @@ -964,17 +956,17 @@ linux_timerfd_settime(struct thread *td, struct linux_timerfd_settime_args *args } mtx_lock(&tfd->tfd_lock); - if (!timespecisset(&nts.it_value)) - timespecclear(&nts.it_interval); - if (args->old_value != NULL) - linux_timerfd_curval(tfd, &ots); + if (!timespecisset(&nts->it_value)) + timespecclear(&nts->it_interval); + if (oval != NULL) + linux_timerfd_curval(tfd, oval); - tfd->tfd_time = nts; + bcopy(nts, &tfd->tfd_time, sizeof(*nts)); tfd->tfd_count = 0; - if (timespecisset(&nts.it_value)) { + if (timespecisset(&nts->it_value)) { linux_timerfd_clocktime(tfd, &cts); - ts = nts.it_value; - if ((args->flags & LINUX_TFD_TIMER_ABSTIME) == 0) { + ts = nts->it_value; + if ((flags & LINUX_TFD_TIMER_ABSTIME) == 0) { timespecadd(&tfd->tfd_time.it_value, &cts, &tfd->tfd_time.it_value); } else { @@ -990,16 +982,60 @@ linux_timerfd_settime(struct thread *td, struct linux_timerfd_settime_args *args } mtx_unlock(&tfd->tfd_lock); - if (args->old_value != NULL) { +out: + fdrop(fp, td); + return (error); +} + +int +linux_timerfd_settime(struct thread *td, struct linux_timerfd_settime_args *args) +{ + struct l_itimerspec lots; + struct itimerspec nts, ots, *pots; + int error; + + error = copyin(args->new_value, &lots, sizeof(lots)); + if (error != 0) + return (error); + error = linux_to_native_itimerspec(&nts, &lots); + if (error != 0) + return (error); + pots = (args->old_value != NULL ? &ots : NULL); + error = linux_timerfd_settime_common(td, args->fd, args->flags, + &nts, pots); + if (error == 0 && args->old_value != NULL) { error = native_to_linux_itimerspec(&lots, &ots); if (error == 0) error = copyout(&lots, args->old_value, sizeof(lots)); } + return (error); +} -out: - fdrop(fp, td); +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +int +linux_timerfd_settime64(struct thread *td, struct linux_timerfd_settime64_args *args) +{ + struct l_itimerspec64 lots; + struct itimerspec nts, ots, *pots; + int error; + + error = copyin(args->new_value, &lots, sizeof(lots)); + if (error != 0) + return (error); + error = linux_to_native_itimerspec64(&nts, &lots); + if (error != 0) + return (error); + pots = (args->old_value != NULL ? &ots : NULL); + error = linux_timerfd_settime_common(td, args->fd, args->flags, + &nts, pots); + if (error == 0 && args->old_value != NULL) { + error = native_to_linux_itimerspec64(&lots, &ots); + if (error == 0) + error = copyout(&lots, args->old_value, sizeof(lots)); + } return (error); } +#endif static void linux_timerfd_expire(void *arg) diff --git a/sys/i386/linux/linux_dummy_machdep.c b/sys/i386/linux/linux_dummy_machdep.c index f4280da8df16..f5852e97ddae 100644 --- a/sys/i386/linux/linux_dummy_machdep.c +++ b/sys/i386/linux/linux_dummy_machdep.c @@ -71,7 +71,6 @@ DUMMY(arch_prctl); /* Linux 5.0: */ DUMMY(clock_adjtime64); DUMMY(timerfd_gettime64); -DUMMY(timerfd_settime64); DUMMY(io_pgetevents_time64); DUMMY(recvmmsg_time64); DUMMY(mq_timedsend_time64);