From nobody Wed May 4 10:08:16 2022 X-Original-To: dev-commits-src-main@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 E94571AAAACC; Wed, 4 May 2022 10:08:16 +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 4KtXb463Blz4dY2; Wed, 4 May 2022 10:08:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651658896; 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=0qBb2qrAMLAPFxEDnVAF5qu0CoU/JrxjNLHPTVaOBbo=; b=is8znWndAk5hOilnqqUZZMvRZRvQx6UxwArDjBFvj0thDTrRSdn/7TEpj/0f5bICSFko8q iRevSYidNdm8XvgD5StAl5HFlI0cLy53Q/1OY4mXtVxNjdBtb+Hnqo6mZDbxAmFsFKzG7m IEyo3e7qTsuPxUzUMqujgg722E9P/hvbczqv2D4LgJfuQgOVBGwlm6boKcLJI1k1OAu/kX 60XV2Vfs/nNNtQSq9yFHq5wocDTpnvSTLtnGJUryjPRmGuQNlR4fbd3XST6v+jL+0GgftH HwfaN9gMbR2ikMZ0Ymu7ZQLpBnarFLIJU+mbgaTuagfasaeSJ81h3dfh+wZIeA== 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 A4DCE110E6; Wed, 4 May 2022 10:08:16 +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 244A8Gno000516; Wed, 4 May 2022 10:08:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 244A8G9c000515; Wed, 4 May 2022 10:08:16 GMT (envelope-from git) Date: Wed, 4 May 2022 10:08:16 GMT Message-Id: <202205041008.244A8G9c000515@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: b1f0b08d9320 - main - linux(4): Implement timerfd_settime64 syscall. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: b1f0b08d932005a574411c829422e81223df14da Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651658896; 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=0qBb2qrAMLAPFxEDnVAF5qu0CoU/JrxjNLHPTVaOBbo=; b=j6pg7A75Y9vP+hQrqAFtrkbY01TmMhjqiMUUldHaiGB9Iie4LUghI5+yAyR720V6YXG/mU V7eYHWrn/qteRoSnYQ8Uyp9D4XxOmuCR2yqWKCfB+s5UHAOuWMSUDg0Uq/oM0rY9N7IEYu inmv0RyDYZzJdZjpW1lSUUg93f2jXcEeCwGWGxBKJTc0XE/I1Ajqp+B5tRwBCGClLo3ud8 5VBDtftV/Hp13cubHyjF9f5RbMRoaOQsTGr/9eYaXroG3EEs8sbKkQ8H4zWIj0U4/YKRE5 NkACX7y6mh93ZYqg784sRjT2nxfjViFQmAulDdqydm2wpfYuufFbbNzXMHwi/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651658896; a=rsa-sha256; cv=none; b=O9HNxqsx3cemKOZ/feWXbpnaMUv49YaBMeTWKYlJso04bAbqGdmTPSSDUxBMt1bMYcJwrE nL+y7sJlSBlAh4YZtT3WAA8I8WoDfqpFymiwzwKdFWH8MYtna1FlGluox17JhvMD+12amY 5FY6gZ/Zi0aHcflQnJwkF9DSyBy9LCLXadIsiBxUy1cqvVWC+6xwMci3LZwcxD6gQbZJmx BEX8U0G9H7qcMOGpsQiJXLVOQT6ZScwPWXbAW6/7kZ14aIM+TZ405MaO9z4U3gjJsrjuIg B58hzQLSTZ7Vq0ddNI8rMslohmwKcL7yBtkdY7Ty3AC3yePclw5Xpzr73tQhbw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=b1f0b08d932005a574411c829422e81223df14da commit b1f0b08d932005a574411c829422e81223df14da Author: Dmitry Chagin AuthorDate: 2022-05-04 10:06:50 +0000 Commit: Dmitry Chagin CommitDate: 2022-05-04 10:06:50 +0000 linux(4): Implement timerfd_settime64 syscall. MFC after: 2weeks --- 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 08d52cd10fc3..09c6391f88d2 100644 --- a/sys/compat/linux/linux_event.c +++ b/sys/compat/linux/linux_event.c @@ -932,28 +932,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; @@ -963,17 +955,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 { @@ -989,16 +981,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);