From nobody Fri Jun 17 19:39:59 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 09FB185C8E7; Fri, 17 Jun 2022 19:40:01 +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 4LPqBS2r7sz3hG6; Fri, 17 Jun 2022 19:39:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494800; 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=5gCJVkm9mbagI0jS70TeOBrd1erkkcvgWGOCpgeTMTk=; b=LZBu9+wkPf3ZldNvY5pdnz3Xvnqapo9Cg6eY+fNwtheCgQ6mlEnECUbyDNHIv2e7InkHrZ 5DGbAqbX6JqKbp7Zqx0BOmV+GlKqQ4So6B4okwB7OQX/ChZpl+RH25Wql9VgyJJuC5wwBX GfK1cfAG7Dnptpt/KGSOgHI9UF2Nywm4Mbfi0kp4pR+9z/TzkkgZhRIAs7WpaB6EEg5mYG E1z98n3t4+jvIWy+2bZxgl/rSVZTu6F4Gesk/BGfIhzK2k9CBC50u0VMjsixGLj9Pqg7Fb PVHZfK0tkFyOQRacosXv1t7i0zBxDWXWb+EWx0HKiXIy9rhQAzjsg+tjusCttw== 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 7F2C825D92; Fri, 17 Jun 2022 19:39:59 +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 25HJdxtC016767; Fri, 17 Jun 2022 19:39:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJdx2X016766; Fri, 17 Jun 2022 19:39:59 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:39:59 GMT Message-Id: <202206171939.25HJdx2X016766@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: 9fd86dde8377 - stable/13 - linux(4): Implement semtimedop syscalls. 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: 9fd86dde8377d11992924c74bf6dabb81081d0fc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494800; 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=5gCJVkm9mbagI0jS70TeOBrd1erkkcvgWGOCpgeTMTk=; b=EsJkJmVB6x4mjKat5pFTOBl1Oe65mwXqqoFHBxYcd0w/Hcm4bpE2LvMMVUKxny6CW6h64U su4XGhVuCWHoDIXOCU3oH1M6o+cqw1zm+QlilqSAfLglx958oi7LkYDNPA6ot7eiuLYinj U495CTfJ6xlUyiKdJoYyWXImGA6oVjKxRog1CIJR8hsmGITLR/nC5zjfjALk/GSUwLM6F1 1DnL7eg6xVeYXSf1yqxX4ZEF9k2CDTRzA6bWNxKZ4AkPhZSCcjyBldPKvbqx2xJCWigl30 0v0ldHwu42FOgAm2QuBOwDD4SQSlTOFIVCOSUu2rdIm1EJRUhv3YHJ5ImG11UA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494800; a=rsa-sha256; cv=none; b=dZg4zsLQuR9EkGAf7B3CrGBhr1RTpjPpEjmblJD9UhoGXgpsVgjR97xAUXDkLY+AI2LSJd ZHTIH4PzLtjRRAUqq4wXda2coYizwohTdGMndxqiWfpjSEJ7mwj5fusCGgoIZAmRzwraP9 WC/thrkk8RCGnWOpFwVNcXSOL9zYh9oh6vxH9Zt/IGTWzs6qCleBANJhWF050tCzuj+1Jo Aq0TYRpCDSqC0GGcL1QRi3nM1hEaG7kfR6i99hcq3UkkCrhmY5Ksj/SUjzYezSqwKMDaWA mnU9KMFNZC+ZUUOCCJRc8088cF6aQFmJ3AAh9+cj+0uI6rFNlIYjjNZcuYhH1Q== 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=9fd86dde8377d11992924c74bf6dabb81081d0fc commit 9fd86dde8377d11992924c74bf6dabb81081d0fc Author: Dmitry Chagin AuthorDate: 2022-05-06 17:02:59 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:34:53 +0000 linux(4): Implement semtimedop syscalls. On i386 are two semtimedop. The old one is called via multiplexor and uses 32-bit timespec, and new semtimedop_tim64, which is uses 64-bit timespec. MFC after: 2 weeks (cherry picked from commit 3245a2ecea21ace3d97cec1266fbe29c88ba1a59) --- sys/amd64/linux/linux_dummy_machdep.c | 1 - sys/amd64/linux32/linux32_dummy_machdep.c | 1 - sys/amd64/linux32/linux32_machdep.c | 9 +++++++ sys/arm64/linux/linux_dummy_machdep.c | 1 - sys/compat/linux/linux_ipc.c | 45 +++++++++++++++++++++++++++++++ sys/compat/linux/linux_ipc.h | 13 +++++++++ sys/i386/linux/linux_dummy_machdep.c | 1 - sys/i386/linux/linux_machdep.c | 9 +++++++ 8 files changed, 76 insertions(+), 4 deletions(-) diff --git a/sys/amd64/linux/linux_dummy_machdep.c b/sys/amd64/linux/linux_dummy_machdep.c index 4e4d0f9c0d8b..3ce407af291c 100644 --- a/sys/amd64/linux/linux_dummy_machdep.c +++ b/sys/amd64/linux/linux_dummy_machdep.c @@ -68,6 +68,5 @@ DUMMY(mq_notify); DUMMY(mq_getsetattr); DUMMY(readahead); DUMMY(restart_syscall); -DUMMY(semtimedop); /* Linux 3.15: */ DUMMY(kexec_file_load); diff --git a/sys/amd64/linux32/linux32_dummy_machdep.c b/sys/amd64/linux32/linux32_dummy_machdep.c index a5c61e252f9d..f3bd8717524a 100644 --- a/sys/amd64/linux32/linux32_dummy_machdep.c +++ b/sys/amd64/linux32/linux32_dummy_machdep.c @@ -71,4 +71,3 @@ DUMMY(clock_adjtime64); DUMMY(io_pgetevents_time64); DUMMY(mq_timedsend_time64); DUMMY(mq_timedreceive_time64); -DUMMY(semtimedop_time64); diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c index baa567339689..e1d7742d0a21 100644 --- a/sys/amd64/linux32/linux32_machdep.c +++ b/sys/amd64/linux32/linux32_machdep.c @@ -279,6 +279,15 @@ linux_ipc(struct thread *td, struct linux_ipc_args *args) return (error); return (linux_semctl(td, &a)); } + case LINUX_SEMTIMEDOP: { + struct linux_semtimedop_args a; + + a.semid = args->arg1; + a.tsops = PTRIN(args->ptr); + a.nsops = args->arg2; + a.timeout = PTRIN(args->arg5); + return (linux_semtimedop(td, &a)); + } case LINUX_MSGSND: { struct linux_msgsnd_args a; diff --git a/sys/arm64/linux/linux_dummy_machdep.c b/sys/arm64/linux/linux_dummy_machdep.c index 0b722c632709..22ad39a84eeb 100644 --- a/sys/arm64/linux/linux_dummy_machdep.c +++ b/sys/arm64/linux/linux_dummy_machdep.c @@ -59,5 +59,4 @@ DUMMY(mq_timedsend); DUMMY(mq_timedreceive); DUMMY(mq_notify); DUMMY(mq_getsetattr); -DUMMY(semtimedop); DUMMY(kexec_file_load); diff --git a/sys/compat/linux/linux_ipc.c b/sys/compat/linux/linux_ipc.c index 3e810c303a2c..51bf18dcd097 100644 --- a/sys/compat/linux/linux_ipc.c +++ b/sys/compat/linux/linux_ipc.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #endif #include #include +#include #include /* @@ -504,6 +505,50 @@ linux_shminfo_pushdown(l_int ver, struct l_shminfo64 *linux_shminfo64, } } +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +int +linux_semtimedop_time64(struct thread *td, struct linux_semtimedop_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 (kern_semop(td, args->semid, PTRIN(args->tsops), + args->nsops, tsa)); +} +#endif /* __i386__) || (__amd64__ && COMPAT_LINUX32) */ + +int +linux_semtimedop(struct thread *td, struct linux_semtimedop_args *args) +{ + struct timespec ts, *tsa; + struct l_timespec lts; + int error; + + if (args->timeout) { + if ((error = copyin(args->timeout, <s, sizeof(lts)))) + return (error); + error = linux_to_native_timespec(&ts, <s); + if (error != 0) + return (error); + tsa = &ts; + } else + tsa = NULL; + + return (kern_semop(td, args->semid, PTRIN(args->tsops), + args->nsops, tsa)); +} + int linux_semget(struct thread *td, struct linux_semget_args *args) { diff --git a/sys/compat/linux/linux_ipc.h b/sys/compat/linux/linux_ipc.h index beef18a09507..a148814b8273 100644 --- a/sys/compat/linux/linux_ipc.h +++ b/sys/compat/linux/linux_ipc.h @@ -37,6 +37,7 @@ #define LINUX_SEMOP 1 #define LINUX_SEMGET 2 #define LINUX_SEMCTL 3 +#define LINUX_SEMTIMEDOP 4 #define LINUX_MSGSND 11 #define LINUX_MSGRCV 12 #define LINUX_MSGGET 13 @@ -82,4 +83,16 @@ #define LINUX_IPC_64 0x0100 /* New version (support 32-bit UIDs, bigger message sizes, etc. */ +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +struct linux_semtimedop_args +{ + l_int semid; + struct sembuf *tsops; + l_uint nsops; + struct l_timespec *timeout; +}; + +int linux_semtimedop(struct thread *, struct linux_semtimedop_args *); +#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ + #endif /* _LINUX_IPC_H_ */ diff --git a/sys/i386/linux/linux_dummy_machdep.c b/sys/i386/linux/linux_dummy_machdep.c index dd89444537d0..0e41a4b3fc56 100644 --- a/sys/i386/linux/linux_dummy_machdep.c +++ b/sys/i386/linux/linux_dummy_machdep.c @@ -73,4 +73,3 @@ DUMMY(clock_adjtime64); DUMMY(io_pgetevents_time64); DUMMY(mq_timedsend_time64); DUMMY(mq_timedreceive_time64); -DUMMY(semtimedop_time64); diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c index 09d4eb42c772..1e665eb9f505 100644 --- a/sys/i386/linux/linux_machdep.c +++ b/sys/i386/linux/linux_machdep.c @@ -154,6 +154,15 @@ linux_ipc(struct thread *td, struct linux_ipc_args *args) return (error); return (linux_semctl(td, &a)); } + case LINUX_SEMTIMEDOP: { + struct linux_semtimedop_args a; + + a.semid = args->arg1; + a.tsops = PTRIN(args->ptr); + a.nsops = args->arg2; + a.timeout = PTRIN(args->arg5); + return (linux_semtimedop(td, &a)); + } case LINUX_MSGSND: { struct linux_msgsnd_args a;