From patchwork Wed Sep 28 08:15:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 610092 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp191093pvb; Wed, 28 Sep 2022 04:28:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7zW4zaKj3I5NqXCqIo6vrwf2FA95AkyrsZiQWVwgTW9XxJfcVD17b24uR3LUOxE27lTMlV X-Received: by 2002:a05:6214:27e9:b0:4aa:9ff0:e8de with SMTP id jt9-20020a05621427e900b004aa9ff0e8demr25093571qvb.99.1664364529315; Wed, 28 Sep 2022 04:28:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664364529; cv=none; d=google.com; s=arc-20160816; b=mWR7/5fRv9cR1JKD5ezdigkYj5ZGrpv8RxcdvIwhMhQllwKcx3fMhRwMdwi/rZW0Ij 1h5ify7G7ShPiE4psbQeRdWoyigiv9dC4s/w+DqYxnCfjKT2OGpizoC0tvoTCEfuRIgh OgL+iw2VPtwVXi9HV/f9uMHP8mdcbe/4sawfRMvaygb36sbuydVLynXXW/rJvv2Hw26D yJullv0FyG2EX5efehkX4NWFb1+RziXbBBQL7EjhnhudnMQy8eby91wG65et4wiZF42o KxRH8KxbtGVNuEQ2odcOPO9rHNBiVmU2PVjNoFF/gsps0rtG0eDgq10eRQZun0M/BKOd AYnQ== 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=QQvTorR0V3OMvI6o6FTU/o3NsTU+bwdd+e4Y9xZmp7zFLC6r9aqGP2qk90ykJfNq// Fvn2O3R7IyCMAXKpgIl8lnRJ9lp7Ug92PVlEzbVHO5QeG+5/c59qe9hlqBca4wzJnZn3 tYDywh5hbkkqYDeFalKtSzdZifDMw5NPQFhDfG+hAln4dcZbzxXfaixy3L6nU9pFeLiR FC9n+rHC23wWNdpHqEN1Fd4DergOp7HmS1tK1U6Abz3oWziWn3DI5BeVE8Ek5obN/0t5 AmmII96U6qIdGfwAiRNY+RIho9hjLbfV2Zh0FBR/24xXTPXikmGL+Y8I7RfzbUEoRG+F eyew== 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 ey8-20020a0562140b6800b004a27d691afesi3380151qvb.383.2022.09.28.04.28.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Sep 2022 04:28:49 -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]:45298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odVF6-00061C-Gy for patch@linaro.org; Wed, 28 Sep 2022 07:28:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEP-0008Ff-HQ for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:53 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:37479) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEL-0008HH-DT for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:48 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MzhWp-1pQLn73msL-00vgUF; Wed, 28 Sep 2022 10:15:37 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 36/38] linux-user: Lock log around strace Date: Wed, 28 Sep 2022 10:15:15 +0200 Message-Id: <20220928081517.734954-37-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:TWXvrr7PU6WcMeI+mKtdiE3jbUWgER8+6r7lUgh/TAqGP5CQGs0 /T380f8LlLO0UdjOd5/cM6g3l7Fdaw+c8cDYAnZ8xuPflft+mKkxd6gghe8LjTwIjwQC8qP UZlNqZxcIbUU6f7QrwTvW4Mp7QGRnzCV5R3tp9EJpfeuLNgBsbgPHQyNlmzNsRnsYFZkeQ0 8W1B9c8gtxY8B0wnHp98Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:7c/b14zdDCg=:hx1cmdsrSQmyEgFoAKy/1a XtipXmOAeWhjj+UvOh9Za0RSOp3H2DTe8DctfTHR7Lg36RP0IWa8mdixDPprgQ4hyxgOnb00B +W18H64eQ0xic88luo/KEkzd1aXm6yb4mIIqhqbGFdJA5+JqC4Eugqk7RCVn9klAua8NTv9/9 jRiMe29VjMlGsQCu1JWt4NZ+Zbrdc0Hyo2mtoaaCD84kna0qxVhDBfxY/3SeDpZS+V2Swv9ku OChp6rsrGq/xJmIqYdZvdnwtriSuTSI0ar9oEitappPjiQpuWVltAFKaXOU8gIiJXWprYitA2 uTgCknPerbGhXb+RCwtWB3j7rQBCA9/ntXQKXtAuVFJgZDtajGyS3Eb16joANY9tQxknHifGo sY0/YihNuWu50jS5B8pPvxoZWdncDWt2lkh/YJU21LY02vmF9il98PNHThPQrTeQEig3Q0siV ZseynwsGZwbrNfQ9DiMZHLSksGY9GR96sQ/bmV3FOjeZtwbno3CrhIn4e/27D9CcqdKcOeT3q pewbbJtfakxP3Fw2z55K3od8yLMgPO7fMT/MYhwmrwScYUnmq8wq2UYK+6xC+QLWiML+ghEty vYNoRTbCDGt3ZToJip0rhRFbqPDWcgOJxx5rfqvlG1ZcbtM83dmHBle6iRXQEG67RAdJFIfwm 0ul5fFgXBBlNbjQ2aAMpR6Ic7/shTyhMJL+Zkl34SomFsyRPFTMsFgfU6FAWKAynLpq2bNZDl 2Xx+/C5nBSNG2TpdJyzqT0/yVxkG3qu/h92gGFzlGk+8y6lWfZ1Zc8oTyoim3PQKFAZqcIP1q Q36uReO Received-SPF: none client-ip=217.72.192.75; 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