From nobody Tue Nov 11 17:34:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=1564405942; cv=none; d=zoho.com; s=zohoarc; b=lPO4H1/G9w7oDDtX8N46ifhI1uJ+Iqsmx8Grsbd+fLAagbZXzxkfVGb78wZoMHFMP7COHN79knDQD2DRkUfqn/WwmOHy48awoivn3j2ZxHhZotIItB+RoSiEV9MV8bqhzt7MKxz31p2Ii5y+CyXYYYx1+y5rM49FpWawsR7KXPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564405942; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=KrL1OWm8Crc2oacE9KjnY506mBLWpQ81sx5wzBi/HY0=; b=DDeQ+f359S0xKmTNT0DMSMV9CeIhEYVOj5cRNhT5fNUrUhIiB1yX+0pAoTUP6SvcRlV1RFfltuzcvD/Hk1BWN7w963cBL6aR81ieVSVTB6lzXYySAdE865fkTs5cq+gdF+x4JK4oI7AzMP0K1TTCTlcZM/ultwOPDiVg4w9Gnt4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1564405942698633.6198886752098; Mon, 29 Jul 2019 06:12:22 -0700 (PDT) Received: from localhost ([::1]:52048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hs5Rt-0004mW-Om for importer@patchew.org; Mon, 29 Jul 2019 09:12:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40755) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hs5Qm-0003Ac-Lr for qemu-devel@nongnu.org; Mon, 29 Jul 2019 09:11:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hs5Ql-0003JZ-Dh for qemu-devel@nongnu.org; Mon, 29 Jul 2019 09:11:12 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:51405 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hs5Ql-0003HZ-7c for qemu-devel@nongnu.org; Mon, 29 Jul 2019 09:11:11 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 14D801A21DD; Mon, 29 Jul 2019 15:10:19 +0200 (CEST) Received: from rtrkw774-lin.domain.local (rtrkw774-lin.domain.local [10.10.13.43]) by mail.rt-rk.com (Postfix) with ESMTPSA id F0D531A20A2; Mon, 29 Jul 2019 15:10:18 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Aleksandar Markovic To: qemu-devel@nongnu.org Date: Mon, 29 Jul 2019 15:09:51 +0200 Message-Id: <1564405791-9147-8-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1564405791-9147-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1564405791-9147-1-git-send-email-aleksandar.markovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH for 4.1 v2 7/7] linux-user: Add support for semtimedop() syscall 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: Aleksandar Rikalo , laurent@vivier.eu, amarkovic@wavecomp.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Aleksandar Rikalo Add support for semtimedop() emulation. It is based on invocation of safe_semtimedop(). Conversion is left out of safe_semtimedop(), since other safe_xxx() usually don't contain similar conversions. Signed-off-by: Aleksandar Rikalo Signed-off-by: Aleksandar Markovic --- linux-user/syscall.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ee80175..c7b08f5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6650,7 +6650,39 @@ static inline abi_long host_to_target_statx(struct t= arget_statx *host_stx, return 0; } #endif +#ifdef TARGET_NR_semtimedop +static inline abi_long do_semtimedop(int semid, abi_long ptr, unsigned nso= ps, + abi_long timeout) +{ + struct sembuf *sops; + struct timespec ts, *pts; + abi_long ret; + + if (timeout) { + pts =3D &ts; + if (target_to_host_timespec(pts, timeout)) { + return -TARGET_EFAULT; + } + } else { + pts =3D NULL; + } =20 + sops =3D g_malloc(sizeof(struct sembuf) * nsops); + if (sops =3D=3D NULL) { + return -TARGET_EFAULT; + } + + if (target_to_host_sembuf(sops, ptr, nsops)) { + g_free(sops); + return -TARGET_EFAULT; + } + + ret =3D get_errno(safe_semtimedop(semid, sops, nsops, pts)); + g_free(sops); + + return ret; +} +#endif =20 /* ??? Using host futex calls even when target atomic operations are not really atomic probably breaks things. However implementing @@ -9194,6 +9226,10 @@ static abi_long do_syscall1(void *cpu_env, int num, = abi_long arg1, case TARGET_NR_semop: return do_semop(arg1, arg2, arg3); #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: return do_semctl(arg1, arg2, arg3, arg4); --=20 2.7.4