From patchwork Thu Jul 2 15:26:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1321571 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49yMXZ2WmGz9sR4 for ; Fri, 3 Jul 2020 01:32:14 +1000 (AEST) Received: from localhost ([::1]:58854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jr1C8-0007gM-2C for incoming@patchwork.ozlabs.org; Thu, 02 Jul 2020 11:32:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17X-0000TU-AD for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:27 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:43037) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17S-0006IL-Ba for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:27 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MhlbM-1jDGRk2hvc-00dlyL; Thu, 02 Jul 2020 17:27:12 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 01/12] target/sparc: Translate flushw opcode Date: Thu, 2 Jul 2020 17:26:59 +0200 Message-Id: <20200702152710.84602-2-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702152710.84602-1-laurent@vivier.eu> References: <20200702152710.84602-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:XAeweq2/wNjsvfr4kwoLXVH2UbpOdVUgt001l1B6y9UtnsVU7/i clHAVj3H2Z9dyFpumAwADp9qufvRmKHx136MWK6JP/Stv96litmiTkk0ujU/MunwGa3YW9s ILkNNe0xzuWocgcFemF73iiP+KxgObKhT5QL0gOQjKVhWu4JGf61QDoe+CePUOL1A9FRmMn 3hGIDTX1VoYsnCj2Sy3Yg== X-UI-Out-Filterresults: notjunk:1;V03:K0:j3CxfANrJiA=:cylJceBTqCdgyPcx1AcEz1 3RW6vms2WH41TLBe413qvBcpmPDavgEJp7i6rLZ2992UT8MW4VOml7PHnGu9/MKbwWzkHi8TS gYy6U1XmjRusa3YQ4b15wXGxnNVW3nzUMqJu2DETzkRbkvjCSrWJJkbFPQ7aTIDNEaPh/lLsB EA7RTu1xDYnhTPGZyhaIc9sJcIq9Z2cgTlq/t+hbpGMuzF/IkQwowu4i/81NcBoc51HF40J/h iKK0mfaHyMo7BvPYX37UDm9DhN5yuer/RStFqMd+FBkSg4Y2qTLMZztlo+SoPEvNZeZnJWgE7 soWbr0jiTFCPEi6jARgVboZrLX104lRWuUCQY+Cdo4c15oY+C5kRrssPxjslfEeOU6FjAOONA Ktx82zySZ47FYOX+IjbpGAXtO1zbYWpUduKtQevy9SKzJdPgwKno8Pahuuk3CAkA0Br6k7mXT f4irVCWIF1zTzoA+G5yzOGD3lHqQbIuKy3G2ysA/KWQz90OjTI+Kmt2mhkJ3ifh/uhtaHf75u x3/XQ08A2yZHXIaKJUXZiDHWXTWDWLWJpGnjQMCl+5+c2Nf2zATOLoI/smqmRaJJF+MNcIpE7 VvaxVWaYB/XkIzB72Sg0U0uVznDujf7uv5Gv3OQNr89pTlvCFemnPkGWC02M1Lf4Wsh95oiZt 4GRoH/ujFlXL+P/etmTAXvW1B49HKjOwWqNdU7OG2FMjothXwhC2+Y1qHP6j47WWFy9i2RBaV PuUx4wKRsDBkHtiBQunTYrfyCaDNvKgESZJfVx5PI959YhscXARZXdGSpN4SZD4yAcQY2PLic 81AsmTFXJRXBCSKUuPP10P4VvbeOvpZSS9kn3jpq8J1DIPa+9U= Received-SPF: none client-ip=212.227.126.130; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/02 11:27:21 X-ACL-Warn: Detected OS = Linux 3.11 and newer 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Giuseppe Musacchio The ifdef logic should unconditionally compile in the `xop == 0x2b` case when targeting sparc64. Signed-off-by: Giuseppe Musacchio Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <20200625091204.3186186-2-laurent@vivier.eu> --- target/sparc/translate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 9416a551cf46..1a4efd4ed665 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -3663,6 +3663,8 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) #endif gen_store_gpr(dc, rd, cpu_tmp0); break; +#endif +#if defined(TARGET_SPARC64) || !defined(CONFIG_USER_ONLY) } else if (xop == 0x2b) { /* rdtbr / V9 flushw */ #ifdef TARGET_SPARC64 gen_helper_flushw(cpu_env); From patchwork Thu Jul 2 15:27:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1321563 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49yMRZ1VCCz9sDX for ; Fri, 3 Jul 2020 01:27:53 +1000 (AEST) Received: from localhost ([::1]:42518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jr17v-0000TT-Cy for incoming@patchwork.ozlabs.org; Thu, 02 Jul 2020 11:27:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17U-0000Rj-Ut for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:24 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:58457) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17T-0006IQ-1y for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:24 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M1HuU-1jpMQV1iI6-002ofL; Thu, 02 Jul 2020 17:27:13 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 02/12] linux-user/sparc64: Fix the handling of window spill trap Date: Thu, 2 Jul 2020 17:27:00 +0200 Message-Id: <20200702152710.84602-3-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702152710.84602-1-laurent@vivier.eu> References: <20200702152710.84602-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:QBrQcB5DztA7knOhNhU9kAxyVGIrVZW7MQBvZv3bpPXqcmpr0PD lJt0QL1MGpdhzf5aHF7bxXcge9ko2BCJcRzzS1MBjQ6dQ/Bs8t+MuFZzf/gcNBPDFiMp95A ivpDodPlYSg4mgyheFQ5J7RbSqmDijyhb4WLKqzu69M6XaYQMRlZdCOpE92toWPCPEFrC/T R6mHxfNFsLxrL9xaqjxiw== X-UI-Out-Filterresults: notjunk:1;V03:K0:JYTIK/MwxHE=:/zhJXYbYcO8mylBuhAhOky pe334IqDBNuUIb4/Gl4cUHPyc3u3EkmhbsDjiZCsK5NpxwaGxgsr+dtvIADPSRbQpILPhRCkZ gN+3OZiqlI758sJFFInIKxNxFQEXS82Uw+v8YqYjOan3Nl5shnSupTVc6bhC/JHLtjm3V18g4 s+dZ8GEKrPudxL7qJuWjxQPwee0awWsPNnCUax0i87ayrbFxZDuos0r0Ymcs+FdZPPAsmuLZP 26nKeFY2dzPEsLA7HV1pLyGX3cFCAERHYEwjkxHTKztJU1tEWOh+niets0CR8IUiZ76nWDLbA niuG7mQnLMnm0BwsQPMX8db+4A2zOt24KedxatWtxLyIHorgeFrc2JM7cimsAfbfMYZRaBkMT Po/n+eHIFpV0AzTmhm6tFAx7cYwXYocb5n3T+wL3sQTo2ln1n/BWZ32f1A8tEZcC7Fl9FStnA 1ZPylbxyel5FXDoZ/Wy0Z5D6qvbUfk5xW+YdwGCGak94xPGFW4q1N5kfgsBAkwhU4o3KNn/Yy gKP/n4QR/c8FjoNeVwOYWLKfyLTiWQ/xvf+xSHNRq6WVrrUDZ8KAhFci2rT57e1ux6dZgiZwx RxbCoYKHEPQu9fCBlTPwvKRU2N03faNullWmFF5Pl4EN13++veO0lT7RpjBzeYdTkQ0EZ4tJN pL43Gvm0VDS7sh0De5FehFNyn0IsvcEQfr23C6ZQ+2Oc8xqqHofiUj/CVwhsjFxcmE1E+gcJl nJPwax7XSRz2T2KXl1oXtgySPaqm7N7Aqas30+7JBXLGyq/hyHoO4ESw6q+wado4ExAtZbFfy kdnlG6u1mWkTMT78pfw8lag3yGy1E7ZTlGsxdeh1AovYurJ2IE= Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/02 10:57:57 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Giuseppe Musacchio Fix the handling of window spill traps by keeping cansave into account when calculating the new CWP. Signed-off-by: Giuseppe Musacchio Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <20200625091204.3186186-3-laurent@vivier.eu> --- bsd-user/main.c | 6 +++++- linux-user/sparc/cpu_loop.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 0bfe46cff93e..ac40d79bfaac 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -413,7 +413,11 @@ static void save_window(CPUSPARCState *env) save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); env->wim = new_wim; #else - save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); + /* + * cansave is zero if the spill trap handler is triggered by `save` and + * nonzero if triggered by a `flushw` + */ + save_window_offset(env, cpu_cwp_dec(env, env->cwp - env->cansave - 2)); env->cansave++; env->canrestore--; #endif diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 7645cc04ca73..02532f198df8 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -69,7 +69,11 @@ static void save_window(CPUSPARCState *env) save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); env->wim = new_wim; #else - save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); + /* + * cansave is zero if the spill trap handler is triggered by `save` and + * nonzero if triggered by a `flushw` + */ + save_window_offset(env, cpu_cwp_dec(env, env->cwp - env->cansave - 2)); env->cansave++; env->canrestore--; #endif From patchwork Thu Jul 2 15:27:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1321569 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49yMVT48qyz9sTN for ; Fri, 3 Jul 2020 01:30:25 +1000 (AEST) Received: from localhost ([::1]:52198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jr1AN-0004XG-Am for incoming@patchwork.ozlabs.org; Thu, 02 Jul 2020 11:30:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17c-0000gx-OG for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:32 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:36085) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17Z-0006Jy-6H for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:32 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MWAjC-1jKRTc3KLi-00XdDH; Thu, 02 Jul 2020 17:27:15 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 03/12] linux-user: syscall: ioctls: support DRM_IOCTL_VERSION Date: Thu, 2 Jul 2020 17:27:01 +0200 Message-Id: <20200702152710.84602-4-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702152710.84602-1-laurent@vivier.eu> References: <20200702152710.84602-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:A01o3pm6jUNrpc8TrQTyHer9BFukw6HaiLJ1ZfemwHHX+QyGSd6 vyON53tz8te2buwjGbwjzRUjX+FIogUfRFfZbhsMhgIzQAdnRTWm5NtqpSafHUhBVLue3cH /P9DArNfUbbdDGlWtC6BL9EvHzbIdNP7jPNZM6yysekJ5fUylddNFNppPFq09C2/eCVEDUS LN2Mj7sblCchsT9eo9WzA== X-UI-Out-Filterresults: notjunk:1;V03:K0:JhWTqS+2J74=:c/h0QWwelUFwE0ogSyk0Jl tPEYXWiAswAUnW/x0dEybNfIRcibtidVu1P/8ia07/A5zyswlyOBlZ0xOeKut46umYYeBLpnf y3xfkTZuDSJnXZp31GuxTqfrurTcwQ3LpYTFxXkU9apCuzH84+hywcKA+NoGbz+wFbRJJb5zq NK53Zo0PIBr4CqPrgkvvKXDAlWJNwyW2sxJrSmDzKMfXvYDgr2f6z2c2m02c0vIiNi0NgTDIc ZBId5E3N0A9gFhRB3AoCpBFBtTAgcDgXQeg5jWwqexhrTb9USUONUbt1pTn2WHA2fRNIDxsP3 wzWfqlOuLWI1x1rOIokO0rJ/cirs64S7nBkD3uwi/TMbBBwpoeSLPGj3Ilg+dttTe2joO662G hidfg7+Ckla01G5KSOE4pGC8yMyo3I9ZxIElbrv8PD4L9YA41v5mEdoR08AsNYd0y6t9M0I0n aB0cWQHznhqN0KrnbbMRrKlBsTba6F9SUVMZ4oAtX4TiQQLRDlZsaQrNx1V4LaZqEJrWM7W66 D+YYoCs8FQE4yvhIk0N4XwtY6nqQLVfEI8xnBjuwpq2J2vL1YRvR8L0R7IcOQvYRE36aM/i+1 gztLYb439Z2SEnNe+QGoi8Ct+TUa4+8fAbElbFGv86WlbZOo6uR8xBGQ+V7IfVer8mzuZEAgv opbEV4+yEhEiwTifrKWgXb70OEyQF9noaBK5cOraomKlYLR6yacSNuuQJHM7iA9zHjoOjtGFX eVwkXND2KSIXYh+uICWAkm6Km/bOfLaOr06FVNFvAENJKoM56b5viCPSUf4hrHg9mhNO/+ljW bJoDNooreqN9vhGywlFAnttOWsR2kgYBFsh8/EU+CH49QLDnxI= Received-SPF: none client-ip=212.227.126.130; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/02 11:27:21 X-ACL-Warn: Detected OS = Linux 3.11 and newer 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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=no fi +######################################### +# libdrm check +have_drm_h=no +if check_include "libdrm/drm.h" ; then + have_drm_h=yes +fi + ########################################## # VTE probe @@ -7377,6 +7384,9 @@ fi if test "$have_ifaddrs_h" = "yes" ; then echo "HAVE_IFADDRS_H=y" >> $config_host_mak fi +if test "$have_drm_h" = "yes" ; then + echo "HAVE_DRM_H=y" >> $config_host_mak +fi if test "$have_broken_size_max" = "yes" ; then echo "HAVE_BROKEN_SIZE_MAX=y" >> $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))) +#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" @@ -5276,6 +5279,101 @@ static abi_long do_ioctl_tiocgptpeer(const IOCTLEntry *ie, uint8_t *buf_temp, } #endif +#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 *target_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 = 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 = 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 = 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 *target_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_patchlevel); + __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 = (struct drm_version *)buf_temp; + ret = target_to_host_drmversion(ver, target_ver); + if (!is_error(ret)) { + ret = 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[] = { #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) +/* drm ioctls */ +#define TARGET_DRM_IOCTL_VERSION TARGET_IOWRU('d', 0x00) + /* from asm/termbits.h */ #define TARGET_NCC 8 @@ -2598,6 +2601,18 @@ struct target_mq_attr { abi_long mq_curmsgs; }; +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" #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 */ +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 */ From patchwork Thu Jul 2 15:27:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1321576 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49yMZk05WJz9sDX for ; Fri, 3 Jul 2020 01:34:06 +1000 (AEST) Received: from localhost ([::1]:39452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jr1Dv-0002pm-Nh for incoming@patchwork.ozlabs.org; Thu, 02 Jul 2020 11:34:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17a-0000b3-H4 for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:30 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:34775) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17W-0006J4-QT for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:30 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MirX2-1jC9zD2VLI-00eru1; Thu, 02 Jul 2020 17:27:15 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 04/12] linux-user: Extend strace support to enable argument printing after syscall execution Date: Thu, 2 Jul 2020 17:27:02 +0200 Message-Id: <20200702152710.84602-5-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702152710.84602-1-laurent@vivier.eu> References: <20200702152710.84602-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:15Cb0Bmyj1TMZtdh8oJw7jlYQovftkTrZjQTP5G1zPpdUI+zUlV +FIH/GLVJDTceprewge6lql+9YUMflGP01UFLN03vdIZ/MRW5y9bg3nZXs1n692e4JQmq67 YwRv3l0xIzKiPIcHPAttC8IGxuaHlQCUPfIxG8D18zPgGakh1uwQCnKSkaEWxnAjtLbYD6U Ai97oCtP+DcphnROdvmcw== X-UI-Out-Filterresults: notjunk:1;V03:K0:0eWG7K9fXnQ=:Kdt5JJYcEB2SslJkDXII4R fE1I5zc15Ib9kV92LwdBbRqxjNraIesUnc7WKyqYvWF+3xBEE7suehkBqUe1Cc3rieJfd5+/c rWrmV6JAH0/84xjqOXEqP+AkZRQvoNzLJkWs9DhBqs/qbSP6NszCJLZyDgSrQcgDwrOPr1nN0 qaJIC2b2gizgKH+l3gIggPoA0s2zTQwkt0LN12pXECH156b+jeF9eXJFJL0VQUfsEyNyxm3xK ovGdvP789V6QITLyi48AxRZWDFs+eXS36ek9t56h+kydc+f75IpiJVewtMciPdY1t5HCdf035 GfhtcXSYk7PNMKLYQ3oozeawFiGdNoOaZY+f+yQb7lyrtRcNaequZ4ZlADYvarr0MdKXiSFgA X6BlrDs2YLskwDTgC81hIwj4O1ciUqMe62QonCh9jXZQRupYtDTPkNp4h3cA/j+deQrwlgoHS 8aJS5EVJpzda3cJi85Uq36toWyYldbwFREPu9e4QlkvA/Hp4zsGzRpO0vIlNHCS9xyBwEMJh/ 2K6NSTexku+5Dl4XK5GoNUep2mMriY1Y472WJ4PK0MsYYxc98mPzi4wQWLQQ0oItxtGuHk73a abn6OUInylkwLaw6iQqqCsLkjYZxcykubbqmrnXNRvxFpq06o1w1RsPQZFOv2ON5SCJ7NBHyx V+q2HTjAryl5xcmPIuQUBIlf7yH5D16/2kxLyZ5nZNMhNvMdWVx3lx+Htavwsb76iphXMXVs2 HyECtzkX6o+biwj67vGI1zAtfe68x2TkGT1VxWw3bherI42dspISA52bSiKedR+lDqTtG7RJZ 1oaIszvn8eCLgCUGz7+3Gi5zdAy3+uKOYdvhdxdWfFL9ugLj1Y= Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/02 10:57:57 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 function takes all syscalls arguments beside the return value. In this way, it enables "-strace" to print arguments of syscalls that have changed after the syscall 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 inside "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 cause build errors (even though syscall arguments are not used in these functions). There is code repetition in these functions for checking the return value 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 these functions. Functions "print_newselect()" and "print_syscall_ret_newselect()" were changed to use this new implemented functionality and not store the 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); }; #ifdef __GNUC__ @@ -631,18 +633,12 @@ print_clockid(int clockid, int last) /* select */ #ifdef TARGET_NR__newselect -static long newselect_arg1 = 0; -static long newselect_arg2 = 0; -static long newselect_arg3 = 0; -static long newselect_arg4 = 0; -static long newselect_arg5 = 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=arg1; - newselect_arg2=arg2; - newselect_arg3=arg3; - newselect_arg4=arg4; - newselect_arg5=arg5; + print_syscall_epilogue(name); } #endif @@ -736,17 +725,29 @@ print_ipc(const struct syscallname *name, */ static void -print_syscall_ret_addr(const struct syscallname *name, abi_long ret) +print_syscall_err(abi_long ret) { const char *errstr = NULL; + qemu_log(" = "); if (ret < 0) { + qemu_log("-1 errno=%d", errno); errstr = target_strerror(-ret); + if (errstr) { + qemu_log(" (%s)", errstr); + } } - if (errstr) { - qemu_log(" = -1 errno=%d (%s)\n", (int)-ret, errstr); - } else { - qemu_log(" = 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 >= 0) { + qemu_log("0x" TARGET_ABI_FMT_lx "\n", ret); } } @@ -760,17 +761,25 @@ print_syscall_ret_raw(struct syscallname *name, abi_long ret) #ifdef TARGET_NR__newselect static void -print_syscall_ret_newselect(const struct syscallname *name, abi_long ret) -{ - qemu_log(" = 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 >= 0) { + qemu_log(" = 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 @@ -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 = NULL; + print_syscall_err(ret); - qemu_log(" = "); - if (ret < 0) { - qemu_log("-1 errno=%d", errno); - errstr = target_strerror(-ret); - if (errstr) { - qemu_log(" (%s)", errstr); - } - } else { + if (ret >= 0) { qemu_log(TARGET_ABI_FMT_ld, ret); switch (ret) { case TARGET_TIME_OK: @@ -2847,25 +2851,25 @@ print_syscall(int num, 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 = NULL; for(i=0;i= 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_long arg1, arg5, arg6, arg7, arg8); if (unlikely(qemu_loglevel_mask(LOG_STRACE))) { - print_syscall_ret(num, ret); + print_syscall_ret(num, ret, arg1, arg2, arg3, arg4, arg5, arg6); } record_syscall_return(cpu, num, ret); From patchwork Thu Jul 2 15:27:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1321564 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49yMRY70lkz9sR4 for ; Fri, 3 Jul 2020 01:27:52 +1000 (AEST) Received: from localhost ([::1]:42464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jr17s-0000RB-E1 for incoming@patchwork.ozlabs.org; Thu, 02 Jul 2020 11:27:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17T-0000R3-Ck for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:23 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:37651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17Q-0006I9-Le for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:23 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MryCb-1j33JZ1es9-00nuRY; Thu, 02 Jul 2020 17:27:16 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 05/12] linux-user: Add strace support for a group of syscalls Date: Thu, 2 Jul 2020 17:27:03 +0200 Message-Id: <20200702152710.84602-6-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702152710.84602-1-laurent@vivier.eu> References: <20200702152710.84602-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:1XMrjVSxvk9CB2IN39hZNQi6GlCjnaSIRXqvfwsk7CQsQVOLZLU cIMoafn1ymfoWo9hXCPjqzR4Bxvkl1aw3AM3JcqpZEuY0VWQOdDZfsnINJdLO9jGQtVp8sO ztP5dqIXmjhb2SligHAHN4GATatU1XgFdkvEu0x/4ucpBZAJdxjAQrozggQEVT9dI0MHAKA Ce34rpQM+oQan46ET3P5g== X-UI-Out-Filterresults: notjunk:1;V03:K0:2vMUf9oL1k8=:mzPIIG0JgQsmI9yJ4CiCIO iiO6iRyB/zKu2nZ3TRgshIlz799xhtqW1UFFlzeTwF3Osbi+GoautBmEOrNLf4nmkvXIoAVjv fjunVLcKtO/YXy4umSdOd3OxwZ1wXdVJTWU9IZtkTS08xm+2BPpicWSXuCTJVpvmd/BiVnHcV YMTNgpWk8EGtHgOiulwMjsZet0oanhGBqHsqp92jW499/BgOCzKR7zO4nzfbnJtuOZVX+MY9N DKXIsGLnHn7e2J55ScDfbnUjeVaszTPYXBSjQmc1DYR8JUOgP78N2ZWMWfken8jdpdK05sbhn rXjXL+7z+RR4qBFPoaRcHFmm3HN2IkZOAkhfDyVKS9kzuNuUv0NvxXW7uY+4vGpOcwN03DO8P LLpjNR0Iw8EfRv1ddtOZcdgic9w8Wz3XvCYgkvLC8gTiIBRmroqqLjhJjNkX+nvEIy+Ji/MNB fdbsFR6eiGh8e1UOQ1Hq9gTvloZ1CiVB0MisYZ3YCmNjaBYxFR3zNbkm5PB9PbZw0wcdwOf3S vhaS5VvXZoiifK+hvEr4NJ3wpeIIS179jsWeX4F0uUcbq4w4vGVvVOMdA/R5rYwQ6dGOy8rY6 qk4l2yaQEW4yxgeP1QbMgi6AfeZ1rLxCEiSGj2x3ssCdo3+vayPjECUo0WbLgSmxAOWAVcUs0 ZL2qoHLLwQN0riy/CrNNK2FmYkBsN/gHTzKYBGaF2twZqsLrqbGQxaGorU3u6A8EFtVWvo/1R 7Pti8uehj9NccUTrlfl3zGOgzaGhqAJdz98vNcs2bvcWhOyZhR3ePN6dZTr5yDVfEh4oFquGV eiA4UpKX9PX/qZaq8rxEiYW0wF0/YOkjVZGk8+uedMhU1TZb3A= Received-SPF: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/02 11:27:18 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscalls: *acct - switch process accounting on or off int acct(const char *filename) man page: https://www.man7.org/linux/man-pages/man2/acct.2.html *fsync, fdatasync - synchronize a file's in-core state with storage device int fsync(int fd) int fdatasync(int fd) man page: https://www.man7.org/linux/man-pages/man2/fsync.2.html *listen - listen for connections on a socket int listen(int sockfd, int backlog) man page: https://www.man7.org/linux/man-pages/man2/listen.2.html Implementation notes: Syscall acct() takes string as its only argument and thus a separate print function "print_acct" is stated in file "strace.list". This function is defined and implemented in "strace.c" by using an existing function used to print string arguments: "print_string()". All the other syscalls have only primitive argument types, so the rest of the implementation was handled by stating an appropriate printing format in file "strace.list". Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200619123331.17387-3-filip.bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 13 ++++++++++++- linux-user/strace.list | 8 ++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 62117e8555f6..123e022c35bf 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1357,6 +1357,18 @@ print_access(const struct syscallname *name, } #endif +#ifdef TARGET_NR_acct +static void +print_acct(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_string(arg0, 1); + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_brk static void print_brk(const struct syscallname *name, @@ -1621,7 +1633,6 @@ print_fcntl(const struct syscallname *name, #define print_fcntl64 print_fcntl #endif - #ifdef TARGET_NR_futimesat static void print_futimesat(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 9281c0a75828..8a887fc16dcc 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -13,7 +13,7 @@ { TARGET_NR_access, "access" , NULL, print_access, NULL }, #endif #ifdef TARGET_NR_acct -{ TARGET_NR_acct, "acct" , NULL, NULL, NULL }, +{ TARGET_NR_acct, "acct" , NULL, print_acct, NULL }, #endif #ifdef TARGET_NR_add_key { TARGET_NR_add_key, "add_key" , NULL, NULL, NULL }, @@ -215,7 +215,7 @@ { TARGET_NR_fcntl64, "fcntl64" , NULL, print_fcntl64, NULL }, #endif #ifdef TARGET_NR_fdatasync -{ TARGET_NR_fdatasync, "fdatasync" , NULL, NULL, NULL }, +{ TARGET_NR_fdatasync, "fdatasync" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_fgetxattr { TARGET_NR_fgetxattr, "fgetxattr" , NULL, NULL, NULL }, @@ -251,7 +251,7 @@ { TARGET_NR_fstatfs64, "fstatfs64" , "%s(%d,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_fsync -{ TARGET_NR_fsync, "fsync" , NULL, NULL, NULL }, +{ TARGET_NR_fsync, "fsync" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_ftime { TARGET_NR_ftime, "ftime" , NULL, NULL, NULL }, @@ -492,7 +492,7 @@ { TARGET_NR_Linux, "Linux" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_listen -{ TARGET_NR_listen, "listen" , NULL, NULL, NULL }, +{ TARGET_NR_listen, "listen" , "%s(%d,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_listxattr { TARGET_NR_listxattr, "listxattr" , NULL, NULL, NULL }, From patchwork Thu Jul 2 15:27:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1321566 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49yMRn6cqMz9sDX for ; Fri, 3 Jul 2020 01:28:05 +1000 (AEST) Received: from localhost ([::1]:43682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jr187-00012G-LW for incoming@patchwork.ozlabs.org; Thu, 02 Jul 2020 11:28:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17a-0000cB-UV for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:30 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:55779) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17X-0006JZ-Gp for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:30 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N2Dks-1ioQ39077W-013gBL; Thu, 02 Jul 2020 17:27:17 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 06/12] linux-user: Add strace support for printing argument of syscalls used for extended attributes Date: Thu, 2 Jul 2020 17:27:04 +0200 Message-Id: <20200702152710.84602-7-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702152710.84602-1-laurent@vivier.eu> References: <20200702152710.84602-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:FQF7oYq3uias1Bm0UEliWmRpxfkN/XM8sOKeUbBszVOluN+bIB0 NPwzzkY6tY6nSs4Jkwl38uMXp8Oamk/JPvk0HXDe5oPlhuzz9ut7CHKjZsN+cTtobGQgsdl jT0Q1rpaVMEP1N8o4oN4amIS6YbaB8NFoCh3iluDZFFD53CMS8CqIa3yV4ZjdhFPcpgHeSL b4P84JihQcaUTb73cJnfA== X-UI-Out-Filterresults: notjunk:1;V03:K0:j935DXDYcCU=:VwbOiCsNo7g/VypsXjfBwg pBl56grbeT+IwWDB3yVi1bZKNzycpuObsAn6IoMS3eCT1IeclI+oVeRPVGZ6Rcl53Rp5rE5G1 97NeWRaWxx9B4XY5GtrIJXeYb+1/MEhwcidBZvJI7lh/eklaI8kyZ5n8zKouFmhyzgWEtUEBv 4nShywJnUU/ujSdltXa6rQtgCMs4FKzQuwR3CkSXbXLMFTtqHS7PpvuDPr3EtoP20KT5gegbC pIXmbIX1huWHn/zUDLADw/Trd+FcNSF+9z0Oa+t3CNvuvSc+Wf35qfkNlsCPqiz4O8wcNOHkm w2YYynrLA/KB2nIDh5jzYSx1mshmvSnwECUhPlSxJ7NHJFuiLwEV4ilcWgOU/oKtdiCVaPfVY WvbbTwp8DRvOOW+D94pfwuwmtlHUQbJ6786gW+P6aeW55gWCK18cvcjEW44YAzH7dvItv/qf5 04frXvA/Y5Q3DGqL3GaPoVvIzRUYBg2gnE/vTwHebUUBuU1Vb3s/A+snGd3h29q63c4MiuQU/ ZQg+x3XVL+CRmUZptUfbeFlAsnXVzRcjiD5aDO35NMvwVr9QBIjy7oE5ud5IUSzz7tY25ah9y c4oobwTY2S1Dg3URxyjfN3zewEnMc5FG/nE/LugU8qU8E6fXNahgzaonLGUTNT2hJQZ//IXIk V7F6ZwfArbwQg6LNRqmUhRiDDA2/AiWkQ6pOAknDz3X15tge4sN8TrVw1K8zxizx48xQpfNyR jk0nC3lBNPQuBn/pl9KxUWZmPs7MfLNrOVfUQer+2FTl61GdrGbjbBvZts3sZNQTlP8DzlxMS b625AAb/VRgau0pDkX8Zc1kpiBLw2U8y+Qy/rKPmmL394oqZx0= Received-SPF: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/02 11:27:23 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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, size_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 size) 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 them. All of these printing functions were defined in "strace.c" using existing 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_lgetxattr") share a same definition. The same statement applies to syscalls "listxattr()" and "llistxattr()". Function "print_syscall_ret_listxattr()" was added to print the returned list of extended attributes for syscalls "print_listxattr(), print_llistxattr() 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 *name, abi_long ret, } #endif +#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 >= 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); + qemu_log(" (list = "); + if (arg1 != 0) { + abi_long attr = arg1; + while (ret) { + if (attr != arg1) { + qemu_log(","); + } + print_string(attr, 1); + ret -= target_strlen(attr) + 1; + attr += 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[] = { FLAG_GENERIC(F_OK), FLAG_GENERIC(R_OK), @@ -1633,6 +1667,93 @@ print_fcntl(const struct syscallname *name, #define print_fcntl64 print_fcntl #endif +#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 }, From patchwork Thu Jul 2 15:27:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1321565 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49yMRb5kb8z9sTN for ; Fri, 3 Jul 2020 01:27:55 +1000 (AEST) Received: from localhost ([::1]:42608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jr17x-0000WD-H1 for incoming@patchwork.ozlabs.org; Thu, 02 Jul 2020 11:27:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43172) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17V-0000SC-6T for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:25 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:53833) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17R-0006IG-Ix for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:24 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MTi9N-1jMved0xQr-00U4JY; Thu, 02 Jul 2020 17:27:18 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 07/12] linux-user: Add strace support for printing arguments of lseek() Date: Thu, 2 Jul 2020 17:27:05 +0200 Message-Id: <20200702152710.84602-8-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702152710.84602-1-laurent@vivier.eu> References: <20200702152710.84602-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:MS247B+cncjovVzKNv2NhuUL3/8iqUyBUSgZ1hmQE++EIQRwNLx jPatrNpAbmjUICNEd57J0k/QUUFuj9TzuXgX5AJfBsjUieDK6M1j/XgpD/PE2uXLjFc6t64 sVASvCdKUXeBnrJGNBhN5Lw+Vmlosbmhkf4FQKBZ7m2+xk9xbOwXnS5dDFR0zWJfNYl/Vx1 kZDmwn/k7Xclxcouw3lag== X-UI-Out-Filterresults: notjunk:1;V03:K0:kyeEI88sOJk=:Y2bHPOyoGrJ7VtdQhmFkzS inZq9SICvnStcpBuYQw2yD0iNAMIUI2p1sEKiPlZV8MCmRsNUJ3Bu/j0LCzXqcXtgAkCxa61I 2rmF5QRNzsoA7AL/8ZHJjWTLLVpdlAYnDOyp1csm+BNExfT+70mEnlOgQhXT/JZpdBwinRM0J QqQ6GDloQjkTausxe9zXZdGD1bL7yWP+Y/T05JDOaq5vd2iUiwWIu4Hq5WbfHl8KYNBwcklX9 Lp4pEMOQrxH3Y9Csb9JXH+9hb+bnmJggUzqUwbIRKWK0l4NVAa7mIGEheyLJr/8s2GFxF/2/o FMf59gct92nJOGPQiQNzt+6Yu2TW/lpH10Zd1A2P+NjyBUZAAX0JEJpeGl8dOXmuy+128aTHz JQdYNZ1yCIi/e0/w+5Y7iR1yUKG20epHZ2RiAaPNpl1lS2ZSrMKzmtjLrY3dadydAaPF+waBJ amMUy5/WIG7Km7Hxf/3L22u+W+kiSiu7yFlL5G/o91jiLbWm+S5P9/bvhE/v8F2cJo4Zeew7Y wX2Fs32eZnSuhqcQ4N9+mCyg+/sbwdikrwtuBSvX2568mjUxvtTczyJ9Wlg7ggtJ4hOoceZ4Q QLwFxa/n5UD0Owv3lkHphRVFSgo8gVC1PjmaONp3U72BUR0dlYgjAwK+ATHjq8tSdR86ILWN5 DQTf9yeZrR7XSMQqoK5Q+5nw/nDAHwSrAggmiorIZui/d15YzQ6Sg4We/YbzYjua2O/Yvnk+O +CxehaHRa6Ik/OlbTxHdP5aXr59fYmBew/baAQoKrZY1spZNkG8q2AAQpx5W+3mGvWoa0EgSj WUJ7H+878L4p64HSqjOPtWClvFZ1dwQXLOBQXSlCASaYaO/PUc= Received-SPF: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/02 11:27:18 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 +#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 }, From patchwork Thu Jul 2 15:27:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1321572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49yMXh0MkGz9sDX for ; Fri, 3 Jul 2020 01:32:20 +1000 (AEST) Received: from localhost ([::1]:59470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jr1CD-0007vL-NB for incoming@patchwork.ozlabs.org; Thu, 02 Jul 2020 11:32:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17Y-0000Wb-VL for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:28 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:50419) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17U-0006Iy-Rq for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:28 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MLAF0-1jZtwK3fyk-00IH9H; Thu, 02 Jul 2020 17:27:19 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 08/12] linux-user: Add strace support for printing arguments of chown()/lchown() Date: Thu, 2 Jul 2020 17:27:06 +0200 Message-Id: <20200702152710.84602-9-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702152710.84602-1-laurent@vivier.eu> References: <20200702152710.84602-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Div1Oj4QFV38XvoLfpAS/N2QSRDhF4/3VWi+zsYAXkIQbOAyZTN PcPebioBEhtv6qfKDGIqsj70FUCpEyWZE+yiWqz4LBstjt+SEeC1eM9eGpIiR2jIgoDg6F5 NhTFsNHI3Ba4jabJhDfIiFC2bMI33hIZnD9q73OrCFhNWuhCCVhEDsxTJchZolmiLX5fu9V Vghhks2UDQaJCD/b7Dsdg== X-UI-Out-Filterresults: notjunk:1;V03:K0:OPZCB9/iFRE=:uPEyeDln5rs0qNiVXYwlG/ E2eNVZlpcmcKpJ//hiajeLU8O6lomJOdF/ogbkqp+E5eaQJxYMeYISG3yCcgdVcAt4YQLNKvT prb7yi1btC5zUayT9CyVKi5rv5eupcuM0YcyL9Oc4bBSBIj61Og83n6Tew/FStVpgvAR+A4bR dKQvnmFPcq+nlJFtBrPX0jq2Vux5rPkm3acZDxGc9TBekIuhp9wxI76Kf4rwwu2CtDV6T1ufu SnqxicDK32VQ1V7zsNQPSqJ2hcR8gPc19cc8aNfCuy5AflY+6nNbZ1rq7hQpV7r6NCqKc+G0p Tc9NlUKY1JRix4fEQPI0icj/Ga2EcKXMpBmsXUpyInU2Bo7k8n0DiVDn7kIFeJWG61zFOLH8e mPKenerTJQl5/JJht3fhwbViSC29C47ukh20r7pZZusJL4eV1H1z5TUFZ9Z9mcZ4rEgUR1NNN 0pkuIFl7NxKv95sXZY2Al+R2SXjJZ8Hw7NzQ1rhYvtKz2UtNIWLaD51IKRUXk7I67xWbWy9Sg BMA8ppSNzIFKT/dV8ov2PTispvghxw4dG6MijoxGrEJjMD8F4RDSdmWzdNBJl6MatB45x2xAY X2/sjnfVxO7KAhrVgMxplKTWLHKhwopyxVtvWZrZLEOZ4/j34SLq6a//8fUZsw7LBcEJHLjzP H6/4iRljNF/rH89FSMiaU4VoFmanXqhlPdOTSGgi2tJIw/Sde+EczGZT931SKH06kTJS/MavW j3Ud8erG8ID48hsmyCXcbpLO+JJnotCeRFF50D+ZurJJN+jAbSpj/M2ScjzRwKlgfhr+cEl5B QHBjEbr5wD9kFbi0fsOTqrE+R3CnXyWvrtpCASM6wlqNSVxd/8= Received-SPF: none client-ip=212.227.126.130; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/02 11:27:21 X-ACL-Warn: Detected OS = Linux 3.11 and newer 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 +#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 }, From patchwork Thu Jul 2 15:27:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1321602 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49yMgF30yDz9sDX for ; Fri, 3 Jul 2020 01:37:59 +1000 (AEST) Received: from localhost ([::1]:56134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jr1Hf-0001wn-LK for incoming@patchwork.ozlabs.org; Thu, 02 Jul 2020 11:37:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17d-0000ht-1x for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:33 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:43027) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17Y-0006Jm-KZ for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:32 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MbAxU-1jFTNX29A8-00bbBZ; Thu, 02 Jul 2020 17:27:19 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 09/12] linux-user: Add strace support for printing arguments of fallocate() Date: Thu, 2 Jul 2020 17:27:07 +0200 Message-Id: <20200702152710.84602-10-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702152710.84602-1-laurent@vivier.eu> References: <20200702152710.84602-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:wAQbsdi2ybPskcxRUNZ0iiHDf3KChToM9lAyGJ/WqCrR5Cb3DwY dNx35lwhloNcujyEx42X/KuzYDqinGVW+C//Wzqg3zh9E456muP2XB9Tfm3rzDKlO6rJFQh JzlbX3eIZOR86s2YbcFGEMnembPeEZYFCp47rGsUAcCN2LVTIIEGKQPO4boTx2UelmfdE02 5iKm1C6Oo9jDU+niAF66w== X-UI-Out-Filterresults: notjunk:1;V03:K0:OkLfliOPCGo=:vuJPrLrM2cM0b8opczaD7p KHcsgFu/KT6l1vylxMksYvRoBdwNwHRl5huljwG+snoheC7lCyg3b4HlQU8otvRXyHHDeQX5v qtFm2DeVcJ+fA2cQ80c6ZBngSrSKm9VDjzBii6I8Odvwxv1WiXAQBJ4lzKE6hllbkyoUrHx8t 08aLjDTBRcq8iaye7nTiXeHZg0x4pCgczBbSh0K9ej8YWMCtv22jQAf70vo9rIoryHkB7x06I RXSj6jEOJfj1FVopYx6/Xv39LRLFQzKENEPw8korUcw+NrIKQprLphIneJudRx8SzhstvWBs6 s2hWLS6XNpqHTPXfNefSd6rBUGyVUNbls50LRKpUwWf+rM84y0a8JZxYKrWoyoraU69prWbyn fOkJkYHJyebK69XX/3JPTMH/LxSFwzOGODIkiHehD6UfawtrivUbyqIXZb/b/fDNqO/F55vCp AqVH5Q7T9s9aic6a7Nouj9c1AR5sxEsq4v8uODmpVAlWhjKFAhRtIQww6W8p6vVCL/aNRw8rh uNLZOgvQ+XaN/LADXiDH1tGAOm8ZVML34tIc3Giy6t4nqR1r0U46jDztu9suHc4YfUv9J0l75 tM+i5h4MgtvpI9ocD+eSX2oB99lrqzNzK9MqA4t21sbIJglCyuhzdExybo1NkL114Und308c3 74U/Cx16siGvMD9l4KFPn0nuc2n7euUCbQJYBqPgcxuHXjqPFU0chpb7atIalrwey9PEJWAMl 11haurRszZxZjcD7qxmJB6ARGJn61ULOL5g/ZJep0/Bhny11O0pFxTfJoj+kwBeHFuUboFMJo uUHcE6GZ6a1XiNKGZrf8JYBpbYoITVmV7QndD3q8Hl0gAAwQhg= Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/02 10:57:57 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 printing function uses an already existing function "print_flags()" to print flags of the "mode" argument. These flags are stated inside an array "falloc_flags" that contains values of type "struct flags". These values are instantiated using an existing macro "FLAG_GENERIC()". Most of these flags are defined 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 variation, 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 >= (abi_ulong)(-4096); } +#if TARGET_ABI_BITS == 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 == 32 */ +static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) +{ + return word0; +} +#endif /* TARGET_ABI_BITS != 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[] = { FLAG_END, }; +UNUSED static struct flags falloc_flags[] = { + 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 +#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 == 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) } } -#if TARGET_ABI_BITS == 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 == 32 */ -static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) -{ - return word0; -} -#endif /* TARGET_ABI_BITS != 32 */ - #ifdef TARGET_NR_truncate64 static inline abi_long target_truncate64(void *cpu_env, const char *arg1, abi_long arg2, From patchwork Thu Jul 2 15:27:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1321604 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49yMk03QsTz9sDX for ; Fri, 3 Jul 2020 01:40:24 +1000 (AEST) Received: from localhost ([::1]:34212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jr1K2-0004vn-7V for incoming@patchwork.ozlabs.org; Thu, 02 Jul 2020 11:40:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17d-0000jY-MV for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:33 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:37185) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17Z-0006KA-ED for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:33 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MQdtO-1jUNd01ICk-00Nkn9; Thu, 02 Jul 2020 17:27:20 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 10/12] linux-user: Add thunk argument types for SIOCGSTAMP and SIOCGSTAMPNS Date: Thu, 2 Jul 2020 17:27:08 +0200 Message-Id: <20200702152710.84602-11-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702152710.84602-1-laurent@vivier.eu> References: <20200702152710.84602-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:3nIlbLU+2yQQKq6NSedOQYPnM4aUXCiwBB0MsNrGnBnEO0mZ4Wd +g4kt6vYOXkWHWhNm3rwGXzTcCab14RncLgR2kk5c5u0mZXNVoUZTNz4UbhIjJHjk1TzaP+ 6hXO8b6Y29O8sN/KmHUaLgYYheSEwj8yTHvWAANWBIz3v2YXWCVxViBORyHUd1SgIXHO//u DU1/wx7bMEIJv4L6goCjA== X-UI-Out-Filterresults: notjunk:1;V03:K0:KPLfRaGoZa0=:ZPpFdgIoaNyOjWACIrLNks uVrd8dUh2mgL+BnJmCDhEY3ipDFyqWqwj1jhYOD6CzoMInqPPUt274kE9GIoYSKMVLSB9WkOs 2zdtESmCcwYmepS3ZXsSP+ZDqGYp0YeqziVqWytgui+RXoUYJ55bWVTBaE5CoLNbKmk/7CXj7 76H+9Khmf+2KAqzM9JKjKx56Thv3+NEzBwY7lfaZU7chkRvqcqYrfBRjFJOSIyPNI8MiluQKH MRp1TUukxi3Sv33eoKC55RVmXVn0FDMV5Td1IuMuikyt7OdDivSQw1ym4qRfDoe+SCdi/cnP1 XTH2L5tQk1gBOApsm+3v9I4h4hhw3PkonMV4aTQi2tbWNhxhOEj6hZo5YFZYuHVIeX2dArQAB 7Zw8iYsXqwMqSC+GUPSg4xoFxioXlSgtn4Vw4fHW/Sada10yAAcEdkyTFoOhjPYjO4Q6wmLyr K4/hZDGCm07WWVzKsUk200wInGvDnQtVSVmpIbQ0DkYFoVR02bwji+Llfm3xs8znfdkAHdjhk o3rIjymNXDY0kGoz7gmnx5GIWxLOeeDPNVT3axaZjCh5tsu8FKKPkb001bnGxyGYh1AIj1HVZ Lrk8FVuAasOBPwWsmKclq6WWKKUQVtp/67NjR7miIg1yy9nfLFSeZvZhcbPtPmGA0M9U1kdHl d7uyFSAUgGrjyl9UK6bZ4SMTw9otdm9CJFbNEDoy2D3lBQ588ULQn+SHMYx+GWorvB1dhePnc n4PvZBJCIDjd0vUSMSIelJj07RrM57stSCPibZemgUjyQUIiwNs0vRLh9iM3gjdoxIZWyc8wd n43bVnQk2ZshMAk40dbA1Ux20rlHISWzCljPBTrpnYXZilHsoU= Received-SPF: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/02 11:27:18 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta Socket ioctls SIOCGSTAMP and SIOCGSTAMPNS, used for timestamping the socket connection, are defined in file "ioctls.h" differently from other ioctls. The reason for this difference is explained in the comments above their definition. These ioctls didn't have defined thunk argument types before changes from this patch. They have special handling functions ("do_ioctl_SIOCGSTAMP" and "do_ioctl_SIOCGSTAMPNS") that take care of setting values for approppriate argument types (struct timeval and struct timespec) and thus no thunk argument types were needed for their implementation. But this patch adds those argument type definitions in file "syscall_types.h" and "ioctls.h" as it is needed for printing arguments of these ioctls with strace. Implementation notes: There are two variants of these ioctls: SIOCGSTAMP_OLD/SIOCGSTAM_NEW and SIOCGSTAMPNS_OLD/SIOCGSTAMPNS_NEW. One is the old existing definition and the other is the 2038 safe variant used for 32-bit architectures. Corresponding structure definitions STRUCT_timespec/STRUCT__kernel_timespec and STRUCT_timeval/STRUCT__kernel_sock_timeval were added for these variants. STRUCT_timeval definition was already inside the file as it is used by another implemented ioctl. Two cases were added for definitions STRUCT_timeval/STRUCT__kernel_sock_timeval to manage the case when the "u_sec" field of the timeval structure is of type int. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200619124727.18080-2-filip.bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 12 ++++++++---- linux-user/syscall_types.h | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index f2e2fa9c878b..0713ae131162 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -279,13 +279,17 @@ * FIXME: create a macro to define this kind of entry */ { TARGET_SIOCGSTAMP_OLD, TARGET_SIOCGSTAMP_OLD, - "SIOCGSTAMP_OLD", IOC_R, do_ioctl_SIOCGSTAMP }, + "SIOCGSTAMP_OLD", IOC_R, do_ioctl_SIOCGSTAMP, + { MK_PTR(MK_STRUCT(STRUCT_timeval)) } }, { TARGET_SIOCGSTAMPNS_OLD, TARGET_SIOCGSTAMPNS_OLD, - "SIOCGSTAMPNS_OLD", IOC_R, do_ioctl_SIOCGSTAMPNS }, + "SIOCGSTAMPNS_OLD", IOC_R, do_ioctl_SIOCGSTAMPNS, + { MK_PTR(MK_STRUCT(STRUCT_timespec)) } }, { TARGET_SIOCGSTAMP_NEW, TARGET_SIOCGSTAMP_NEW, - "SIOCGSTAMP_NEW", IOC_R, do_ioctl_SIOCGSTAMP }, + "SIOCGSTAMP_NEW", IOC_R, do_ioctl_SIOCGSTAMP, + { MK_PTR(MK_STRUCT(STRUCT__kernel_sock_timeval)) } }, { TARGET_SIOCGSTAMPNS_NEW, TARGET_SIOCGSTAMPNS_NEW, - "SIOCGSTAMPNS_NEW", IOC_R, do_ioctl_SIOCGSTAMPNS }, + "SIOCGSTAMPNS_NEW", IOC_R, do_ioctl_SIOCGSTAMPNS, + { MK_PTR(MK_STRUCT(STRUCT__kernel_timespec)) } }, IOCTL(RNDGETENTCNT, IOC_R, MK_PTR(TYPE_INT)) IOCTL(RNDADDTOENTCNT, IOC_W, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index e2b0484f50e5..3f1f0334649b 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -137,10 +137,32 @@ STRUCT(snd_timer_params, TYPE_INT, /* filter */ MK_ARRAY(TYPE_CHAR, 60)) /* reserved */ +#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) +STRUCT(timeval, + TYPE_LONG, /* tv_sec */ + TYPE_INT) /* tv_usec */ + +STRUCT(_kernel_sock_timeval, + TYPE_LONG, /* tv_sec */ + TYPE_INT) /* tv_usec */ +#else +STRUCT(timeval, + TYPE_LONG, /* tv_sec */ + TYPE_LONG) /* tv_usec */ + +STRUCT(_kernel_sock_timeval, + TYPE_LONGLONG, /* tv_sec */ + TYPE_LONGLONG) /* tv_usec */ +#endif + STRUCT(timespec, TYPE_LONG, /* tv_sec */ TYPE_LONG) /* tv_nsec */ +STRUCT(_kernel_timespec, + TYPE_LONGLONG, /* tv_sec */ + TYPE_LONGLONG) /* tv_nsec */ + STRUCT(snd_timer_status, MK_STRUCT(STRUCT_timespec), /* tstamp */ TYPE_INT, /* resolution */ From patchwork Thu Jul 2 15:27:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1321575 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49yMZc2t5jz9sDX for ; Fri, 3 Jul 2020 01:34:00 +1000 (AEST) Received: from localhost ([::1]:38800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jr1Dq-0002XC-6K for incoming@patchwork.ozlabs.org; Thu, 02 Jul 2020 11:33:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17Y-0000VW-Cj for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:28 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:55509) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17U-0006Iw-KR for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:28 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Ma1oK-1jKzi03uVg-00VxzB; Thu, 02 Jul 2020 17:27:21 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 11/12] linux-user: Add strace support for printing arguments of ioctl() Date: Thu, 2 Jul 2020 17:27:09 +0200 Message-Id: <20200702152710.84602-12-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702152710.84602-1-laurent@vivier.eu> References: <20200702152710.84602-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:E+0dm+HWfCguEDzHrtn8eQbhZFfat0ROl5K0fA5A9/w8sctK+RM Xo06laWCKAeFZylufldzBYcMjZmgycJOp+Z6Zddg4T+g/KkRp72oYKfuf0B5MKRbjqoTgXg 1/c9oy8DrEbnAfZ98Px4/A3ZuEKlETEwNTqXIBeNGsRwv61WkufbKBS8tVZ9g4MypmWDTpa oRhx325XfXnT4HuRWRS1w== X-UI-Out-Filterresults: notjunk:1;V03:K0:JLhb5A2y2mw=:9dXDTE5bDUsN2X9M46nbqO hTrKTXSTkb50uL06jkyu2kfptRz8SMDC0LXWszYUIqirLu5oeFOvQE7PrRCdNwr2ySk0U+OS8 15Naz9rCcy/Z7bY+tWNWwvDsHVa/eqo+4qRWUgmPKnwGz15ESGpBZeYzxMMG7gHLMhFahGu2X uwPyy+NkL6gXGr6+XdPSG6gL4E/m5XgiJnWfsZCiAcQwyhzczUoaEifL87KaGpJdKyw/RPE4J 0ipt6Te3B5ILAchNVc/XH4pSEvQkniCxCDV2STsojhoTXAezEO6BJGPckW+DDY9S1sf/jClHw +fgNJmWBcuvaMfoniXGQGifISVVvAyDoWU6623Co2DOLVW39dRj9MaZtBEnzZH2JfcFTNzKB5 pKgUkJ7L0xWUwAXENShwsCE0hMTQ0HKYZ8akZK+G7UpZyV5ZLbCFA2mx5d5h95pwOpvRmW72O 2sni7DL4ExdtdQC5AKGQa91NiZgYJ2YopVnKroE5W1fnRLlAJ3XDuZRgr/mbA8MSYEbO7+FWE JxNcfopPavT/k6BAIWgjivx8x18mtVrn199GUjUrXbSBkvBsyJjvSe6q5UmCjx7PlXGBIlqEC R8zJJCWWp3A263zghCvkUhifytdy8srYnjaRYXRQYWd9XYgsMBrn0vPjHioydFicn40F96raS 9RB6auCHrRrWdo92rLsRzYr9ZswNcYJhWLVm4iImHak4DXq4XXmm4GmnPsKf73tZ71qnAQ+0h 6SfqD5qxh8X0aB2pi4NSjCYx2UI889sIDhDJHxjnBCkeIU35W7yQucQ5Gnyy2VnVaVzW7cNJj io0En4lxZ+1ZOZebnDndMz2Y4cxANdZ8lcF5VSkMKfojAgVTEQ= Received-SPF: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/02 11:27:23 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality for strace argument printing for ioctls. When running ioctls through qemu with "-strace", they get printed in format: "ioctl(fd_num,0x*,0x*) = ret_value" where the request code an the ioctl's third argument get printed in a hexadicemal format. This patch changes that by enabling strace to print both the request code name and the contents of the third argument. For example, when running ioctl RTC_SET_TIME with "-strace", with changes from this patch, it gets printed in this way: "ioctl(3,RTC_SET_TIME,{12,13,15,20,10,119,0,0,0}) = 0" In case of IOC_R type ioctls, the contents of the third argument get printed after the return value, and the argument inside the ioctl call gets printed as pointer in hexadecimal format. For example, when running RTC_RD_TIME with "-strace", with changes from this patch, it gets printed in this way: "ioctl(3,RTC_RD_TIME,0x40800374) = 0 ({22,9,13,11,5,120,0,0,0})" In case of IOC_RW type ioctls, the contents of the third argument get printed both inside the ioctl call and after the return value. Implementation notes: Functions "print_ioctl()" and "print_syscall_ret_ioctl()", that are defined in "strace.c", are listed in file "strace.list" as "call" and "result" value for ioctl. Structure definition "IOCTLEntry" as well as predefined values for IOC_R, IOC_W and IOC_RW were cut and pasted from file "syscall.c" to file "qemu.h" so that they can be used by these functions to print the contents of the third ioctl argument. Also, the "static" identifier for array "ioctl_entries[]" was removed and this array was declared as "extern" in "qemu.h" so that it can also be used by these functions. To decode the structure type of the ioctl third argument, function "thunk_print()" was defined in file "thunk.c" and its definition is somewhat simillar to that of function "thunk_convert()". Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200619124727.18080-3-filip.bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- include/exec/user/thunk.h | 1 + linux-user/qemu.h | 20 +++++ linux-user/strace.c | 107 ++++++++++++++++++++++++++ linux-user/strace.list | 3 +- linux-user/syscall.c | 20 +---- thunk.c | 154 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 285 insertions(+), 20 deletions(-) diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h index eae2c27f99da..7992475c9f8a 100644 --- a/include/exec/user/thunk.h +++ b/include/exec/user/thunk.h @@ -73,6 +73,7 @@ void thunk_register_struct_direct(int id, const char *name, const StructEntry *se1); const argtype *thunk_convert(void *dst, const void *src, const argtype *type_ptr, int to_host); +const argtype *thunk_print(void *arg, const argtype *type_ptr); extern StructEntry *struct_entries; diff --git a/linux-user/qemu.h b/linux-user/qemu.h index be67391ba49d..5c964389c101 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -184,6 +184,26 @@ struct linux_binprm { int (*core_dump)(int, const CPUArchState *); /* coredump routine */ }; +typedef struct IOCTLEntry IOCTLEntry; + +typedef abi_long do_ioctl_fn(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, int cmd, abi_long arg); + +struct IOCTLEntry { + int target_cmd; + unsigned int host_cmd; + const char *name; + int access; + do_ioctl_fn *do_ioctl; + const argtype arg_type[5]; +}; + +extern IOCTLEntry ioctl_entries[]; + +#define IOC_R 0x0001 +#define IOC_W 0x0002 +#define IOC_RW (IOC_R | IOC_W) + void do_init_thread(struct target_pt_regs *regs, struct image_info *infop); abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, abi_ulong stringp, int push_ptr); diff --git a/linux-user/strace.c b/linux-user/strace.c index 32e5e987acbb..5235b2260cdd 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -860,6 +860,44 @@ print_syscall_ret_listxattr(const struct syscallname *name, abi_long ret, #define print_syscall_ret_flistxattr print_syscall_ret_listxattr #endif +#ifdef TARGET_NR_ioctl +static void +print_syscall_ret_ioctl(const struct syscallname *name, abi_long ret, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_err(ret); + + if (ret >= 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); + + const IOCTLEntry *ie; + const argtype *arg_type; + void *argptr; + int target_size; + + for (ie = ioctl_entries; ie->target_cmd != 0; ie++) { + if (ie->target_cmd == arg1) { + break; + } + } + + if (ie->target_cmd == arg1 && + (ie->access == IOC_R || ie->access == IOC_RW)) { + arg_type = ie->arg_type; + qemu_log(" ("); + arg_type++; + target_size = thunk_type_size(arg_type, 0); + argptr = lock_user(VERIFY_READ, arg2, target_size, 1); + thunk_print(argptr, arg_type); + unlock_user(argptr, arg2, target_size); + qemu_log(")"); + } + } + qemu_log("\n"); +} +#endif + UNUSED static struct flags access_flags[] = { FLAG_GENERIC(F_OK), FLAG_GENERIC(R_OK), @@ -3026,6 +3064,75 @@ print_statx(const struct syscallname *name, } #endif +#ifdef TARGET_NR_ioctl +static void +print_ioctl(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + + const IOCTLEntry *ie; + const argtype *arg_type; + void *argptr; + int target_size; + + for (ie = ioctl_entries; ie->target_cmd != 0; ie++) { + if (ie->target_cmd == arg1) { + break; + } + } + + if (ie->target_cmd == 0) { + print_raw_param("%#x", arg1, 0); + print_raw_param("%#x", arg2, 1); + } else { + qemu_log("%s", ie->name); + arg_type = ie->arg_type; + + if (arg_type[0] != TYPE_NULL) { + qemu_log(","); + + switch (arg_type[0]) { + case TYPE_PTRVOID: + print_pointer(arg2, 1); + break; + case TYPE_CHAR: + case TYPE_SHORT: + case TYPE_INT: + print_raw_param("%d", arg2, 1); + break; + case TYPE_LONG: + print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); + break; + case TYPE_ULONG: + print_raw_param(TARGET_ABI_FMT_lu, arg2, 1); + break; + case TYPE_PTR: + switch (ie->access) { + case IOC_R: + print_pointer(arg2, 1); + break; + case IOC_W: + case IOC_RW: + arg_type++; + target_size = thunk_type_size(arg_type, 0); + argptr = lock_user(VERIFY_READ, arg2, target_size, 1); + thunk_print(argptr, arg_type); + unlock_user(argptr, arg2, target_size); + break; + } + break; + default: + g_assert_not_reached(); + } + } + } + print_syscall_epilogue(name); +} +#endif + /* * An array of all of the syscalls we know about */ diff --git a/linux-user/strace.list b/linux-user/strace.list index ebb713252ce3..a04706a524ae 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -433,7 +433,8 @@ { TARGET_NR_io_cancel, "io_cancel" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_ioctl -{ TARGET_NR_ioctl, "ioctl" , "%s(%d,%#x,%#x)", NULL, NULL }, +{ TARGET_NR_ioctl, "ioctl" , NULL, print_ioctl, + print_syscall_ret_ioctl}, #endif #ifdef TARGET_NR_io_destroy { TARGET_NR_io_destroy, "io_destroy" , NULL, NULL, NULL }, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 506b94a12c1e..82afadcea0e2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4481,24 +4481,6 @@ STRUCT_MAX #undef STRUCT #undef STRUCT_SPECIAL -typedef struct IOCTLEntry IOCTLEntry; - -typedef abi_long do_ioctl_fn(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, int cmd, abi_long arg); - -struct IOCTLEntry { - int target_cmd; - unsigned int host_cmd; - const char *name; - int access; - do_ioctl_fn *do_ioctl; - const argtype arg_type[5]; -}; - -#define IOC_R 0x0001 -#define IOC_W 0x0002 -#define IOC_RW (IOC_R | IOC_W) - #define MAX_STRUCT_SIZE 4096 #ifdef CONFIG_FIEMAP @@ -5374,7 +5356,7 @@ static abi_long do_ioctl_drm(const IOCTLEntry *ie, uint8_t *buf_temp, #endif -static IOCTLEntry ioctl_entries[] = { +IOCTLEntry ioctl_entries[] = { #define IOCTL(cmd, access, ...) \ { TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } }, #define IOCTL_SPECIAL(cmd, access, dofn, ...) \ diff --git a/thunk.c b/thunk.c index 7f31cffe0968..992a19b1c946 100644 --- a/thunk.c +++ b/thunk.c @@ -271,6 +271,160 @@ const argtype *thunk_convert(void *dst, const void *src, return type_ptr; } +const argtype *thunk_print(void *arg, const argtype *type_ptr) +{ + int type; + + type = *type_ptr++; + + switch (type) { + case TYPE_CHAR: + qemu_log("%c", *(uint8_t *)arg); + break; + case TYPE_SHORT: + qemu_log("%" PRId16, tswap16(*(uint16_t *)arg)); + break; + case TYPE_INT: + qemu_log("%" PRId32, tswap32(*(uint32_t *)arg)); + break; + case TYPE_LONGLONG: + qemu_log("%" PRId64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_ULONGLONG: + qemu_log("%" PRIu64, tswap64(*(uint64_t *)arg)); + break; +#if HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 32 + case TYPE_PTRVOID: + qemu_log("0x%" PRIx32, tswap32(*(uint32_t *)arg)); + break; + case TYPE_LONG: + qemu_log("%" PRId32, tswap32(*(uint32_t *)arg)); + break; + case TYPE_ULONG: + qemu_log("%" PRIu32, tswap32(*(uint32_t *))arg); + break; +#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 32 + case TYPE_PTRVOID: + qemu_log("0x%" PRIx32, tswap32(*(uint64_t *)arg & 0xffffffff)); + break; + case TYPE_LONG: + qemu_log("%" PRId32, tswap32(*(uint64_t *)arg & 0xffffffff)); + break; + case TYPE_ULONG: + qemu_log("%" PRIu32, tswap32(*(uint64_t *)arg & 0xffffffff)); + break; +#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 64 + case TYPE_PTRVOID: + qemu_log("0x%" PRIx64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_LONG: + qemu_log("%" PRId64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_ULONG: + qemu_log("%" PRIu64, tswap64(*(uint64_t *)arg)); + break; +#else + case TYPE_PTRVOID: + qemu_log("0x%" PRIx64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_LONG: + qemu_log("%" PRId64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_ULONG: + qemu_log("%" PRIu64, tswap64(*(uint64_t *)arg)); + break; +#endif + case TYPE_OLDDEVT: + { + uint64_t val = 0; + switch (thunk_type_size(type_ptr - 1, 1)) { + case 2: + val = *(uint16_t *)arg; + break; + case 4: + val = *(uint32_t *)arg; + break; + case 8: + val = *(uint64_t *)arg; + break; + } + switch (thunk_type_size(type_ptr - 1, 0)) { + case 2: + qemu_log("%" PRIu16, tswap16(val)); + break; + case 4: + qemu_log("%" PRIu32, tswap32(val)); + break; + case 8: + qemu_log("%" PRIu64, tswap64(val)); + break; + } + } + break; + case TYPE_ARRAY: + { + int i, array_length, arg_size; + uint8_t *a; + int is_string = 0; + + array_length = *type_ptr++; + arg_size = thunk_type_size(type_ptr, 0); + a = arg; + + if (*type_ptr == TYPE_CHAR) { + qemu_log("\""); + is_string = 1; + } else { + qemu_log("["); + } + + for (i = 0; i < array_length; i++) { + if (i > 0 && !is_string) { + qemu_log(","); + } + thunk_print(a, type_ptr); + a += arg_size; + } + + if (is_string) { + qemu_log("\""); + } else { + qemu_log("]"); + } + + type_ptr = thunk_type_next(type_ptr); + } + break; + case TYPE_STRUCT: + { + int i; + const StructEntry *se; + uint8_t *a; + const argtype *field_types; + const int *arg_offsets; + + se = struct_entries + *type_ptr++; + a = arg; + + field_types = se->field_types; + arg_offsets = se->field_offsets[0]; + + qemu_log("{"); + for (i = 0; i < se->nb_fields; i++) { + if (i > 0) { + qemu_log(","); + } + field_types = thunk_print(a + arg_offsets[i], field_types); + } + qemu_log("}"); + } + break; + default: + g_assert_not_reached(); + } + return type_ptr; +} + /* from em86 */ /* Utility function: Table-driven functions to translate bitmasks From patchwork Thu Jul 2 15:27:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1321594 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49yMg21csBz9sTN for ; Fri, 3 Jul 2020 01:37:50 +1000 (AEST) Received: from localhost ([::1]:55450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jr1HX-0001fO-Vj for incoming@patchwork.ozlabs.org; Thu, 02 Jul 2020 11:37:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17e-0000mH-B8 for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:34 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:54709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17c-0006L3-BL for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:33 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MBUVj-1jf9IE3rIN-00Cx8Y; Thu, 02 Jul 2020 17:27:22 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 12/12] MAINTAINERS: update linux-user maintainer Date: Thu, 2 Jul 2020 17:27:10 +0200 Message-Id: <20200702152710.84602-13-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702152710.84602-1-laurent@vivier.eu> References: <20200702152710.84602-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:lXhXPznCtWYYW3+WyUHDrGvvWVjzfXO6GQjA6wBzYeNZjV1tOYi uoDfny3oXNdUl5yoNsWkmyXphKn0c8P1sr87micitv6oFDho16LIgO/uUBM2b9Q0EVtXKa9 mCjvgxhk7mJDLPJULk4CiQWBdqaaZysMoUsQtwXDtM2ygrJSPTGAmiPUNPRPOgfE8Ca5wgW 6ZkNFZEwKo9yBADLBckAg== X-UI-Out-Filterresults: notjunk:1;V03:K0:THQ+ikUN7eU=:MjZMX6pFxd69XlXO7zCrLB womscvlv93L7pueBhjno0L+jHjkkym1t06gDJlRkf1eiKYwuk5rnNZCNSIxn9S7pci9BHbNWa QOk9rc2Zj39hF0JkkzTAK4B5lgRL+nGtzZglLOAH7rXiqE7aD1t4vHh5rO9ZL1rLp/A/bT8pX rbAa/oeRVetdKEg/pEo4Ngh6Z6Ex/oix5WehX1Mqfy4rfw64+pblsM8dg+0791/DLysv6CRrp IdSVaCvG+2YnOMMQU67Gp4An9G7HdzrY6TXjOWX09+gBe0LwYxRGWbzyJ8atLv2fSUaDrQWmr mp09pvtJOzjZbPPjKQprTU/HiYE3zoCN680ymkNX3EAnaZYD1tPCsm1C+Y/skg1q1v1QWLXL7 n9Ya036KVg5i7TzGwVPagMK+iJpv44S493nipBlrinQVtTO3xVC/2xhVo5NrplsTA6c/sbdlg qH/8jsv6OuBduAdPTpPQQD7oYev3FfSY0NjvwQxGg0EQuD5+LQvMZEx8bLYi6/NBnLDJU7zG8 g1Zw4wfAo3XA1XCoB/nV8SSvchZE5X6dSK+b/U0w7BkC7aJC6HlBdXDye58zSyGRKHK4oZM+c VCYwQUzCvVFxizk/mDCXKSuy85yFxDQh/1q5x3rrx2qwzB/Jod6T9DGeNQsvsbzxkZyQxE2Vk HnCrfvodJctpF/962w0fzRyNgcELMvVWdzmv3kTLcGsHXkp7sxtk00cUd2EyMnmazfnpzjjX3 lzPcqAq9iZyJTihe2wv0pIavqeCw87ixYjR/g8Uzo6qzuCnm+4fNeAB4F2q8gXLxQb5+BJuit ZyTJaeAq/jHToM7TUyvrxH/9EKmitVUQc8ylZleWCk/QvuJ4JQ= Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/02 10:57:57 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Riku Voipio , Mark Cave-Ayland , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Artyom Tarasenko Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Riku Voipio I haven't been active for a while. Pass the maintainer hat forward to Laurent, who has done a stellar job filling in. Signed-off-by: Riku Voipio Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20200702111636.25792-1-riku.voipio@linaro.org> Signed-off-by: Laurent Vivier --- MAINTAINERS | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index dec252f38b1d..29a23b6d3a5a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2629,8 +2629,7 @@ F: bsd-user/ F: default-configs/*-bsd-user.mak Linux user -M: Riku Voipio -R: Laurent Vivier +M: Laurent Vivier S: Maintained F: linux-user/ F: default-configs/*-linux-user.mak