From nobody Mon Apr 29 16:21:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593880045; cv=none; d=zohomail.com; s=zohoarc; b=ezqpWefAFAXxPHx4zFL6FxKKb8SnHWRCgWiz8Dl0i9slyFxC5ERRzcFqVqugULtPJuQlsug2i1gIFvUkC3x0YUSSlF6OHUg2C8rIsMYL3yl8zH+5p5wVvBlbS4wIY9MsZjXw5u2xz0XOrrKknBLOafycopVJGEWK6Bjl0UrSwdw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593880045; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CamW9IdXfAmwooxscXpO323WelBj6wO/YEDLv1sO6oI=; b=KlPAq+w0ULTZcet5t1zMQ3U5eIH+QyjxsdtqaaJN41wNB6zWo+lWdPQjSWE6Q8vNER/GKetpggQc6LZ4IccceQ+4r2mcx2sIog5dzlacGiiiKb3BWTkjdCAGYefjC4FbgwG+ZM5OYeU1h/zUxk7Jk39I/O0w1AAYXJel/NfXnX0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593880044980943.9297526803975; Sat, 4 Jul 2020 09:27:24 -0700 (PDT) Received: from localhost ([::1]:44624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl0d-0007dB-Qn for importer@patchew.org; Sat, 04 Jul 2020 12:27:23 -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 Content-Transfer-Encoding: quoted-printable 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: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Giuseppe Musacchio The ifdef logic should unconditionally compile in the `xop =3D=3D 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, unsig= ned int insn) #endif gen_store_gpr(dc, rd, cpu_tmp0); break; +#endif +#if defined(TARGET_SPARC64) || !defined(CONFIG_USER_ONLY) } else if (xop =3D=3D 0x2b) { /* rdtbr / V9 flushw */ #ifdef TARGET_SPARC64 gen_helper_flushw(cpu_env); --=20 2.26.2 From nobody Mon Apr 29 16:21:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593880133; cv=none; d=zohomail.com; s=zohoarc; b=OJfKo6N/ZJYTiiYbN5zM2jmalBlA4TvxICgy1K6DhyM8uac/cEhvdH6MESk/l4w7XcOK8m42M7Ji7dMd9Jr+4UiH9+/wAp5zPsAm5JkAxrSBT09MFn1iMh79pErKNkFBrhmjQbDLLBTFKg6HLqt8YkbB/poQNcbPqksVnDe/YTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593880133; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RwgKmGVfILhQkzL45CPdv5h8McfAH79F5DWYJxYxps4=; b=gL8TtgaeOWjZKyGRPeXWmkElyl6NvaBwriJvnXhG5sRaeqqCYRIlRxnnk5wwoz3Xf3+29yrOUay6ChC3rZVW24QrFcrjmp9lDZYandgqrQyDsMEvh3L1Aah+33g08wrucOS4LgnzISdv7GKoT98kJpmnYHUeYDBFN7kQylx4vKc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593880133706720.3714325888525; Sat, 4 Jul 2020 09:28:53 -0700 (PDT) Received: from localhost ([::1]:51332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl24-0001ua-Fn for importer@patchew.org; Sat, 04 Jul 2020 12:28:52 -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 Content-Transfer-Encoding: quoted-printable 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: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 =3D 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 =3D 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 --=20 2.26.2 From nobody Mon Apr 29 16:21:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593880532; cv=none; d=zohomail.com; s=zohoarc; b=RvdRM9fs4PKyjb83P1wCHI4lm0/lvwI3/XjeKBzAD/XQDjVBS0D3XAv2m4la6aewATA7SzTivslCv5YPq48leSiPvi2+Ecl1zkP32XxJr4MpqVnr0BSDw6YtNOXQ1E6rJbns+fvlhb+nR+zv0l5/kROepwP0jJVCzph9oc1RVYI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593880532; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4RBKcKJANbJqCC6mg4Xf9HMk5nBriaQkP/hbhn+/P1A=; b=RKVotAiiCc6by2aUC6clAqfCyD4ObBrl12pM3iCcouM/mQZIgzDmW1JRJW0TyFR5bPL61VD4ADH3EogNn9+iq1hx8MwdYWrXpXle43ZZLfLfgPxTQLzjC0JVFDpu6kMvrsCOoHKw5vf1lv7P3CVH9liY8Nz3gV58M5NZbtIYjgM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593880532317816.0119365556039; Sat, 4 Jul 2020 09:35:32 -0700 (PDT) Received: from localhost ([::1]:43876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl8V-00030N-4J for importer@patchew.org; Sat, 04 Jul 2020 12:35:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzb-0005bC-ML for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:21 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:44939) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzU-0002Pg-DM for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:19 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MVvGt-1kJYkT3ztt-00RmpQ; Sat, 04 Jul 2020 18:25:57 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 03/12] linux-user: syscall: ioctls: support DRM_IOCTL_VERSION Date: Sat, 4 Jul 2020 18:25:36 +0200 Message-Id: <20200704162545.311133-4-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 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:NvELknXk+02Hu8JoKBvPs5LQq1Z0kFiJwSfSi9vYBD7uNBGUYot mAS3bOknZwayIJ0D568exxCvHwXcOlm/UlfX677lZAmIvsaSs9aqKQfM8Pc3b3vNtPgMGPq HCgPnvIM0dxKjXuo+mtBPwcfRdPGDaEZllmlCsB3c18drSoirQgW66cJNFTT8rXfPCv9UsJ WGj+kJEf+QnHGI1dqmVJQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:N/MuDt63pYc=:3gE0nRv+p6CqF30U6KzdBs /fm4yPlbXK3qA7ZNBGRKU3Sus13KVMSpX7kXWElvyqzsZJZSWpP2WktuZUbEIw8lN8Qbxh6Zu KZv6yTzDBEpcACZDVB2qsYHj1b7C5Q18w6qvfDSWmzHqsCpsyr5kpoIfDgPnFJmJ0A1/b194q ecD9zKxT0iVPTtDqAEl27+BG3mKF+bcKl500TV3nN6fRav1TEsZNqO2hKTvYpupw2RqkDxpJk PBcuo1xCA3y/i+2TQ+0UpALGEHsaYX+1zIhAAkr3XY2ExAlvWL1qfx3xMGFN/NBFDsgWk/T9X bDwM0b8/0z/I78RGqJD5cwmZUBWzQLPzcVq5LbwAVTXQYhpDErX6bxaHIOHIdm+JesnFswhwl uGKNBpG8yRDOrJjmbHmX6f/Z4CROnlureCPCcBGkUlpiyQ2UUNLpcvdaKhJnwY2TADZokDpeP XJig15zsh48jbpQiv740EZX0H2ELjbGYMdE4Qudu1bLhg/0zOI5LzKpL3O8so71BechPBbGvb 6sG9BJ+tfyoJSAwRlon/nBgMPOZXkEZWIaL2LvEZCrr5JfUHte1jt3vAzBC9kwcJYgum4NIUC U5wWDAYvu8JZHPoanyzDZpKuO6pgJDhXdY7o9fm+2Dm+kCpI7RStt66KlkYnYSUcep5i6aC/e Uyo4YL+JJ6GEj6+cnWfOGBoM5Ux3GvFmo70ZqQ2+2W17SyjYSiBaza/IsK8v5GLdc048PD2S3 zIfJHiTAQjZVY8UW5vGjT2/wW3aEumWK9uej8p+5o8eG3lwG5NxVslcN+dIvw9PvMaxouDib1 gY4WEVLcV/drF3C3J8hb49Pey54xGnQ+jBH8iw9EHfFRK6fUr0= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: Chen Gang , Riku Voipio , Mark Cave-Ayland , Laurent Vivier , Artyom Tarasenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Chen Gang Another DRM_IOCTL_* commands will be done later. Signed-off-by: Chen Gang Reviewed-by: Laurent Vivier Message-Id: <20200605013221.22828-1-chengang@emindsoft.com.cn> Signed-off-by: Laurent Vivier --- configure | 10 ++++ linux-user/ioctls.h | 5 ++ linux-user/syscall.c | 98 ++++++++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 15 ++++++ linux-user/syscall_types.h | 11 +++++ 5 files changed, 139 insertions(+) diff --git a/configure b/configure index 4a22dcd5631d..2014c72b674d 100755 --- a/configure +++ b/configure @@ -3194,6 +3194,13 @@ if ! check_include "ifaddrs.h" ; then have_ifaddrs_h=3Dno fi =20 +######################################### +# libdrm check +have_drm_h=3Dno +if check_include "libdrm/drm.h" ; then + have_drm_h=3Dyes +fi + ########################################## # VTE probe =20 @@ -7377,6 +7384,9 @@ fi if test "$have_ifaddrs_h" =3D "yes" ; then echo "HAVE_IFADDRS_H=3Dy" >> $config_host_mak fi +if test "$have_drm_h" =3D "yes" ; then + echo "HAVE_DRM_H=3Dy" >> $config_host_mak +fi if test "$have_broken_size_max" =3D "yes" ; then echo "HAVE_BROKEN_SIZE_MAX=3Dy" >> $config_host_mak fi diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 0defa1d8c18d..f2e2fa9c878b 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -574,6 +574,11 @@ IOCTL_SPECIAL(SIOCDELRT, IOC_W, do_ioctl_rt, MK_PTR(MK_STRUCT(STRUCT_rtentry))) =20 +#ifdef HAVE_DRM_H + IOCTL_SPECIAL(DRM_IOCTL_VERSION, IOC_RW, do_ioctl_drm, + MK_PTR(MK_STRUCT(STRUCT_drm_version))) +#endif + #ifdef TARGET_TIOCSTART IOCTL_IGNORE(TIOCSTART) IOCTL_IGNORE(TIOCSTOP) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 97de9fb5c92a..17ed7f8d6b59 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -112,6 +112,9 @@ #include #include #include +#ifdef HAVE_DRM_H +#include +#endif #include "linux_loop.h" #include "uname.h" =20 @@ -5276,6 +5279,101 @@ static abi_long do_ioctl_tiocgptpeer(const IOCTLEnt= ry *ie, uint8_t *buf_temp, } #endif =20 +#ifdef HAVE_DRM_H + +static void unlock_drm_version(struct drm_version *host_ver, + struct target_drm_version *target_ver, + bool copy) +{ + unlock_user(host_ver->name, target_ver->name, + copy ? host_ver->name_len : 0); + unlock_user(host_ver->date, target_ver->date, + copy ? host_ver->date_len : 0); + unlock_user(host_ver->desc, target_ver->desc, + copy ? host_ver->desc_len : 0); +} + +static inline abi_long target_to_host_drmversion(struct drm_version *host_= ver, + struct target_drm_version *targe= t_ver) +{ + memset(host_ver, 0, sizeof(*host_ver)); + + __get_user(host_ver->name_len, &target_ver->name_len); + if (host_ver->name_len) { + host_ver->name =3D lock_user(VERIFY_WRITE, target_ver->name, + target_ver->name_len, 0); + if (!host_ver->name) { + return -EFAULT; + } + } + + __get_user(host_ver->date_len, &target_ver->date_len); + if (host_ver->date_len) { + host_ver->date =3D lock_user(VERIFY_WRITE, target_ver->date, + target_ver->date_len, 0); + if (!host_ver->date) { + goto err; + } + } + + __get_user(host_ver->desc_len, &target_ver->desc_len); + if (host_ver->desc_len) { + host_ver->desc =3D lock_user(VERIFY_WRITE, target_ver->desc, + target_ver->desc_len, 0); + if (!host_ver->desc) { + goto err; + } + } + + return 0; +err: + unlock_drm_version(host_ver, target_ver, false); + return -EFAULT; +} + +static inline void host_to_target_drmversion( + struct target_drm_version *targe= t_ver, + struct drm_version *host_ver) +{ + __put_user(host_ver->version_major, &target_ver->version_major); + __put_user(host_ver->version_minor, &target_ver->version_minor); + __put_user(host_ver->version_patchlevel, &target_ver->version_patchlev= el); + __put_user(host_ver->name_len, &target_ver->name_len); + __put_user(host_ver->date_len, &target_ver->date_len); + __put_user(host_ver->desc_len, &target_ver->desc_len); + unlock_drm_version(host_ver, target_ver, true); +} + +static abi_long do_ioctl_drm(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, int cmd, abi_long arg) +{ + struct drm_version *ver; + struct target_drm_version *target_ver; + abi_long ret; + + switch (ie->host_cmd) { + case DRM_IOCTL_VERSION: + if (!lock_user_struct(VERIFY_WRITE, target_ver, arg, 0)) { + return -TARGET_EFAULT; + } + ver =3D (struct drm_version *)buf_temp; + ret =3D target_to_host_drmversion(ver, target_ver); + if (!is_error(ret)) { + ret =3D get_errno(safe_ioctl(fd, ie->host_cmd, ver)); + if (is_error(ret)) { + unlock_drm_version(ver, target_ver, false); + } else { + host_to_target_drmversion(target_ver, ver); + } + } + unlock_user_struct(target_ver, arg, 0); + return ret; + } + return -TARGET_ENOSYS; +} + +#endif + static IOCTLEntry ioctl_entries[] =3D { #define IOCTL(cmd, access, ...) \ { TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } }, diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 152ec637cba6..3c261cff0e5e 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1167,6 +1167,9 @@ struct target_rtc_pll_info { #define TARGET_DM_TARGET_MSG TARGET_IOWRU(0xfd, 0x0e) #define TARGET_DM_DEV_SET_GEOMETRY TARGET_IOWRU(0xfd, 0x0f) =20 +/* drm ioctls */ +#define TARGET_DRM_IOCTL_VERSION TARGET_IOWRU('d', 0x00) + /* from asm/termbits.h */ =20 #define TARGET_NCC 8 @@ -2598,6 +2601,18 @@ struct target_mq_attr { abi_long mq_curmsgs; }; =20 +struct target_drm_version { + int version_major; + int version_minor; + int version_patchlevel; + abi_ulong name_len; + abi_ulong name; + abi_ulong date_len; + abi_ulong date; + abi_ulong desc_len; + abi_ulong desc; +}; + #include "socket.h" =20 #include "errno_defs.h" diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 4e12c1661ea6..e2b0484f50e5 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -292,6 +292,17 @@ STRUCT(dm_target_versions, STRUCT(dm_target_msg, TYPE_ULONGLONG) /* sector */ =20 +STRUCT(drm_version, + TYPE_INT, /* version_major */ + TYPE_INT, /* version_minor */ + TYPE_INT, /* version_patchlevel */ + TYPE_ULONG, /* name_len */ + TYPE_PTRVOID, /* name */ + TYPE_ULONG, /* date_len */ + TYPE_PTRVOID, /* date */ + TYPE_ULONG, /* desc_len */ + TYPE_PTRVOID) /* desc */ + STRUCT(file_clone_range, TYPE_LONGLONG, /* src_fd */ TYPE_ULONGLONG, /* src_offset */ --=20 2.26.2 From nobody Mon Apr 29 16:21:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593880290; cv=none; d=zohomail.com; s=zohoarc; b=nWnLX9trFgC6GyU89gV4rPucMwv3yYGwceUGJD5tuAhz4bd5Qtcf9IypifFjjbxtkewVb+XbjPjo3OeN2GR9+LqA9pLcSaOuUOIGJNg/xJlImP0fc2k6J678ASN6Vsgfl4taJZVWlMFXnO1VqXd3l75KdWm31FbG8BasNazoN/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593880290; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tumXyO/k1xMcYTW2Aoqfq+uu5UGo2A4l4UouH7UIBIQ=; b=Q9nMijd1dubroi8dN6M+bEc90/ovWYk7/iUFXn8hwE2XzRZMKiAg8MRwbIT91GJ639G39iQ2NlUtwLRC7PUHfHUViJhtXUmz6UGBmrJdCFET3vgGDKI/giAwhBgs+UAZhdf9zMWLRGkWfkK81dT4U2xc5GTBImFNmWJgfM6WoyE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593880290856157.79294322418207; Sat, 4 Jul 2020 09:31:30 -0700 (PDT) Received: from localhost ([::1]:59086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl4b-0005Hz-DN for importer@patchew.org; Sat, 04 Jul 2020 12:31:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzS-0005NQ-B5 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:11 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:57527) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzP-0002PJ-Kx for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:10 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MORIm-1kHgGB2rVO-00PuDf; Sat, 04 Jul 2020 18:25:58 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 04/12] linux-user: Extend strace support to enable argument printing after syscall execution Date: Sat, 4 Jul 2020 18:25:37 +0200 Message-Id: <20200704162545.311133-5-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 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:M5B1LK085gQ1Z3csJthheFo055SJx8H0gNzV/IKO46xVff1HWNR INeszLe2G90j9/BWlD5JYW/fUwkqdSyZ4wZodlroK1TSgPny8GCibA8oWANkYdWJCC09mMx TXgADmrgAnEzwiOfSGrxdEPnMFMDxNC+U8IMqTYpX0pXOzktqsVov7rmzTzluGkT8UYIx0j KBg3QV/xJ/ZAXqZDGaVQA== X-UI-Out-Filterresults: notjunk:1;V03:K0:sEESX7mjVsU=:asGfKS8yNSX8gonHBQnTk0 eOCSgQhySebXQ/6gnmCXxVmJ1daUmPuPYKW8gbgdHtKj4UVtXucFTQis/Upu3pWp6/zw85C4w qldQHI4faiZt2029Oc/1+OiHXnGrdzv3ktxU7l59EMxzkYHHEAwvDKYOjRnZaK1EFk4x9lv5w 6qFdAf9h2TfTpfRX6KlfeF4XultAU+TJMnDkpEicl2vg/IQuPPq4DqJi1ixKuoat5Ml4EaNWS qcGemdhsZaaRQ4Kg98AUNzRMQifusSWluYVshmZDcGdU7E2DndPD2KR611BYfWSc/hnxSnDYF biuQUVSNie+RCu7r/T1VOt00afXpmnF2lZPQ34OnwlEr587WAxX+lyogFXjQ56UsHe8Oq/JyY 1tv+JMkFs1/QhDdMlX2OofpiJ03wANjC3xRahbtK0rOGlPq4nvMCoTmvLKcAfScq3i46K67ae Usf9+A8z24777VqFTOVS6G2Y3CUHRCxHRZOM392TW5FY8fLV5WUjj0G8cr7CxKA2Cfmzw8xZb P/kfE8KgYi0pQ88A5dfI99Mq3aCDqjtGO4muoEUJeQ2uq3iCyfGkizOhnLbRZeTxWTsTivTDD cYAUImdlDZTOBSffLy1AAfBlVX6m+ROU/sASGM9kVapRNwz6pARQfiCA+duL/06o9b4Bmsx1C Uho7heh/jHqy2GgAv+5o2WftgyucBW4fy8ltJRIAoA/o/xI+4sz1M4KWGCtc0fNgH1JqqYUBp pHE1f8BOonpnfYrDyvMQ42f2+eMBwYjuhocmpYtGsktxA5oEnWbXr9NC272EUm4AiB2QDVsmX LH9YAmKEVX+S4apwbmnv0LUH27AQaDbB7CQZOJYYi+3xMTUy84= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta Structure "struct syscallname" in file "strace.c" is used for "-strace" to print arguments and return values of syscalls. The last field of this structure "result" represents the calling function that prints the return values. This field was extended in this patch so that this funct= ion takes all syscalls arguments beside the return value. In this way, it e= nables "-strace" to print arguments of syscalls that have changed after the sy= scall execution. This extension will be useful as there are many syscalls that return values inside their arguments (i.e. listxattr() that returns the= list of extended attributes inside the "list" argument). Implementation notes: Since there are already three existing "print_syscall_ret*" functions i= nside "strace.c" ("print_syscall_ret_addr()", "print_syscall_ret_adjtimex()", "print_syscall_ret_newselect()"), they were changed to have all syscall= arguments beside the return value. This was done so that these functions don't ca= use build errors (even though syscall arguments are not used in these functions). There is code repetition in these functions for checking the return val= ue and printing the approppriate error message (this code is also located = in print_syscall_ret() at the end of "strace.c"). That is the reason why a function "syscall_print_err()" was added for this code and put inside t= hese functions. Functions "print_newselect()" and "print_syscall_ret_newsele= ct()" were changed to use this new implemented functionality and not store th= e syscall argument values in separate static variables. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200619123331.17387-2-filip.bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/qemu.h | 4 +- linux-user/strace.c | 110 ++++++++++++++++++++++--------------------- linux-user/syscall.c | 2 +- 3 files changed, 61 insertions(+), 55 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index ce902f5132a6..8f938b8105b3 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -383,7 +383,9 @@ int host_to_target_waitstatus(int status); void print_syscall(int num, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6); -void print_syscall_ret(int num, abi_long arg1); +void print_syscall_ret(int num, abi_long ret, + abi_long arg1, abi_long arg2, abi_long arg3, + abi_long arg4, abi_long arg5, abi_long arg6); /** * print_taken_signal: * @target_signum: target signal being taken diff --git a/linux-user/strace.c b/linux-user/strace.c index 0d9095c674f4..62117e8555f6 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -19,7 +19,9 @@ struct syscallname { void (*call)(const struct syscallname *, abi_long, abi_long, abi_long, abi_long, abi_long, abi_long); - void (*result)(const struct syscallname *, abi_long); + void (*result)(const struct syscallname *, abi_long, + abi_long, abi_long, abi_long, + abi_long, abi_long, abi_long); }; =20 #ifdef __GNUC__ @@ -631,18 +633,12 @@ print_clockid(int clockid, int last) =20 /* select */ #ifdef TARGET_NR__newselect -static long newselect_arg1 =3D 0; -static long newselect_arg2 =3D 0; -static long newselect_arg3 =3D 0; -static long newselect_arg4 =3D 0; -static long newselect_arg5 =3D 0; - static void print_newselect(const struct syscallname *name, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) { - qemu_log("%s(" TARGET_ABI_FMT_ld ",", name->name, arg1); + print_syscall_prologue(name); print_fdset(arg1, arg2); qemu_log(","); print_fdset(arg1, arg3); @@ -650,14 +646,7 @@ print_newselect(const struct syscallname *name, print_fdset(arg1, arg4); qemu_log(","); print_timeval(arg5, 1); - qemu_log(")"); - - /* save for use in the return output function below */ - newselect_arg1=3Darg1; - newselect_arg2=3Darg2; - newselect_arg3=3Darg3; - newselect_arg4=3Darg4; - newselect_arg5=3Darg5; + print_syscall_epilogue(name); } #endif =20 @@ -736,17 +725,29 @@ print_ipc(const struct syscallname *name, */ =20 static void -print_syscall_ret_addr(const struct syscallname *name, abi_long ret) +print_syscall_err(abi_long ret) { const char *errstr =3D NULL; =20 + qemu_log(" =3D "); if (ret < 0) { + qemu_log("-1 errno=3D%d", errno); errstr =3D target_strerror(-ret); + if (errstr) { + qemu_log(" (%s)", errstr); + } } - if (errstr) { - qemu_log(" =3D -1 errno=3D%d (%s)\n", (int)-ret, errstr); - } else { - qemu_log(" =3D 0x" TARGET_ABI_FMT_lx "\n", ret); +} + +static void +print_syscall_ret_addr(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 >=3D 0) { + qemu_log("0x" TARGET_ABI_FMT_lx "\n", ret); } } =20 @@ -760,17 +761,25 @@ print_syscall_ret_raw(struct syscallname *name, abi_l= ong ret) =20 #ifdef TARGET_NR__newselect static void -print_syscall_ret_newselect(const struct syscallname *name, abi_long ret) -{ - qemu_log(" =3D 0x" TARGET_ABI_FMT_lx " (", ret); - print_fdset(newselect_arg1,newselect_arg2); - qemu_log(","); - print_fdset(newselect_arg1,newselect_arg3); - qemu_log(","); - print_fdset(newselect_arg1,newselect_arg4); - qemu_log(","); - print_timeval(newselect_arg5, 1); - qemu_log(")\n"); +print_syscall_ret_newselect(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 >=3D 0) { + qemu_log(" =3D 0x" TARGET_ABI_FMT_lx " (", ret); + print_fdset(arg0, arg1); + qemu_log(","); + print_fdset(arg0, arg2); + qemu_log(","); + print_fdset(arg0, arg3); + qemu_log(","); + print_timeval(arg4, 1); + qemu_log(")"); + } + + qemu_log("\n"); } #endif =20 @@ -783,18 +792,13 @@ print_syscall_ret_newselect(const struct syscallname = *name, abi_long ret) #define TARGET_TIME_ERROR 5 /* clock not synchronized */ #ifdef TARGET_NR_adjtimex static void -print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret) +print_syscall_ret_adjtimex(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) { - const char *errstr =3D NULL; + print_syscall_err(ret); =20 - qemu_log(" =3D "); - if (ret < 0) { - qemu_log("-1 errno=3D%d", errno); - errstr =3D target_strerror(-ret); - if (errstr) { - qemu_log(" (%s)", errstr); - } - } else { + if (ret >=3D 0) { qemu_log(TARGET_ABI_FMT_ld, ret); switch (ret) { case TARGET_TIME_OK: @@ -2847,25 +2851,25 @@ print_syscall(int num, =20 =20 void -print_syscall_ret(int num, abi_long ret) +print_syscall_ret(int num, abi_long ret, + abi_long arg1, abi_long arg2, abi_long arg3, + abi_long arg4, abi_long arg5, abi_long arg6) { int i; - const char *errstr =3D NULL; =20 for(i=3D0;i=3D 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); } + qemu_log("\n"); } break; } diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 17ed7f8d6b59..1b971c06b270 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -12565,7 +12565,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_lon= g arg1, arg5, arg6, arg7, arg8); =20 if (unlikely(qemu_loglevel_mask(LOG_STRACE))) { - print_syscall_ret(num, ret); + print_syscall_ret(num, ret, arg1, arg2, arg3, arg4, arg5, arg6); } =20 record_syscall_return(cpu, num, ret); --=20 2.26.2 From nobody Mon Apr 29 16:21:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593880473; cv=none; d=zohomail.com; s=zohoarc; b=Jj+dAxTeyoanHSGcozFHV4ppzBE+DEQPE5YNAkDsT5+m0PoVxywvB/pN+SM+Etj51nawsl+vfIXgxj/6e+09Sx/Et0JbFPAkt96sMUZ12eWflQioqXn4JgQUEi0Obxg3hU42IY7Hw/o/nD3PH4Gxj022H6KuQVj6oKFXhjpZjiA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593880473; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5ZJoeUi38V4E7oFEH4YKDhEhwWlXkLDrvjivnxeftjg=; b=iXxxQj/DEFvS5KKFeZure1G4me4xUMUgxeYdA8nvfkYswECPy0HwV2lJWVUZ1qiZKdW/vCorkj1gftxQd1CSqXwF2Qcd2vU88eKnldxptF56z0NptlXb8K6WeIlH08x1kPbyWVtaVsASaEOyF2E6JKz2IvVpUF2qYVRjZGK51rU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593880473434212.64293781635706; Sat, 4 Jul 2020 09:34:33 -0700 (PDT) Received: from localhost ([::1]:41276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl7Y-0001fw-9j for importer@patchew.org; Sat, 04 Jul 2020 12:34:32 -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 Content-Transfer-Encoding: quoted-printable 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: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 dev= ice 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 =20 +#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 =20 - #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 }, --=20 2.26.2 From nobody Mon Apr 29 16:21:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593880048; cv=none; d=zohomail.com; s=zohoarc; b=adnZ9LPr0dJwyuWUiGRIIQ9p3ElqqLFCplV6erRilO1RvTTf3cg05apAlNQcj2HbUmHJ8Mf66Qxjmyxsx5hDd6HWeX6niLMG2oC5Bgo9U6YpXx7oK2YyWjVLBthdKTyvISD0buThZvgW6W/s4onPy8NsQlRrVqlGgIS1awpRjGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593880048; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vBAIF7BDXW6oGmA9/Tfa6gIDw1w6ieix5g4Aub302iQ=; b=P0VCKf6WHlsy/eQrQwuW8OHnx3y4RgiU0rNtmgJAHDkizUBZAC3+0dxJIDGo4e/lFeZxu0LfgQfbwcU/XKKuZQZ8CpkUG3/9ixa/WPRnArig0v1GpKzrDO4WSnMvpDp44t7A9VETZR1PxXJAAtt12zyETe/q0RN3So6eAU7m6A4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593880048744840.296848875127; Sat, 4 Jul 2020 09:27:28 -0700 (PDT) Received: from localhost ([::1]:44838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl0h-0007iO-7u for importer@patchew.org; Sat, 04 Jul 2020 12:27:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzN-0005EX-Ly for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:05 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:38683) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzK-0002OY-Jh for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:05 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MA7Om-1k3GWL0UJO-00BcSB; Sat, 04 Jul 2020 18:25:59 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 06/12] linux-user: Add strace support for printing argument of syscalls used for extended attributes Date: Sat, 4 Jul 2020 18:25:39 +0200 Message-Id: <20200704162545.311133-7-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 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:82muBEwMrNmJCSZMC3XvJ8SAEMCgKosfzRESzkdgt0Vrub/Jcqo Ioxw6of/zCi9fo8YFCn4AnDn9jCvuaIkF5SwAEiTwRyW/6Inms73GUPX6X/rArHuz9FbWTw UFsR8vKg6EiZewY4Dy0lRE2Mh50tMdiXGSCrXE0uvVuluseqZMWLNxbrR1ZUko/D3HRibMh 5GI2MWYX18LASqEFE0pIg== X-UI-Out-Filterresults: notjunk:1;V03:K0:F8DhPqyMl9k=:fTcAPaB8uKY1mbCPUH6Xtk FvQrdgDwpKygZRz2dDup6N1QxH13GpBoB/b8w3Nufy61JPfLF2VE+07leMrgcFVUJkjz9Zt6b hg/vbkE6EV4XQqKayqQKMpaOKsf/DlC1R/Ry4MJA6H7/xggK0A66VIzToIv3Ku8eyF5MmvcsZ rgAHVkMQQBVkuTQfyHKVMUCd9Icbh3Yv8cEZ1eWHflReHT2gj1LcLH63aD9M6pH2upQM6RByg +wvlG/gWueAz1sVQCRDc9Gqlf75d2PkB3XsIzI+5B+ejF7WFZdg1yBXpKBgA2no8tT6Eu7pPo 5V8jjLMPQuAU+VdELdGE97besF2nJz657MqwKaRBOVcAT4LHtC+sk/CvVrD1Kdcs9RTV16Lez +2q3rePvS1FpDP+bBWCPNG+7YIm6yZfd1uDpiMqgOiDl/17xx4NJOoKAtGnpcDUu6bQ1o73HF CKmxUFabKM9wJBHJWQuaQeiDMZrC/S1VAPOZVCElC2ZJmnEfdkRGKQptmbS08fLgwuJRgn2kg QsLakQjl2kLCkKiVNMb9CLv2bud/eXOR7WzHtSw41pjWB1KZ6Nh22dYSDACCFLru3n6L63qMa 11mi9Y1oxOh6jBz3yz+nvtEovhKozHKfAtiavZulMU7/AzP9Umzy8Qdj37QcP2RW+rI60FvL2 kE9C+vyA1g/IJKsULr5Pg65jFySJg6uxYFJX6odIM2ez0bc3Mdby445unlKadWYBkYDkg464Z KoDxFp3GEclk7IQ+HVqRBWP7eqZGTXJlDcFM+fBg1wFswdK0HYRt0WyS4pG/GY0I91yzLwKAE Kv+9RKeo6eP+qhj4GIuL1MeqHuaeFF2KaWAO58SUoxkYDkAJDw= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch implements strace argument printing functionality for following = syscalls: *getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value ssize_t getxattr(const char *path, const char *name, void *value, s= ize_t size) ssize_t lgetxattr(const char *path, const char *name, void *value, = size_t size) ssize_t fgetxattr(int fd, const char *name, void *value, size_t siz= e) man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html *listxattr, llistxattr, flistxattr - list extended attribute names ssize_t listxattr(const char *path, char *list, size_t size) ssize_t llistxattr(const char *path, char *list, size_t size) ssize_t flistxattr(int fd, char *list, size_t size) man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html *removexattr, lremovexattr, fremovexattr - remove an extended attribute int removexattr(const char *path, const char *name) int lremovexattr(const char *path, const char *name) int fremovexattr(int fd, const char *name) man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.= html Implementation notes: All of the syscalls have strings as argument types and thus a separate printing function was stated in file "strace.list" for every one of the= m. All of these printing functions were defined in "strace.c" using existi= ng printing functions for appropriate argument types: "print_string()" - for (const char*) type "print_pointer()" - for (char*) and (void *) type "print_raw_param()" for (int) and (size_t) type Syscalls "getxattr()" and "lgetxattr()" have the same number and type of arguments and thus their print functions ("print_getxattr", "print_lget= xattr") share a same definition. The same statement applies to syscalls "listxa= ttr()" and "llistxattr()". Function "print_syscall_ret_listxattr()" was added to print the returne= d list of extended attributes for syscalls "print_listxattr(), print_llistxatt= r() and print_flistxattr()". Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200619123331.17387-4-filip.bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 121 +++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 21 ++++--- 2 files changed, 133 insertions(+), 9 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 123e022c35bf..760020132b5a 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -826,6 +826,40 @@ print_syscall_ret_adjtimex(const struct syscallname *n= ame, abi_long ret, } #endif =20 +#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \ + || defined(TARGGET_NR_flistxattr) +static void +print_syscall_ret_listxattr(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 >=3D 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); + qemu_log(" (list =3D "); + if (arg1 !=3D 0) { + abi_long attr =3D arg1; + while (ret) { + if (attr !=3D arg1) { + qemu_log(","); + } + print_string(attr, 1); + ret -=3D target_strlen(attr) + 1; + attr +=3D target_strlen(attr) + 1; + } + } else { + qemu_log("NULL"); + } + qemu_log(")"); + } + + qemu_log("\n"); +} +#define print_syscall_ret_llistxattr print_syscall_ret_listxattr +#define print_syscall_ret_flistxattr print_syscall_ret_listxattr +#endif + UNUSED static struct flags access_flags[] =3D { FLAG_GENERIC(F_OK), FLAG_GENERIC(R_OK), @@ -1633,6 +1667,93 @@ print_fcntl(const struct syscallname *name, #define print_fcntl64 print_fcntl #endif =20 +#ifdef TARGET_NR_fgetxattr +static void +print_fgetxattr(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); + print_string(arg1, 0); + print_pointer(arg2, 0); + print_raw_param(TARGET_FMT_lu, arg3, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_flistxattr +static void +print_flistxattr(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); + print_pointer(arg1, 0); + print_raw_param(TARGET_FMT_lu, arg2, 1); + print_syscall_epilogue(name); +} +#endif + +#if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr) +static void +print_getxattr(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, 0); + print_string(arg1, 0); + print_pointer(arg2, 0); + print_raw_param(TARGET_FMT_lu, arg3, 1); + print_syscall_epilogue(name); +} +#define print_lgetxattr print_getxattr +#endif + +#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) +static void +print_listxattr(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, 0); + print_pointer(arg1, 0); + print_raw_param(TARGET_FMT_lu, arg2, 1); + print_syscall_epilogue(name); +} +#define print_llistxattr print_listxattr +#endif + +#if defined(TARGET_NR_fremovexattr) +static void +print_fremovexattr(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); + print_string(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr) +static void +print_removexattr(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, 0); + print_string(arg1, 1); + print_syscall_epilogue(name); +} +#define print_lremovexattr print_removexattr +#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 8a887fc16dcc..d04ad507b0fb 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -218,13 +218,14 @@ { TARGET_NR_fdatasync, "fdatasync" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_fgetxattr -{ TARGET_NR_fgetxattr, "fgetxattr" , NULL, NULL, NULL }, +{ TARGET_NR_fgetxattr, "fgetxattr" , NULL, print_fgetxattr, NULL }, #endif #ifdef TARGET_NR_finit_module { TARGET_NR_finit_module, "finit_module" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_flistxattr -{ TARGET_NR_flistxattr, "flistxattr" , NULL, NULL, NULL }, +{ TARGET_NR_flistxattr, "flistxattr" , NULL, print_flistxattr, + print_syscall_ret_flistxattr}, #endif #ifdef TARGET_NR_flock { TARGET_NR_flock, "flock" , NULL, NULL, NULL }, @@ -233,7 +234,7 @@ { TARGET_NR_fork, "fork" , "%s()", NULL, NULL }, #endif #ifdef TARGET_NR_fremovexattr -{ TARGET_NR_fremovexattr, "fremovexattr" , NULL, NULL, NULL }, +{ TARGET_NR_fremovexattr, "fremovexattr" , NULL, print_fremovexattr, NULL = }, #endif #ifdef TARGET_NR_fsetxattr { TARGET_NR_fsetxattr, "fsetxattr" , NULL, NULL, NULL }, @@ -396,7 +397,7 @@ { TARGET_NR_getuid32, "getuid32" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getxattr -{ TARGET_NR_getxattr, "getxattr" , NULL, NULL, NULL }, +{ TARGET_NR_getxattr, "getxattr" , NULL, print_getxattr, NULL }, #endif #ifdef TARGET_NR_getxgid { TARGET_NR_getxgid, "getxgid" , NULL, NULL, NULL }, @@ -480,7 +481,7 @@ { TARGET_NR_lchown32, "lchown32" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_lgetxattr -{ TARGET_NR_lgetxattr, "lgetxattr" , NULL, NULL, NULL }, +{ TARGET_NR_lgetxattr, "lgetxattr" , NULL, print_lgetxattr, NULL }, #endif #ifdef TARGET_NR_link { TARGET_NR_link, "link" , NULL, print_link, NULL }, @@ -495,10 +496,12 @@ { TARGET_NR_listen, "listen" , "%s(%d,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_listxattr -{ TARGET_NR_listxattr, "listxattr" , NULL, NULL, NULL }, +{ TARGET_NR_listxattr, "listxattr" , NULL, print_listxattr, + print_syscall_ret_listxattr}, #endif #ifdef TARGET_NR_llistxattr -{ TARGET_NR_llistxattr, "llistxattr" , NULL, NULL, NULL }, +{ TARGET_NR_llistxattr, "llistxattr" , NULL, print_llistxattr, + print_syscall_ret_llistxattr}, #endif #ifdef TARGET_NR__llseek { TARGET_NR__llseek, "_llseek" , NULL, print__llseek, NULL }, @@ -510,7 +513,7 @@ { TARGET_NR_lookup_dcookie, "lookup_dcookie" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_lremovexattr -{ TARGET_NR_lremovexattr, "lremovexattr" , NULL, NULL, NULL }, +{ TARGET_NR_lremovexattr, "lremovexattr" , NULL, print_lremovexattr, NULL = }, #endif #ifdef TARGET_NR_lseek { TARGET_NR_lseek, "lseek" , NULL, NULL, NULL }, @@ -1116,7 +1119,7 @@ { TARGET_NR_remap_file_pages, "remap_file_pages" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_removexattr -{ TARGET_NR_removexattr, "removexattr" , NULL, NULL, NULL }, +{ TARGET_NR_removexattr, "removexattr" , NULL, print_removexattr, NULL }, #endif #ifdef TARGET_NR_rename { TARGET_NR_rename, "rename" , NULL, print_rename, NULL }, --=20 2.26.2 From nobody Mon Apr 29 16:21:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593880161; cv=none; d=zohomail.com; s=zohoarc; b=KLehPpNFK9rOsMF4IGElg1Qn1tCkLKYbGzDIh6Xi+8Hn6MLGqHf+Z3CqeE4OX7KLJovqj/YNzka0aGYu8xjTUm8VnS2ceWSebjtnM0QmSnMcsaAI2B1zjI6qCs5ApL29p/loXMNWIrhgaPhly9oz9O9gpudG0N4EUWMW1vYr8Z8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593880161; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JKwGze8IAIK5xRWoP1ssANzzaAoO3l+TFmml4kcjJ/M=; b=Yi1FEtVv/T0nve0MdEaC5Fa3HmG851bnForujbtZu1NYxcDBx5jdz5lDIvxf8dPQxtA9ah4i+Umf9MMjxIkMDdLFGWaYyXoIKHrxhZ4yNBXzzLCA9gD0aHnlIc7uy4VxalLjG9cj8KB5CN/5Wne49bfwmdTCSpVLh8KhHOR3JrE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593880161093225.80475486368425; Sat, 4 Jul 2020 09:29:21 -0700 (PDT) Received: from localhost ([::1]:52882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl2V-0002Yj-Si for importer@patchew.org; Sat, 04 Jul 2020 12:29:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzW-0005Sb-34 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:14 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:42245) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzR-0002PS-Vg for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:13 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mq2rM-1keYCr3T1O-00nBG7; Sat, 04 Jul 2020 18:26:00 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 07/12] linux-user: Add strace support for printing arguments of lseek() Date: Sat, 4 Jul 2020 18:25:40 +0200 Message-Id: <20200704162545.311133-8-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 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:6ExM+EIb8avJ3JyTQbsZEpcNibGSfYsBF2ON6SMDwHW5Alh18y8 Jq1bCQLjM7SlpZv1ukTAh5QOAi4vpmJvn1hv6P5K14DZVW76mlQCaEGG6T2g8F+/klaLba5 dZO8aAUmlJVSJVZENnPE/HPpxGcQrHDRl5SxoIwvs5q7W53IM3WIEZ8+vYRVm+sM5DaQrq0 /npOVAldix6EymIHLx/5g== X-UI-Out-Filterresults: notjunk:1;V03:K0:c5WfpDzHTmU=:LyfsDKluSBP60gLGWZfrV7 MCCd+DR3OWix77hihDwR2/5AxyqAFAhtgim+yb8rDf7fqtpKESV6+KlW4uWgrDlK/ykhzOsGh B18FrC8+QbYwaUdE+2Q8sSeKEQVUbggmcixX0T1uPTy4can3223cd9fs/f/aKOQ1iK+r0DL6O CpFMy2hJTYtw55TBbnZZHw8nUoCTQIP2CPzIwdM7slsYiIHnvQ1DWK8G4uCWxHUXOctQ/qCbr zJ3QOti473+X6sfk0mvKdKQXpZJpiTRoWz3IiL/8thf9ZMudZiLsndNURSqhHo6q6FYV5Kffw PNdvJkQaJA+tMkOFH46nTYQ1LLMNLu0X4RUJuoHRc1h9Xel2cWXOwUuJYwUqAIuvZNSbKOOFw XHaFfkAy6DwLVNUHSM8IEv6qtXn5R8zgb9QzvcVuGCet9zd2Ky89BMB9O4zNKBaS0xbNMsbOG IYYd7k2qEuTLRZQyB2wdePgEyosux6Ae8APkbwQKtgLhu5aJ7be6zCt5HRzhXBkC/9hMZV+Aj panxqDZ4zd7oEQ9MmnpRuqlG4iVLHzllv3JeBAF2qxXGqLX0pITxRZtJ7dOVArwdcl0ggbQCS 0iNoLapByHLIQt/vHS4u/F9BGfcV7pDo0EFhSZr4iAoIW4SazlZRM0YTwjC9KxuxWEuVaD1y6 QJGNTNnqhi18rXL9hkNQsnWdG7BqpDOqSk4sRZfvx3axa8DPq+sndtDFv+8+OA+5iASV3s7hP GJXZL8JlW6m5nS45TFzNAs+Pm/x6G/SxN1xyjdIW2NEzex7a61bH9FPQNid4scgAUQQpgVWCv Df4kAVti60HiwBcq0kAAafK3ZdkCdJbzTRc7qBXZNcpATahLc4= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 12:26:07 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch implements strace argument printing functionality for syscall: *lseek - reposition read/write file offset off_t lseek(int fd, off_t offset, int whence) man page: https://www.man7.org/linux/man-pages/man2/lseek.2.html Implementation notes: The syscall's third argument "whence" has predefined values: "SEEK_SET","SEEK_CUR","SEEK_END","SEEK_DATA","SEEK_HOLE" and thus a separate printing function "print_lseek" was stated in file "strace.list". This function is defined in "strace.c" by using an existing function "print_raw_param()" to print the first and second argument and a switch(case) statement for the predefined values of the third argument. Values "SEEK_DATA" and "SEEK_HOLE" are defined in kernel version 3.1. That is the reason why case statements for these values are enwrapped in #ifdef directive. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200619123331.17387-5-filip.bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 31 +++++++++++++++++++++++++++++++ linux-user/strace.list | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 760020132b5a..a26736516bab 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1833,6 +1833,37 @@ print__llseek(const struct syscallname *name, } #endif =20 +#ifdef TARGET_NR_lseek +static void +print_lseek(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); + print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); + switch (arg2) { + case SEEK_SET: + qemu_log("SEEK_SET"); break; + case SEEK_CUR: + qemu_log("SEEK_CUR"); break; + case SEEK_END: + qemu_log("SEEK_END"); break; +#ifdef SEEK_DATA + case SEEK_DATA: + qemu_log("SEEK_DATA"); break; +#endif +#ifdef SEEK_HOLE + case SEEK_HOLE: + qemu_log("SEEK_HOLE"); break; +#endif + default: + print_raw_param("%#x", arg2, 1); + } + print_syscall_epilogue(name); +} +#endif + #if defined(TARGET_NR_socket) static void print_socket(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index d04ad507b0fb..a4a8c61969cd 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -516,7 +516,7 @@ { TARGET_NR_lremovexattr, "lremovexattr" , NULL, print_lremovexattr, NULL = }, #endif #ifdef TARGET_NR_lseek -{ TARGET_NR_lseek, "lseek" , NULL, NULL, NULL }, +{ TARGET_NR_lseek, "lseek" , NULL, print_lseek, NULL }, #endif #ifdef TARGET_NR_lsetxattr { TARGET_NR_lsetxattr, "lsetxattr" , NULL, NULL, NULL }, --=20 2.26.2 From nobody Mon Apr 29 16:21:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593880377; cv=none; d=zohomail.com; s=zohoarc; b=khIDM316QX2FUU8tB150stw1xKF2vKBh7kCjrwoY4X7XePbf/EhRXI7mt8Aa8ED0DuGodSEoZZBbCPfFT/odJB6yZGL1SywSsKX9GwVo1RjLVITNnsXJhm5/hZjyZ0HBofanhZJhcx5MXch6LiDhuBagBOjf2eg9P3B4XPnnTRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593880377; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fzpmwN6XhqzFDdvG26B7FzN+8TaVvGMwxTHV/lZxPIM=; b=P6L5thrvpnIizZ/lKyF88VrPCsp8c+V1DNd07I5K6POuXRQoDUUnN0Hx9XGRrGuMCgRvwdp2MyD3OnjTU2cytoHRW9MU6UvrtutwOCfy/8h1uIR9dEphDvkJH9TnWaUIF6cRQlN7Wi3BnZptV9S15xriWZbnEv4RF1XOs2soAOw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593880377190330.77718664165377; Sat, 4 Jul 2020 09:32:57 -0700 (PDT) Received: from localhost ([::1]:34640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl5y-0006ye-RA for importer@patchew.org; Sat, 04 Jul 2020 12:32:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzZ-0005Xy-PI for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:18 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:42201) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzR-0002PX-V7 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:16 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MAOVx-1k3XV51xHf-00BtZK; Sat, 04 Jul 2020 18:26:00 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 08/12] linux-user: Add strace support for printing arguments of chown()/lchown() Date: Sat, 4 Jul 2020 18:25:41 +0200 Message-Id: <20200704162545.311133-9-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 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:czKZRX6NarPlZ1JUy9KbABIUfVDaLZV5B8Bw2Af3vsiwCk71Z4v yAniG3k4KCGd8QEOrV58BdTcfN8alpEaG7Hdw+ENrdytWP1MU9Tvghga1aBnW1fb508yg1w GGHMkpDuep9tPjFDV0L4x7aFAYZsydSHIDrEUoLYu8pPBXU2kGLvC087GaVXGZqHsvhpsIY 8L4SsvvLfVBKGhn7D93DQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:6JciE7Ux9sg=:9MPbnuu+lQU/wR/8KTKy93 XLW5FzAhkXuPVR48QJ0jV9OS5m/jq+d5kDTWL0I3mDCLY5zWnx7Z5YtUZudVGwGFKYo73D4Pf KVGLh6hruFrZi8G7jSVKh8clTy55TegSQxND8GD9A2mtzNtEr8md3jsa/7Z7rxmfIygpVQbJY HCiw/C09BkJ1d5wErDt/a28wDKOHWzQHia2nzLw2PQ2qfjZ6aJXE1fbfz50lAkSvE2yowIe8o 5MzHQABhBj9sFcQp1B6JByjR+XsKI0/CxAh61tyGYZXz0Bv44J/DxgS4JmbPeDcGQoE0AoaNb uGFmcZPg3wGRCwXNawwLLqXZi5P6Z2NfYHOoSx7szoTdfzP379zA151Q72UNPsvNF4TG/wjgm FZobGuvasPHZHMQXl6P3brRlFe6TSX3Ka8ajuGP01VXxK7FjpwID4/dYNOJkP8ww3smTOewfb VBmwEpcQ2VjlwLpNTB6+KEuHMU90OZ5WIX1HvxxMHQs/2JKVFcF/TT7pmGfgefJlzQVVmjWUd FkV4fzZbGEzh3Q69m3HxcSvQCbXOBbm06LkMBbGfixJ2NMgtPAlcVBzQFgx84HhZcO0FD1i+y +ox+YU+Gtpb698UhAcVVnjYoL21WbmmewIqimJ88w0vQSzmUz1bOGyb1fL3TxT8dvNzKQDl3N EggU1iHBgY4udgxjmsWF+d6qHqrXCbmlYTiqOW0G6ExtjZ/bOzq9PnH7QSUSU968+aPWvYrRx WquQzXlAMWCNPVByFGHwOrnaTymOUQGQVp0ZoF2zMXokUZ5Sx4hqffd1V2bQbCnXmcm5Gzkwk LowgribDZgU0esEgyEcGgAwqyLwdT3brD3qf9Cs1Hxlw3lpFiQ= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch implements strace argument printing functionality for syscalls: *chown, lchown - change ownership of a file int chown(const char *pathname, uid_t owner, gid_t group) int lchown(const char *pathname, uid_t owner, gid_t group) man page: https://www.man7.org/linux/man-pages/man2/lchown.2.html Implementation notes: Both syscalls use strings as arguments and thus a separate printing function was stated in "strace.list" for them. Both syscalls share the same number and types of arguments and thus share a same definition in file "syscall.c". This defintion uses existing functions "print_string()" to print the string argument and "print_raw_param()" to print other two arguments that are of basic types. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200619123331.17387-6-filip.bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 15 +++++++++++++++ linux-user/strace.list | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index a26736516bab..957f08f1adf2 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1452,6 +1452,21 @@ print_chmod(const struct syscallname *name, } #endif =20 +#if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown) +static void +print_chown(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, 0); + print_raw_param("%d", arg1, 0); + print_raw_param("%d", arg2, 1); + print_syscall_epilogue(name); +} +#define print_lchown print_chown +#endif + #ifdef TARGET_NR_clock_adjtime static void print_clock_adjtime(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index a4a8c61969cd..e99030c9ef39 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -71,7 +71,7 @@ { TARGET_NR_chmod, "chmod" , NULL, print_chmod, NULL }, #endif #ifdef TARGET_NR_chown -{ TARGET_NR_chown, "chown" , NULL, NULL, NULL }, +{ TARGET_NR_chown, "chown" , NULL, print_chown, NULL }, #endif #ifdef TARGET_NR_chown32 { TARGET_NR_chown32, "chown32" , NULL, NULL, NULL }, @@ -475,7 +475,7 @@ { TARGET_NR_kill, "kill", NULL, print_kill, NULL }, #endif #ifdef TARGET_NR_lchown -{ TARGET_NR_lchown, "lchown" , NULL, NULL, NULL }, +{ TARGET_NR_lchown, "lchown" , NULL, print_lchown, NULL }, #endif #ifdef TARGET_NR_lchown32 { TARGET_NR_lchown32, "lchown32" , NULL, NULL, NULL }, --=20 2.26.2 From nobody Mon Apr 29 16:21:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593880448; cv=none; d=zohomail.com; s=zohoarc; b=HKFzxBkAZhjspu2+andjXrGQ0WwaDjWWV5CODJxvMQmXT78xQolPyxUZjX42lDc/8wG3tZuQHdHDDGTBQeLzMyFGEJy8B4ZOMVz5K9imHGKq0D94e56Sa65bquBFdNO+ChTDZ3d8w0f01855UhnJj8WaRSMQTcza1lhjFmreNtI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593880448; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J+iyb/FJGuY2VMZVelh+2Te4z7FfCd3NLwSYJvuSi/k=; b=NJvOz7T7JzLJUcD6G1SLoTN3w4q9Il/cZMEW4+KW07oz4jRi/jon/7JVDGiYgNSk00BMn3C1aw64zgWisbZcIFtPD6RI+2sE9zjTci4iJCGCNhKZEyJYBRwhZFbFGrwcBDAmrQyplY7QBnYrOw3M310LRUViJALLBVN14QLjmvQ= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593880448635628.7402918191833; Sat, 4 Jul 2020 09:34:08 -0700 (PDT) Received: from localhost ([::1]:39658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl79-0000rF-Gm for importer@patchew.org; Sat, 04 Jul 2020 12:34:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzb-0005ax-JA for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:19 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:57367) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkzS-0002Pd-Ak for qemu-devel@nongnu.org; Sat, 04 Jul 2020 12:26:18 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MqJyX-1kepBq0PLv-00nSNG; Sat, 04 Jul 2020 18:26:01 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 09/12] linux-user: Add strace support for printing arguments of fallocate() Date: Sat, 4 Jul 2020 18:25:42 +0200 Message-Id: <20200704162545.311133-10-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 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:7XmTRK8VlOZpkscqkLnES9Gyntcavkz6rWMS0o7riS0XVxq4SQ9 eTbdSCRO//59HhlEcqNxCxYhKt6zm7bWFsjQcLd0P4NFxR5hEjduPLt8wHoP3OQAPkPWGHi R3vj4HYcNLzHZG8b/osaSNUCdrW7H5TN0nEYe3JgKyjFgMhWDSVgRyh+Zp8qNCZIn9JLH8L FaAbGlIbot7g8voJPIIqA== X-UI-Out-Filterresults: notjunk:1;V03:K0:d/l9t9vXShE=:6UFHjv4pdA6mR8XQD1cddt GqyDbN7EpEzpN5ARAh4ql/qAcva6vOnpQBVIrNHxuo271yGdFZuEPh9db4nalOhSoBCprgCQG m1mTlIaXeS+GLD86wrSIOU7+UF8icQSiLaMuoTHioZ5tVE7gbF4vZIKecVHYzJbCVb/acnEPN 0L3WCFgF7ZLjjoc+Wbmr9b/fUU9s1dcMyXT+hYjRJ2hm6btBA1jX8S6s3BLzDdLR4zEOgD+8o SI3KbPMLM4rAjZFCbmCJceFashP2x8OGBHTfBm0wLAGbIsb6OWdir4Eo1+gf7hVRg1a6x8UfN R3f2U3Wmo+wYEh8TE3xZihHoiw8IjmndlfKrpH9bOjG1DTC+DHcp8S/PhL1rsq6ArF/zXTD3b uYQLjnukKpcsKYbNpu+kzAy2j8OXKZLQZrOBmk3wMKZnOxDTsoKT2FXUaEeWddU3p/rgQPKIw GQtvqc05IEwLwOFXeqc76b/kXHpw6Cd+YBhOPtWl11slqf1yir9EaYRqq7gU/6LuToXUoew/S 7NPd2A0EUQ77ofpwekR2qKINq6+E8yfU4ZEMCdSDBs81Z2GU8oveZw0GTXnqJEO1T7GaGf3NC pPplzNA1idygZ3onC+rTKmJL6opq0Gtgfzi4HX0Js3CTtDt5RrG2byxVCod/mG328MO4f35cf aAQEDDnwYrWnj9C3mfmwLiUOWGjBfBo8M/TSFGOviH1DWWl+5aF9YpYYvnK8fxsnoYQP5uIvR 8oNxUUNO/rOBvw2np5VYcQR7mCY9T6LJiS7yBFoh9uDzMqqApdAL1gXiNWwLp8RlhDTtN/Bf8 AU0tqh6lnjOoI+X7p4w5hHGssmBqHWvaKZzrGcW8jZsRVqc1GA= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 12:26:07 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch implements strace argument printing functionality for following = syscall: *fallocate - manipulate file space int fallocate(int fd, int mode, off_t offset, off_t len) man page: https://www.man7.org/linux/man-pages/man2/fallocate.2.html Implementation notes: This syscall's second argument "mode" is composed of predefined values which represent flags that determine the type of operation that is to be performed on the file space. For that reason, a printing function "print_fallocate" was stated in file "strace.list". This print= ing function uses an already existing function "print_flags()" to print fla= gs of the "mode" argument. These flags are stated inside an array "falloc_fla= gs" that contains values of type "struct flags". These values are instantia= ted using an existing macro "FLAG_GENERIC()". Most of these flags are defin= ed after kernel version 3.0 which is why they are enwrapped in an #ifdef directive. The syscall's third ant fourth argument are of type "off_t" which can cause variations between 32/64-bit architectures. To handle this variat= ion, function "target_offset64()" was copied from file "strace.c" and used in "print_fallocate" to print "off_t" arguments for 32-bit architectures. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200619123331.17387-7-filip.bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/qemu.h | 16 ++++++++++++++++ linux-user/strace.c | 40 ++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 16 ---------------- 4 files changed, 57 insertions(+), 17 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 8f938b8105b3..be67391ba49d 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -670,6 +670,22 @@ static inline int is_error(abi_long ret) return (abi_ulong)ret >=3D (abi_ulong)(-4096); } =20 +#if TARGET_ABI_BITS =3D=3D 32 +static inline uint64_t target_offset64(uint32_t word0, uint32_t word1) +{ +#ifdef TARGET_WORDS_BIGENDIAN + return ((uint64_t)word0 << 32) | word1; +#else + return ((uint64_t)word1 << 32) | word0; +#endif +} +#else /* TARGET_ABI_BITS =3D=3D 32 */ +static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) +{ + return word0; +} +#endif /* TARGET_ABI_BITS !=3D 32 */ + /** * preexit_cleanup: housekeeping before the guest exits * diff --git a/linux-user/strace.c b/linux-user/strace.c index 957f08f1adf2..32e5e987acbb 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1135,6 +1135,26 @@ UNUSED static struct flags statx_mask[] =3D { FLAG_END, }; =20 +UNUSED static struct flags falloc_flags[] =3D { + FLAG_GENERIC(FALLOC_FL_KEEP_SIZE), + FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE), +#ifdef FALLOC_FL_NO_HIDE_STALE + FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE), +#endif +#ifdef FALLOC_FL_COLLAPSE_RANGE + FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE), +#endif +#ifdef FALLOC_FL_ZERO_RANGE + FLAG_GENERIC(FALLOC_FL_ZERO_RANGE), +#endif +#ifdef FALLOC_FL_INSERT_RANGE + FLAG_GENERIC(FALLOC_FL_INSERT_RANGE), +#endif +#ifdef FALLOC_FL_UNSHARE_RANGE + FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE), +#endif +}; + /* * print_xxx utility functions. These are used to print syscall * parameters in certain format. All of these have parameter @@ -1552,6 +1572,26 @@ print_faccessat(const struct syscallname *name, } #endif =20 +#ifdef TARGET_NR_fallocate +static void +print_fallocate(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); + print_flags(falloc_flags, arg1, 0); +#if TARGET_ABI_BITS =3D=3D 32 + print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0); + print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1); +#else + print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); + print_raw_param(TARGET_ABI_FMT_ld, arg3, 1); +#endif + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_fchmodat static void print_fchmodat(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index e99030c9ef39..ebb713252ce3 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -182,7 +182,7 @@ { TARGET_NR_fadvise64_64, "fadvise64_64" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_fallocate -{ TARGET_NR_fallocate, "fallocate" , NULL, NULL, NULL }, +{ TARGET_NR_fallocate, "fallocate" , NULL, print_fallocate, NULL }, #endif #ifdef TARGET_NR_fanotify_init { TARGET_NR_fanotify_init, "fanotify_init" , NULL, NULL, NULL }, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1b971c06b270..506b94a12c1e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6712,22 +6712,6 @@ void syscall_init(void) } } =20 -#if TARGET_ABI_BITS =3D=3D 32 -static inline uint64_t target_offset64(uint32_t word0, uint32_t word1) -{ -#ifdef TARGET_WORDS_BIGENDIAN - return ((uint64_t)word0 << 32) | word1; -#else - return ((uint64_t)word1 << 32) | word0; -#endif -} -#else /* TARGET_ABI_BITS =3D=3D 32 */ -static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) -{ - return word0; -} -#endif /* TARGET_ABI_BITS !=3D 32 */ - #ifdef TARGET_NR_truncate64 static inline abi_long target_truncate64(void *cpu_env, const char *arg1, abi_long arg2, --=20 2.26.2 From nobody Mon Apr 29 16:21:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593880164; cv=none; d=zohomail.com; s=zohoarc; b=i7fAZ6K0nlT5DpahApAU5Ej33cY4YNRaSJjN+E9WDH6XrbBQdgNYusLJ/GBpzouRcTR0607Kvc0BMZAo63QsaOGJLskY0dkxgP9e/YMj0YCoZzYyj/ulZ4MA+6YoVwRMM4622LxsDZ8mnj+Y+jn/CEhI+spy4nAJhMi145dO51o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593880164; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xjj7sazkKBobNE6s1Ud34DU3UqvVWnEfZhWVfKrNkEI=; b=YeDfyGXRbLxyawmrTtwCWRv25g0BslS0TJoJhwMFXC+F2GbXH/XAnC9Ox6yWFqZkAdnPAGrh6SXSqEOldBGrZuZse1XAPoZDnpoGEZYfcolXNI+RYLAX5eGtq+B5b7J15NL1+2yUmvEI0fZlNkRyWk4yvFhLqosAVlr+yBE0cR4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593880164514144.3490744083574; Sat, 4 Jul 2020 09:29:24 -0700 (PDT) Received: from localhost ([::1]:53208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl2Z-0002gn-4h for importer@patchew.org; Sat, 04 Jul 2020 12:29:23 -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 Content-Transfer-Encoding: quoted-printable 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: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 def= inition. These ioctls didn't have defined thunk argument types before changes from t= his 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 de= finitions in file "syscall_types.h" and "ioctls.h" as it is needed for printing argum= ents 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 a= nd the other is the 2038 safe variant used for 32-bit architectures. Correspon= ding structure definitions STRUCT_timespec/STRUCT__kernel_timespec and STRUCT_timeval/STRUCT__kernel_sock_timeval were added for these variant= s. 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)) } }, =20 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 */ =20 +#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 */ =20 +STRUCT(_kernel_timespec, + TYPE_LONGLONG, /* tv_sec */ + TYPE_LONGLONG) /* tv_nsec */ + STRUCT(snd_timer_status, MK_STRUCT(STRUCT_timespec), /* tstamp */ TYPE_INT, /* resolution */ --=20 2.26.2 From nobody Mon Apr 29 16:21:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593880562; cv=none; d=zohomail.com; s=zohoarc; b=EEM+15QwG/RziY0AuKkxWPLNEdiXw1uIRAq6QM6eiY8owR2K7GZo7C+uuXzUIMCqmReYphwB9hNUuF2oRvzcP6IyBNiP4FeurqLpzVvn6MqEbRJLbE0M2a2XsIlnVrvJod9T8YzpJFdmKFBMBk+NomEioKwRmQST8ewQGqNmPjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593880562; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f2aMtPRs92mqCkEHHoFxq0VqGdQBKcoNEcJ6av/Mvow=; b=CHR+1n/mz16kjCTGYJndu70FMWwMaHZi3EMX37I6JbGUmAqloQBG8s8FX3cbV0G5bRG059PQ7wk31QJL1Tas7pbt6pi1HSbYI5XDo1HghWllxUdKFrY7Z+Q/d3nu55BH9BIBOjX+CmhxYdnzt9Xp+3gmigmsQfsBmihHSZPlfgE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593880562533113.4046705910597; Sat, 4 Jul 2020 09:36:02 -0700 (PDT) Received: from localhost ([::1]:46046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl8z-00045E-8V for importer@patchew.org; Sat, 04 Jul 2020 12:36:01 -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 Content-Transfer-Encoding: quoted-printable 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: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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*) =3D ret_value" where the request code an the ioctl's third argument get printed in a hexad= icemal format. This patch changes that by enabling strace to print both the reques= t 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}) =3D 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) =3D 0 ({22,9,13,11,5,120,0,0,0})" In case of IOC_RW type ioctls, the contents of the third argument get print= ed both inside the ioctl call and after the return value. Implementation notes: Functions "print_ioctl()" and "print_syscall_ret_ioctl()", that are def= ined 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 "sysca= ll.c" to file "qemu.h" so that they can be used by these functions to print t= he contents of the third ioctl argument. Also, the "static" identifier for= array "ioctl_entries[]" was removed and this array was declared as "extern" i= n "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 fi= le "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 *nam= e, 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); =20 extern StructEntry *struct_entries; =20 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 */ }; =20 +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 =20 +#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 >=3D 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); + + const IOCTLEntry *ie; + const argtype *arg_type; + void *argptr; + int target_size; + + for (ie =3D ioctl_entries; ie->target_cmd !=3D 0; ie++) { + if (ie->target_cmd =3D=3D arg1) { + break; + } + } + + if (ie->target_cmd =3D=3D arg1 && + (ie->access =3D=3D IOC_R || ie->access =3D=3D IOC_RW)) { + arg_type =3D ie->arg_type; + qemu_log(" ("); + arg_type++; + target_size =3D thunk_type_size(arg_type, 0); + argptr =3D 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[] =3D { FLAG_GENERIC(F_OK), FLAG_GENERIC(R_OK), @@ -3026,6 +3064,75 @@ print_statx(const struct syscallname *name, } #endif =20 +#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 =3D ioctl_entries; ie->target_cmd !=3D 0; ie++) { + if (ie->target_cmd =3D=3D arg1) { + break; + } + } + + if (ie->target_cmd =3D=3D 0) { + print_raw_param("%#x", arg1, 0); + print_raw_param("%#x", arg2, 1); + } else { + qemu_log("%s", ie->name); + arg_type =3D ie->arg_type; + + if (arg_type[0] !=3D 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 =3D thunk_type_size(arg_type, 0); + argptr =3D 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 =20 -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 =20 #ifdef CONFIG_FIEMAP @@ -5374,7 +5356,7 @@ static abi_long do_ioctl_drm(const IOCTLEntry *ie, ui= nt8_t *buf_temp, =20 #endif =20 -static IOCTLEntry ioctl_entries[] =3D { +IOCTLEntry ioctl_entries[] =3D { #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 *s= rc, return type_ptr; } =20 +const argtype *thunk_print(void *arg, const argtype *type_ptr) +{ + int type; + + type =3D *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 =3D=3D 32 && TARGET_ABI_BITS =3D=3D 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 =3D=3D 64 && TARGET_ABI_BITS =3D=3D 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 =3D=3D 64 && TARGET_ABI_BITS =3D=3D 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 =3D 0; + switch (thunk_type_size(type_ptr - 1, 1)) { + case 2: + val =3D *(uint16_t *)arg; + break; + case 4: + val =3D *(uint32_t *)arg; + break; + case 8: + val =3D *(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 =3D 0; + + array_length =3D *type_ptr++; + arg_size =3D thunk_type_size(type_ptr, 0); + a =3D arg; + + if (*type_ptr =3D=3D TYPE_CHAR) { + qemu_log("\""); + is_string =3D 1; + } else { + qemu_log("["); + } + + for (i =3D 0; i < array_length; i++) { + if (i > 0 && !is_string) { + qemu_log(","); + } + thunk_print(a, type_ptr); + a +=3D arg_size; + } + + if (is_string) { + qemu_log("\""); + } else { + qemu_log("]"); + } + + type_ptr =3D 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 =3D struct_entries + *type_ptr++; + a =3D arg; + + field_types =3D se->field_types; + arg_offsets =3D se->field_offsets[0]; + + qemu_log("{"); + for (i =3D 0; i < se->nb_fields; i++) { + if (i > 0) { + qemu_log(","); + } + field_types =3D thunk_print(a + arg_offsets[i], field_type= s); + } + qemu_log("}"); + } + break; + default: + g_assert_not_reached(); + } + return type_ptr; +} + /* from em86 */ =20 /* Utility function: Table-driven functions to translate bitmasks --=20 2.26.2 From nobody Mon Apr 29 16:21:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593880407; cv=none; d=zohomail.com; s=zohoarc; b=GVDBKDguYGB6uNDBKGjHzB0Ak8fq01gURSacqNYXEPXr8hUTWX4+ZBHG3BpcG7fFoLR78r0TbxdT3TwzRoSjivM5uxh/QsTQvKDUN8coGTmEKzxbq45f7uzWLrv2e+NVdANzNetAUkajU/ZSxm9zPCimY4X4Kjo1wTFLNYR/QE8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593880407; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=o3GRM4NdsMmA1n1g9ivdcI80g3X+Mg7b7clupkT/Nd8=; b=AuJR+cGt5FLmD9M2petRjXpVUomPt/HEu1s2rHjool1OnOmkoIB4y7HnoQrYCpx1xjHPCHBeMAyZ4MartCye1kSkm2pqfdYcgaxcAwwjVJv6GLsX6/Q3eq85QUd2fyWcxSWBp8ibg51/itVuDdOJQhJUgn+10UN8lL9DE8j56hg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593880407409627.1380240007851; Sat, 4 Jul 2020 09:33:27 -0700 (PDT) Received: from localhost ([::1]:37058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrl6U-00084G-3Y for importer@patchew.org; Sat, 04 Jul 2020 12:33:26 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= , Artyom Tarasenko Errors-To: qemu-devel-bounces+importer=patchew.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=C3=A9 Message-Id: <20200702111636.25792-1-riku.voipio@linaro.org> Signed-off-by: Laurent Vivier --- MAINTAINERS | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 =20 Linux user -M: Riku Voipio -R: Laurent Vivier +M: Laurent Vivier S: Maintained F: linux-user/ F: default-configs/*-linux-user.mak --=20 2.26.2