From nobody Fri May 06 17:03:40 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 60DD11A82935; Fri, 6 May 2022 17:03:42 +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 4KvxjT0dzqz4TNF; Fri, 6 May 2022 17:03:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651856621; 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=XqpIUnxPo0gVhBzjswsDeHHwvXNXqCK3lqCw1xm95No=; b=omK+G+4Y3NnzYs59Ux8HTlsKrrRLNmD+pNZXbAmB8fjRdKNOX3H/BLxblh6Hd2fXZUw3nk iEtWYKj0lOvije1+5ft4mSfmOF3HgZHfyLd/6+7vS5G5SGROnDtdcGImR/mepwmNBaYE34 UVWdwgTUIigdEG9/vtv4mt0A+Pq4txd5m1Wvdx789anWYiDQyjexk43UCUAf3oIV96KIes b/4L8LGSY0vcvQiyHVwqf/oY56k50gbFMqsNKKKgjnobMPx5L++gNWA1OxSvRI45CuWW4J IIgpBrjSb4goLN8pGotpl/xsdMPJ2HHezF4MeqnzjdiU4M5GLxoehCq3NCy7NQ== 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 E9AEC1F946; Fri, 6 May 2022 17:03:40 +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 246H3eIZ058994; Fri, 6 May 2022 17:03:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 246H3e0J058993; Fri, 6 May 2022 17:03:40 GMT (envelope-from git) Date: Fri, 6 May 2022 17:03:40 GMT Message-Id: <202205061703.246H3e0J058993@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: 3245a2ecea21 - main - linux(4): Implement semtimedop syscalls. 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: 3245a2ecea21ace3d97cec1266fbe29c88ba1a59 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651856621; 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=XqpIUnxPo0gVhBzjswsDeHHwvXNXqCK3lqCw1xm95No=; b=vJ+b4H1/V6Q+IHgsnD9iZ7e6Ua77L/dOiZ5V9ZAyQfBJqqVdykKA061UxHjWyy5qkN86QA 7EjyHDMRpIgEEUbyC6lVMnE1kWPZPHdXHvdkDlhnPNB/+HMjU5KxJhpKyMoI3GUUYYw2p3 dX7U4TGL9GlQjmldt3YRzTSVgPupDmc+ZuA6f2SQHOPAYTrEibkdgvTkICBm1H7Uz5q6Nv UiUVobkKRwjhEvK4yG9Em8vDfyKj4p+Q7wR37Jqdb5E2khHe2Sv0CYwVnSqWuqcPYuDTH1 R3ArilD7937lVif+GfXravtKjDdp7GBOMkPve9pkizv7klhHdjjzAQr6eV8Bbw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651856621; a=rsa-sha256; cv=none; b=O7z18Ri2uxZdl5frPhPDiaW8tkR67vA4MsbGwpG1dbalZEymRWsZpiLeDCMi5fXzvqFc9K JLaC7JV/zHVCGd8S0UZd48c6ZB4yHVVP8f1dcpG41PjH+CtVfwOeo/Mq29vGwO1JzSXyVO +VQ9eI1KYOrSiR+XJ561+ifcApb3kPuAQQ36Hv9TyVLN2Z6M+fGdqNyN7t8kKaRTv81uUH TgUFhcwkv2XEU458qdoC9RXCpfzv//qZRSOiH3JXEmz/42DIu3DvqF+efb7+vwjdlEgIyB 2SZWIWhtocs5W+ur5uyo17+SuP9fkSv/S3Rb96GqznUgFKC5Pqu29mtuWpdHtw== 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=3245a2ecea21ace3d97cec1266fbe29c88ba1a59 commit 3245a2ecea21ace3d97cec1266fbe29c88ba1a59 Author: Dmitry Chagin AuthorDate: 2022-05-06 17:02:59 +0000 Commit: Dmitry Chagin CommitDate: 2022-05-06 17:02:59 +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 --- 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;