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: 12992172 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98B23C32771 for ; Wed, 28 Sep 2022 11:29:49 +0000 (UTC) Received: from localhost ([::1]:55322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odVG8-0000NJ-N8 for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 07:29:48 -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+qemu-devel=archiver.kernel.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