From patchwork Wed Sep 28 20:27:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 610094 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp501416pvb; Wed, 28 Sep 2022 13:54:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5xWxLPWoVKwXmXT5lSuAZ77JQlxfhfSyPpGYgBqjatBQp6iBkbFqYa0WN7JgBbp6j0K5aL X-Received: by 2002:a05:6214:2306:b0:473:f77a:85a7 with SMTP id gc6-20020a056214230600b00473f77a85a7mr26891092qvb.106.1664398454042; Wed, 28 Sep 2022 13:54:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664398454; cv=none; d=google.com; s=arc-20160816; b=0weeuvKTWB49GFBj6llLzOFzHVbsKtR15URw2GN/DuXxfmbmbPld3AQPvRiwxrFyYW P1ttrFD5ySXlO2O+pfVT7lcyR2P0gCGnmXwUApkItErgVJgrmJaXm7+j+7oSQRnHPrhw JFV6V9UC0Hbt+iHNjGEKWSgf4NNz7MOXu82ch1H4bSbyixdW1/8zp6zkDDpFRA+JJOxW RLb0bFwrFmSuRbtb+BEQcmHpLebMUZ2YevHGI+E1SftuKFFD0d+JoUM+Y57VacIvyWO5 Oxt9LMVBkYRdGyOwxKr1ulKmARPYaFLLDl555WfbUxSd5TaVg0AIvTJdN1DNPVJzXC1H xjRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=aVH6XgoRnj/lxNtTeBLZH7eFffPHtTxEsiDca0jShPg=; b=JQr8hLwpMWUlm0C4PDpuhzAXH7qdHzDkJNSMgMP+t5DIkqXqQ1ZcuYCzLxfxYHRUQ6 WJgsZjjhvIaBZpYdkJHsA6sIF4dk8yt4jqLiJ/aXGO7+QYC58AyCYh8mxGjGD+4Fs8C0 5znHAN5ja9JCKhxiOdC0EBP2AWi672tsyYXSQefdJtQFAz17+n4dUpN4w+8JHeXB/NKv mQ40QITexX0fewnAhVb2Czc+GSEvHnobm21mbm3wNKgXPV2woI0Zuo5OumAGLb4R+6ni HEYk3d8isQN9j7pdENuL+Sawer05x2NfIKvoYo8Sp+sebQc0QZ2VngY9YnPhLLhElp7u wZIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r10-20020a056214212a00b004ad7b54e002si3823000qvc.102.2022.09.28.13.54.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Sep 2022 13:54:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:40446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ode4L-0005hi-IY for patch@linaro.org; Wed, 28 Sep 2022 16:54:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf1-0000Qo-BA for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:03 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:60277) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddez-0006WM-Ip for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:03 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M7am5-1oacSJ2MzF-0085OZ; Wed, 28 Sep 2022 22:27:58 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Peter Maydell , Jon Alduan , Laurent Vivier Subject: [PULL 26/37] linux-user: Don't assume 0 is not a valid host timer_t value Date: Wed, 28 Sep 2022 22:27:26 +0200 Message-Id: <20220928202737.793171-27-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928202737.793171-1-laurent@vivier.eu> References: <20220928202737.793171-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:d0MrNzFRlhOdVfypNKkFitcF4YU1Y03IDUrK9VzxoFo39+aDiGu h35Mmo6dx8QqbtVPyGbkbM76Q75e6bD9xi7GmtO9YCSsKVlIVnmKGuCzrtKW7IU11lM9eGP RNIe+FyeZGXmu1qOMgHMjmlgcLNDlxDfPIvWVlVsdEFSRQAN+4h3JS7Yair452Vei+mnJAh pi17WHv70hKoFc7IBHX2A== X-UI-Out-Filterresults: notjunk:1;V03:K0:YAvLgBDKtRQ=:trvDAzaxeCI0LIO3SJy/1Z 5ch1fNVpADcikPEZT6kUkcTPXyY8j2u09QG4Z7viC+p9Jgm119xEzKj2fG8KY5Ld5SbIaotk0 tRdZOPfZRC01IAOu425BQzWnO+clO1eHFdgGpsbkML8ZR59iQSdXWwg40QQEbeC91OsMwgM0g c31MNhJJENIdo42OnHnzXYud1arrJJZTe51j4HLycWveIAZOp62AY3B8xzvjHuEjpfLJY1Ma4 sy33XYszirkbPPW7DN7Dt3zCn2/XFtun4yVqOG8qk9l2BegpS/YYzB/3Vn+hubCKT12/ull8x qYK4Sdx7fK4YhmeFW1k2f9rU1NP2sVkaen+iL5AcsEL+9v3D0A3WpSOGHc6z+jDnddxEG+giK 1uSZlzgXvqEqtBZeoXm+kgzHEcJ6j7/AHeRLDKSlCQ6NiDW8m9jxvGFTlPuZ3zMfT0LoYORsD K9p5JvlsmsNZgjZTic9ceqPkKvfF4610+WPjWJpBvI9mh6b3MRpXJ/F9fYcCGFvApGy6QbJuD CtHjMsXXxc0cKw1U76eWp38mgnNnWpCtv56jiDDckYkdeOkPYZvavI4O8qtlMt5gj3mlENxAQ +g+XgJnaf86OmEuwCZyqab7pQrTBQYF3XAQ30OOQIrD5atqoA2+HexKmKktALpMOc1+n+Gy0Q xD85Gj3RL7bNnkLQ39rnyHqbOmBEDhLybjTmDlZGfFRnZXcO5GxR81nOSr/9/RknTOGkndpWj e/6gWJ5GcF80nSUwUtZtTRK4kBjqRuY8G/TJiY91kojLl0i5rWba5/x5TAhoQxGVYwdI59SDK pyRMZMH Received-SPF: none client-ip=212.227.126.131; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell For handling guest POSIX timers, we currently use an array g_posix_timers[], whose entries are a host timer_t value, or 0 for "this slot is unused". When the guest calls the timer_create syscall we look through the array for a slot containing 0, and use that for the new timer. This scheme assumes that host timer_t values can never be zero. This is unfortunately not a valid assumption -- for some host libc versions, timer_t values are simply indexes starting at 0. When using this kind of host libc, the effect is that the first and second timers end up sharing a slot, and so when the guest tries to operate on the first timer it changes the second timer instead. Rework the timer allocation code, so that: * the 'slot in use' indication uses a separate array from the host timer_t array * we grab the free slot atomically, to avoid races when multiple threads call timer_create simultaneously * releasing an allocated slot is abstracted out into a new free_host_timer_slot() function called in the correct places This fixes: * problems on hosts where timer_t 0 is valid * the FIXME in next_free_host_timer() about locking * bugs in the error paths in timer_create where we forgot to release the slot we grabbed, or forgot to free the host timer Reported-by: Jon Alduan Signed-off-by: Peter Maydell Message-Id: <20220725110035.1273441-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 54b29f3b406a..e0e0f058121f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -525,20 +525,25 @@ _syscall4(int, sys_prlimit64, pid_t, pid, int, resource, #if defined(TARGET_NR_timer_create) /* Maximum of 32 active POSIX timers allowed at any one time. */ -static timer_t g_posix_timers[32] = { 0, } ; +#define GUEST_TIMER_MAX 32 +static timer_t g_posix_timers[GUEST_TIMER_MAX]; +static int g_posix_timer_allocated[GUEST_TIMER_MAX]; static inline int next_free_host_timer(void) { - int k ; - /* FIXME: Does finding the next free slot require a lock? */ - for (k = 0; k < ARRAY_SIZE(g_posix_timers); k++) { - if (g_posix_timers[k] == 0) { - g_posix_timers[k] = (timer_t) 1; + int k; + for (k = 0; k < ARRAY_SIZE(g_posix_timer_allocated); k++) { + if (qatomic_xchg(g_posix_timer_allocated + k, 1) == 0) { return k; } } return -1; } + +static inline void free_host_timer_slot(int id) +{ + qatomic_store_release(g_posix_timer_allocated + id, 0); +} #endif static inline int host_to_target_errno(int host_errno) @@ -12896,15 +12901,18 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, phost_sevp = &host_sevp; ret = target_to_host_sigevent(phost_sevp, arg2); if (ret != 0) { + free_host_timer_slot(timer_index); return ret; } } ret = get_errno(timer_create(clkid, phost_sevp, phtimer)); if (ret) { - phtimer = NULL; + free_host_timer_slot(timer_index); } else { if (put_user(TIMER_MAGIC | timer_index, arg3, target_timer_t)) { + timer_delete(*phtimer); + free_host_timer_slot(timer_index); return -TARGET_EFAULT; } } @@ -13040,7 +13048,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, } else { timer_t htimer = g_posix_timers[timerid]; ret = get_errno(timer_delete(htimer)); - g_posix_timers[timerid] = 0; + free_host_timer_slot(timerid); } return ret; } From patchwork Wed Sep 28 20:27:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 610098 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp508086pvb; Wed, 28 Sep 2022 14:08:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7UM6lqOpRnwJQF/pDYlDhkn0tfjY7G9zs7uDSRwZDZkw1xlNKu+mwia/5mvsARqIEti0g6 X-Received: by 2002:a37:e116:0:b0:6cf:4dbd:18f1 with SMTP id c22-20020a37e116000000b006cf4dbd18f1mr28547qkm.120.1664399287125; Wed, 28 Sep 2022 14:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664399287; cv=none; d=google.com; s=arc-20160816; b=fjLSByKqW28zICy+VI3IFncRrbMKBprZLcd6iunh1BsugXTCS9A6r8tV2/+tSlspaf rD9FrNDy8dL2zj6wl5/QvvKxQBs973TCpo59gjX9K3f+vY/jzDh0x4YhVi1plGofEILd opFjgKzHhRJ38TRzgRDrhJyI1/TDDNtbUjk2H8+SqBD6EsPaHeOk4nwgcD640is6Aef8 fY2cvN0qSInuuUJsGzLiApB8AlxXve0fHflsRI1+bMHVGNtJYFhX370Atc0GpEhOs35g 37+I4btDn7mVrx5bSt/mBdW+/3v95K1F/i2UdLAqJv5bndmA4XjA5WrtqJHAMHZqGxgl nqkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=6wnqkVmwXtbq0Y1JFwFpZSePdxl9eCRyQLBvrmXyKyU=; b=zt3dZJ72fmqLW5LcLqDYxSabGYq2WGFRq+lNOxPVyjhEoNoQF+D62W0drG9j5nvclM 0SDwWyHXJwUnY2lFOqeoCXENTglL7fkAec/ghMtyIANFru/B+df04UvUUw+BIncLRMVI XkceSnawRpmAH+5AiQxIeHWNoByl6AFnk2RCgl566zqySSy4qHktXHy3wQpRIxTeADlc dJQDIFWLZJ6kaIOoy+CaVQXfl5lANpdWfxBs39ePsvexRq3ZU4/xcNRLoqZFlC4/s1Qk A9wIC1CVEiliYeCAAorFlkwVjXRJa1sCigtox6tIkvl1fwlproy58jB0yp/oE+tOHS4g NWEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y23-20020a37f617000000b006b5db917713si160096qkj.664.2022.09.28.14.08.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Sep 2022 14:08:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:35786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odeHm-0000uQ-L6 for patch@linaro.org; Wed, 28 Sep 2022 17:08:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf3-0000XW-3l for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:05 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:37061) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf1-0006XU-Bi for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:04 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MYvse-1oi5cv1L4i-00Unr0; Wed, 28 Sep 2022 22:28:01 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 30/37] linux-user: Combine do_futex and do_futex_time64 Date: Wed, 28 Sep 2022 22:27:30 +0200 Message-Id: <20220928202737.793171-31-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928202737.793171-1-laurent@vivier.eu> References: <20220928202737.793171-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:JzmsyS0Y7f03zx4SXYAFTBAFPn3GbPokU4K6X5Rhijd2sQXthY2 JPo3VSh+bzfg/QHrtxTJWqNxrvKqR39KRowWuFywsEpVRqR84HI8of2nFnsVuy3I5Zh7RNB 9pfKOuOTUyvbrmgLT1F2WKC9bIPImxUQuHTLbjeXXSfiHwia93tiseUOZwyNESUOF25gzuz n/U4Eid94ZpaREIVy5pVQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:xAdfGUoZHNQ=:bYPt78or1+RyMfd5MOLPns BnWJgZFBHyEoHfbAXAVN0UJ+wBOFbIGya3G/jG45HcKez+UlHkSiEnq07Ed3RmYEP46li/UUy woxbUHwfbeROjOBEoNO7pxO34nZmMLaZTRv84AnJqPsuZVsaRJg/EdEfrPj+/mOEKodC76/Al 2wyLG/mzR2QAW2upnG3AtpWC9KMQ6G0QjBm58SoRz3HSMaNIjqGz9zz/IkRAazZ2NMqeqgFs+ Jzrh2f5uxHGu8cyeOFGB77yo2yrT0TuPT+cXdxksFLMIZgzS7/BGHM930tol13Skh3y8b0AoG DvNwRGoIdOS93uyymNAaWks2nSBqrIYDIeytS0wSO4g+5lNgoHxB7/ZZPj2J3bHWViiWNFrn/ OUzIyboG+9OH1jVC0+L/R8GHcjMg1O9khAkf0q8jZl1cG4DukvYNwpSlxGtAyM4e38fkrr6QP eenDv4pCfL84Wr/C1uVuwCnEABtwp4acJhnrIIBD6sBpKrFYfaRgr8PGE65kBNAFRiD1/a8MZ 77OqNJ2EyPr7d3ZfQ8uFtWC8YY4iX076KHHXPh+gUsMyRDR80FwytRJXBh43WGAMJrRMbYFTc 8PB6sUgjDPEECn+w7HwiVE+jXWPY83T7DiQ+1Qv0le/DtrZTwc3snKStneD5bp0yyN0KTPPzn W8Bo0Pc7JmB1+Fv4/kPww5cwqWAxPuy3MRcSmDCl0DKnGR9HEsTc9gBS3nVz8z8lrtiuoefHx wuO4IMdNUkXv56ycst+3/FcFGe0wXAr2TOD+eGpDqmMFsA+NNCsnTclO6VsXuo5XgMZc2nca1 t2bYEZW Received-SPF: none client-ip=212.227.126.187; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Pass a boolean to select between time32 and time64. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220829021006.67305-2-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 67 ++++++++------------------------------------ 1 file changed, 11 insertions(+), 56 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e0e0f058121f..af3a605fc458 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7768,9 +7768,10 @@ static int do_safe_futex(int *uaddr, int op, int val, futexes locally would make futexes shared between multiple processes tricky. However they're probably useless because guest atomic operations won't work either. */ -#if defined(TARGET_NR_futex) -static int do_futex(CPUState *cpu, target_ulong uaddr, int op, int val, - target_ulong timeout, target_ulong uaddr2, int val3) +#if defined(TARGET_NR_futex) || defined(TARGET_NR_futex_time64) +static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, + int op, int val, target_ulong timeout, + target_ulong uaddr2, int val3) { struct timespec ts, *pts; int base_op; @@ -7787,7 +7788,11 @@ static int do_futex(CPUState *cpu, target_ulong uaddr, int op, int val, case FUTEX_WAIT_BITSET: if (timeout) { pts = &ts; - target_to_host_timespec(pts, timeout); + if (time64 + ? target_to_host_timespec64(pts, timeout) + : target_to_host_timespec(pts, timeout)) { + return -TARGET_EFAULT; + } } else { pts = NULL; } @@ -7817,56 +7822,6 @@ static int do_futex(CPUState *cpu, target_ulong uaddr, int op, int val, } #endif -#if defined(TARGET_NR_futex_time64) -static int do_futex_time64(CPUState *cpu, target_ulong uaddr, int op, - int val, target_ulong timeout, - target_ulong uaddr2, int val3) -{ - struct timespec ts, *pts; - int base_op; - - /* ??? We assume FUTEX_* constants are the same on both host - and target. */ -#ifdef FUTEX_CMD_MASK - base_op = op & FUTEX_CMD_MASK; -#else - base_op = op; -#endif - switch (base_op) { - case FUTEX_WAIT: - case FUTEX_WAIT_BITSET: - if (timeout) { - pts = &ts; - if (target_to_host_timespec64(pts, timeout)) { - return -TARGET_EFAULT; - } - } else { - pts = NULL; - } - return do_safe_futex(g2h(cpu, uaddr), op, - tswap32(val), pts, NULL, val3); - case FUTEX_WAKE: - return do_safe_futex(g2h(cpu, uaddr), op, val, NULL, NULL, 0); - case FUTEX_FD: - return do_safe_futex(g2h(cpu, uaddr), op, val, NULL, NULL, 0); - case FUTEX_REQUEUE: - case FUTEX_CMP_REQUEUE: - case FUTEX_WAKE_OP: - /* For FUTEX_REQUEUE, FUTEX_CMP_REQUEUE, and FUTEX_WAKE_OP, the - TIMEOUT parameter is interpreted as a uint32_t by the kernel. - But the prototype takes a `struct timespec *'; insert casts - to satisfy the compiler. We do not need to tswap TIMEOUT - since it's not compared to guest memory. */ - pts = (struct timespec *)(uintptr_t) timeout; - return do_safe_futex(g2h(cpu, uaddr), op, val, pts, g2h(cpu, uaddr2), - (base_op == FUTEX_CMP_REQUEUE - ? tswap32(val3) : val3)); - default: - return -TARGET_ENOSYS; - } -} -#endif - #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) static abi_long do_name_to_handle_at(abi_long dirfd, abi_long pathname, abi_long handle, abi_long mount_id, @@ -12372,11 +12327,11 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_futex case TARGET_NR_futex: - return do_futex(cpu, arg1, arg2, arg3, arg4, arg5, arg6); + return do_futex(cpu, false, arg1, arg2, arg3, arg4, arg5, arg6); #endif #ifdef TARGET_NR_futex_time64 case TARGET_NR_futex_time64: - return do_futex_time64(cpu, arg1, arg2, arg3, arg4, arg5, arg6); + return do_futex(cpu, true, arg1, arg2, arg3, arg4, arg5, arg6); #endif #ifdef CONFIG_INOTIFY #if defined(TARGET_NR_inotify_init) From patchwork Wed Sep 28 20:27:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 610095 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp505091pvb; Wed, 28 Sep 2022 14:02:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Y+p53CYNhaN+m6Nps3hYqn8PCjCw0KdCJ5jhdnUHBEag+ddV29WP5RBau8EWtZtpjE/zL X-Received: by 2002:ac8:58d0:0:b0:35c:eb96:5f38 with SMTP id u16-20020ac858d0000000b0035ceb965f38mr29305077qta.392.1664398953520; Wed, 28 Sep 2022 14:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664398953; cv=none; d=google.com; s=arc-20160816; b=ItnMHhSHC1IcMoAzqsi5aPSt3DIcfVnKzLtXwbBaxpnXTgW3ck7mqzbRZkrbOTBMWG ridv6osFoLRczuoe8A6alEC4H5O7CuusQgEFVG8/oPL+BECiakGPZpU8DcyRaH4ewrMn E2bEJP1DA5PMd2wG2Le669KSKAOE97+cEHw63RJpWoZqB2/ACG6ZRo8I+rEuloPPpKKT lSmfQOocTqyyt/7/o9QfhuW2iEb9aqAurggtb8O+CAK8AycTMbV5bH6QhseCZbrIKMWG 6Ta3msFyndaDuyEooN4SGrbc8XIlpSjBDRu3DV0q6IpWzwtnoGIPe0JbKqaNZS1SwUVP 2HSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=Xu5ZYA0q7fKqcNO3p+Orp2kbGugTYczykR7Oo/W0m9w=; b=jBF2v4cPE0mt1/2xEDHxiJa7Aq3VPVwz/GRTFxguB6+BaQqsFSmdn98XOmpWkFAqGZ GlAop+I83C64OFd1O8wF96kGuM8KGStS65rYdsTTO7TAekt0x6aQK9StDzyIS8zxGTAO /X67XsodWA5cSwU85E4B4BuXCP8qlKhxd34YTYogXZLToWY6vnlHaZjED1PfMctyga7k o8mymKAa7Oj47EqiQ3LIzja95Taejz//BbkIZNRZniAKRQlFpTH63Iy12EOIaxC063xc TuvRtsKQn100XeFEnyax8L/qB8u3C0Kvdp7Y8BGG0Hi22g0a6c9oGO/k7n+6zudmkpte 7ZGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a29-20020aed279d000000b00343288592dcsi184362qtd.455.2022.09.28.14.02.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Sep 2022 14:02:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:46138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odeCP-0000tZ-3n for patch@linaro.org; Wed, 28 Sep 2022 17:02:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf4-0000bS-Nt for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:06 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:45253) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf2-0006Xe-2G for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:06 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M7JnA-1oaLL348L6-007oPe; Wed, 28 Sep 2022 22:28:02 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 31/37] linux-user: Sink call to do_safe_futex Date: Wed, 28 Sep 2022 22:27:31 +0200 Message-Id: <20220928202737.793171-32-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928202737.793171-1-laurent@vivier.eu> References: <20220928202737.793171-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:3Dsd8htV0Ts3QTvlCwAirljX2/FKlMrweXRllB2x8razXLD97+P tKSyEzY6naVsL7/VsZ1ql8zjfm5WtW7TPIlNXAAeyGXSWNu8MQhpbEQnyWNX2sZYDazTjLQ WdD/nWrjUC15bn6vhauj3wyVV7z69ZomCf/2VnaLBVegOtpwxZRm7OZXPxL6Uh0e3mrvhZN VP1lDkley9Ihi2bUkgRSg== X-UI-Out-Filterresults: notjunk:1;V03:K0:FKcYcn75Hsg=:Fo1Oq4HggXlxH7Ip9m7M1R lcAooG2HB7jze0gAJLzE3M4yuiCIuPxrC4DA5I51mjmOjak5gFphE/LCzthwwyx81xaJhJJ0n iIc+/1RmOSU0f2t2p3M7urp+AByYGJiRD0wE1GCMDQaWrUrkKpHudO2abYlVy+aC2ReT5cRq1 JqayIhIrDmJsjKKNdkukQHSeLn01jOL8i31EnKFT9rUEQ7eNzAUvRnL3hN4SGrXk46n2z49SP hNUSM46WZcMIPKtWuHKhnU6AOlq5n6gNrEhj+3KoK/mGlTUEy0kItYywiCvRa2tTlRdZ0C+DI wV68My3hdhZfWYddG6e6O3shOJquCOu7s96hO0bN04HcayPNVp8JNzKZr2bYD0oY4dbbznXMy qRTiAg/PBIrB0xlLXGwah6xsdL4g7BJqEu9ce7o/GpF6WtY3Mn+d/7s8b+yxvRANPVdwObH7l BocAS1A2Fz6t1ooWAHtKmYu23+cL7O6qnCS5hkKx5tXJSBZ/xizmmpxoHYOvVwN8QWVhisXPW 4wpFud7BQIX6gBxgXORrAOzeV5sLh7jGeBq1ZzQRCOAvAl7vdrUOjybpdXgjmvDgBgEn9Ap2b v/LiDsj+LrFVJE5l9NjybJDrR9InB7rcUrf2fJ0i+k5QzMdxJNK2+jUssmhblO+cWH1zOXtCs zFVRNzknyMGmnTU8vahogi3xoajLNGoFAaWmGgB2xrN8Kwb5A2ikhkgxjUdxVrty0fZGhiefE Lmx/+OqhcFEmt5C1EzTAREqvX5SKt5TlYXhDCY8fiwEaUJMWoAsl7xQkep3xl6NPoQssKjRau lwF9Wxz Received-SPF: none client-ip=212.227.126.130; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Leave only the argument adjustments within the shift, and sink the actual syscall to the end. Sink the timespec conversion as well, as there will be more users. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220829021006.67305-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 60 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index af3a605fc458..17e17f480456 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7773,11 +7773,11 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, int op, int val, target_ulong timeout, target_ulong uaddr2, int val3) { - struct timespec ts, *pts; + struct timespec ts, *pts = NULL; + void *haddr2 = NULL; int base_op; - /* ??? We assume FUTEX_* constants are the same on both host - and target. */ + /* We assume FUTEX_* constants are the same on both host and target. */ #ifdef FUTEX_CMD_MASK base_op = op & FUTEX_CMD_MASK; #else @@ -7786,39 +7786,41 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, switch (base_op) { case FUTEX_WAIT: case FUTEX_WAIT_BITSET: - if (timeout) { - pts = &ts; - if (time64 - ? target_to_host_timespec64(pts, timeout) - : target_to_host_timespec(pts, timeout)) { - return -TARGET_EFAULT; - } - } else { - pts = NULL; - } - return do_safe_futex(g2h(cpu, uaddr), - op, tswap32(val), pts, NULL, val3); + val = tswap32(val); + break; case FUTEX_WAKE: - return do_safe_futex(g2h(cpu, uaddr), - op, val, NULL, NULL, 0); + timeout = 0; + break; case FUTEX_FD: - return do_safe_futex(g2h(cpu, uaddr), - op, val, NULL, NULL, 0); - case FUTEX_REQUEUE: + timeout = 0; + break; case FUTEX_CMP_REQUEUE: + val3 = tswap32(val3); + /* fall through */ + case FUTEX_REQUEUE: case FUTEX_WAKE_OP: - /* For FUTEX_REQUEUE, FUTEX_CMP_REQUEUE, and FUTEX_WAKE_OP, the - TIMEOUT parameter is interpreted as a uint32_t by the kernel. - But the prototype takes a `struct timespec *'; insert casts - to satisfy the compiler. We do not need to tswap TIMEOUT - since it's not compared to guest memory. */ - pts = (struct timespec *)(uintptr_t) timeout; - return do_safe_futex(g2h(cpu, uaddr), op, val, pts, g2h(cpu, uaddr2), - (base_op == FUTEX_CMP_REQUEUE - ? tswap32(val3) : val3)); + /* + * For these, the 4th argument is not TIMEOUT, but VAL2. + * But the prototype of do_safe_futex takes a pointer, so + * insert casts to satisfy the compiler. We do not need + * to tswap VAL2 since it's not compared to guest memory. + */ + pts = (struct timespec *)(uintptr_t)timeout; + timeout = 0; + haddr2 = g2h(cpu, uaddr2); + break; default: return -TARGET_ENOSYS; } + if (timeout) { + pts = &ts; + if (time64 + ? target_to_host_timespec64(pts, timeout) + : target_to_host_timespec(pts, timeout)) { + return -TARGET_EFAULT; + } + } + return do_safe_futex(g2h(cpu, uaddr), op, val, pts, haddr2, val3); } #endif From patchwork Wed Sep 28 20:27:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 610099 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp510387pvb; Wed, 28 Sep 2022 14:13:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4f4FOEN3rQsgfNlTRi4VSKRNkB41iIf/witZ7S2fkYismhSOYJARm0j81NbcHs5gH8ikdx X-Received: by 2002:a05:622a:2c5:b0:35d:4ade:e0c3 with SMTP id a5-20020a05622a02c500b0035d4adee0c3mr9748481qtx.414.1664399602063; Wed, 28 Sep 2022 14:13:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664399602; cv=none; d=google.com; s=arc-20160816; b=KdTIeyz75FfUYNB7NamDEzt4W16E5HH3gtKKWjz0nloVRNzovGaMe/u+AxMKOjVg6Y 6KlCYRH7yu2+eFJDZ88zGjo0j8Fg/SRnmaxJ3v8mI2EWwnh8lrMX6wwhy+SnewNL12Bl LhCpsWfDm97pGcKCsUQQPtt6MPuPKUb57+mroOpKwixTBYayKg4rUwVf3MJlk1BFqK9E nR8uR5mCdFPcAoYGBO3afHTXnWJxOk386i5TbNYAewpaA4AuVmlIIBB3s9qOBAMhaFla gsoc9vORrCLgEkii6WJA0jlNKDnzQ0vQEHO3Wn4sl2VartIZQZGuGkd1wxjPvbSdwI0h YY7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=YF9+4kBAVm5Yh6Z4eDUXac8hJFpAnSNxfDKNa0w/4pU=; b=a6yNFH7/ElwgYEFmzxO2SbF2yM8C9A6hbKLzKMTYcEMA1IA+ro+D/Aa+4pTc28rB0F 1782iANXE3vKHhYrmasj1NBHYKf3LMaqHHvEJKG7zI6Z1G1BVCLytKH/21uazozhfXYV Pg2yCaa+dLYcwUu56+E/9kmhQrO348YUfzRvCPaPpixJI5cttND9M0mqndxp7X84qfbU 9glws2tu2mvNLnf134acSrz5/EZSx3+k9E1TeYdral7yhiA7prCfdduPDkxGQPD5hMWe fGeZce6NjdRvBGH9KVf0hHILgFJwvkbhnxl8hgGrWkG7SwVBZlfNxn9k4HEW1xtc0i+l qfbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s6-20020a05620a0bc600b006cf43485529si253008qki.604.2022.09.28.14.13.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Sep 2022 14:13:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:33246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odeMr-0006gP-Jv for patch@linaro.org; Wed, 28 Sep 2022 17:13:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf4-0000aL-9X for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:06 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:37561) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf2-0006Xp-En for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:05 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MRT6b-1oq5yB1gmL-00NPKB; Wed, 28 Sep 2022 22:28:02 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 32/37] linux-user: Implement FUTEX_WAKE_BITSET Date: Wed, 28 Sep 2022 22:27:32 +0200 Message-Id: <20220928202737.793171-33-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928202737.793171-1-laurent@vivier.eu> References: <20220928202737.793171-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:agDZ5w13uWTXRVud1+gyB8UI2xF8y6S1qbUxxTUhx7Qf4H0VeIe INTtSpmrYzmghA+z5CYN21MW+k4t6Luf6+6Jv1MvP8SrVos9hQMV3woJj9tnKRCKkuKOafT xgwbU2+tQ3Dmti60jl/k4mXoiKxn+HtqP4yDq1Zm14q9yGUzItb9igzcJaU8vvnKrPLOf+I DnG1ZqaNrd/gBBpadHb2A== X-UI-Out-Filterresults: notjunk:1;V03:K0:/BeXZgQ+A0M=:1ZTPUsNwlJGTtR6yzmEQ1a zlvzWATXOGFubmUu2vxYDG+V4p7AZ5c3MyhGoGEo3zJwzG7xrHwddkuGktG2GZZuwOHJzKDxp tUF1QlE5cLuiT7ljWsqT48ekWjskYtD0Nl5F7o32H2f/yv90ZHP7K0uXpxNq2nTaJwTO5SBrO 1W3hPeDbx++pNF1tS1cRt+C23PmDEHd0f4p/x/aWzUlAPlJJWH6IEDzqZeo4smzw82NkXKRf6 TcBoEez/2MrsrkBQgYHYtoh5NI7ZKmQWkJRmeKGtLUhb147STprFeOc05IZz9ZX6UuPtsJi/o JW39pga3f1ekUg+LadgWimZLusiKilq3n4VqRqfJhrhjqA6te+jYRzOyIXRnYnICwtMIzofpS 8rq1LTTINDvuP7kkLoCJFKzfZYbBWSoHUqZsnANcfcDzcr8eMsIUBmuW7XQb0z9yAZ9UPv38L QCRpDNzR2EDhcE1TJWENSyCYT72RD4A5559MkEEhKmgypCHHOBeS4S28GUDaORY8oHt9+vxOt ZNVWDL9lTu4MNGyerh8k4pLv5fCyOXJowNOUhRnkifHJMfR6NpHSnXaPP6cjI/nwxRPZ//2Ik oY3M3irP02V9O577e7YgPHi1rvJ+oS7a/clihqaVrbSPj+q1NcNxXPWVKl6mzqYC1TmoVLwIP DQNfJ6SQIuEJSqj1ALB2fYO0stE9NjOnDoT9UWiT5UNnX7dKWjaKSjluY802G4pGW2HLwZxOu wEg/1juswKTQdkjGEv2dC1oEjs5o5dMCW11sYEnhkHmfPFzSKEv21BvZhppmyZmfHcPNoTnS7 AkpCOSj Received-SPF: none client-ip=212.227.126.131; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220829021006.67305-4-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 17e17f480456..e2b6b564e6cb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7789,6 +7789,7 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, val = tswap32(val); break; case FUTEX_WAKE: + case FUTEX_WAKE_BITSET: timeout = 0; break; case FUTEX_FD: From patchwork Wed Sep 28 20:27:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 610096 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp506611pvb; Wed, 28 Sep 2022 14:05:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4zoBMOrX+/6Y+656M7SngQSujCvtZ+/FjBoRZtg/JGROTfLjPa4NuupisMUtGhmHSGVmgF X-Received: by 2002:ac8:5889:0:b0:35c:cb1e:68cc with SMTP id t9-20020ac85889000000b0035ccb1e68ccmr29627797qta.406.1664399115043; Wed, 28 Sep 2022 14:05:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664399115; cv=none; d=google.com; s=arc-20160816; b=P89qTAp7I33iB6lVsPXyw9pDPOR1r6YA9BpNntIjNrJVq0obc2kRrygfbBp48/ja1H 0MXtbAYFS5v4Q3UFFmYPEnKHwCG5ZB1ROWtBgyQUNhRj5Mp4Gue2WkIqe1f4jxvsILYm woUPLwctpNPeD3J+BYYOkk5ygyYc2/QS/wfCzjLVsfyE53mGkuBtZ6VyQhntY2IRTmDG kga3aVnrvLnuq6w8DHuVvoKjAvYUOzEIuNWjwJ6nwH8vv/X/BNWLduLHCxDIg5Cc9oYB TdE0WBzUqqVK7OeB3AiZiJXLdA1GEyqifglo0BB0O5mcAQ1yrsVWLJyhcVbr5dh1HHXi gk4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=UwHywidPfehjkXp/kJ6T79Fe022LSXCYVHND6WPWu1s=; b=TW48x218/0JPnADeoGjbxsdHWtiWMXTU1zCnn3gmkStPFcHccWGNpWcVhECWS01zZa UO6qg1BdnFLF1jtNHj4AzA2/Sp+ksHnQ94m1MORFPpYdLC7VrkyK36nJpXWY1vexyz6l JSn1UnAlKRUnih5M19TKLVHv3b7ogNFgPKoCapgM9sos/ToasbY4OtIqEfjXAQFYCU7l nxwGEdLOjhq6xr22KblmHuHRaN2TZu8pqQf9gdNf3YhF3DVvmHIMC+3E9tGwt4IKgJgK 9Kwt8XJ+3kevlFOLS7Tlw52ZSBpLEYMdTbwZjUO/NDS7NkyXVxkvWzW7QwK/rYrZyNPK j+Gw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id iv1-20020ad45ce1000000b004af93cf743bsi3778901qvb.341.2022.09.28.14.05.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Sep 2022 14:05:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:38198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odeEz-0004ao-5T for patch@linaro.org; Wed, 28 Sep 2022 17:05:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf4-0000bT-OO for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:06 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:36759) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf3-0006Y0-20 for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:06 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N8oOk-1pGatp07OA-015mlY; Wed, 28 Sep 2022 22:28:03 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 33/37] linux-user: Convert signal number for FUTEX_FD Date: Wed, 28 Sep 2022 22:27:33 +0200 Message-Id: <20220928202737.793171-34-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928202737.793171-1-laurent@vivier.eu> References: <20220928202737.793171-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:LrQ/4Fa8vgjiL1wbQ8E31IiRFOIh714S5n80a490IYN/Q9sVr0w 8SGRYi+XxfzOZTCwN3D5/+Nh6MT/9isFyCDIivTTwSuJ8CjLV0CqBIlW40gvhV46jlEzaG9 dJ4lAdxLrSUpiIA7DMNsYm6hNZ4HiZk9LqittnjmgMvKcdjR6aIzEWl94z+URvtae3kty27 j2VIvRGEXwINQGMuYGFIA== X-UI-Out-Filterresults: notjunk:1;V03:K0:wz9bXzUcxwc=:asapbxYxPYATZTBfRa6har 6SWslz4A70lnp3BemVDIHfK57UfDIGLSrz/po6cLi9h+Eh1nFTotezUxuOYG6ehOdVMdYLzVL FiRyFlzOJ4amrrI/b1WX6adJIn+JURLIOk/2EAZP0CsAtv/vL7BzfTwnxt2t5sM77smadCSS6 YIpDTeDkk61QSDOg+6pkvH92dzjE3OR46EGj3siezpx0QrZPMa/OWbyt5miVRsDxjS3Bc6ZDp VQFWOvXWZWXUFmMkxbFk8nCE3m6aqgUatgciDYQ7sIoJOFG8lBOfvima+9PNR6PwMebZ6ZtX8 8y/5L/aUAtY+zFJEtJ6SAyaMNZwVpKy652pt3Lic+w+JU4MdoOded0p0z/H67Y7wSJiy/c9Y4 DpTEfZHHGfhiGjs65D6NefMwhIOmP0D+XsLE6y77rkU3mgUud+F22DaJXAz4ZbTCuCQ/Bzwnw yYMN6bBSxcXj5SmrenplZev/ioeHakA8WzuXmuDI07GPxZHmgKIao1IozrLpO0DQSer8MZVc/ BkD4zRfYYS9OtiwcnRELlAm6BbEM52CKQBumM6KGnaDdUheYoX2Y7MGZvS+xjT64qxUK1uQmF T5uZCOh3GAoTpu+EDxWEWZL3IhQQ+13mv4acBR98O5c0LE0FthXnUtSFj7vChUfUt28zgROfK K9ZfPcvoJcOxKGJ1IMpCqxrVWAjo7brdMXoJ+FrEnT9Zeuz0/OggXZE9RdQ74a8zPtgwR7Gvz PB5s0HJ3REATScO5ylmNRknsBrtOYecYySkVwVilnAlgJs/CremLXd8c3QEdK2MOGNjL/K9Is VRhSVL+ Received-SPF: none client-ip=212.227.126.131; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The val argument to FUTEX_FD is a signal number. Convert to match the host, as it will be converted back when the signal is delivered. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220829021006.67305-5-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e2b6b564e6cb..3f144e3c1f5d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7793,6 +7793,7 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, timeout = 0; break; case FUTEX_FD: + val = target_to_host_signal(val); timeout = 0; break; case FUTEX_CMP_REQUEUE: From patchwork Wed Sep 28 20:27:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 610101 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp512714pvb; Wed, 28 Sep 2022 14:19:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4zuyKWJJQ8OaPywZv+nWAH0GEwUqCxeEtoCpc1Pug4ezSw2v42CgzV92bVJD4hmfJlrwdK X-Received: by 2002:ac8:5b96:0:b0:35c:ceb4:c1c2 with SMTP id a22-20020ac85b96000000b0035cceb4c1c2mr29153510qta.461.1664399961080; Wed, 28 Sep 2022 14:19:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664399961; cv=none; d=google.com; s=arc-20160816; b=VQWIoEBoWZi7zqLuGE0hm4u2+eZ4sTfef/KO8c/xfYao1eWIFf96nVDQO0oOVTcq0q f9spM4Zwooj2I+18niu37LWiFdyCDB+qyvDAQqrpC+Y+gpHcwiJkebhLq7+jGEF0TonF NzpMUI/EcC94/SbMcwVEZihIBDV0Eyc+xZTwq9yNnHXv72DCE6zmlcik8bdm+OdALNuY 3mzXNAqhyj3w5cw+KPRA5V/lJ6WgMiq7c2xL9pfIq0qxw25o7vPdaAKJHcE+RYFQJCeM lsW0PVZpqa85BdbrVhAPweG+3/XubD8w7TtcJhVU723bV78mJUd9rJAouNmaSAQoGU1v r2zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=6y8xU0F66KIoMvplobXnbP/sCMXlkm3LwPz1PJrcq9c=; b=G4RirJjuICnrfEqtYtCXn5UVbd1rWxFTWE/rngiCp6KWZhU7PAdnlpAl1LMd4fRmOv UC0RhTegfLOlU7idQupkU5tCiqJE208YbcA3bxksHNv8OeEDxsFKXOEPhZL+KePkYMjH y9sZfuTpuU1za01VUxkp7o+0NZ45qB36V0tjsW7pNHp2mhSMKJ68G27mC+UW/bDjztzl 5V+5jn91ufwXtpypFSZQ7o3VsFIaJePihlOA+POrsNPiKTga81npOrVMNc2yCwVK9z/A mT6q1AGbqBo+b0EkOBPeyQ+kVVDNFupmXHARdsc4Ri++A6JKViCPngIj0mvnMojRoAaQ 43Nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e26-20020ac845da000000b0031eb7a0f17bsi226950qto.264.2022.09.28.14.19.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Sep 2022 14:19:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:54450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odeSd-000464-Ks for patch@linaro.org; Wed, 28 Sep 2022 17:19:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf5-0000eD-ET for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:07 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:53173) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf3-0006YC-Ry for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:07 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MTzve-1on1JR2Pru-00QyN6; Wed, 28 Sep 2022 22:28:03 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 34/37] linux-user: Implement PI futexes Date: Wed, 28 Sep 2022 22:27:34 +0200 Message-Id: <20220928202737.793171-35-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928202737.793171-1-laurent@vivier.eu> References: <20220928202737.793171-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:ZgvfdCGvrXdYFhC9TqX60aEUkAF5VzmrV0EUY4pGCK7Jn+si3LI oYNrom6aQ/3FjBTFpsRHD1CH2WDWU41lXCsOicOXyq+aapXYY6FyNml2akG8Y+PxRza5rUe htCvEW6IvqIgeO7ZlhAF8cMlq1WDdADskwKIn9t5J0Vi3L3OubN4lVOLQgK05W/sSMhUwH7 cSFJrpqjEyVi7zlhY4/UQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:dbf6zThDfDg=:WGnTVHEAs/DwGg8jGUYaqe kYO4mFBY4Uo23XB6UBxaIRhFOlGc+sao3vpguyhxeHHaI1LUnuZ9nVMtS4u5qc43dnQXM6d0v i5WFquLNKzfL75lcXu01xRSKW+Z3L0jyU5GonB2wU0jHWM26/jeSYgVDz8oeXt3xhPmT1RWfo 4iMggATj97A8zrUiFI8611aOq+qyOQruW04FWwSt5bEYF1es0iXzza0r+Assd1HStsafa4MDi O2Fyio6bkRsDMsVM4LqKCfBXRcRa01MfZlC4aT0FBpI1CvT6agK/tFNhLDoK1JvzWPjwZhfhQ QRHrfxRUkfb/t2Pr4YljTaPdAtjH1IKReaEFNgl3BgNKyJ8smn1mKwhyL6VvY8OD5IMtVXShc XQsv/UxLBwBjtTpikeO4fZaYrU2f6xInRDMK8xS4HfsUeTYEd78HP8iqrgoUz2zHvs6ZJzuW4 uiAMwkt9XrtnGn0PhmNXO2eF1YZY88zETsgjWkNclRt8YLTu0teXjIMFswER+HcJHZ9qBmUYu 1GzimwWyZuzxg5Z3pmmQUUPylK2I+fztCiynU81WAzL1nBokHsAyk/ex4G6LglSQSZwR1bf5a bEUmhHE/ZAjYMotSBRiHU06qcHHtdov9m+W17FZZcf+huzWhZHesDa3xi+raA5Sxjeg1jwhLO owbriQpNlIcjEaRpfrsBgPT2ZwkLAlC3Zg5/S00en+YbwvlKfniBSwWIEbkMXYKcvS/ZajHWX iiK6fk+3T8MgmYSpbpvMP/1mII+XCr5bckoAd0MqAJNQHClBF/vfJi08wAEbYPWWYmQ3nXYl+ ssFhHqz Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Define the missing FUTEX_* constants in syscall_defs.h Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220829021006.67305-6-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 10 ++++++++++ linux-user/syscall_defs.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3f144e3c1f5d..2e954d8dbd9e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7788,8 +7788,17 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, case FUTEX_WAIT_BITSET: val = tswap32(val); break; + case FUTEX_WAIT_REQUEUE_PI: + val = tswap32(val); + haddr2 = g2h(cpu, uaddr2); + break; + case FUTEX_LOCK_PI: + case FUTEX_LOCK_PI2: + break; case FUTEX_WAKE: case FUTEX_WAKE_BITSET: + case FUTEX_TRYLOCK_PI: + case FUTEX_UNLOCK_PI: timeout = 0; break; case FUTEX_FD: @@ -7797,6 +7806,7 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, timeout = 0; break; case FUTEX_CMP_REQUEUE: + case FUTEX_CMP_REQUEUE_PI: val3 = tswap32(val3); /* fall through */ case FUTEX_REQUEUE: diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 1e3577bfa56f..01ee10a88fe0 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2699,6 +2699,9 @@ struct target_drm_i915_getparam { #define FUTEX_TRYLOCK_PI 8 #define FUTEX_WAIT_BITSET 9 #define FUTEX_WAKE_BITSET 10 +#define FUTEX_WAIT_REQUEUE_PI 11 +#define FUTEX_CMP_REQUEUE_PI 12 +#define FUTEX_LOCK_PI2 13 #define FUTEX_PRIVATE_FLAG 128 #define FUTEX_CLOCK_REALTIME 256 From patchwork Wed Sep 28 20:27:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 610097 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp507076pvb; Wed, 28 Sep 2022 14:06:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM48Wh1Ib3RQps9gIBT7Hj6I4SYD3TkDnMkSSuaD/swSv6XtNhgKkxnfYRY4wTDHa1fxn4he X-Received: by 2002:a37:63c7:0:b0:6ce:801b:5e7 with SMTP id x190-20020a3763c7000000b006ce801b05e7mr22797149qkb.557.1664399164198; Wed, 28 Sep 2022 14:06:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664399164; cv=none; d=google.com; s=arc-20160816; b=XognGA+oMIdhR/z8TUqYu5gUF+EAM3Hc+rmJH43+QW+RxI+0H7xsR7n3XOLsj75SL/ xpVZ2LtWB6mKFeL6Rai+7hzrzPNxwPMwqEQxUt+5tY8qFrEdEixSrRlQUvYo09mPNSH9 3lP1bDjTbvhpp1i8QMnRHl2lJEowx1MoLMoWIy/k213Kxmcv8ltK8fsVkb7cFicgK2Jy i+nFyiIwYHzIvyUdguXFIKEHOSxD+iIGfAMa0yY7N8Nmit4rFjR3LiEBYr83nNxpdwv/ ZcO54uv1GGX/Rnm3IsCQvdURJISFtD7FSAtf7hyJ04y7HVV2n71GcoDi8jIjrI99DBv8 SFQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=75i5cvTneBUkPxfiqy5WTWxGGAt9iK/Fwt8pP7WD8cg=; b=UHcSZFhX0AwD1z2iae+CQn2kirqETJ6V59FbNlIof/RvU6B5gVT87e1Bx9BHXwGLan PMv+ogteTudhPAY+WAgJ6pmvY3lUF5EeIhQkQqkMNbkBei7mzUdX7rZ6Of6yL+cexjrE oMvx9JGFIPsiO9Eu2yy+jNho/qTvl+tHEk4jhAaqQqbStYPKp6FmlqBGbYw5BeOw3SRQ 3NP7BA0UQ1HQdE/gemCd7xt53sFLcaInAEVsOamSvz5jT2NmdSuZeTvBPJw8ey43L1K2 KMpSqNuiWhN7CaYmEEEiDtXHZytjfDqfbD5lkkrwQCo+8kmH4GB1Ah1K42ueNPAgyRRN O1Dw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b10-20020a05622a020a00b003435c985624si251698qtx.250.2022.09.28.14.06.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Sep 2022 14:06:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:49026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odeFl-0005Vp-7y for patch@linaro.org; Wed, 28 Sep 2022 17:06:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf6-0000hr-F6 for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:08 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:49501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf4-0006YX-Lq for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:08 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Myb09-1pRLb72Mpx-00ywzv; Wed, 28 Sep 2022 22:28:04 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 35/37] linux-user: Update print_futex_op Date: Wed, 28 Sep 2022 22:27:35 +0200 Message-Id: <20220928202737.793171-36-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928202737.793171-1-laurent@vivier.eu> References: <20220928202737.793171-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:lIb77sB6JdUnv2GeVFDsdSEuAi4q+peZJJB3PjBOjCo6tQOking fXMbsdE7jYteSMdCkW44ykwNVcu0o5dQPP2llLR31S6gFLP965jUar7plfVETNGE6NvGmc2 sjLpFwGxHhG9kup301xVNX5uoyZ30fnzp4Lojsv57ff98JNPz3sJlGkRyK9QocC5hig37CL dvwOWJ7fxrA1I0hfBHHeg== X-UI-Out-Filterresults: notjunk:1;V03:K0:aqWYxsrcghQ=:a+GUDRSuQqGT+zbg/i+Bto 61QxKjGeA1aACl+wMpqyt5cpkWtcgyXLlYouSbzZ/imClwsFP34P7kwVN2AwmOeld8B8R2pbg bUupwKq3o/IDPnbNKb8SEF+a3kMn+SfMNGK9RVcjP1gi05UGkm0q/IISB//JZsUEjWh69VX+4 VqghXp8rroXwCuSq1pPTTMrYGXM+CImljAahA4RaMGfwg+kXlwwhQJeAEGA86QfuGETZq8upS jEgNYKcDU2FmlmWnjH/trs9I8kiL/y7oEIm3ohtyzsRmKx4F8L00VbMXAdb4KLx4+TU5KNUff 1wCCYGDupKQuXZwlIdXDgStZ4vuVRPKmN9zIwHyu6xZOsdzVcLhntqf0VbPxlC1D97JsE6V0x 6piibayqBrhpc0QdlgMqEG+oQNrm/fPWslUUY/UAu5HkkklFUfREg7G4g9JmduYRFNF0E9BSA CfwwYZ68eZ64wdc3FN9rtsMIrhG5ShoXcQjhgFXTRV/MJ8w5+eu378EpGUzX6c7lCazcyGbrn Pms14ZeZrPO6SWAJH4jpj+nQAgvk7GxN0/+GzNbsoTMj/Ja7Hzuv46ZB+sp4zOy/DDsTlHQ6m iVI/mjcZCzIcrq+iHQpfaEkeIbd9RXTkUv3PmLIN4/LQJ/zC6FROlUdbmPH0nMl6DVBCZQtH5 CP1FI/XzAkSj6KSOYFVjNEadFgGmgOaahl8S+b0pO4jdDOlUD9OcIU6/9xEpi3a5gIqQtfAjX 2MlzasBR5Rabn70eCfJSlTPwZmffo99aFdcbDGDgOSBRPmbUs6YzQ9BI14J/irGE8nXke/lZm hFOvFym Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Use a table for the names; print unknown values in hex, since the value contains flags. Signed-off-by: Richard Henderson Message-Id: <20220829021006.67305-7-richard.henderson@linaro.org> [lv: update print_futex() according to "linux-user: Show timespec on strace for futex()"] Signed-off-by: Laurent Vivier --- linux-user/strace.c | 70 +++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 2deb84a2c106..faa733125624 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -3710,44 +3710,37 @@ print_munmap(CPUArchState *cpu_env, const struct syscallname *name, #endif #ifdef TARGET_NR_futex -static void print_futex_op(abi_long tflag, int last) -{ -#define print_op(val) \ -if( cmd == val ) { \ - qemu_log(#val); \ - return; \ -} - - int cmd = (int)tflag; -#ifdef FUTEX_PRIVATE_FLAG - if (cmd & FUTEX_PRIVATE_FLAG) { - qemu_log("FUTEX_PRIVATE_FLAG|"); - cmd &= ~FUTEX_PRIVATE_FLAG; - } -#endif -#ifdef FUTEX_CLOCK_REALTIME - if (cmd & FUTEX_CLOCK_REALTIME) { - qemu_log("FUTEX_CLOCK_REALTIME|"); - cmd &= ~FUTEX_CLOCK_REALTIME; +static void print_futex_op(int cmd, int last) +{ + static const char * const futex_names[] = { +#define NAME(X) [X] = #X + NAME(FUTEX_WAIT), + NAME(FUTEX_WAKE), + NAME(FUTEX_FD), + NAME(FUTEX_REQUEUE), + NAME(FUTEX_CMP_REQUEUE), + NAME(FUTEX_WAKE_OP), + NAME(FUTEX_LOCK_PI), + NAME(FUTEX_UNLOCK_PI), + NAME(FUTEX_TRYLOCK_PI), + NAME(FUTEX_WAIT_BITSET), + NAME(FUTEX_WAKE_BITSET), + NAME(FUTEX_WAIT_REQUEUE_PI), + NAME(FUTEX_CMP_REQUEUE_PI), + NAME(FUTEX_LOCK_PI2), +#undef NAME + }; + + unsigned base_cmd = cmd & FUTEX_CMD_MASK; + + if (base_cmd < ARRAY_SIZE(futex_names)) { + qemu_log("%s%s%s", + (cmd & FUTEX_PRIVATE_FLAG ? "FUTEX_PRIVATE_FLAG|" : ""), + (cmd & FUTEX_CLOCK_REALTIME ? "FUTEX_CLOCK_REALTIME|" : ""), + futex_names[base_cmd]); + } else { + qemu_log("0x%x", cmd); } -#endif - print_op(FUTEX_WAIT) - print_op(FUTEX_WAKE) - print_op(FUTEX_FD) - print_op(FUTEX_REQUEUE) - print_op(FUTEX_CMP_REQUEUE) - print_op(FUTEX_WAKE_OP) - print_op(FUTEX_LOCK_PI) - print_op(FUTEX_UNLOCK_PI) - print_op(FUTEX_TRYLOCK_PI) -#ifdef FUTEX_WAIT_BITSET - print_op(FUTEX_WAIT_BITSET) -#endif -#ifdef FUTEX_WAKE_BITSET - print_op(FUTEX_WAKE_BITSET) -#endif - /* unknown values */ - qemu_log("%d", cmd); } static void @@ -3763,6 +3756,9 @@ print_futex(CPUArchState *cpu_env, const struct syscallname *name, switch (op) { case FUTEX_WAIT: case FUTEX_WAIT_BITSET: + case FUTEX_LOCK_PI: + case FUTEX_LOCK_PI2: + case FUTEX_WAIT_REQUEUE_PI: print_timespec(arg3, 0); break; default: From patchwork Wed Sep 28 20:27:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 610100 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp510690pvb; Wed, 28 Sep 2022 14:14:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM49Fz9q8v23OiA4YAQORkJVFwGPIP2jIUrsxGJqild3Yt8YyYvCjmFgCOb1Y+WmX4xUcrbZ X-Received: by 2002:a05:6214:5e89:b0:4ad:77be:92d2 with SMTP id mm9-20020a0562145e8900b004ad77be92d2mr46116qvb.44.1664399656951; Wed, 28 Sep 2022 14:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664399656; cv=none; d=google.com; s=arc-20160816; b=QIAFt2LESDa7dKHZXpORGtYzqluVs2DI6EQ4yVKQ6mdtdoENqsTjyfENjeU5iHjX6d aZIPolAdfH7vhZb3trVo+TrV2aMPFp1dZ2xGBoW2XNVEMgpM1KrPaMqvP7FBqiY5k9j4 HZ9reubNlwsWG3SlNoHzmN6JVDsEHEMaSrwojKGysjcoOidPhh1B7LizcioUDCW0wIs2 EbV10r7XzEVAt1yIvAkaaIMUcREV+Ac8+48EYkqUI+idf15+mO7mv9GDAateqRHQ/hrk mmOFDdFDn6EB8+1ZTdEbuFB6FcTCq62gyKmkY405q63+Jf0N3QBaWFK/bfngPCFCzj6r INqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=c2yVu58Igc/rF97GdGSBnNGv+o/zkcCaimjjWk4smDs=; b=vhAEAC1vr9YTMth7hKR4pIIZ9saD1kHUj+Wx/1v7leuF88Q4T2ef2BhmI8tcnJaTzB JHsUKdkzpib2iQ36vdgXPjN9wHjOMR1btwOdhqwHpNkNcOEOZAVPePCgMhx1ui1ABhem d1K0AJieY0NIRv+mNEGw9YcFZ2tfckBpSf5zht80yeQKiIcXLE59UsyR59RJoZN78vf5 10sP26o/2liv1gRZY+6Uu/m1IEFIMIJg5OBV28936BUVrFp9oJMKi2m76V6DZMr4xFTc 3AepYg34NTBny5Z8oW3ANjW2dOIIO20IBw3dJyzxC8PN8YEeXx1ZQc0w4p6RVvk62BwK duyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f4-20020a05620a408400b006b8ef971f17si285199qko.420.2022.09.28.14.14.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Sep 2022 14:14:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:36224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odeNk-0007mr-H6 for patch@linaro.org; Wed, 28 Sep 2022 17:14:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf7-0000nr-S3 for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:09 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:40413) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oddf5-0006Yq-9u for qemu-devel@nongnu.org; Wed, 28 Sep 2022 16:28:09 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MaInF-1ohGHQ0IwX-00WAlb; Wed, 28 Sep 2022 22:28:05 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 36/37] linux-user: Lock log around strace Date: Wed, 28 Sep 2022 22:27:36 +0200 Message-Id: <20220928202737.793171-37-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928202737.793171-1-laurent@vivier.eu> References: <20220928202737.793171-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:ICkfNbLA3GARt9rmqMcZa7OiDge8auiR8jnvWVpmopwJz/D8/G7 o/kKuoe6V5kEysrqjZNXg8YP9SHUo2H84wQvCpMwu/EXAOIsyyeDcycXFAYuGGBMBWSMswU Fw9eO2RsOGg+E+KdRfutSOF50zVMhix/+BLwNtMqklSbd94weXAC+hvV9M9zKbXx3bFGTfD e6mi95iZcSruNwJvqi7zw== X-UI-Out-Filterresults: notjunk:1;V03:K0:7hhY9wMUQAU=:VEuOuG2sExr9lbVtUeJJrU 8g1PnfZfby/8Waq60zgT+I6+R6c8VXxAg2n1TNtSgmLDnhemSNG/LvS0pZBfrlPqpfRHkjwJd F6RSNWdoiQtEFbVgrmFxLyQYzymi5t8XU1MiHsdliaVhkil3u/SH5tXaL6LgufessOma167m1 ENEuq58Q8tuLegW3afDtm4ASNO79Y9BGJP9KqGuo1JfXy9IFRmG7hFHa8gEstEUD+PE3Zuyw2 ERlaKuCU0jaU+fXrZUvyOMISeVN6q7xMoiQKCUmbtnkAjtgCabm7q7od/g/8FY7eudIY+OcsD N21zVr/pdl4R5Vzwy/qBuSMSa5/LCr14+t6VgrmuwuRrXIj+grjKXqDZpKcqAHR/qM6OMYLMQ Ep3zVP83BW0tARegEjdJeFR9wLexTUgQWXFYk2l+6WlztOpAFxo0gRQQ4OVzJDl6AkRFDZahc 8nKJbqwljfyoY7kuwnyWm8o//dwqkbk9elH5H956W40/U51Hj0D6Lr6KXlk3kjyEf54bpaTJ0 JE3L/D56pxnyVfr3SJb8NiRmLfhr3Nm4nSR4lTKHh8JsObT7gB607IF3D5Ie9x7b3QKbqj30A KcF29xicxnQKM432tVj6zG3+uYl4sIIMREbUHVMoWfeq/MHQwSb/YsNhtrw3+sGgymUF78peL kfFFwuzBbftjChtPsmeJWfvTMfsSO0jZ6GY+bWQXN0ScbBWM99G6kJRlayYJCZ+zEq+x4jDEJ aot48RX84LN294U9N1pz0yiprz35hS4JvmI0v/8PIie3CCH/czmJFaOASPkDBjt6Okefqt5/1 yLt04ko Received-SPF: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Do not allow syscall arguments to be interleaved between threads. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220829021006.67305-8-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 65 ++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index faa733125624..37bc96df9bb6 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -3919,26 +3919,37 @@ print_syscall(CPUArchState *cpu_env, int num, abi_long arg4, abi_long arg5, abi_long arg6) { int i; - const char *format="%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")"; + FILE *f; + const char *format = "%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," + TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," + TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")"; - qemu_log("%d ", getpid()); + f = qemu_log_trylock(); + if (!f) { + return; + } + fprintf(f, "%d ", getpid()); - for(i=0;i