From patchwork Sat Jul 4 16:25:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 278574 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BC27C433E0 for ; Sat, 4 Jul 2020 16:27:21 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D8BB5206B6 for ; Sat, 4 Jul 2020 16:27:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D8BB5206B6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl0a-0007dB-4H for qemu-devel@archiver.kernel.org; Sat, 04 Jul 2020 12:27:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzI-00052r-KZ for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:00 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:36099) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzF-0002NX-Uy for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:00 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MPXlM-1kEOTD2cFe-00Mbtr; Sat, 04 Jul 2020 18:25:53 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 01/12] target/sparc: Translate flushw opcode Date: Sat, 4 Jul 2020 18:25:34 +0200 Message-Id: <20200704162545.311133-2-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200704162545.311133-1-laurent@vivier.eu> References: <20200704162545.311133-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:zJMSMPD1WCs2H/7T1KaIqqNDXh4awHcxaW3nmKyDH0rv+EUv9xx G88TlDnAcjdphBJcwk1Icj299tS5X61pBIaDFUMqHr8p7oB4Z4RL9U8gEGKBOINW09YIY9d KiCWRl5UZkU9iiplnFa8QItDyGjSW+MQxi7xttDhiINbMIOrf4dNuI6hoAtbrBy+iJGEsVm nEA7a9lJxbjyeHNlNEyXg== X-UI-Out-Filterresults: notjunk:1; V03:K0:20r6uQB412g=:qONXXoXnJ+VoT+YBMvr5R9 SecnkV9lLrXKO8m4n0ENqQW14OAXPQ4gkIPI1sYvA0Ojnw0AZVvyF4nVhzSJ21jdTqzel+Y/t c3S2lfUPVzYQja2bydWQZTl+RPkrlnZMKG81Il3P8Q8Ai9KwJlWZ5lUoNbI0lTM7i2oqV1Jy9 I5oy+fcFtLiw3jxtngXsCuyiSR+1SGJQnBa9nGDd7n/EWUtYCsDyKUHNr4vVIj1tXyw7yLVyg YTbZLTxVX0vhElwHX/hmCGwEwnfysWb2AMFMo/PoT5OA2LOTfuzXszmg25Ads+6hes/zY7CDe H43AbnFVwvzNaDbSpVndmu7pR95ceh39HASy+utnDV1ws5u1bSczTsIla1XjLotjqc/9YQf5H ohW+3NQWhWOU3kWomANsswSSAnfZmDezhmJ/02/tPVCtftS69B2nXMKheigUUOUKU1WZi0gHL v704e32nISjgygk8J9dBB7Xx2KDqAewvgH0nUpHJKVQnbaLnMKfEh/r48+nuIezw7Vamm5F5b Js0KqnBQZDFJUyZT5FrSP/G7PA66nrwee5Vab1pkdtI6yeT0gfxz9WxospALkqDTFO9hupcKk XnMIAeIwGKpvcnHQ0NHnEqX8wPhG360KAPAAguhCwxAwvPBWbOrBnysZmuCOEXuAcf+2sratw LrvWHAdAkV6QiHqhHql05NtrYkwI31nQ5V49JrqtRIQ1hvJed+2EQTatVhQFxqiSu4DUZu53x pXzTwHupe49AVIDZUiNbrUBauvN6yMOaCJkkA9UEw7Cz5nUoQCyMKKolSIoMYkxHrpV7uH+Sb UE2R5JR429d08JKHZo5nqaYQ1Sdo2uwJMIIAhPbpyFfg9gFkzE= Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 12:25:55 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=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: Giuseppe Musacchio , Mark Cave-Ayland , Riku Voipio , Richard Henderson , Laurent Vivier , Artyom Tarasenko Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Giuseppe Musacchio The ifdef logic should unconditionally compile in the `xop == 0x2b` case when targeting sparc64. Signed-off-by: Giuseppe Musacchio Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <20200625091204.3186186-2-laurent@vivier.eu> --- target/sparc/translate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 9416a551cf46..1a4efd4ed665 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -3663,6 +3663,8 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) #endif gen_store_gpr(dc, rd, cpu_tmp0); break; +#endif +#if defined(TARGET_SPARC64) || !defined(CONFIG_USER_ONLY) } else if (xop == 0x2b) { /* rdtbr / V9 flushw */ #ifdef TARGET_SPARC64 gen_helper_flushw(cpu_env); From patchwork Sat Jul 4 16:25:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 278573 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B94C3C433DF for ; Sat, 4 Jul 2020 16:28:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8A302206B6 for ; Sat, 4 Jul 2020 16:28:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A302206B6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl20-0001ua-Q0 for qemu-devel@archiver.kernel.org; Sat, 04 Jul 2020 12:28:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzI-00053O-VH for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:00 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:40589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzG-0002Nf-3U for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:00 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MVvGt-1kJYkZ1G0j-00RmpQ; Sat, 04 Jul 2020 18:25:54 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 02/12] linux-user/sparc64: Fix the handling of window spill trap Date: Sat, 4 Jul 2020 18:25:35 +0200 Message-Id: <20200704162545.311133-3-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200704162545.311133-1-laurent@vivier.eu> References: <20200704162545.311133-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:CZpX6YXxb7WOdVWhB9j9G6aVu4bzOf2oJWOAAtQezpH5aN5AZOD HE9BNn7lyhrixircWt3LQecA7EGMAmPl9d6op527Yvn4Lv1slsRRrkgXEiuIdn6/ujqWNew bLKqg9D7AdcKpFQQkDu/jIrKjotdb/c+ROlVCwoRb7WsMC029dzpr6h6nE0kZPjmKF9D/Lv ljEiza9bQu4MoNXgnltuQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:LF5MlfSwLoU=:fIVAsQp4pfVZJEZplL46hP Y3UPx4KpHUN1ih87pVvt9KyB882y3WLKvxwCTXns44vGVC5++8DszGn/zV2w15Yg3/08CBUnW dTYT66UC6UWJXlaPMOWPBMtR1ExyWGrLjmLEf4JUfOYxQEPZC92mHVmG7hBAcLqo6jCkbvY4d bF/nr9m4pd984tWvcxvuoziyfiKGoB6A+MJsNhZ6V7rRDCV7IHOxVfbkfvaeS8BbGpw7l3HLb 08BVU7LAQsikox3iKss08JDvZs1TjwWTxEBc5OxS/v8BhpCmKj4/xNg89pPSyfCnldkp8rNgi TZKNn/6ZF8/KQxddR3TFaM3961I15YCq5iESTbmyFKSpqlDbcqNbZNDP/lwgwcR+aCaAZqZ9s RQ+hxzHm6fy5XSAjPYmcKD768wrFHwkvP0roLRmXnY58aD1TXF87WAkhTXBVNsgOSES7hU1oD Il2DIjJaG/h0fJI6Td9SKNu7XFDkP6pO7yqm0UHBO0WT+XaYd9pr1xvVPs2+j1pS/JkSXkcgc yMOHE4R25hFLDgtn+BuqgYHT3zG2azJ1u+x2x1fLZ1X0P/0W8MVakSZhM8kcq8gWUD2bqhuFZ ALgdDDK1nU/D6vxidVabFDOKRIlaLOhgp1UgFfB87daOJ6PPEqi7BBJ0XASNV8dDcUOJA5uD8 iAJjIS8noQDKKvVGZMB4SqD8Q+E6npFTO2BN3/TWSfuqRdlwmrco27/hYYhZ3aj6Fy2nutjpW 0baRGtqX0P+ZNkeoF+s+x03InsMFO3PeJAccrRIk9yfCxPuaYCfogdk8xwuqU5em+iSwNcSo4 Qks77ehtyP9gLRIrKH8tDRwo7KTgzykrS53MYWTFwLHHXqVvTw= Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 12:25:56 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=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: Giuseppe Musacchio , Mark Cave-Ayland , Riku Voipio , Richard Henderson , Laurent Vivier , Artyom Tarasenko Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Giuseppe Musacchio Fix the handling of window spill traps by keeping cansave into account when calculating the new CWP. Signed-off-by: Giuseppe Musacchio Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <20200625091204.3186186-3-laurent@vivier.eu> --- bsd-user/main.c | 6 +++++- linux-user/sparc/cpu_loop.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 0bfe46cff93e..ac40d79bfaac 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -413,7 +413,11 @@ static void save_window(CPUSPARCState *env) save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); env->wim = new_wim; #else - save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); + /* + * cansave is zero if the spill trap handler is triggered by `save` and + * nonzero if triggered by a `flushw` + */ + save_window_offset(env, cpu_cwp_dec(env, env->cwp - env->cansave - 2)); env->cansave++; env->canrestore--; #endif diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 7645cc04ca73..02532f198df8 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -69,7 +69,11 @@ static void save_window(CPUSPARCState *env) save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); env->wim = new_wim; #else - save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); + /* + * cansave is zero if the spill trap handler is triggered by `save` and + * nonzero if triggered by a `flushw` + */ + save_window_offset(env, cpu_cwp_dec(env, env->cwp - env->cansave - 2)); env->cansave++; env->canrestore--; #endif From patchwork Sat Jul 4 16:25:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 278570 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14F82C433E0 for ; Sat, 4 Jul 2020 16:34:30 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id CE96C20724 for ; Sat, 4 Jul 2020 16:34:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE96C20724 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl7V-0001fw-2K for qemu-devel@archiver.kernel.org; Sat, 04 Jul 2020 12:34:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzX-0005Tw-Na for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:15 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:51321) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzQ-0002PP-HT for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:14 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MulyX-1kjJJN21z9-00rnzO; Sat, 04 Jul 2020 18:25:58 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 05/12] linux-user: Add strace support for a group of syscalls Date: Sat, 4 Jul 2020 18:25:38 +0200 Message-Id: <20200704162545.311133-6-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200704162545.311133-1-laurent@vivier.eu> References: <20200704162545.311133-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:qe57hQRhfBDJQOgfjZj7Dgsl40shKE68Jo0N/0JuhK0mjBPtIcy rss6qmCcWiImDOp6cKRsP/NbNF3+Q3UMlnGX/5oV9RzmYo7NTWC+cevpxg05lvbd742OrQe JeSycWR7c5Ptemwk1yti4MiUZ9Dln4HavW6czkibASrcfYr2uWfxVT7fH4Osf6JtP1MnO39 XwEfZJlbS9Jk0zxb+T/dA== X-UI-Out-Filterresults: notjunk:1; V03:K0:Bot2vp0/3eY=:QDiOupgX6JcGXkUGe2ABfn R7sDzSOI8hxFevjYrWsINImzd8kW6/bbDxJdl/LhSwRNBN+wmloFyiVTMro4ygqb3+CWFvC3z 8MEnvUXm6w7MkYGJh0uDgKzenF2ARSE4tDl3zVES88RtmTeRZP8r7BkxPY2zVZ7oELzmDNPgl DOWMXYsd/eqrtDsj+p1BpMXRPGS58KhWHoS5Njf67+MHngq5f/l4cBjXqjIwf7nrfL0qDXHci sEhMc/sdEH9pTppJ+ECnT2Dz7AeEl/X3RMam8939KeGmmcuTXlnnthEop14eEapt4YOIyC+KE 20PIcnaX/qGNfl4U4MsX6Sx1SZzqL/LxY84aQtcm4IPOasPtduHyHwPanDhRskN354M58dCsd JvMTczHjameAe6rAFgZoYLFxGaJpwCPxov+013RsOT9ftHWH2dloW2fYr9MhH5QIQHn0Y5U43 vXZYFRkbbS2MZlbW7cKcH+mOooU2U8MfNZs6QxXXADLCLonqBPYsDn+J//Ql+EFTbP9ARHAcJ MgkMjSSZHhE9ZCep6NdxdlcZuzbJFONJNd8GRk/PFJESMW/kI1wyWrtkqatNaOQpLxQx97CXv wHJejzpLJ3inBEzdMim9qGKVOK8z6fvZPsbOSERuLBehzUxe6YoBqfNKLc5bdj6eRIXMlctmV Pn7BO8/ZsrEZjZPYkKJqsmoXmACl8mjjY0TLuwZBy1n0MEI4we/kzj3ur0hAnIGrR4iW0NyJ4 dgj4pNWyaH3/a0PeXYtX3SOQEP00xMkRzPHNksQ+HiAIsfvBeZTk6Cn66Uqms9ymvLqBpeiZo M3F4D/JBVUm/D+VWV87QJmoOxewd/zA9Xw12ZCwhg4k2FxA8PY= Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 12:25:55 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=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: Filip Bozuta , Riku Voipio , Mark Cave-Ayland , Laurent Vivier , Artyom Tarasenko Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscalls: *acct - switch process accounting on or off int acct(const char *filename) man page: https://www.man7.org/linux/man-pages/man2/acct.2.html *fsync, fdatasync - synchronize a file's in-core state with storage device int fsync(int fd) int fdatasync(int fd) man page: https://www.man7.org/linux/man-pages/man2/fsync.2.html *listen - listen for connections on a socket int listen(int sockfd, int backlog) man page: https://www.man7.org/linux/man-pages/man2/listen.2.html Implementation notes: Syscall acct() takes string as its only argument and thus a separate print function "print_acct" is stated in file "strace.list". This function is defined and implemented in "strace.c" by using an existing function used to print string arguments: "print_string()". All the other syscalls have only primitive argument types, so the rest of the implementation was handled by stating an appropriate printing format in file "strace.list". Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200619123331.17387-3-filip.bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 13 ++++++++++++- linux-user/strace.list | 8 ++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 62117e8555f6..123e022c35bf 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1357,6 +1357,18 @@ print_access(const struct syscallname *name, } #endif +#ifdef TARGET_NR_acct +static void +print_acct(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_string(arg0, 1); + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_brk static void print_brk(const struct syscallname *name, @@ -1621,7 +1633,6 @@ print_fcntl(const struct syscallname *name, #define print_fcntl64 print_fcntl #endif - #ifdef TARGET_NR_futimesat static void print_futimesat(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 9281c0a75828..8a887fc16dcc 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -13,7 +13,7 @@ { TARGET_NR_access, "access" , NULL, print_access, NULL }, #endif #ifdef TARGET_NR_acct -{ TARGET_NR_acct, "acct" , NULL, NULL, NULL }, +{ TARGET_NR_acct, "acct" , NULL, print_acct, NULL }, #endif #ifdef TARGET_NR_add_key { TARGET_NR_add_key, "add_key" , NULL, NULL, NULL }, @@ -215,7 +215,7 @@ { TARGET_NR_fcntl64, "fcntl64" , NULL, print_fcntl64, NULL }, #endif #ifdef TARGET_NR_fdatasync -{ TARGET_NR_fdatasync, "fdatasync" , NULL, NULL, NULL }, +{ TARGET_NR_fdatasync, "fdatasync" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_fgetxattr { TARGET_NR_fgetxattr, "fgetxattr" , NULL, NULL, NULL }, @@ -251,7 +251,7 @@ { TARGET_NR_fstatfs64, "fstatfs64" , "%s(%d,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_fsync -{ TARGET_NR_fsync, "fsync" , NULL, NULL, NULL }, +{ TARGET_NR_fsync, "fsync" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_ftime { TARGET_NR_ftime, "ftime" , NULL, NULL, NULL }, @@ -492,7 +492,7 @@ { TARGET_NR_Linux, "Linux" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_listen -{ TARGET_NR_listen, "listen" , NULL, NULL, NULL }, +{ TARGET_NR_listen, "listen" , "%s(%d,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_listxattr { TARGET_NR_listxattr, "listxattr" , NULL, NULL, NULL }, From patchwork Sat Jul 4 16:25:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 278572 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21905C433DF for ; Sat, 4 Jul 2020 16:29:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EFE4C20782 for ; Sat, 4 Jul 2020 16:29:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EFE4C20782 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl2V-0002gn-8e for qemu-devel@archiver.kernel.org; Sat, 04 Jul 2020 12:29:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzX-0005UJ-Qv for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:15 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:49483) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzT-0002Pj-V3 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:15 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mq2rM-1keYCx3cLS-00nBG7; Sat, 04 Jul 2020 18:26:02 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 10/12] linux-user: Add thunk argument types for SIOCGSTAMP and SIOCGSTAMPNS Date: Sat, 4 Jul 2020 18:25:43 +0200 Message-Id: <20200704162545.311133-11-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200704162545.311133-1-laurent@vivier.eu> References: <20200704162545.311133-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:pTTCOxm2ObIFqhLPF/KT8+Fby1UqCBeHIhaRvTpY31mrNZRQrPT iMsJmXhASEu77lIURFFp52J8U9lPS1MrSkOVXVu8/BAqOxi1hYrF9lfd7Lq6cZDYMIq0oyZ KqFS/wN2TZZVuX3RVe8CXi9JWe4kwJ3oBBqsMoV66wXTGuJdKq56gWKJoKbJEuQcA2L+tN5 ups1U59LsX+M3KSYJvyYA== X-UI-Out-Filterresults: notjunk:1; V03:K0:Rv6DaqYj6K4=:6xM3IcwC1R7bl+7SQ0VJuJ 2zkPdYL9kOAYwmY+Dm0uMg7LVmBxsRm9kag+gmWfZmSYFjbSxHiQMifr4tUGEHf4FGvboUutZ oq5Rzgr5Uue35Ql33bGXAscW12omMGjUEwpChwcIcwWfWthD1W6/TM8Zy3BN0GZj2oIMwBd+V 21h0AoQQXrSVd3IBmB6ioIgOcR4jV/B7Oyp7vipkZYOtHHY+kUttiBAMmYeIFmowUfd8/1Yrp I3Qr51yWO6t8vGdUe8B6JIu91hVG3louz0/XKkllytzdDwZJLW157jqZGAQiSjW67ZtklPSbL oRTC3n398ux2PpbBm97kb0spyY+AfiH3yHEQsOfG+RD9J25u3WOlNI1fikCB87D/vQBoTjaAf Dlx791k8kWIFJPWG4Be4mpuu8rW3u9uEi6YewHJVi+C/6oVUtqa9H/AwvDI9gbZNZwP5n7lXN 0EvWRqifkISyjjPzrvaUD/ZSjPAqYOr8rt7I469Gb4kC18BQeCPsMVHGpv5MsAv83krBuhKUn RNIXlQVQwttPQDZMnZIvcg2ERyArPId+D5WH5usOHT+qwwSkUqDSNOZ/1aPOjfXRMWQjgb5p/ CqAYNY39WF70u6Q9vWv+g14USqzhQJGli44blwnEjvP/FpLMAVAnmWrP/Xf1VVuYm/91Nh3D1 PICJq9YAj25dXcdO++sgjwJchGin9tf4arjKdSI2wjaLXH7jNgEVo31nvq5gle9ye2HbCcTvF dv6KAoEw6PsOJnlOWslW+FMuuncU+431DOt+PyMehowcid2o9Hq5sUDDKSiOjQVg6PMwzvE/x FeOXypCf2oWJdn/eDfXLPGyYdTBgrbqa6n3FyxmvVrZ5fLiMHM= Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 12:25:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=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: Filip Bozuta , Riku Voipio , Mark Cave-Ayland , Laurent Vivier , Artyom Tarasenko Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta Socket ioctls SIOCGSTAMP and SIOCGSTAMPNS, used for timestamping the socket connection, are defined in file "ioctls.h" differently from other ioctls. The reason for this difference is explained in the comments above their definition. These ioctls didn't have defined thunk argument types before changes from this patch. They have special handling functions ("do_ioctl_SIOCGSTAMP" and "do_ioctl_SIOCGSTAMPNS") that take care of setting values for approppriate argument types (struct timeval and struct timespec) and thus no thunk argument types were needed for their implementation. But this patch adds those argument type definitions in file "syscall_types.h" and "ioctls.h" as it is needed for printing arguments of these ioctls with strace. Implementation notes: There are two variants of these ioctls: SIOCGSTAMP_OLD/SIOCGSTAM_NEW and SIOCGSTAMPNS_OLD/SIOCGSTAMPNS_NEW. One is the old existing definition and the other is the 2038 safe variant used for 32-bit architectures. Corresponding structure definitions STRUCT_timespec/STRUCT__kernel_timespec and STRUCT_timeval/STRUCT__kernel_sock_timeval were added for these variants. STRUCT_timeval definition was already inside the file as it is used by another implemented ioctl. Two cases were added for definitions STRUCT_timeval/STRUCT__kernel_sock_timeval to manage the case when the "u_sec" field of the timeval structure is of type int. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200619124727.18080-2-filip.bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 12 ++++++++---- linux-user/syscall_types.h | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index f2e2fa9c878b..0713ae131162 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -279,13 +279,17 @@ * FIXME: create a macro to define this kind of entry */ { TARGET_SIOCGSTAMP_OLD, TARGET_SIOCGSTAMP_OLD, - "SIOCGSTAMP_OLD", IOC_R, do_ioctl_SIOCGSTAMP }, + "SIOCGSTAMP_OLD", IOC_R, do_ioctl_SIOCGSTAMP, + { MK_PTR(MK_STRUCT(STRUCT_timeval)) } }, { TARGET_SIOCGSTAMPNS_OLD, TARGET_SIOCGSTAMPNS_OLD, - "SIOCGSTAMPNS_OLD", IOC_R, do_ioctl_SIOCGSTAMPNS }, + "SIOCGSTAMPNS_OLD", IOC_R, do_ioctl_SIOCGSTAMPNS, + { MK_PTR(MK_STRUCT(STRUCT_timespec)) } }, { TARGET_SIOCGSTAMP_NEW, TARGET_SIOCGSTAMP_NEW, - "SIOCGSTAMP_NEW", IOC_R, do_ioctl_SIOCGSTAMP }, + "SIOCGSTAMP_NEW", IOC_R, do_ioctl_SIOCGSTAMP, + { MK_PTR(MK_STRUCT(STRUCT__kernel_sock_timeval)) } }, { TARGET_SIOCGSTAMPNS_NEW, TARGET_SIOCGSTAMPNS_NEW, - "SIOCGSTAMPNS_NEW", IOC_R, do_ioctl_SIOCGSTAMPNS }, + "SIOCGSTAMPNS_NEW", IOC_R, do_ioctl_SIOCGSTAMPNS, + { MK_PTR(MK_STRUCT(STRUCT__kernel_timespec)) } }, IOCTL(RNDGETENTCNT, IOC_R, MK_PTR(TYPE_INT)) IOCTL(RNDADDTOENTCNT, IOC_W, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index e2b0484f50e5..3f1f0334649b 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -137,10 +137,32 @@ STRUCT(snd_timer_params, TYPE_INT, /* filter */ MK_ARRAY(TYPE_CHAR, 60)) /* reserved */ +#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) +STRUCT(timeval, + TYPE_LONG, /* tv_sec */ + TYPE_INT) /* tv_usec */ + +STRUCT(_kernel_sock_timeval, + TYPE_LONG, /* tv_sec */ + TYPE_INT) /* tv_usec */ +#else +STRUCT(timeval, + TYPE_LONG, /* tv_sec */ + TYPE_LONG) /* tv_usec */ + +STRUCT(_kernel_sock_timeval, + TYPE_LONGLONG, /* tv_sec */ + TYPE_LONGLONG) /* tv_usec */ +#endif + STRUCT(timespec, TYPE_LONG, /* tv_sec */ TYPE_LONG) /* tv_nsec */ +STRUCT(_kernel_timespec, + TYPE_LONGLONG, /* tv_sec */ + TYPE_LONGLONG) /* tv_nsec */ + STRUCT(snd_timer_status, MK_STRUCT(STRUCT_timespec), /* tstamp */ TYPE_INT, /* resolution */ From patchwork Sat Jul 4 16:25:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 278569 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1549C433E0 for ; Sat, 4 Jul 2020 16:35:58 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 62F9520723 for ; Sat, 4 Jul 2020 16:35:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62F9520723 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl8v-00045E-L6 for qemu-devel@archiver.kernel.org; Sat, 04 Jul 2020 12:35:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkza-0005Y9-7H for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:18 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:51375) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzV-0002QW-Da for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:17 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N6bo8-1kzVP223vq-0180Sl; Sat, 04 Jul 2020 18:26:02 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 11/12] linux-user: Add strace support for printing arguments of ioctl() Date: Sat, 4 Jul 2020 18:25:44 +0200 Message-Id: <20200704162545.311133-12-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200704162545.311133-1-laurent@vivier.eu> References: <20200704162545.311133-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:3jdLZ4I29TuXL7Hg0KMy9NfjIrXvdUxJ6Tr1OzjUxCT4M5ViJae IbNHAbWSm86VJoh99q2f6w8MXYFP6a8DmZR58apKJUHgSQXzc4r9JbGKXGcGfv3decWzCDl +W07cfND+6Ufx6Mn10C6/aQ8KjTD6axSDjyFPmRkkPe1I4Tas7ULYi4MUKztYsWZmoI5d2r /79q29a6EN3YMVAW8vYNw== X-UI-Out-Filterresults: notjunk:1; V03:K0:0z1CpmjPsDU=:eL0tPhuxd2NpB/kGUgFN0y D6u2B0bVLGNjjgaLgWYxvXDs2AkcXB1FrRUdt+9gud1LFdraWCnlvYB6zz55S9r7YiSOHTR5k JtoHwaSZKR4l5FlGP0QX3jDHo9LlHPCkDpGE5ji1ljfTf1i0C7x2iMqCKnpa/7FwPoZITGqNK XAkDMH94d7n0+xq4ohgiQ29trX3FInsQ9IULlZXGPW02nTVOoSuO4ecBll1ugMx5sEN8LA6VF lvXOpSv1ty5AL2EtyjyxxrzFYhN9TkVcdf/LThEKv0HGcfuX0CflQUZ0sq1giZzRbD2xAd0ZW UpNDaKU7vgToiUTZ3pRc7f1GM3h9jjLTaFQUCDyviwF4TPFdzYwNcod6VShnrp1zRmcjaFQQC XEt8mxW2ODz2Gv+N+LM79hh08NyTntPkbUqH+bSJNv+cEFe5/BEdh9OovowA6Z7eY/VJ4iBQM JqrACWMOIaU0OVm987uQ1fWqKj5S8/aYHI0LJONJdNESp8O4pi6X6zNem3eJJepG77dNURlpK b19VfU+7Rl6esywHWptEjb2PN8nVoQ6fiDub4LmLO2Gx3ks2ItRSJXoRvXOwh2NHdhRY0XsZf DD/Gr7GNF/Trn0NW4fHra5xEFs6oN4SsznYafCBCgqama/hR0/6ComR4/I0/34FHvLfo+bbCb FVdQNs+ik5uIzZArQF2vzt/vHfu1pEAcQ5yWhTjauwQLoN4W78Xzs34q2ibq3ZeIYzq+k9Ql/ HZYLuv1YlBa79AWWaJ/NtbZjVyHfhmWSsFge+fL9xGZX3X1soG6MU1J4rtcsFTSO4qomVxsET FSKVIlwo8+EjU2Nwc7aDSYLOwlmBCUWZpx+PvJuixT8245kvrs= Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 12:26:01 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=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: Filip Bozuta , Riku Voipio , Mark Cave-Ayland , Laurent Vivier , Artyom Tarasenko Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality for strace argument printing for ioctls. When running ioctls through qemu with "-strace", they get printed in format: "ioctl(fd_num,0x*,0x*) = ret_value" where the request code an the ioctl's third argument get printed in a hexadicemal format. This patch changes that by enabling strace to print both the request code name and the contents of the third argument. For example, when running ioctl RTC_SET_TIME with "-strace", with changes from this patch, it gets printed in this way: "ioctl(3,RTC_SET_TIME,{12,13,15,20,10,119,0,0,0}) = 0" In case of IOC_R type ioctls, the contents of the third argument get printed after the return value, and the argument inside the ioctl call gets printed as pointer in hexadecimal format. For example, when running RTC_RD_TIME with "-strace", with changes from this patch, it gets printed in this way: "ioctl(3,RTC_RD_TIME,0x40800374) = 0 ({22,9,13,11,5,120,0,0,0})" In case of IOC_RW type ioctls, the contents of the third argument get printed both inside the ioctl call and after the return value. Implementation notes: Functions "print_ioctl()" and "print_syscall_ret_ioctl()", that are defined in "strace.c", are listed in file "strace.list" as "call" and "result" value for ioctl. Structure definition "IOCTLEntry" as well as predefined values for IOC_R, IOC_W and IOC_RW were cut and pasted from file "syscall.c" to file "qemu.h" so that they can be used by these functions to print the contents of the third ioctl argument. Also, the "static" identifier for array "ioctl_entries[]" was removed and this array was declared as "extern" in "qemu.h" so that it can also be used by these functions. To decode the structure type of the ioctl third argument, function "thunk_print()" was defined in file "thunk.c" and its definition is somewhat simillar to that of function "thunk_convert()". Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200619124727.18080-3-filip.bozuta@syrmia.com> [lv: fix close-bracket] Signed-off-by: Laurent Vivier --- include/exec/user/thunk.h | 1 + linux-user/qemu.h | 20 +++++ linux-user/strace.c | 107 ++++++++++++++++++++++++++ linux-user/strace.list | 3 +- linux-user/syscall.c | 20 +---- thunk.c | 154 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 285 insertions(+), 20 deletions(-) diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h index eae2c27f99da..7992475c9f8a 100644 --- a/include/exec/user/thunk.h +++ b/include/exec/user/thunk.h @@ -73,6 +73,7 @@ void thunk_register_struct_direct(int id, const char *name, const StructEntry *se1); const argtype *thunk_convert(void *dst, const void *src, const argtype *type_ptr, int to_host); +const argtype *thunk_print(void *arg, const argtype *type_ptr); extern StructEntry *struct_entries; diff --git a/linux-user/qemu.h b/linux-user/qemu.h index be67391ba49d..5c964389c101 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -184,6 +184,26 @@ struct linux_binprm { int (*core_dump)(int, const CPUArchState *); /* coredump routine */ }; +typedef struct IOCTLEntry IOCTLEntry; + +typedef abi_long do_ioctl_fn(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, int cmd, abi_long arg); + +struct IOCTLEntry { + int target_cmd; + unsigned int host_cmd; + const char *name; + int access; + do_ioctl_fn *do_ioctl; + const argtype arg_type[5]; +}; + +extern IOCTLEntry ioctl_entries[]; + +#define IOC_R 0x0001 +#define IOC_W 0x0002 +#define IOC_RW (IOC_R | IOC_W) + void do_init_thread(struct target_pt_regs *regs, struct image_info *infop); abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, abi_ulong stringp, int push_ptr); diff --git a/linux-user/strace.c b/linux-user/strace.c index 32e5e987acbb..5235b2260cdd 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -860,6 +860,44 @@ print_syscall_ret_listxattr(const struct syscallname *name, abi_long ret, #define print_syscall_ret_flistxattr print_syscall_ret_listxattr #endif +#ifdef TARGET_NR_ioctl +static void +print_syscall_ret_ioctl(const struct syscallname *name, abi_long ret, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_err(ret); + + if (ret >= 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); + + const IOCTLEntry *ie; + const argtype *arg_type; + void *argptr; + int target_size; + + for (ie = ioctl_entries; ie->target_cmd != 0; ie++) { + if (ie->target_cmd == arg1) { + break; + } + } + + if (ie->target_cmd == arg1 && + (ie->access == IOC_R || ie->access == IOC_RW)) { + arg_type = ie->arg_type; + qemu_log(" ("); + arg_type++; + target_size = thunk_type_size(arg_type, 0); + argptr = lock_user(VERIFY_READ, arg2, target_size, 1); + thunk_print(argptr, arg_type); + unlock_user(argptr, arg2, target_size); + qemu_log(")"); + } + } + qemu_log("\n"); +} +#endif + UNUSED static struct flags access_flags[] = { FLAG_GENERIC(F_OK), FLAG_GENERIC(R_OK), @@ -3026,6 +3064,75 @@ print_statx(const struct syscallname *name, } #endif +#ifdef TARGET_NR_ioctl +static void +print_ioctl(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + + const IOCTLEntry *ie; + const argtype *arg_type; + void *argptr; + int target_size; + + for (ie = ioctl_entries; ie->target_cmd != 0; ie++) { + if (ie->target_cmd == arg1) { + break; + } + } + + if (ie->target_cmd == 0) { + print_raw_param("%#x", arg1, 0); + print_raw_param("%#x", arg2, 1); + } else { + qemu_log("%s", ie->name); + arg_type = ie->arg_type; + + if (arg_type[0] != TYPE_NULL) { + qemu_log(","); + + switch (arg_type[0]) { + case TYPE_PTRVOID: + print_pointer(arg2, 1); + break; + case TYPE_CHAR: + case TYPE_SHORT: + case TYPE_INT: + print_raw_param("%d", arg2, 1); + break; + case TYPE_LONG: + print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); + break; + case TYPE_ULONG: + print_raw_param(TARGET_ABI_FMT_lu, arg2, 1); + break; + case TYPE_PTR: + switch (ie->access) { + case IOC_R: + print_pointer(arg2, 1); + break; + case IOC_W: + case IOC_RW: + arg_type++; + target_size = thunk_type_size(arg_type, 0); + argptr = lock_user(VERIFY_READ, arg2, target_size, 1); + thunk_print(argptr, arg_type); + unlock_user(argptr, arg2, target_size); + break; + } + break; + default: + g_assert_not_reached(); + } + } + } + print_syscall_epilogue(name); +} +#endif + /* * An array of all of the syscalls we know about */ diff --git a/linux-user/strace.list b/linux-user/strace.list index ebb713252ce3..a04706a524ae 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -433,7 +433,8 @@ { TARGET_NR_io_cancel, "io_cancel" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_ioctl -{ TARGET_NR_ioctl, "ioctl" , "%s(%d,%#x,%#x)", NULL, NULL }, +{ TARGET_NR_ioctl, "ioctl" , NULL, print_ioctl, + print_syscall_ret_ioctl}, #endif #ifdef TARGET_NR_io_destroy { TARGET_NR_io_destroy, "io_destroy" , NULL, NULL, NULL }, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 506b94a12c1e..82afadcea0e2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4481,24 +4481,6 @@ STRUCT_MAX #undef STRUCT #undef STRUCT_SPECIAL -typedef struct IOCTLEntry IOCTLEntry; - -typedef abi_long do_ioctl_fn(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, int cmd, abi_long arg); - -struct IOCTLEntry { - int target_cmd; - unsigned int host_cmd; - const char *name; - int access; - do_ioctl_fn *do_ioctl; - const argtype arg_type[5]; -}; - -#define IOC_R 0x0001 -#define IOC_W 0x0002 -#define IOC_RW (IOC_R | IOC_W) - #define MAX_STRUCT_SIZE 4096 #ifdef CONFIG_FIEMAP @@ -5374,7 +5356,7 @@ static abi_long do_ioctl_drm(const IOCTLEntry *ie, uint8_t *buf_temp, #endif -static IOCTLEntry ioctl_entries[] = { +IOCTLEntry ioctl_entries[] = { #define IOCTL(cmd, access, ...) \ { TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } }, #define IOCTL_SPECIAL(cmd, access, dofn, ...) \ diff --git a/thunk.c b/thunk.c index 7f31cffe0968..c5d971974783 100644 --- a/thunk.c +++ b/thunk.c @@ -271,6 +271,160 @@ const argtype *thunk_convert(void *dst, const void *src, return type_ptr; } +const argtype *thunk_print(void *arg, const argtype *type_ptr) +{ + int type; + + type = *type_ptr++; + + switch (type) { + case TYPE_CHAR: + qemu_log("%c", *(uint8_t *)arg); + break; + case TYPE_SHORT: + qemu_log("%" PRId16, tswap16(*(uint16_t *)arg)); + break; + case TYPE_INT: + qemu_log("%" PRId32, tswap32(*(uint32_t *)arg)); + break; + case TYPE_LONGLONG: + qemu_log("%" PRId64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_ULONGLONG: + qemu_log("%" PRIu64, tswap64(*(uint64_t *)arg)); + break; +#if HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 32 + case TYPE_PTRVOID: + qemu_log("0x%" PRIx32, tswap32(*(uint32_t *)arg)); + break; + case TYPE_LONG: + qemu_log("%" PRId32, tswap32(*(uint32_t *)arg)); + break; + case TYPE_ULONG: + qemu_log("%" PRIu32, tswap32(*(uint32_t *)arg)); + break; +#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 32 + case TYPE_PTRVOID: + qemu_log("0x%" PRIx32, tswap32(*(uint64_t *)arg & 0xffffffff)); + break; + case TYPE_LONG: + qemu_log("%" PRId32, tswap32(*(uint64_t *)arg & 0xffffffff)); + break; + case TYPE_ULONG: + qemu_log("%" PRIu32, tswap32(*(uint64_t *)arg & 0xffffffff)); + break; +#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 64 + case TYPE_PTRVOID: + qemu_log("0x%" PRIx64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_LONG: + qemu_log("%" PRId64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_ULONG: + qemu_log("%" PRIu64, tswap64(*(uint64_t *)arg)); + break; +#else + case TYPE_PTRVOID: + qemu_log("0x%" PRIx64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_LONG: + qemu_log("%" PRId64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_ULONG: + qemu_log("%" PRIu64, tswap64(*(uint64_t *)arg)); + break; +#endif + case TYPE_OLDDEVT: + { + uint64_t val = 0; + switch (thunk_type_size(type_ptr - 1, 1)) { + case 2: + val = *(uint16_t *)arg; + break; + case 4: + val = *(uint32_t *)arg; + break; + case 8: + val = *(uint64_t *)arg; + break; + } + switch (thunk_type_size(type_ptr - 1, 0)) { + case 2: + qemu_log("%" PRIu16, tswap16(val)); + break; + case 4: + qemu_log("%" PRIu32, tswap32(val)); + break; + case 8: + qemu_log("%" PRIu64, tswap64(val)); + break; + } + } + break; + case TYPE_ARRAY: + { + int i, array_length, arg_size; + uint8_t *a; + int is_string = 0; + + array_length = *type_ptr++; + arg_size = thunk_type_size(type_ptr, 0); + a = arg; + + if (*type_ptr == TYPE_CHAR) { + qemu_log("\""); + is_string = 1; + } else { + qemu_log("["); + } + + for (i = 0; i < array_length; i++) { + if (i > 0 && !is_string) { + qemu_log(","); + } + thunk_print(a, type_ptr); + a += arg_size; + } + + if (is_string) { + qemu_log("\""); + } else { + qemu_log("]"); + } + + type_ptr = thunk_type_next(type_ptr); + } + break; + case TYPE_STRUCT: + { + int i; + const StructEntry *se; + uint8_t *a; + const argtype *field_types; + const int *arg_offsets; + + se = struct_entries + *type_ptr++; + a = arg; + + field_types = se->field_types; + arg_offsets = se->field_offsets[0]; + + qemu_log("{"); + for (i = 0; i < se->nb_fields; i++) { + if (i > 0) { + qemu_log(","); + } + field_types = thunk_print(a + arg_offsets[i], field_types); + } + qemu_log("}"); + } + break; + default: + g_assert_not_reached(); + } + return type_ptr; +} + /* from em86 */ /* Utility function: Table-driven functions to translate bitmasks From patchwork Sat Jul 4 16:25:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 234825 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp3361461ilg; Sat, 4 Jul 2020 09:33:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOQ5stXsIixTpIWnN39lPQdwM20ujG+wSorSFeBl3HjprKSPN2xgZux9G6b9Xm9iSO8Bpn X-Received: by 2002:a25:3851:: with SMTP id f78mr67159613yba.212.1593880386736; Sat, 04 Jul 2020 09:33:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593880386; cv=none; d=google.com; s=arc-20160816; b=KGru/90tEZDZ1aMf6oiIMvtCj1I+EVI8Ewt45WI4kbKRIa+BN96658bzJftfHsPF4a 4mAGIAjn+e7uMFKx9NADiEL6m7U6mMdo/nV4BeDC8F43evrGcdr8nrM6bnTOn36K6/uH 0ZGIOm3rAR5YMZmkeMVw0ycmsTcWrR7+aLm0yWfJtztfzkO91gIJUcnCzSCEXfWZ02pR kJJU/8tqQozGU5l6xTst+4LRgkOF7kNQfK9/OjYXv63qFf7T0ca04YmYDMVkH7r5uwYU T9t4FLofGRTV1yJsptlojpahw417jmioos1J84AvEZRrZW+DXB0avNQA2GIOO1jyIy7c X3TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from; bh=o3GRM4NdsMmA1n1g9ivdcI80g3X+Mg7b7clupkT/Nd8=; b=l8Mgkf4nhTxIN2sXDg28OL3xwAhfP4LjxmJ6uKxEItcxI693obTX/SJl7I+Tduyc87 xGoEnMEr3kN3CsPMI1NPMQK6FufVLyJ+7vpPBodHVlmgbLFx+coeT14KSCuGbY4PKrEM CoMgFxcpVghKeNP8Mn6TeSuZi6vrZ0WZsbX+5KqKckMfQDBZo1hGU1jdXs7l5Wyt5JQu 50F+rrwr+IRUE2KOQ1gWLPgipc2bUypQyHeYEd89mk5lshdkZONePdId98H/VzDF51/L i0B29vYtiIeWUaPiKfyBy3e20lM5JMDob+IvOeWLyQa94FTjUWNtLc9guwOnJE2Vf2wC IdbQ== 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 g64si15008981ybi.438.2020.07.04.09.33.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 04 Jul 2020 09:33:06 -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]:34052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl6A-0006eq-5k for patch@linaro.org; Sat, 04 Jul 2020 12:33:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzV-0005Rb-EB for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:13 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:56457) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzQ-0002PL-2z for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:11 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mg6i8-1kZ4YH1ozO-00hi9X; Sat, 04 Jul 2020 18:26:03 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 12/12] MAINTAINERS: update linux-user maintainer Date: Sat, 4 Jul 2020 18:25:45 +0200 Message-Id: <20200704162545.311133-13-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200704162545.311133-1-laurent@vivier.eu> References: <20200704162545.311133-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:8sX+e2NSDaIHCQu0TTEDNlcZ/VwtWKnGjqGdSQNDsdPP4ZpZrR2 enIelki7JMOnKwyJih3gJEsuwOV6wpr4POBzNLbxQW/1byQtMBQMj4Mx+cP+OjfRZY+qIWv VtGs6zjR+z4JKHAzuc0aY47V7R8QRnY0Boc1RdJVpSu7t3f1KnpwlgRqbNzfliO12z7F/T4 Cq58+XMKib2+jVqEgOOXw== X-UI-Out-Filterresults: notjunk:1; V03:K0:NlzIBrMGrl0=:h8HamdyMe011bgR8o55aK2 uhMXEHhP+QI9UsMm6Fvn1ubMZrVEJmN2ORPG2MEVheVdk/Vn7Idzzd6GJ/IP/4oYQlBnKkpTj JEbexuFNewFoC51GV18Q+xv6Whq2uJbNOhCBVZ/cRSLGJfYFac6MTqgxuVWdiySvt10nRmPbF XZ/PgQV8+R/gc6peRkTXfUTNrHDc/XjELieZtl1QLghIv9laxyLim9YaWiN4o6CAhN/kjRvaD 0G1A5XyI7ysB7ZuA2qs/lJEN4eKxVQMK6IkYbapL1tTmxTRZPalOOIH/bHE1ymH5MCbz2ry91 vVvvEasMA6vx22U0G/oapUOJcmAD8ALeJjZvSJyhMjLsApL4J7Jxi1mkIj5cNTx23DIcXFE3m 6qrFMwgo0mRqDBAksgZyTRcd4SZl+aAJvpGXG/Oo8w4fMNbcaJSEQTVmuRMOSXnF+G8C6Bvhh RV1d9QJYVQo0ACgS8OycXqbXT16QNd6hBu3/3UuKMqf4TfITBJWr4aPMyA/dkVGW3ozif+KJi k0jLnputa5MtLYkM++ayhXMga5xF0cKq9NipnKcYPT0gnhjAiSNN4rJce38v/jSGKwqStjlXn ZDZ2H8dxmZuaCHlF/teLue7jTUtvbESk4eRTsGJFprlIlUzdNgNVQREe/taH14wsvgnlXWg3T 2PmYfLlhwxLVGe2JzUqx9+f2Nqb34vc440ujn8o+2Prw3aM8jLfDHpvDHClBfSg1cp5mHOYb3 Plut9rFhkungsUBGVxEhhsK5Qvhjr6mVgZLcGiitchN+4aJtm9Cj06quoJG2cHNas8iFrKFWw fAS+DBhDrFixaPJExbDxnZX1NqbycP1XkbSvcZczBm89F+A7WI= Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 12:25:55 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=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: Riku Voipio , Riku Voipio , Mark Cave-Ayland , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Artyom Tarasenko Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Riku Voipio I haven't been active for a while. Pass the maintainer hat forward to Laurent, who has done a stellar job filling in. Signed-off-by: Riku Voipio Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20200702111636.25792-1-riku.voipio@linaro.org> Signed-off-by: Laurent Vivier --- MAINTAINERS | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.26.2 diff --git a/MAINTAINERS b/MAINTAINERS index dec252f38b1d..29a23b6d3a5a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2629,8 +2629,7 @@ F: bsd-user/ F: default-configs/*-bsd-user.mak Linux user -M: Riku Voipio -R: Laurent Vivier +M: Laurent Vivier S: Maintained F: linux-user/ F: default-configs/*-linux-user.mak