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: 12993147 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 007BAC04A95 for ; Wed, 28 Sep 2022 21:15:22 +0000 (UTC) Received: from localhost ([::1]:50510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odeOn-00026S-Rk for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 17:15:21 -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+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