From nobody Sat May 18 12:12:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594634791; cv=none; d=zohomail.com; s=zohoarc; b=MSO//2XP1g3J1gqzDjRh3iaQFvnCwglDh9LvhMNT6U4tSBUj6QWx5Fap/2+aB7OSZw3p/274ilQPIDyXtvBLIvvbuYWmaM5/ul7DKudt98vyrE37horAG4tcdmPBV0oszLb1daKr+EY9y7KAyMJKhHE48Gm6RbHyNXgtmHWeW7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594634791; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=uTmYnnLF/y2s932MALDb5ALA0A26XUAgx7jlCs7PxRQ=; b=IWp+/WpAwUtpC+RWvTPYy20qWNroATApMvh8urE6+beqj0wztNj93Nl2TMHu+/lAklYQjgB34YVe84Et1UIGZSnUMuWk757Hp34ncGiB23VUsczNd8i8rTcGED8uoIkfUC/SaRstJw09Wol4gsIm6PKlP2Pp/h6K9ZZEMvtP7uc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594634791842977.4407740555313; Mon, 13 Jul 2020 03:06:31 -0700 (PDT) Received: from localhost ([::1]:53172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1juvLy-0003Rh-CB for importer@patchew.org; Mon, 13 Jul 2020 06:06:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1juvL5-0002Ze-HG for qemu-devel@nongnu.org; Mon, 13 Jul 2020 06:05:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:52748) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1juvL3-00048C-Te for qemu-devel@nongnu.org; Mon, 13 Jul 2020 06:05:35 -0400 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A1A3DB0B6; Mon, 13 Jul 2020 10:05:34 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Andreas Schwab To: Laurent Vivier Subject: [PATCH] linux-user: implement the semtimedop syscall X-Yow: .. the MYSTERIANS are in here with my CORDUROY SOAP DISH!! Date: Mon, 13 Jul 2020 12:05:32 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux) MIME-Version: 1.0 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.15; envelope-from=schwab@suse.de; helo=mx2.suse.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/13 00:02:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x (no timestamps) [generic] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Andreas Schwab --- linux-user/syscall.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9ec03a889d..7c0f5b83ff 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3877,23 +3877,37 @@ static inline abi_long target_to_host_sembuf(struct= sembuf *host_sembuf, return 0; } =20 -static inline abi_long do_semop(int semid, abi_long ptr, unsigned nsops) +static inline abi_long do_semtimedop(int semid, abi_long ptr, unsigned nso= ps, + abi_long timeout) { struct sembuf sops[nsops]; + struct timespec ts, *pts; abi_long ret; =20 if (target_to_host_sembuf(sops, ptr, nsops)) return -TARGET_EFAULT; =20 + if (timeout) { + pts =3D &ts; + if (target_to_host_timespec(pts, timeout)) { + return -TARGET_EFAULT; + } + } else { + pts =3D NULL; + } + ret =3D -TARGET_ENOSYS; #ifdef __NR_semtimedop - ret =3D get_errno(safe_semtimedop(semid, sops, nsops, NULL)); + ret =3D get_errno(safe_semtimedop(semid, sops, nsops, pts)); #endif #ifdef __NR_ipc if (ret =3D=3D -TARGET_ENOSYS) { - ret =3D get_errno(safe_ipc(IPCOP_semtimedop, semid, nsops, 0, sops= , 0)); + ret =3D get_errno(safe_ipc(IPCOP_semtimedop, semid, nsops, 0, sops= , pts)); } #endif + if (!is_error(ret) && timeout) { + ret =3D host_to_target_timespec(timeout, pts); + } return ret; } =20 @@ -4371,7 +4385,11 @@ static abi_long do_ipc(CPUArchState *cpu_env, =20 switch (call) { case IPCOP_semop: - ret =3D do_semop(first, ptr, second); + ret =3D do_semtimedop(first, ptr, second, 0); + break; + + case IPCOP_semtimedop: + ret =3D do_semtimedop(first, ptr, second, third); break; =20 case IPCOP_semget: @@ -9683,7 +9701,11 @@ static abi_long do_syscall1(void *cpu_env, int num, = abi_long arg1, #endif #ifdef TARGET_NR_semop case TARGET_NR_semop: - return do_semop(arg1, arg2, arg3); + return do_semtimedop(arg1, arg2, arg3, 0); +#endif +#ifdef TARGET_NR_semtimedop + case TARGET_NR_semtimedop: + return do_semtimedop(arg1, arg2, arg3, arg4); #endif #ifdef TARGET_NR_semctl case TARGET_NR_semctl: --=20 2.26.2 --=20 Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint =3D 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."