From nobody Fri Nov 14 17:01:13 2025 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=1589269666; cv=none; d=zohomail.com; s=zohoarc; b=Td1LTHGKQePZXQYlt5cIL0+NjvvZEpcrfK/nNqzBDk+nk/WivGfAtGnxmkida3CBjw+hVT4clodDoDnzQ6e3FCkvQhDN6BrFdF5lJnj6yxz2F1+PyAgIL4KyItpltYnFkjU74HKDMAL2tLaSfjVdZvMDuP/ZbO3EgqLqtK29o8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589269666; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject; bh=U3XSf/jZvS6WVaHR2ZCS9gfZnldxMqJtOl5qepxmplg=; b=V0QWdURHgyVWwk26IG7yC0aUxPZrHrQLxZasZ3G0qaad5F1l+dkEqJ6sIx5FS+GW9xW8n/4lnzei4FbsaWts2IAS41LWgSwoz9LEnYM7AkPF+iSDlmqMdrfiJqBbEbQdOK9zblTs3lkhPDCjQnAl83+4jTko0yUcvXFPIHd7NQA= 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 1589269666602834.6936096288155; Tue, 12 May 2020 00:47:46 -0700 (PDT) Received: from localhost ([::1]:33134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYPdh-0007xU-45 for importer@patchew.org; Tue, 12 May 2020 03:47:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYPct-0007Ye-DO for qemu-devel@nongnu.org; Tue, 12 May 2020 03:46:55 -0400 Received: from mx1.tachyum.com ([66.160.133.170]:55333 helo=mail.tachyum.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYPcs-0002kL-II for qemu-devel@nongnu.org; Tue, 12 May 2020 03:46:55 -0400 Received: by mail.tachyum.com (Postfix, from userid 1001) id ADA9162C; Mon, 11 May 2020 16:46:55 -0700 (PDT) Received: from tsk-dev-swd001.tachyum.sk (unknown [93.184.71.90]) by mail.tachyum.com (Postfix) with ESMTP id B6009103; Mon, 11 May 2020 16:46:51 -0700 (PDT) From: Matus Kysel To: Subject: [PATCH v2] linux-user: support of semtimedop syscall Date: Tue, 12 May 2020 09:45:10 +0200 Message-Id: <20200512074510.40215-1-mkysel@tachyum.com> X-Mailer: git-send-email 2.17.1 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=66.160.133.170; envelope-from=mkysel@tachyum.com; helo=mail.tachyum.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/12 03:46:53 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: "open list:All patches CC here" , Riku Voipio , Laurent Vivier , Matus Kysel 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" We should add support of semtimedop syscall as new version of glibc 2.31 uses semop based on semtimedop (commit: https://gitlab.com/freed= esktop-sdk/mirrors/sourceware/glibc/-/commit/765cdd0bffd77960ae852104fc4ea5= edcdb8aed3 ). Signed-off-by: Matus Kysel Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 05f03919ff..7c6f9439e0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1227,7 +1227,8 @@ static inline abi_long copy_to_user_timeval64(abi_ulo= ng target_tv_addr, defined(TARGET_NR_pselect6) || defined(TARGET_NR_pselect6) || \ defined(TARGET_NR_nanosleep) || defined(TARGET_NR_clock_settime) || \ defined(TARGET_NR_utimensat) || defined(TARGET_NR_mq_timedsend) || \ - defined(TARGET_NR_mq_timedreceive) + defined(TARGET_NR_mq_timedreceive) || defined(TARGET_NR_ipc) || \ + defined(TARGET_NR_semop) || defined(TARGET_NR_semtimedop) static inline abi_long target_to_host_timespec(struct timespec *host_ts, abi_ulong target_addr) { @@ -3875,25 +3876,39 @@ static inline abi_long target_to_host_sembuf(struct= sembuf *host_sembuf, return 0; } -static inline abi_long do_semop(int semid, abi_long ptr, unsigned nsops) +#if defined(TARGET_NR_ipc) || defined(TARGET_NR_semop) || \ + defined(TARGET_NR_semtimedop) +static inline abi_long do_semtimedop(int semid, + abi_long ptr, + unsigned nsops, + abi_long timeout) { struct sembuf sops[nsops]; + struct timespec ts, *pts =3D NULL; abi_long ret; + if (timeout) { + pts =3D &ts; + if (target_to_host_timespec(pts, timeout)) { + return -TARGET_EFAULT; + } + } + if (target_to_host_sembuf(sops, ptr, nsops)) return -TARGET_EFAULT; 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 return ret; } +#endif struct target_msqid_ds { @@ -4369,7 +4384,10 @@ static abi_long do_ipc(CPUArchState *cpu_env, 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; case IPCOP_semget: @@ -9594,7 +9612,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: -- 2.17.1