From patchwork Sat Feb 4 16:08:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128752 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54215C636CC for ; Sat, 4 Feb 2023 16:09:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5o-0005At-J9; Sat, 04 Feb 2023 11:08:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5l-00054q-6h for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:42 -0500 Received: from mout.kundenserver.de ([217.72.192.73]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5h-0006u9-TX for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:39 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MWBGG-1p8W8u2nRy-00XY5X; Sat, 04 Feb 2023 17:08:34 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier Subject: [PULL 01/22] linux-user/strace: Constify struct flags Date: Sat, 4 Feb 2023 17:08:09 +0100 Message-Id: <20230204160830.193093-2-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:ww6E4GBQVIgoAwjoBcEGp8wxBInQNIbPz0KfCNPVFzuEExhcso9 muF7eOly0bBuTo5C8NX/tLG0xufWG2p7YfSvIW0nRsA0usbodWvcFggd7P9dW8WjFkxtfbK a2WgxE0wxQ84upSWKKm3MXbFgXY19QgED2Z+ZMNy+hpEkuABbkPhyaK7rNdRFbg/IV9SJnd ud/G8kLTjGn+Hc/o9jx3g== UI-OutboundReport: notjunk:1;M01:P0:Kqdqdyhosj8=;vSrnSoHtRzrSP9f8oJSQhc2xSb4 cVOvCex2tGjmfc30PHoNlzjjEW7ijdgIMLQ5SJ37QYCs05BVGbLq8TOSL0FOqLlFh906MHg6p EyN1I4kvAJU0cZZj/YM59jh1VZAIkhpYwtaaWtu7OT5c1W8H+O+5N3dsJxKhFsfB4IyPadXAO gQnTh5JzeLLzsJIy8aso5rQnwNbCga0gINVvYSQunfD3xnZprzyel0mkoBlHcahVJqdKw2byF vGVJe4WmZNMWiWmokvigQORm4OmwYHN2eOlRP3Xi+i7GIfq1BJbbKwIu4tb2K2epcQMzgBlxS nmMmJhb/a14Y8/Wr6wEAkce/4nOXjZOzWqSBXIBLUgMn66WGqVw1kw/0WIrY00DgMx2xGdWYF ZbfQsMcjg9McsSw7/3MOuGTNZVACMGL/D7js8c4EVoEx1yufjnpSHveaoyEOwd1cXhIN89CxB 1GguS5cGuWRhJEDnFHWgKODP97dbNK5cW2BHmwKnrUibbgvBBwv/ZITmFJcycqD/I0St7HQIU FhXBpYrYD7kMvXBYbPQyVFcZwOahMXO0MNHZuaDGPb+kvkzzpWJuQF3NyjOvzl7eZaXwKpMJC XYs6Xa0TTrTnVuCgj6jPacE6YIorLfLMFVGZxyGbIbkzzWUKQc7mTdHsyOUpEVoY732nGMxkc rFBH1Q1Gq9Tx1o9jusp0M3f2XL/+A2ysw7i38A0emw== Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Philippe Mathieu-Daudé print_flags() takes a const pointer. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20221104173632.1052-2-philmd@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 9ae5a812cd71..25c47f03160d 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -945,7 +945,7 @@ print_syscall_ret_ioctl(CPUArchState *cpu_env, const struct syscallname *name, } #endif -UNUSED static struct flags access_flags[] = { +UNUSED static const struct flags access_flags[] = { FLAG_GENERIC(F_OK), FLAG_GENERIC(R_OK), FLAG_GENERIC(W_OK), @@ -953,7 +953,7 @@ UNUSED static struct flags access_flags[] = { FLAG_END, }; -UNUSED static struct flags at_file_flags[] = { +UNUSED static const struct flags at_file_flags[] = { #ifdef AT_EACCESS FLAG_GENERIC(AT_EACCESS), #endif @@ -963,14 +963,14 @@ UNUSED static struct flags at_file_flags[] = { FLAG_END, }; -UNUSED static struct flags unlinkat_flags[] = { +UNUSED static const struct flags unlinkat_flags[] = { #ifdef AT_REMOVEDIR FLAG_GENERIC(AT_REMOVEDIR), #endif FLAG_END, }; -UNUSED static struct flags mode_flags[] = { +UNUSED static const struct flags mode_flags[] = { FLAG_GENERIC(S_IFSOCK), FLAG_GENERIC(S_IFLNK), FLAG_GENERIC(S_IFREG), @@ -981,14 +981,14 @@ UNUSED static struct flags mode_flags[] = { FLAG_END, }; -UNUSED static struct flags open_access_flags[] = { +UNUSED static const struct flags open_access_flags[] = { FLAG_TARGET(O_RDONLY), FLAG_TARGET(O_WRONLY), FLAG_TARGET(O_RDWR), FLAG_END, }; -UNUSED static struct flags open_flags[] = { +UNUSED static const struct flags open_flags[] = { FLAG_TARGET(O_APPEND), FLAG_TARGET(O_CREAT), FLAG_TARGET(O_DIRECTORY), @@ -1019,7 +1019,7 @@ UNUSED static struct flags open_flags[] = { FLAG_END, }; -UNUSED static struct flags mount_flags[] = { +UNUSED static const struct flags mount_flags[] = { #ifdef MS_BIND FLAG_GENERIC(MS_BIND), #endif @@ -1044,7 +1044,7 @@ UNUSED static struct flags mount_flags[] = { FLAG_END, }; -UNUSED static struct flags umount2_flags[] = { +UNUSED static const struct flags umount2_flags[] = { #ifdef MNT_FORCE FLAG_GENERIC(MNT_FORCE), #endif @@ -1057,7 +1057,7 @@ UNUSED static struct flags umount2_flags[] = { FLAG_END, }; -UNUSED static struct flags mmap_prot_flags[] = { +UNUSED static const struct flags mmap_prot_flags[] = { FLAG_GENERIC(PROT_NONE), FLAG_GENERIC(PROT_EXEC), FLAG_GENERIC(PROT_READ), @@ -1068,7 +1068,7 @@ UNUSED static struct flags mmap_prot_flags[] = { FLAG_END, }; -UNUSED static struct flags mmap_flags[] = { +UNUSED static const struct flags mmap_flags[] = { FLAG_TARGET(MAP_SHARED), FLAG_TARGET(MAP_PRIVATE), FLAG_TARGET(MAP_ANONYMOUS), @@ -1092,7 +1092,7 @@ UNUSED static struct flags mmap_flags[] = { FLAG_END, }; -UNUSED static struct flags clone_flags[] = { +UNUSED static const struct flags clone_flags[] = { FLAG_GENERIC(CLONE_VM), FLAG_GENERIC(CLONE_FS), FLAG_GENERIC(CLONE_FILES), @@ -1136,7 +1136,7 @@ UNUSED static struct flags clone_flags[] = { FLAG_END, }; -UNUSED static struct flags msg_flags[] = { +UNUSED static const struct flags msg_flags[] = { /* send */ FLAG_GENERIC(MSG_CONFIRM), FLAG_GENERIC(MSG_DONTROUTE), @@ -1156,7 +1156,7 @@ UNUSED static struct flags msg_flags[] = { FLAG_END, }; -UNUSED static struct flags statx_flags[] = { +UNUSED static const struct flags statx_flags[] = { #ifdef AT_EMPTY_PATH FLAG_GENERIC(AT_EMPTY_PATH), #endif @@ -1178,7 +1178,7 @@ UNUSED static struct flags statx_flags[] = { FLAG_END, }; -UNUSED static struct flags statx_mask[] = { +UNUSED static const struct flags statx_mask[] = { /* This must come first, because it includes everything. */ #ifdef STATX_ALL FLAG_GENERIC(STATX_ALL), @@ -1226,7 +1226,7 @@ UNUSED static struct flags statx_mask[] = { FLAG_END, }; -UNUSED static struct flags falloc_flags[] = { +UNUSED static const struct flags falloc_flags[] = { FLAG_GENERIC(FALLOC_FL_KEEP_SIZE), FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE), #ifdef FALLOC_FL_NO_HIDE_STALE @@ -1246,7 +1246,7 @@ UNUSED static struct flags falloc_flags[] = { #endif }; -UNUSED static struct flags termios_iflags[] = { +UNUSED static const struct flags termios_iflags[] = { FLAG_TARGET(IGNBRK), FLAG_TARGET(BRKINT), FLAG_TARGET(IGNPAR), @@ -1265,7 +1265,7 @@ UNUSED static struct flags termios_iflags[] = { FLAG_END, }; -UNUSED static struct flags termios_oflags[] = { +UNUSED static const struct flags termios_oflags[] = { FLAG_TARGET(OPOST), FLAG_TARGET(OLCUC), FLAG_TARGET(ONLCR), @@ -1349,7 +1349,7 @@ UNUSED static struct enums termios_cflags_CSIZE[] = { ENUM_END, }; -UNUSED static struct flags termios_cflags[] = { +UNUSED static const struct flags termios_cflags[] = { FLAG_TARGET(CSTOPB), FLAG_TARGET(CREAD), FLAG_TARGET(PARENB), @@ -1360,7 +1360,7 @@ UNUSED static struct flags termios_cflags[] = { FLAG_END, }; -UNUSED static struct flags termios_lflags[] = { +UNUSED static const struct flags termios_lflags[] = { FLAG_TARGET(ISIG), FLAG_TARGET(ICANON), FLAG_TARGET(XCASE), @@ -1380,7 +1380,7 @@ UNUSED static struct flags termios_lflags[] = { FLAG_END, }; -UNUSED static struct flags mlockall_flags[] = { +UNUSED static const struct flags mlockall_flags[] = { FLAG_TARGET(MCL_CURRENT), FLAG_TARGET(MCL_FUTURE), #ifdef MCL_ONFAULT From patchwork Sat Feb 4 16:08:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128766 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 28CB2C636CC for ; Sat, 4 Feb 2023 16:11:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5v-0005GC-5H; Sat, 04 Feb 2023 11:08:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5n-00059O-W7 for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:44 -0500 Received: from mout.kundenserver.de ([217.72.192.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5k-0006uc-W1 for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:43 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MZT2u-1p9c4T1wIw-00WSh1; Sat, 04 Feb 2023 17:08:35 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Drew DeVault , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier Subject: [PULL 02/22] linux-user/strace: Extract print_execve_argv() from print_execve() Date: Sat, 4 Feb 2023 17:08:10 +0100 Message-Id: <20230204160830.193093-3-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:/wwAHRG41kOMHBmZzPjChXAhyasVmjbQUpwUd4IowSyv9bnii5J /Mqk7vXWBPft76w2rt2EOtpsIPXySm7Soik9U2jFT+K4zlPn4OEkvC2Xt1cP7MQS27qYaDG Vti8ucjLUVMYSx4y1hCMZAwCcbEYVxyqTN6CvBIAobwmZTdfPA1QyrSXsn3+YqOrdou1/XC 4iwNji/Eif7ds/x23/fAw== UI-OutboundReport: notjunk:1;M01:P0:YfGAEvojSWw=;ln7bmJf/s+DzcRTi+wg4BNRkpzf e2UGvdnMS2mKpisg++TUyzRAAFpe21TIKM7OiavBca6f2eeScGP+re2U5sj90anWq3EcM6ZtK JBHNby8WdH4dk2dHvHkepof+XTQ8pf+wS4VHM2Eqm8xPmv3m3pbGDnmmQzkT9Q0MGBqO0yrOB UOgdOLoOyldeaSflGs6/wuhAqpLCC67REd87WAB4eAlPj32tbPsw5FZw6wyrziiJVc3OFPPJ1 I6GAuS5btIC1RB6DPRTGDfI4e0zyqVMoPySP1Fp4KeQmlc3Vn8sZTb4+fAFg+H42x2NoXiSj1 Z//pb15JfTDRKeUovZG+qncqh+J8rdFXIrYwQziME+InP7pts8E6zkQrhlOPRfymKbezKu57K aRd8QIVaLQHhysGMr526g+GbkLf7qcBNYKNjTvSOOfqRqfRmKmqrORiT6QlGAPgv9QUDzQCS1 X+XuIjmBNZj3n26y3SPib4wJKD1wSuU+1e0AIsdPYnKUBxdygCb90i3DJkSTurkVsy7Xks91/ WYHqb3I6uDKtJkXveDRt0NsGyRtoh/CtDc2Si5R8lC8qTtzSjxbRp2mRHCg8G5WGFsVuDvU/n J4cXxtyuGbT31yusTHVMrdYSfcBmp899T+PSklRvjd8cnLxUbsqZBLc38L5NKs9g8es6DygqO NoUxvCkxJEvw7dQo1rVWyk7ohh6oyyGHfHTCKsuMJw== Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Drew DeVault In order to add print_execveat() which re-use common code from print_execve(), extract print_execve_argv() from it. Signed-off-by: Drew DeVault Message-Id: <20221104081015.706009-1-sir@cmpwn.com> [PMD: Split of bigger patch, filled description, fixed style] Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20221104173632.1052-3-philmd@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 71 +++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 25c47f03160d..3d11d2f75978 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -616,38 +616,6 @@ print_semctl(CPUArchState *cpu_env, const struct syscallname *name, } #endif -static void -print_execve(CPUArchState *cpu_env, const struct syscallname *name, - abi_long arg1, abi_long arg2, abi_long arg3, - abi_long arg4, abi_long arg5, abi_long arg6) -{ - abi_ulong arg_ptr_addr; - char *s; - - if (!(s = lock_user_string(arg1))) - return; - qemu_log("%s(\"%s\",{", name->name, s); - unlock_user(s, arg1, 0); - - for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) { - abi_ulong *arg_ptr, arg_addr; - - arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1); - if (!arg_ptr) - return; - arg_addr = tswapal(*arg_ptr); - unlock_user(arg_ptr, arg_ptr_addr, 0); - if (!arg_addr) - break; - if ((s = lock_user_string(arg_addr))) { - qemu_log("\"%s\",", s); - unlock_user(s, arg_addr, 0); - } - } - - qemu_log("NULL})"); -} - #ifdef TARGET_NR_ipc static void print_ipc(CPUArchState *cpu_env, const struct syscallname *name, @@ -1969,6 +1937,45 @@ print_execv(CPUArchState *cpu_env, const struct syscallname *name, } #endif +static void +print_execve_argv(abi_long argv, int last) +{ + abi_ulong arg_ptr_addr; + char *s; + + qemu_log("{"); + for (arg_ptr_addr = argv; ; arg_ptr_addr += sizeof(abi_ulong)) { + abi_ulong *arg_ptr, arg_addr; + + arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1); + if (!arg_ptr) { + return; + } + arg_addr = tswapal(*arg_ptr); + unlock_user(arg_ptr, arg_ptr_addr, 0); + if (!arg_addr) { + break; + } + s = lock_user_string(arg_addr); + if (s) { + qemu_log("\"%s\",", s); + unlock_user(s, arg_addr, 0); + } + } + qemu_log("NULL}%s", get_comma(last)); +} + +static void +print_execve(CPUArchState *cpu_env, const struct syscallname *name, + abi_long arg1, abi_long arg2, abi_long arg3, + abi_long arg4, abi_long arg5, abi_long arg6) +{ + print_syscall_prologue(name); + print_string(arg1, 0); + print_execve_argv(arg2, 1); + print_syscall_epilogue(name); +} + #if defined(TARGET_NR_faccessat) || defined(TARGET_NR_faccessat2) static void print_faccessat(CPUArchState *cpu_env, const struct syscallname *name, From patchwork Sat Feb 4 16:08:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128770 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 63DE3C636CC for ; Sat, 4 Feb 2023 16:11:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5u-0005Fq-A7; Sat, 04 Feb 2023 11:08:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5n-00057x-OR for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:43 -0500 Received: from mout.kundenserver.de ([212.227.17.24]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5k-0006uJ-WB for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:43 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Ml76o-1ouYG742qi-00lWjJ; Sat, 04 Feb 2023 17:08:36 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Drew DeVault , Helge Deller , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= , Laurent Vivier Subject: [PULL 03/22] linux-user/strace: Add output for execveat() syscall Date: Sat, 4 Feb 2023 17:08:11 +0100 Message-Id: <20230204160830.193093-4-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:4NWYFXMpGpe9nwLf8GbrrOkc9jWO4PxeZQRYrc22OkRgYaj+V42 exMS7dOQgtRjqnoZ5ltKz4DIfzmTpV6ZMjLjO9jopZD1Ocso4KRojIylNM4VtK4hagdWKa3 OwbOJEW1CPPW+4+wwU1RQQXZ4dGEC+PMQfkN4BlqktNDABtgRa5uM82JF0QGyHKw6oxywkU ZZnte84lto7TRWNcGqgpg== UI-OutboundReport: notjunk:1;M01:P0:wcL2QtL1BMs=;sojRCxOjnazA1ltxDGvlapJT/yr Ws+gZbyYoD21r9/UBJCjc5cqxII0WJvuGjMsA+MBtGthqdJ7wNIsVNw+1kowZY3j7HEYhGrpf Uy1FBeos9Ax172l2If1XkBZDh3vmNewuvE8E8WwN9zerfDBCvdMXmka4+zWEiewYkPkhwZpL+ aWiAAZ0tinnht8PdW9rvDVbostZ1LNc0kuMgN4y2FvzDrPUr8J/XBNdKA7/hQXEfkakvwDEVq 1hp7PHgcMBCR57mbZm/VXAve12yUbZ1tsK+V2Yj1I9QaRqCaShnsPzAewCpI7wAQeoe6l8D/E K5S+EoCAOAwheb0Tr0I+Ne5m5DlmIBLfnm7QnyPqqvjPR3zYsq+9AJ0Mid2MSLvTe7APzxqfd cgAWJRv2k6J2WuH8BvMyw4bOPqLaBGdp7vVhBcKsVJelqRMwksPODkEt41XF6NDqjSIggx5Vu RmDInhCWeG0RxD+gUlHV39D9Spfb8FEuGCh58JwoWKIabP4c+Z0vpgSaZa+9PkpmGBfruyyrQ rSoI0xw/WawudnvL1mPHPwi3aCKQqFeGK9IYxV8qccQsFwvAQYx+vuoz6uhwvWZzZ1yylL5MV nw7nhhEwJfNeAvdkS9DzFY0Hlpd5Yb6Y9MfoqwAH3lHIVYJVbOfEW/Ql0EfR14ggv+YKf6Z8l BJ8j/ofZMa8oQ8slLxIwBIDMoRtC9gL1+cpU8oAdgA== Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Drew DeVault Signed-off-by: Drew DeVault Message-Id: <20221104081015.706009-1-sir@cmpwn.com> Suggested-by: Helge Deller [PMD: Split of bigger patch] Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20221104173632.1052-4-philmd@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 23 +++++++++++++++++++++++ linux-user/strace.list | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 3d11d2f75978..7bccb4f0c067 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1104,6 +1104,16 @@ UNUSED static const struct flags clone_flags[] = { FLAG_END, }; +UNUSED static const struct flags execveat_flags[] = { +#ifdef AT_EMPTY_PATH + FLAG_GENERIC(AT_EMPTY_PATH), +#endif +#ifdef AT_SYMLINK_NOFOLLOW + FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), +#endif + FLAG_END, +}; + UNUSED static const struct flags msg_flags[] = { /* send */ FLAG_GENERIC(MSG_CONFIRM), @@ -1976,6 +1986,19 @@ print_execve(CPUArchState *cpu_env, const struct syscallname *name, print_syscall_epilogue(name); } +static void +print_execveat(CPUArchState *cpu_env, const struct syscallname *name, + abi_long arg1, abi_long arg2, abi_long arg3, + abi_long arg4, abi_long arg5, abi_long arg6) +{ + print_syscall_prologue(name); + print_at_dirfd(arg1, 0); + print_string(arg2, 0); + print_execve_argv(arg3, 0); + print_flags(execveat_flags, arg5, 1); + print_syscall_epilogue(name); +} + #if defined(TARGET_NR_faccessat) || defined(TARGET_NR_faccessat2) static void print_faccessat(CPUArchState *cpu_env, const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 3a898e2532d3..bb21c054148e 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -164,7 +164,7 @@ { TARGET_NR_execve, "execve" , NULL, print_execve, NULL }, #endif #ifdef TARGET_NR_execveat -{ TARGET_NR_execveat, "execveat" , NULL, NULL, NULL }, +{ TARGET_NR_execveat, "execveat" , NULL, print_execveat, NULL }, #endif #ifdef TARGET_NR_exec_with_loader { TARGET_NR_exec_with_loader, "exec_with_loader" , NULL, NULL, NULL }, From patchwork Sat Feb 4 16:08:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128760 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4EB12C61DA4 for ; Sat, 4 Feb 2023 16:10:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5t-0005FP-MA; Sat, 04 Feb 2023 11:08:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5p-0005CW-7r for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:48 -0500 Received: from mout.kundenserver.de ([217.72.192.74]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5m-0006vs-1r for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:45 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MTRhS-1pCM9o1nNU-00TirZ; Sat, 04 Feb 2023 17:08:36 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Drew DeVault , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier Subject: [PULL 04/22] linux-user/syscall: Extract do_execve() from do_syscall1() Date: Sat, 4 Feb 2023 17:08:12 +0100 Message-Id: <20230204160830.193093-5-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:PE0V9ZjRpSFuIvGQtSv+AotUhtFBGiJoD/oADrfSOzyyPFbAssV eWR4CfLe2IPVrtZ7rKe+G1PZACy7+mol6yfTZXMMfJHq+mHklnChGa4Ejh9rTODA+G77lFP mRzl6pAduVzxSU6A6FYQfX4ucRB60AqZ6zTZ8n5c27/wRmXlVSxbNjGvrUaEYgpJothU93v r91++L2VZExtn8XHFVhDA== UI-OutboundReport: notjunk:1;M01:P0:Ov5CDAmCstM=;iObgGanYpTx/0gFk6iaCcB3AFDS nOUjBT14Z+jGWO9JxVBqr9vzHOZ5kRE9aCbIABVhnU0ZPmDgpCUR4QgWPfPQdm9M3RtIwcVNZ XhaOkK2RhpMFEHZUPNEUmyOcQ6vlcDxr/PHh8BHuA0GpsS9HOLZdFPZC0k6ugaQPyJ6doFCdD 6XKsIJpb97LPPieHm6yuCYe/YNw9M8ofNUEbiT7vK0Xk8mT/13Por9vw66FA5rHkKOQvn6iU9 CcEPSVWYov1VT2wwIeo2BTFviUR8fGw9Pn5maL8ghvwDVat1KkOvGe7WVJhpaLSyc2S1Fg6Ep r6taFwa8UJojAeBf7czn5G0Tjw3LjQbkvpIb7QgCSaxHDn8fz2XBoYZYkMLFB471A7H1lwpOQ 7Kyhy7tGHjaNpJgoFP1405WKKvitzr8xMJy0rj4o0+sdaE5HQHABbqTGKGcF9bhpXRr6LmlPd cDVIRj8uUuHKPNoZ3rPS6t8tHN5daELnmfenLGwmKH6diRTIDMeUtEoJl2l1ubCKbR/lVi8er WptFVRo0akDwCzSMmCLxuJQZD3wxDtJhA7XIgwtzmrWYX7nOYlL0HE91G7JCMculo4iaWFrvM WsV0mGGrmErAXoylal2jiq0xsngNwNN6RKLVuVYq8eLAKkAJJZIml7QgYDITXxl2Fj1SP5L0c iAAC+RBLACeMqea9kNMbO3O9kEElSQ/6zGgwGPDbTQ== Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Drew DeVault execve() is a particular case of execveat(). In order to add do_execveat(), first factor do_execve() out. Signed-off-by: Drew DeVault Message-Id: <20221104081015.706009-1-sir@cmpwn.com> [PMD: Split of bigger patch, filled description, fixed style] Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20221104173632.1052-5-philmd@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 211 +++++++++++++++++++++++-------------------- 1 file changed, 114 insertions(+), 97 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1f8c10f8ef94..11236d16a372 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8357,6 +8357,119 @@ static int do_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, int return safe_openat(dirfd, path(pathname), flags, mode); } +static int do_execve(CPUArchState *cpu_env, + abi_long pathname, abi_long guest_argp, + abi_long guest_envp) +{ + int ret; + char **argp, **envp; + int argc, envc; + abi_ulong gp; + abi_ulong addr; + char **q; + void *p; + + argc = 0; + + for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) { + if (get_user_ual(addr, gp)) { + return -TARGET_EFAULT; + } + if (!addr) { + break; + } + argc++; + } + envc = 0; + for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) { + if (get_user_ual(addr, gp)) { + return -TARGET_EFAULT; + } + if (!addr) { + break; + } + envc++; + } + + argp = g_new0(char *, argc + 1); + envp = g_new0(char *, envc + 1); + + for (gp = guest_argp, q = argp; gp; gp += sizeof(abi_ulong), q++) { + if (get_user_ual(addr, gp)) { + goto execve_efault; + } + if (!addr) { + break; + } + *q = lock_user_string(addr); + if (!*q) { + goto execve_efault; + } + } + *q = NULL; + + for (gp = guest_envp, q = envp; gp; gp += sizeof(abi_ulong), q++) { + if (get_user_ual(addr, gp)) { + goto execve_efault; + } + if (!addr) { + break; + } + *q = lock_user_string(addr); + if (!*q) { + goto execve_efault; + } + } + *q = NULL; + + /* + * Although execve() is not an interruptible syscall it is + * a special case where we must use the safe_syscall wrapper: + * if we allow a signal to happen before we make the host + * syscall then we will 'lose' it, because at the point of + * execve the process leaves QEMU's control. So we use the + * safe syscall wrapper to ensure that we either take the + * signal as a guest signal, or else it does not happen + * before the execve completes and makes it the other + * program's problem. + */ + p = lock_user_string(pathname); + if (!p) { + goto execve_efault; + } + + if (is_proc_myself(p, "exe")) { + ret = get_errno(safe_execve(exec_path, argp, envp)); + } else { + ret = get_errno(safe_execve(p, argp, envp)); + } + + unlock_user(p, pathname, 0); + + goto execve_end; + +execve_efault: + ret = -TARGET_EFAULT; + +execve_end: + for (gp = guest_argp, q = argp; *q; gp += sizeof(abi_ulong), q++) { + if (get_user_ual(addr, gp) || !addr) { + break; + } + unlock_user(*q, addr, 0); + } + for (gp = guest_envp, q = envp; *q; gp += sizeof(abi_ulong), q++) { + if (get_user_ual(addr, gp) || !addr) { + break; + } + unlock_user(*q, addr, 0); + } + + g_free(argp); + g_free(envp); + return ret; +} + #define TIMER_MAGIC 0x0caf0000 #define TIMER_MAGIC_MASK 0xffff0000 @@ -8867,103 +8980,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, return ret; #endif case TARGET_NR_execve: - { - char **argp, **envp; - int argc, envc; - abi_ulong gp; - abi_ulong guest_argp; - abi_ulong guest_envp; - abi_ulong addr; - char **q; - - argc = 0; - guest_argp = arg2; - for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) { - if (get_user_ual(addr, gp)) - return -TARGET_EFAULT; - if (!addr) - break; - argc++; - } - envc = 0; - guest_envp = arg3; - for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) { - if (get_user_ual(addr, gp)) - return -TARGET_EFAULT; - if (!addr) - break; - envc++; - } - - argp = g_new0(char *, argc + 1); - envp = g_new0(char *, envc + 1); - - for (gp = guest_argp, q = argp; gp; - gp += sizeof(abi_ulong), q++) { - if (get_user_ual(addr, gp)) - goto execve_efault; - if (!addr) - break; - if (!(*q = lock_user_string(addr))) - goto execve_efault; - } - *q = NULL; - - for (gp = guest_envp, q = envp; gp; - gp += sizeof(abi_ulong), q++) { - if (get_user_ual(addr, gp)) - goto execve_efault; - if (!addr) - break; - if (!(*q = lock_user_string(addr))) - goto execve_efault; - } - *q = NULL; - - if (!(p = lock_user_string(arg1))) - goto execve_efault; - /* Although execve() is not an interruptible syscall it is - * a special case where we must use the safe_syscall wrapper: - * if we allow a signal to happen before we make the host - * syscall then we will 'lose' it, because at the point of - * execve the process leaves QEMU's control. So we use the - * safe syscall wrapper to ensure that we either take the - * signal as a guest signal, or else it does not happen - * before the execve completes and makes it the other - * program's problem. - */ - if (is_proc_myself(p, "exe")) { - ret = get_errno(safe_execve(exec_path, argp, envp)); - } else { - ret = get_errno(safe_execve(p, argp, envp)); - } - unlock_user(p, arg1, 0); - - goto execve_end; - - execve_efault: - ret = -TARGET_EFAULT; - - execve_end: - for (gp = guest_argp, q = argp; *q; - gp += sizeof(abi_ulong), q++) { - if (get_user_ual(addr, gp) - || !addr) - break; - unlock_user(*q, addr, 0); - } - for (gp = guest_envp, q = envp; *q; - gp += sizeof(abi_ulong), q++) { - if (get_user_ual(addr, gp) - || !addr) - break; - unlock_user(*q, addr, 0); - } - - g_free(argp); - g_free(envp); - } - return ret; + return do_execve(cpu_env, arg1, arg2, arg3); case TARGET_NR_chdir: if (!(p = lock_user_string(arg1))) return -TARGET_EFAULT; From patchwork Sat Feb 4 16:08:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68E5CC636CC for ; Sat, 4 Feb 2023 16:09:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5z-0005QF-Bo; Sat, 04 Feb 2023 11:08:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5n-00059G-Tp for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:43 -0500 Received: from mout.kundenserver.de ([217.72.192.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5k-0006ud-Uz for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:43 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M8xwu-1pIJDW414w-006ANn; Sat, 04 Feb 2023 17:08:37 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Drew DeVault , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 05/22] linux-user/syscall: Implement execveat() Date: Sat, 4 Feb 2023 17:08:13 +0100 Message-Id: <20230204160830.193093-6-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:8NSopOUTQc+8BCwkydaU2iaPDi8LCXCQQSwxb9KybrHBSBbfIA3 idjaj+obc+RJJ3lh/OqXCpo7dFpJ/cL+srnzTgueWj0dAVh3FOMczmOeR8Wk3NYYKIvV/55 BHeW3LUEa4VwcFGzYFv9qjkSY5wdLrHt1BWFwgXmxlQkJarjCexcgd7Jlyaax1quVmjbEEu FEDkv9mpSNZpYHDYte2HQ== UI-OutboundReport: notjunk:1;M01:P0:ERcDDCGNyXk=;WlN06gnSUH8TpcobIPKMEkcENxg TsdRxr5xYpEGxgIR2RydOO5Fm0i9h7VmuDPCSwWI7tmvx3TXx6rnrNLJ0mvkmlQhzfBwl9fNF 5x+y5z3IxHZML1wltbV20O1H/DbQxhPWQT3f4ln2Y2JIRM5nRFIKIx3P1V9dfKok2mJ3BSzMP l/N2VHJKcbmqjAdETZ1IUtqHp8I5Y5dPGI71LL7f29NYbUi9MCGJe9HLYkTHpnAzJvTO37yyb SetOyCCJO0spirr5h8UzF2EzGQUkRW3OtdfA0Zk6pnRA7ZlZggUk/IntXfrVpZzRj7z8BAfB4 +IkNIViXL614rdSVh8+jj35DqwttDU6LpqQttp6Lf5HGjq88i+ZiywQe3lFhUbd6IFtMN81td y0Vbt3nC1JYIjkkXsYSbSY0KfyNgEcxzRtMIABk50SqkaexrdPVJyZWzdj2XnOKB1EAM1iMOX 5GtcLcLY2wUaBsGhyFfaJoIY4XCd4AjkwUb/pitJbEAOBzwS+phd4vazcAi7oV+kFUOODXr67 aWvGk7U2GNk2filkAYj+VTztFGk3fYJaefcx5tgy6d0ROnXe7WNoEm4GE21RBvpoqUZQLHLDv WQRRp2nYRgX0oA4g9gHcB973FhQ3koctEDFlrXrnTA3iK8bmv9MG58Z8egf2DLvD2Cr8tysXa 1we57O2ZgEgBS1lD1N0N15n+pjmtvjds+VuKdKq35A== Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Drew DeVault References: https://gitlab.com/qemu-project/qemu/-/issues/1007 Signed-off-by: Drew DeVault Reviewed-by: Laurent Vivier Message-Id: <20221104081015.706009-1-sir@cmpwn.com> Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20221104173632.1052-6-philmd@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 11236d16a372..3e72bd333ede 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -696,7 +696,8 @@ safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, \ #endif safe_syscall5(int, waitid, idtype_t, idtype, id_t, id, siginfo_t *, infop, \ int, options, struct rusage *, rusage) -safe_syscall3(int, execve, const char *, filename, char **, argv, char **, envp) +safe_syscall5(int, execveat, int, dirfd, const char *, filename, + char **, argv, char **, envp, int, flags) #if defined(TARGET_NR_select) || defined(TARGET_NR__newselect) || \ defined(TARGET_NR_pselect6) || defined(TARGET_NR_pselect6_time64) safe_syscall6(int, pselect6, int, nfds, fd_set *, readfds, fd_set *, writefds, \ @@ -8357,9 +8358,9 @@ static int do_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, int return safe_openat(dirfd, path(pathname), flags, mode); } -static int do_execve(CPUArchState *cpu_env, +static int do_execveat(CPUArchState *cpu_env, int dirfd, abi_long pathname, abi_long guest_argp, - abi_long guest_envp) + abi_long guest_envp, int flags) { int ret; char **argp, **envp; @@ -8439,9 +8440,9 @@ static int do_execve(CPUArchState *cpu_env, } if (is_proc_myself(p, "exe")) { - ret = get_errno(safe_execve(exec_path, argp, envp)); + ret = get_errno(safe_execveat(dirfd, exec_path, argp, envp, flags)); } else { - ret = get_errno(safe_execve(p, argp, envp)); + ret = get_errno(safe_execveat(dirfd, p, argp, envp, flags)); } unlock_user(p, pathname, 0); @@ -8979,8 +8980,10 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, unlock_user(p, arg2, 0); return ret; #endif + case TARGET_NR_execveat: + return do_execveat(cpu_env, arg1, arg2, arg3, arg4, arg5); case TARGET_NR_execve: - return do_execve(cpu_env, arg1, arg2, arg3); + return do_execveat(cpu_env, AT_FDCWD, arg1, arg2, arg3, 0); case TARGET_NR_chdir: if (!(p = lock_user_string(arg1))) return -TARGET_EFAULT; From patchwork Sat Feb 4 16:08:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128753 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DB8B5C61DA4 for ; Sat, 4 Feb 2023 16:09:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5s-0005E8-To; Sat, 04 Feb 2023 11:08:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5m-00054v-9A for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:42 -0500 Received: from mout.kundenserver.de ([217.72.192.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5j-0006uI-Ov for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:42 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MpUpW-1oqAXp1W5E-00puS1; Sat, 04 Feb 2023 17:08:37 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 06/22] linux-user: Add missing MAP_HUGETLB and MAP_STACK flags in strace Date: Sat, 4 Feb 2023 17:08:14 +0100 Message-Id: <20230204160830.193093-7-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:XiaAp+TTEsJR9aSqgLqynKu2dBnzmWzQwc4qFGC/nLCsy9a+2V6 0t0+VR2VK3oxpWfQP42i4S3BWEp0Mz4OT/GzwdB507oe98fxBzYN+IZuOA9qiJaudih/AgR ZHCJE9BjGPxQqOrHUBb67Oo7NLNnGLk70bymVpnClZFwb5+5I/8wfqdE3XL3+Gbj8YGm5TC 7cI8+i38BkWj2oiXSc5fw== UI-OutboundReport: notjunk:1;M01:P0:/O4a5IIlNAQ=;Soutl/AAgfUISe0A0IxFGf+EaBb Hd5hUKVsQXo4HpxaQsHQu1q0DuzPVaflEdhfBpW4271TlDV8lPLAY+YxOppxXG/1YkNlNRYJO /MPZlomzTTxIHWGO+deL6YB9yYAyHaWKXVDmP63Qb1lvyvRbxLnbUrJ9F7DG2x+dgb6eXR32B Fv/xo/f6IZnhqPUXb/vpQiS3Ekk6QkzYcMse6Cn2VDROKG9NA6ZGpXtnXVqAoPrwsX4RZbYgI JXzSIYTSuU+6cykPf17dcPfaPX8r+qKqgRISPNjyqM9Tqt/5OKmZvRb8C7vIePHMt/CZTvQkJ Xkr4evSMhCO0LLeUWfvZxueqUNQM3W8UqMvb3VpLn+W4jV8cd9nLXLXmxJDlzMa9CEfFZq02g FtGDQavQb9/hcM1zgF2rNqMMz+WJHA2clA2p6jU6YcOkXmMddAI9pOSizYcYAm+3L3nRe4oJB yhyHgCVpk0uBL+jTRYbdPp96Pnr6i4HQcJEJBmjJDqnYA5007kYF9Jo0PULTlL5HmlEEHm28Q 2HvBiglEMnetwjiqmvHKKC0tK3DmtM4qYn3yyn4RDGsQ32NXcr+Y3G41qQhLnnYatY3iEM8dE RyR5vPDWeF1Qa+7dpUHFlN6MJbPML7E5LEIDOTYegvIkTS0wn+1rg9tXshm0PHonrxpi8PGRd B/2J+yoef/twxZgVoEyk2TflQwVdlQFagYSMIIkgAA== Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Helge Deller Add two missing mmap flags. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: Signed-off-by: Laurent Vivier --- linux-user/strace.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/strace.c b/linux-user/strace.c index 7bccb4f0c067..5027289bdde4 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1057,6 +1057,8 @@ UNUSED static const struct flags mmap_flags[] = { #ifdef TARGET_MAP_UNINITIALIZED FLAG_TARGET(MAP_UNINITIALIZED), #endif + FLAG_TARGET(MAP_HUGETLB), + FLAG_TARGET(MAP_STACK), FLAG_END, }; From patchwork Sat Feb 4 16:08:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4F95C61DA4 for ; Sat, 4 Feb 2023 16:08:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5s-0005D4-RI; Sat, 04 Feb 2023 11:08:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5m-00054w-LE for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:42 -0500 Received: from mout.kundenserver.de ([217.72.192.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5j-0006uL-Pz for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:42 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M58SY-1pNFA13WJ2-001EhF; Sat, 04 Feb 2023 17:08:38 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Laurent Vivier Subject: [PULL 07/22] linux-user: un-parent OBJECT(cpu) when closing thread Date: Sat, 4 Feb 2023 17:08:15 +0100 Message-Id: <20230204160830.193093-8-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Owlqyx/EvkIoUWNRsGD4j+1tCD4Nki7NYcXG55uQHL7ZVWMbifu 2AgzM+olSZVjAUb3g/wRaqopX1csaZ/3wS+CCoN7AZePULsy/LhICylAy51dg1IZDb/OJT5 6yNzGjO8tJ2pOjYCqSACDI94s4q81Hjf19NPLr6E3uxfx6GjzhFmUagHeK/aB3YSa+2Loer EoseEHop/6SX3YKaf9ywA== UI-OutboundReport: notjunk:1;M01:P0:PrJprO64Gww=;4oMAwbGPJHekz3HNgnTbk3NPld7 yk5NYxI9dzEK+FwBmnLtPDec+Ifz/fGAHjso3v0KCG7EXncGWt8p2nSzPMga3MK2vFGN20ZMU 2CFV4pR3FNbspeYIVSjR/C5JULPVsJDe4iGrcpXPLBZjWOYOATVAGkl8Hjf5+m6nVUc6IPXtb r7ssHKjKN6ZvIj1LXVxd5Ng2O9o3Sq9PQvE268W8aLwUv5KaJggZPO19BXUK1Ww01g0V5khlD NS2AbuQtaLUA0KVaPtD7f/EV6OP84crS2hPV8gLXRhtwLt7TlTN4GEFt6TkSKTgXiorP2MLNt be3Ojq7wuFYS1FuApW9pcG6g1HHmRn5RnweQuaJULuV1Qixzwb1jhmrm8nUSxIIlzEjLf/x1p 8xjNo2gnJCRDvKNYEYtm6wNhcw9L/+SWqc7qNCTIOzF+Drq5Rt76qw8D9sO/eeDzghBnNhxTH FllDg21r3jJ8yjYPx17kvDBMIutImCxKpavz0D8nIdmblMWRZE02tmL9vKInrvBkPZPy7i9sG d5D4lqw0n16WZYResDFshfD3ILfvFywCCxdHqx3041kH1SbWFLXRaeN0JMvE6yM3yZOrE76vS Q3iN7Y5A2VOZ2Sb0XX2IRDMeUEprkrVcSx319/A/rwla+S1nq/UkpqFehEJgFQ8whHjNo0xn2 AIK21Q04YxV6esUa37yTFwj48m50jlSHa+/BftSF/w== Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Richard Henderson This reinstates commit 52f0c1607671293afcdb2acc2f83e9bccbfa74bb: While forcing the CPU to unrealize by hand does trigger the clean-up code we never fully free resources because refcount never reaches zero. This is because QOM automatically added objects without an explicit parent to /unattached/, incrementing the refcount. Instead of manually triggering unrealization just unparent the object and let the device machinery deal with that for us. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/866 Signed-off-by: Alex Bennée Reviewed-by: Laurent Vivier Message-Id: <20220811151413.3350684-2-alex.bennee@linaro.org> The original patch tickled a problem in target/arm, and was reverted. But that problem is fixed as of commit 3b07a936d3bf. Signed-off-by: Richard Henderson Message-Id: <20230124201019.3935934-1-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3e72bd333ede..dbf51e500b4f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8756,7 +8756,13 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, if (CPU_NEXT(first_cpu)) { TaskState *ts = cpu->opaque; - object_property_set_bool(OBJECT(cpu), "realized", false, NULL); + if (ts->child_tidptr) { + put_user_u32(0, ts->child_tidptr); + do_sys_futex(g2h(cpu, ts->child_tidptr), + FUTEX_WAKE, INT_MAX, NULL, NULL, 0); + } + + object_unparent(OBJECT(cpu)); object_unref(OBJECT(cpu)); /* * At this point the CPU should be unrealized and removed @@ -8766,11 +8772,6 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, pthread_mutex_unlock(&clone_lock); - if (ts->child_tidptr) { - put_user_u32(0, ts->child_tidptr); - do_sys_futex(g2h(cpu, ts->child_tidptr), - FUTEX_WAKE, INT_MAX, NULL, NULL, 0); - } thread_cpu = NULL; g_free(ts); rcu_unregister_thread(); From patchwork Sat Feb 4 16:08:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128764 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A9A5C61DA4 for ; Sat, 4 Feb 2023 16:10:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL60-0005R6-0E; Sat, 04 Feb 2023 11:08:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5w-0005Kg-IP for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:52 -0500 Received: from mout.kundenserver.de ([212.227.17.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5u-0006zS-Ux for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:52 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MXYAj-1p7hCD28QZ-00YvX0; Sat, 04 Feb 2023 17:08:38 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Mike Frysinger , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Laurent Vivier Subject: [PULL 08/22] linux-user: fix strace build w/out munlockall Date: Sat, 4 Feb 2023 17:08:16 +0100 Message-Id: <20230204160830.193093-9-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:TXK4FqR9qjyFAonsH4M/OZWSVZH3r1jiO4ELpU4pNRZ72hBGDfg WiWFfUYdoo5icvJlrTDCTWfZOBbo1Gg/CERdn29uhUADyuLaKD0RUWZAXljZE2hFgpU4nEb YlJoMwwfX0T1Rg7qSUqtLXjP/vm6BKJZxhFyl8N4dUBMx6c4letndAte5ywnTxAV6bBlaZO 1OiO/USqDcPZfYm9QsBXw== UI-OutboundReport: notjunk:1;M01:P0:3NsjH6rPRBc=;5F8Ket0NJIN1Vwdt7DPbFKBLS7B mme9GZZCt9b/9n51o5jVkMqyIEnIi+f75tKUh0DBtn6OYuOofx65JtiCK1lmOh0P64iWqOYUt CeNJ2CABzFGSkqKpLWPJbxhYbUAW5147qyQTqQfT0OPL0vlOUzCAQvXCmM3RhhEeSQAfiSHOP dFv4ROfX7AJJnI+INabRJPDU+G/OlZ7XMbsvmwp3VnLIggeI0rYanjJi/LHJYx7To8Ysf2cp9 aBR0KVxt6l6mz9gzU3fxpK+Ar3dgzzEN/5MxfDub8k3lAmSCxJm1l1m4cqf78g3hFdTprRpFT rnOC6luVfInXYqElJyutfDtm9u9+Rg9c3/gVmFR2d+dg06oqXz3LpJCdCBzZ94hmFsZokOBT1 wGjkIt4bkXbKbU5CMKoCpy8ojUdiLSHTROnmBobTYYyfatj6ZPuSfEnR+aaDxpB2/jNfn8NtI 9bc1NBH/mSi721ehIauS4ChBhqr4zeIEVbpXDkE9Y9SSeHJxs80Yfrp/631SZ/PtLcM2EfuWi KDhBkZFcSnb5JsicheDnmH1LS9O95hrvdd9/q1DHVsBDyfJKgVlUGD5YfhTX4QnO4lUOT5NDc BR7QrFqIofXLcySL7pzhodMhW2Zs9ivoDC5DCS+t4Iwr5pMZT/EGd/FASnGJ9ZosvoNIJZrR4 jwYBTV8OVqAj2z6k5CmWBXaT1ocFdCnKeCuXSGJxRw== Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Mike Frysinger Signed-off-by: Mike Frysinger Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230118090144.31155-1-vapier@gentoo.org> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 5027289bdde4..081fc87344ca 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1360,7 +1360,8 @@ UNUSED static const struct flags termios_lflags[] = { FLAG_END, }; -UNUSED static const struct flags mlockall_flags[] = { +#ifdef TARGET_NR_mlockall +static const struct flags mlockall_flags[] = { FLAG_TARGET(MCL_CURRENT), FLAG_TARGET(MCL_FUTURE), #ifdef MCL_ONFAULT @@ -1368,6 +1369,7 @@ UNUSED static const struct flags mlockall_flags[] = { #endif FLAG_END, }; +#endif /* IDs of the various system clocks */ #define TARGET_CLOCK_REALTIME 0 From patchwork Sat Feb 4 16:08:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 65E09C636CC for ; Sat, 4 Feb 2023 16:10:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5t-0005FS-L3; Sat, 04 Feb 2023 11:08:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5n-00057w-KP for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:43 -0500 Received: from mout.kundenserver.de ([217.72.192.73]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5l-0006vp-Ed for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:43 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MrxfX-1osdNr3prh-00nzZo; Sat, 04 Feb 2023 17:08:39 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Letu Ren , Laurent Vivier Subject: [PULL 09/22] linux-user: add more netlink protocol constants Date: Sat, 4 Feb 2023 17:08:17 +0100 Message-Id: <20230204160830.193093-10-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:6NGrLWZ+s5gBpApTLYcdfmN6u/320x6R5kH3KIyzfzPAD5UugkU 3H1+oJhJ8h62Yt5+9O8+u9brYpjz8am9ICxgHxwcPDcjbCc/mMUyGaKAq/EZGxBpGHlMYcJ +PHkezlJW7XgMCL/r4w/bYmZVI30gkzAiMzONg8tyPMxB2g8gAQYPqK3zIs0OzEZzNgxH9C g8Zd99e2XaDdR8/57oiUQ== UI-OutboundReport: notjunk:1;M01:P0:uH5CD42gIVk=;gIFhXFw97OxbvoJiiVB+VLyEtlm Cm0EwCRRiWdpfduPdVzE0iY9PcwY9KJmlTB4iATbI/Q0gO/bcMtuqR1oUGWJD+oc1e214K9Z9 FQFgiqhrBXrE1oF4tfZKfWwH0bhNTA6lHUQ7AFw4+jleJ/O6snJGalIVIqm/xXybF6v0E9rAM BdPfWQG5nVR7Q1Q3iWN+SRI9rAKvJE6s+ozXUhyEPxPVp7kmuqzWFGjjAu3iTuTlkyLzud/rR IBAKDSaSnW8gnFnuxptrZ65f9Vu/pllLFxYVTfhUtkFl3d9RknGAV11ZugDalFbLSqUz/OTAy v7593KH0+wMcWU+eXJ/Dm6Ds3d3JFLaWpZkEKtTQfJ+WIryGg+pq5kGnKB5HkLhT6tBUt4qRN t5NfxA4Z6/qHZZMaFvo5qD5FfCLUn9ciqRIsT4Bm6LihkomLcY9VyaaK0eS9N42viUyiSgMaw UzcOfTQNWr2VFkCP6o1UEUMS6QYT7c7lo/ydhNyaH2LVjZ6fS9NwoEkBfh06zyOcITHyRbkeN 534+mBaTfHi/voiPf8yqls9UxhvF+xWsIpjLpFA/wV5EyYw5H5e/qkAKG2gxYqQFNnuGy93WR LFVBZrxXu0pNRtLco66n9NBQrcI+dSK0VSt8e4IaHVO7KEmnWDsh6i7vl/AzSxYy8MjAHMJ2a xz0VWa+17KFrv79EulAGulRA35zQxLcynvZR+mf7rA== Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Letu Ren Currently, qemu strace only prints four protocol contants. This patch adds others listed in "linux/netlink.h". Signed-off-by: Letu Ren Message-Id: <20230101141105.12024-1-fantasquex@gmail.com> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/linux-user/strace.c b/linux-user/strace.c index 081fc87344ca..f38227ba5db5 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -506,21 +506,69 @@ print_socket_protocol(int domain, int type, int protocol) case NETLINK_ROUTE: qemu_log("NETLINK_ROUTE"); break; + case NETLINK_UNUSED: + qemu_log("NETLINK_UNUSED"); + break; + case NETLINK_USERSOCK: + qemu_log("NETLINK_USERSOCK"); + break; + case NETLINK_FIREWALL: + qemu_log("NETLINK_FIREWALL"); + break; + case NETLINK_SOCK_DIAG: + qemu_log("NETLINK_SOCK_DIAG"); + break; + case NETLINK_NFLOG: + qemu_log("NETLINK_NFLOG"); + break; + case NETLINK_XFRM: + qemu_log("NETLINK_XFRM"); + break; + case NETLINK_SELINUX: + qemu_log("NETLINK_SELINUX"); + break; + case NETLINK_ISCSI: + qemu_log("NETLINK_ISCSI"); + break; case NETLINK_AUDIT: qemu_log("NETLINK_AUDIT"); break; + case NETLINK_FIB_LOOKUP: + qemu_log("NETLINK_FIB_LOOKUP"); + break; + case NETLINK_CONNECTOR: + qemu_log("NETLINK_CONNECTOR"); + break; case NETLINK_NETFILTER: qemu_log("NETLINK_NETFILTER"); break; + case NETLINK_IP6_FW: + qemu_log("NETLINK_IP6_FW"); + break; + case NETLINK_DNRTMSG: + qemu_log("NETLINK_DNRTMSG"); + break; case NETLINK_KOBJECT_UEVENT: qemu_log("NETLINK_KOBJECT_UEVENT"); break; + case NETLINK_GENERIC: + qemu_log("NETLINK_GENERIC"); + break; + case NETLINK_SCSITRANSPORT: + qemu_log("NETLINK_SCSITRANSPORT"); + break; + case NETLINK_ECRYPTFS: + qemu_log("NETLINK_ECRYPTFS"); + break; case NETLINK_RDMA: qemu_log("NETLINK_RDMA"); break; case NETLINK_CRYPTO: qemu_log("NETLINK_CRYPTO"); break; + case NETLINK_SMC: + qemu_log("NETLINK_SMC"); + break; default: qemu_log("%d", protocol); break; From patchwork Sat Feb 4 16:08:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF4A1C61DA4 for ; Sat, 4 Feb 2023 16:11:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5v-0005JE-Vt; Sat, 04 Feb 2023 11:08:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5p-0005CX-Au for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:48 -0500 Received: from mout.kundenserver.de ([212.227.17.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5n-0006wP-E8 for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:45 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mofst-1orXSQ1bbt-00p4yK; Sat, 04 Feb 2023 17:08:39 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?M?= =?utf-8?q?arc-Andr=C3=A9_Lureau?= , Laurent Vivier Subject: [PULL 10/22] Revert "linux-user: add more compat ioctl definitions" Date: Sat, 4 Feb 2023 17:08:18 +0100 Message-Id: <20230204160830.193093-11-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:svgt2oceWJbPahMz+LMGOdoqgEG/gcRO6U3u+w/SqpsOerQmeTn DcUJhJRLMWFnQ6XhRTRqa5Ussd2YSrbYoIRE1raUuRLY8pUY3/pHSs7Kuo38uc8da20EEH8 yKPygljyLtgEGJoHvrYy9VJkuKKOFXmBeZTd1a4Rzovhthdqaf+JxZhUBscK+5hHQo0IkG0 JK35swQXz0efdXPiR8DqQ== UI-OutboundReport: notjunk:1;M01:P0:v3Fttt1pRRM=;05ToAbD8fdcYep8uwvmH6va0RXT jUyPfi0+Mv1R74scRxNV95rf7aWs4HS+fuY65RRhfv4M43O9RE396l9KsYLSHJzpGdToArU75 52a5MRi2XvJcwjVG8PKhqscpmU9GFc4TcPPBs/raxsB00wL0OF0gEe/OTcX4H3bQmkQw+elRV hxb22MLd97z6ToBcpR0RQwC7acagwTXzyIjgT2d7QT8xOZ9sbQC/SfOdB+GLzyeYkIprVKG9K 5gGXtmJXKIB+b41m2wGLRiSvW9XJVRGnmahULnnR4+gnrg7hmiookgPPY3bEQxC8PNAd7YhJc 9kBijvQPdLIcREIfsTpiD52LWcqQF82QV1g1Ag0vMUOjJgsFl058sysbYY1XT6mGfG3/5u+v2 cljGji/A3F2lf390Un7tAcovjk4dHiEkDvTWhJY10LieEJfzvrIO5ebD4begfPTun0gL7XkkI PLHFylG4SsMsfbIAVNExLtE6Y38b11B0pMmqUATjSOsV7dC6aL/85rvSV1kNhFvGOk1l2ceg8 OVfAfVturN9n58QMoIp62YH0zf7JNZTx8Aag/aj2wWoUCZBv/pqOFxtPBHCRZtBkmSBxFCIr0 8Fg4m/7GQydbk5oYGShNOaWnJtodCo1sYoKjYdKPdS/aOlqRZJ8L0GttaqYZoFrOC9u2aTt0E uJC07osBoAhwgnOmqgpNVoFGldEO1+EBnAE67bW8PQ== Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel P. Berrangé This reverts commit c5495f4ecb0cdaaf2e9dddeb48f1689cdb520ca0. glibc has fixed (in 2.36.9000-40-g774058d729) the problem that caused a clash when both sys/mount.h annd linux/mount.h are included, and backported this to the 2.36 stable release too: https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E It is saner for QEMU to remove the workaround it applied for glibc 2.36 and expect distros to ship the 2.36 maint release with the fix. This avoids needing to add a further workaround to QEMU to deal with the fact that linux/brtfs.h now also pulls in linux/mount.h via linux/fs.h since Linux 6.1 Signed-off-by: Daniel P. Berrangé Reviewed-by: Marc-André Lureau Message-Id: <20230110174901.2580297-2-berrange@redhat.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index dbf51e500b4f..b88f8ee96f0f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -111,31 +111,6 @@ #define FS_IOC32_SETFLAGS _IOW('f', 2, int) #define FS_IOC32_GETVERSION _IOR('v', 1, int) #define FS_IOC32_SETVERSION _IOW('v', 2, int) - -#define BLKGETSIZE64 _IOR(0x12,114,size_t) -#define BLKDISCARD _IO(0x12,119) -#define BLKIOMIN _IO(0x12,120) -#define BLKIOOPT _IO(0x12,121) -#define BLKALIGNOFF _IO(0x12,122) -#define BLKPBSZGET _IO(0x12,123) -#define BLKDISCARDZEROES _IO(0x12,124) -#define BLKSECDISCARD _IO(0x12,125) -#define BLKROTATIONAL _IO(0x12,126) -#define BLKZEROOUT _IO(0x12,127) - -#define FIBMAP _IO(0x00,1) -#define FIGETBSZ _IO(0x00,2) - -struct file_clone_range { - __s64 src_fd; - __u64 src_offset; - __u64 src_length; - __u64 dest_offset; -}; - -#define FICLONE _IOW(0x94, 9, int) -#define FICLONERANGE _IOW(0x94, 13, struct file_clone_range) - #else #include #endif From patchwork Sat Feb 4 16:08:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CEEF8C636CC for ; Sat, 4 Feb 2023 16:09:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5w-0005L6-PG; Sat, 04 Feb 2023 11:08:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5p-0005CZ-Jz for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:48 -0500 Received: from mout.kundenserver.de ([217.72.192.74]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5n-0006wg-OJ for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:45 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MiIlc-1oiySv3Z0Y-00fV8N; Sat, 04 Feb 2023 17:08:40 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?M?= =?utf-8?q?arc-Andr=C3=A9_Lureau?= , Laurent Vivier Subject: [PULL 11/22] Revert "linux-user: fix compat with glibc >= 2.36 sys/mount.h" Date: Sat, 4 Feb 2023 17:08:19 +0100 Message-Id: <20230204160830.193093-12-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:jLDCtuDVWRqeSCeV8SbZ7vV4N7WbyyQL5KhzkTrO80M+yTxEe0Z 5VMfH4BcP0r4f+jNN8N7/AAqnv1frvDO7n0Ulsf8ijQsRdGigEtA1aWEyYhlju+Au144ip+ 1FzeFSRkSZw7j2vatpURWbMkcXpD8jVLZ5cIPPpoT7r/4Desrkv7LsrXf99tzsFpHilmPuk 4gA5/NGxKyQSRFtg8wUxg== UI-OutboundReport: notjunk:1;M01:P0:oMB9u0CgNqs=;EnNLq5PfsrVH2dItMqTh1ytfGf8 y7BEN6Il2IVGAihtFGn/c7Dga/Y3CWSKWs7KsHcaYn3zPAaRa28uYhFOssw8MY1xpEldzEdpK 9mCEc8zfL6nyzguv+gAgoXnzi5IsG2Wd0s2cFJDLIruc1ebs26WoHdncpdmsOrNSVTL4O6xQA ruBtzapg5SEZeg3lbuzUbOC81mXdnv4TiY2VwyNuHV9yGWhBwMhInGdaqP5xS0+RADOpp50/J XDZOOOjKArL/DjDzbqFalwhIhdY/WStJLEJJK0yocfv1SFBZB45Nk8cBNWrlTJTMDkp11uhNn eV3OM9TXCuP2/xvr+HgscWR6d4muAPDNMhbsDxj8gH8appybcInGZxcSGTtXS/5NeDcGitSyE aX2u58hhPI5Hz2MistphlPSgtqQxfDyEuRGrHQAuBi8DxVkmkQ/1WSzsjU6O+OwqWRpWZcOH9 7EvUL8qYQvQxXngGHkkCsreg9RGKVmHvcJBRbOaur7Ev+eF9klTlg+BTya+mepiXaq+XrF+HW XqdrXbBzsn7ZrUfH7YCRjFL+RsKepHR0lPJAL+4Y1ENvQ9xAPMOKWjoWz4Wn3Zqs6RuyyesgL dVhB2TdcW99B0uJ0uZ6/bUn5HGTYd/b5QF5FPXiCqB8c4BGsOyzl2GthqfMXGRLdpmfk3dsqm hoDcGg5IcCmDMOcYKSTe85TQcL2qtPtX7/XGDUqN5w== Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel P. Berrangé This reverts commit 3cd3df2a9584e6f753bb62a0028bd67124ab5532. glibc has fixed (in 2.36.9000-40-g774058d729) the problem that caused a clash when both sys/mount.h annd linux/mount.h are included, and backported this to the 2.36 stable release too: https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E It is saner for QEMU to remove the workaround it applied for glibc 2.36 and expect distros to ship the 2.36 maint release with the fix. This avoids needing to add a further workaround to QEMU to deal with the fact that linux/brtfs.h now also pulls in linux/mount.h via linux/fs.h since Linux 6.1 Signed-off-by: Daniel P. Berrangé Reviewed-by: Marc-André Lureau Message-Id: <20230110174901.2580297-3-berrange@redhat.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 18 ------------------ meson.build | 2 -- 2 files changed, 20 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b88f8ee96f0f..210db5f0be94 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -95,25 +95,7 @@ #include #include #include - -#ifdef HAVE_SYS_MOUNT_FSCONFIG -/* - * glibc >= 2.36 linux/mount.h conflicts with sys/mount.h, - * which in turn prevents use of linux/fs.h. So we have to - * define the constants ourselves for now. - */ -#define FS_IOC_GETFLAGS _IOR('f', 1, long) -#define FS_IOC_SETFLAGS _IOW('f', 2, long) -#define FS_IOC_GETVERSION _IOR('v', 1, long) -#define FS_IOC_SETVERSION _IOW('v', 2, long) -#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap) -#define FS_IOC32_GETFLAGS _IOR('f', 1, int) -#define FS_IOC32_SETFLAGS _IOW('f', 2, int) -#define FS_IOC32_GETVERSION _IOR('v', 1, int) -#define FS_IOC32_SETVERSION _IOW('v', 2, int) -#else #include -#endif #include #if defined(CONFIG_FIEMAP) #include diff --git a/meson.build b/meson.build index 6d3b66562975..cccd19f864e3 100644 --- a/meson.build +++ b/meson.build @@ -2046,8 +2046,6 @@ config_host_data.set('HAVE_OPTRESET', cc.has_header_symbol('getopt.h', 'optreset')) config_host_data.set('HAVE_IPPROTO_MPTCP', cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP')) -config_host_data.set('HAVE_SYS_MOUNT_FSCONFIG', - cc.has_header_symbol('sys/mount.h', 'FSCONFIG_SET_FLAG')) # has_member config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID', From patchwork Sat Feb 4 16:08:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128768 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B2D2C636CC for ; Sat, 4 Feb 2023 16:11:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL67-0005Tw-CE; Sat, 04 Feb 2023 11:09:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5o-00059c-2B for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:44 -0500 Received: from mout.kundenserver.de ([212.227.17.24]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5l-0006vv-Vw for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:43 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M7bJ5-1pGwZZ12Cr-0085Fw; Sat, 04 Feb 2023 17:08:40 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 12/22] linux-user: Add strace output for clock_getres_time64() and futex_time64() Date: Sat, 4 Feb 2023 17:08:20 +0100 Message-Id: <20230204160830.193093-13-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:LCimNpfcYEuESv6q3mNEdhG5rgaF6JAhH3rIuk5LEBXQ7ca6Z95 HMGHhMksrFu5sI9F8V/+2kIWsCr/YP3zhNIkjXOfT9SJNp/o2TNhVaovF5XdEkFaQu4hoOC ibGjIJk46FYHUHwDrN3uvZDN1AmGNKJiivxdXagvN77gSOoeUc28j4ansOkQ7QLkNg6sUqB 67y8OXnIq/znKyaTRZBFQ== UI-OutboundReport: notjunk:1;M01:P0:0SOrIXwGa5Y=;Lvxd8CK+cJofO26MfI6W/D2gGIM 0RR/PxBohvs5b/ESPICZkYI7Ki7XyFY0Lt0aYGIJKhdOvwkA1dL/pZSgFLq0c+Pa9eIgBSFzk RkACN7xiWukB3jpMJpW0Gon24UrK0xfFno6S2lt9Y1Ex3hZsyLhcKeqjjbiUFxbz6U2EAyCxP asAMuFK3v5BwmbVz21DDhUy/LrOrRfWVZWGPGydRYUffwAy11kHhxYmSsio8j1j2SLUlca+VP wVtGYlTzH8WK/GuiZIqzc5KXD5fIL6VZwngpapI/97XwyciPmrCPJ7LNWyzmM6nP/YRQK28aT RdST5UB7x0yn4O+EGRtaoNb4YGd5HwmHRo1Y/aPtoCOqawGLmu1NkvRtnTNMYBsj8ygXpnYHe R8f49IhCuHZGKBaDdLBRGVDrvjTEMiHkTmbME8mTZjgAj4qZw2nmyQLRwignadIV+onLYPG5b GDtFtmqyeAOqxluQJORBvVvdKSi2cwruZNqjVWIYoYhxOUTx6gfOcrHW00y4HT2KtJSywZLqx EdIhlWo66MClVlzLPBhUt18pGdtGmAC712sZDV9pMPGV9xscabOp5YJm5v6k1YwIP9kYyWkMC MuVcVdYwppa8F5C7cKhZjXUX/PE2+al3tHZ4PqTQ97T8KQOMU7DJ96+a7txcCR5CEBSk0ndIm /bLiwPCERNrdSbGUcJNCUHc73DnWl9MsVi+iE+yeGQ== Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Helge Deller Add the two syscalls to strace output to avoid "Unknown syscall" message. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20230115113517.25143-1-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/strace.list | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/linux-user/strace.list b/linux-user/strace.list index bb21c054148e..64db8e6b8412 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -86,6 +86,9 @@ { TARGET_NR_clock_getres, "clock_getres" , NULL, print_clock_getres, print_syscall_ret_clock_getres }, #endif +#ifdef TARGET_NR_clock_getres_time64 +{ TARGET_NR_clock_getres_time64, "clock_getres_time64" , NULL, NULL, NULL }, +#endif #ifdef TARGET_NR_clock_gettime { TARGET_NR_clock_gettime, "clock_gettime" , NULL, print_clock_gettime, print_syscall_ret_clock_gettime }, @@ -275,6 +278,9 @@ #ifdef TARGET_NR_futex { TARGET_NR_futex, "futex" , NULL, print_futex, NULL }, #endif +#ifdef TARGET_NR_futex_time64 +{ TARGET_NR_futex_time64, "futex_time64" , NULL, NULL, NULL }, +#endif #ifdef TARGET_NR_futimesat { TARGET_NR_futimesat, "futimesat" , NULL, print_futimesat, NULL }, #endif From patchwork Sat Feb 4 16:08:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128754 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DF5C7C63797 for ; Sat, 4 Feb 2023 16:09:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5x-0005Ls-An; Sat, 04 Feb 2023 11:08:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5o-0005CN-V5 for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:48 -0500 Received: from mout.kundenserver.de ([212.227.17.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5m-0006w8-FS for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:44 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M6m5o-1pG7MM2jxm-008MEt; Sat, 04 Feb 2023 17:08:40 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 13/22] linux-user: Improve strace output of getgroups() and setgroups() Date: Sat, 4 Feb 2023 17:08:21 +0100 Message-Id: <20230204160830.193093-14-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:yRChEJ7Ba1AWgTnS+fmQyxbTgisMENhq5AuoFIhUK0Acw9aBOm3 jvHcC3Z19RCi2qZOlpgp3/WBlAP0vy5c0OMD7NtsqKmYphlcXxZulC442cA0Ul1eY7u23e6 tHllPD6s8G2HYv9af1qHOnT2h/odvSbZmoP4YGeDOD9cZVcWWeq6Dp1TaC38MxCLoFtQHHM wdhWUgy4O54re2EbG1bBw== UI-OutboundReport: notjunk:1;M01:P0:qQ3kTK21Wqo=;jTH5aSeWNScW/tsRFxyRoe6S4fI U01wYXyvx96sBKMRnIY3q24RQQIzqu1KOnbkWpL/3946SN6o6oWqbmu/nWsRgdVywIdmkzj+w fsf3b3bhF2rdHTo6g+vaXjKu1PG9z6vi8VzrL9FJjR8qEoVHaZAV+JWRIhVBasXsAijzXHpWU qQuqftrgVraG8WpM/3BZO8m+WVHfZA3QFAkX9SqU13iN0rhCSbFS2U5K0O80qm3V5ghgwGVPL Q1VgFtznXHl/4CO1A3lPfgUXxkLeB7pGgCZAEkbDIcvtxUIF4KIOH0sK2K4kRtxQqW8KYWgtb sTa1CSH01PjwysdWKOySt111XFcMOc/AIfKV25UysItTDjjQiMBfRHm7avA/riZebBYF6bP9/ 7FtxNPAD042DLewYh44jwjHt4B71marl5UByR+ELiXYh8ggGngN9ktMS3tkHVOm0f13RpIj4K Ek6VZREh/ITFL5MWMOdfRKdMZzPbR/CGYfY5Lk7QqT8M0ShmmqfahI87mu/K+nTHpjU9heVHA KnF3JB8rMXOKB/fouqZZsBSaGzva09VGURZQ21q6AVed++YaitWUxyaGzM12Fb8OPwm6QYjTD A5QovOPiK7fvKl+h9+Fyh2DKx63out6frFF6rQXI4HGofbxm5ZfY8L6uICDz+chNx+NOeCd1w oaOqOnuKyfgFmrwvB13m+ixg9gEFDWqebe7CXa3fXw== Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Helge Deller Make the strace look nicer for those syscalls. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20230115210057.445132-1-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/strace.list | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/linux-user/strace.list b/linux-user/strace.list index 64db8e6b8412..cf291d02edfe 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -321,10 +321,10 @@ { TARGET_NR_getgid32, "getgid32" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getgroups -{ TARGET_NR_getgroups, "getgroups" , NULL, NULL, NULL }, +{ TARGET_NR_getgroups, "getgroups" , "%s(%d,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_getgroups32 -{ TARGET_NR_getgroups32, "getgroups32" , NULL, NULL, NULL }, +{ TARGET_NR_getgroups32, "getgroups32" , "%s(%d,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_gethostname { TARGET_NR_gethostname, "gethostname" , NULL, NULL, NULL }, @@ -1304,10 +1304,10 @@ { TARGET_NR_setgid32, "setgid32" , "%s(%u)", NULL, NULL }, #endif #ifdef TARGET_NR_setgroups -{ TARGET_NR_setgroups, "setgroups" , NULL, NULL, NULL }, +{ TARGET_NR_setgroups, "setgroups" , "%s(%d,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_setgroups32 -{ TARGET_NR_setgroups32, "setgroups32" , NULL, NULL, NULL }, +{ TARGET_NR_setgroups32, "setgroups32" , "%s(%d,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_sethae { TARGET_NR_sethae, "sethae" , NULL, NULL, NULL }, From patchwork Sat Feb 4 16:08:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8586C636CC for ; Sat, 4 Feb 2023 16:10:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL64-0005RF-AP; Sat, 04 Feb 2023 11:09:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5y-0005Ne-3J for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:54 -0500 Received: from mout.kundenserver.de ([217.72.192.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5w-0006ze-Bx for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:53 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M2wbS-1pL3Ir0ORY-003QYL; Sat, 04 Feb 2023 17:08:41 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Mike Frysinger , Richard Henderson , Laurent Vivier Subject: [PULL 14/22] linux-user: move target_flat.h to target subdirs Date: Sat, 4 Feb 2023 17:08:22 +0100 Message-Id: <20230204160830.193093-15-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:uzF3dc4th1dKxiw9UOa0Y3dK5GTHMJ9W/ghwV3ffxj1NCwKqbBP vMyIO4HRObwmGdINUG7E5ZTjNXmmsAra+b4XEuhl/SIfwLWpRMeERt6/Tv5GuzWjcqh++ts ADNwLjvOx5W+xBWLQwjwAafqeTGMUT/VP9LKVJIFYl6Je0puTpAdXNQfK+sTVvpQE3l6ixb e9lBKh26mhkccAhI4YgNw== UI-OutboundReport: notjunk:1;M01:P0:r09LaFXwISY=;6gpTsTVxzThU7fSzlrKwnhN7cV/ 87hkcTBEX5gQrB1JZUARMyTk/iuePU64osjqNd1bcdhxZH0IaGuBpRgRRRjlrW0jIGSbaFqn5 KXP/YJpA89PoIGdj36cHcrRqbjIMFjGA8IoMAxQRI4VGl0vytMGpNctVbIZEkui45wWtqpAzH YOWXzRwixgxFoY4NfQF/XHIcyMgqymLQiNjrb1ksbu/UgU8IXvCcatXWmPsN6NsJpAfuZq9g2 FTklohTzG/tvPU6jbvIHwno5DQLw5xc01T/VzMeQ81NZgDt0SnMBnmlxy0CwGZgHti9eV8R+U UUpfgWGNjZ5gXr/IqSicnsxz9i3ZP0JCmG8VGSe/33bz0yGBcwFQLHDO5ExxLrKaq5tBfubGr zbhmgU+zTHrFsh693i889Huu/wQuSjQald6NEE/JcSLBE/N39QE+3SlvxpaA8BqSpjAkx9k/C VQzUl4vbBjNLQ0gTbkGA0qCH3N3VGN18SAB8VOlW4N7ELMpSiNzp7R/s0eg9brqsboFAdEKIK Uw+QUB+t2NzqXMXnDXFEfE/nyvTcjGEpFzIh1N/6g5W58L69srmgRVQjYcUit+vM/CkmRt27A fgPCQnDQS02Xpvt8jZDpig1DPZQcIK7eNBF4ZNOjFxEZksv/3bun6ttaBhT8g0yq+3g3mrhxw PtRRZhqp2tvRpzNeHACJ6sA9orIgD72F9oBlrirdvA== Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Mike Frysinger This makes target_flat.h behave like every other target_xxx.h header. It also makes it actually work -- while the current header says adding a header to the target subdir overrides the common one, it doesn't. This is for two reasons: * meson.build adds -Ilinux-user before -Ilinux-user/$arch * the compiler search path for "target_flat.h" looks in the same dir as the source file before searching -I paths. This can be seen with the xtensa port -- the subdir settings aren't used which breaks stack setup. Move it to the generic/ subdir and add include stubs like every other target_xxx.h header is handled. Signed-off-by: Mike Frysinger Reviewed-by: Richard Henderson Message-Id: <20230129004625.11228-1-vapier@gentoo.org> Signed-off-by: Laurent Vivier --- linux-user/aarch64/target_flat.h | 1 + linux-user/arm/target_flat.h | 1 + linux-user/{ => generic}/target_flat.h | 0 linux-user/m68k/target_flat.h | 1 + linux-user/microblaze/target_flat.h | 1 + linux-user/sh4/target_flat.h | 1 + 6 files changed, 5 insertions(+) create mode 100644 linux-user/aarch64/target_flat.h create mode 100644 linux-user/arm/target_flat.h rename linux-user/{ => generic}/target_flat.h (100%) create mode 100644 linux-user/m68k/target_flat.h create mode 100644 linux-user/microblaze/target_flat.h create mode 100644 linux-user/sh4/target_flat.h diff --git a/linux-user/aarch64/target_flat.h b/linux-user/aarch64/target_flat.h new file mode 100644 index 000000000000..bc83224cea12 --- /dev/null +++ b/linux-user/aarch64/target_flat.h @@ -0,0 +1 @@ +#include "../generic/target_flat.h" diff --git a/linux-user/arm/target_flat.h b/linux-user/arm/target_flat.h new file mode 100644 index 000000000000..bc83224cea12 --- /dev/null +++ b/linux-user/arm/target_flat.h @@ -0,0 +1 @@ +#include "../generic/target_flat.h" diff --git a/linux-user/target_flat.h b/linux-user/generic/target_flat.h similarity index 100% rename from linux-user/target_flat.h rename to linux-user/generic/target_flat.h diff --git a/linux-user/m68k/target_flat.h b/linux-user/m68k/target_flat.h new file mode 100644 index 000000000000..bc83224cea12 --- /dev/null +++ b/linux-user/m68k/target_flat.h @@ -0,0 +1 @@ +#include "../generic/target_flat.h" diff --git a/linux-user/microblaze/target_flat.h b/linux-user/microblaze/target_flat.h new file mode 100644 index 000000000000..bc83224cea12 --- /dev/null +++ b/linux-user/microblaze/target_flat.h @@ -0,0 +1 @@ +#include "../generic/target_flat.h" diff --git a/linux-user/sh4/target_flat.h b/linux-user/sh4/target_flat.h new file mode 100644 index 000000000000..bc83224cea12 --- /dev/null +++ b/linux-user/sh4/target_flat.h @@ -0,0 +1 @@ +#include "../generic/target_flat.h" From patchwork Sat Feb 4 16:08:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 989C4C636CC for ; Sat, 4 Feb 2023 16:11:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5u-0005Fs-Bg; Sat, 04 Feb 2023 11:08:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5p-0005CY-HS for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:48 -0500 Received: from mout.kundenserver.de ([212.227.17.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5n-0006wm-UD for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:45 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MTRhS-1pCM9l2EcG-00TirZ; Sat, 04 Feb 2023 17:08:41 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Laurent Vivier Subject: [PULL 15/22] linux-user: Fix SO_ERROR return code of getsockopt() Date: Sat, 4 Feb 2023 17:08:23 +0100 Message-Id: <20230204160830.193093-16-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:ctvkeRRaSGp+LXDc9zYwdH5ofs1nRVuBV2Q51cNatjilB/ph77y zJgj/+iy98/AHljUE5MjCTcwXU4pEq1Ozz5Gbz4L/PENYFETM74I4Oq8sSfj1oswequOZ42 +wtFuBQNGK7gt5Q4sbN92hPdkB3eezZDEL+d4ELT0YkOYBTAPLmi4HzLQb0qr8CjZfcaVOG RmtqxT309SMq4Q+g09xag== UI-OutboundReport: notjunk:1;M01:P0:XaT9SpYvLG4=;B7vR44XIuM9Iemjr6GCram7TmrM UF67rcoHFf2dZbr/PyQ/YpzyWje4AJd8hv7/yF+Fx5cLMUbegow6Qa0C6sqYwjbpMGRPTM6Cj 8DPCiWipuzmj0N4aqKYtoDqN5VRqNrL5Q6RiWwOwPtFTEmBYv+RZQPyFCjPTzgmXcvtfoGbPk HvdfNge9uqZ7E1ACcglkzK653OyJ4BgErDEUnkhQD/CXGxrqYzIvxzZTQd7EpX/7KlW51Gjka oFjcLdd+nPEDfVk89tJa/AZUUKgANrJEysnaSuifdATXNzu2OxzUFTzPfJmO3ZRD223ucDjMH qB/qCsnicebv3UqGT292swq19pb3F+a6wHZBtQU6LZ05tWPmPXx374v4Ka/sZIxUE8A5e0zY6 xxvBbEOyryXq7GkycikHgNWa3FNFNlS3aN/u/1YkZxccemasmfMjdfgA1Wbwdvg9iaiS7Fw7A 5skARRFcLJBfaTlDcR1ucxx82kzA8BF3lwk/j7AUhVPxP8Ujrs4OxeEIDeeuHj1t8y7eOO7+U C6M0lPGiOuzwtpfUh4bP7u44D8ucokGy3g/AWJTMa4qGq9EuIkTdzhlQiMfr+Z8+Kbedl7ay+ 7YhOD6C6XPOChIXUhi8Ws4/oJzoRewprnbXmDvZyBQKe4t/JxiPa+OR0r2YsrxN2+O5B4jB9D g5+s/IBQuacHC+Yrs3AkHb4LAkEq5vuWyLF5okVFGg== Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Helge Deller Add translation for the host error return code of: getsockopt(19, SOL_SOCKET, SO_ERROR, [ECONNREFUSED], [4]) = 0 This fixes the testsuite of the cockpit debian package with a hppa-linux guest on a x86-64 host. Signed-off-by: Helge Deller Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 210db5f0be94..1c42df651801 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2758,8 +2758,13 @@ get_timeout: ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv)); if (ret < 0) return ret; - if (optname == SO_TYPE) { + switch (optname) { + case SO_TYPE: val = host_to_target_sock_type(val); + break; + case SO_ERROR: + val = host_to_target_errno(val); + break; } if (len > lv) len = lv; From patchwork Sat Feb 4 16:08:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128772 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4C75DC636CC for ; Sat, 4 Feb 2023 16:11:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5u-0005G2-IB; Sat, 04 Feb 2023 11:08:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5q-0005Ca-9X for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:48 -0500 Received: from mout.kundenserver.de ([212.227.17.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5o-0006x0-A9 for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:46 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MIxqu-1p449I0CCo-00KOwR; Sat, 04 Feb 2023 17:08:42 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Laurent Vivier Subject: [PULL 16/22] linux-user: Fix /proc/cpuinfo output for hppa Date: Sat, 4 Feb 2023 17:08:24 +0100 Message-Id: <20230204160830.193093-17-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:6J504CEHn1Rc8H1oFDl2Q7pG356j0LjPO4dQa0OAbxk6fddwWnd aqCddakJB+FyeSbc92DFnQoLpvXit79Fe0IfETmmPBN8wf7cj/YUG/BzdVcY3QgL4lBHRR5 NeO6+AKanxTP8FOgZWdQkOBQvVWaop2d4YRug01ZyeQ/+CsKzVDzlE9khuzu8E7BW9K7/GT mwSMoxlIzF+3lSNZ9WY/w== UI-OutboundReport: notjunk:1;M01:P0:W19q2aZfjns=;6qemAJC+bAf4EJ3Xlkt06vUfyRi QJ/k58Ge5UEQi8CfAUBTtOOV62UQEwn8J/tUfa/tXKx06xyU4O3D0XQp4P6phU0QL8NUTgrJF 9BGuAqefXro3Sm8fzlCC78a7uZC85zRpgjVMZ7g02ucWI7wuhUpVvM43lGrp3fxzumAXlB84M 0ny97Pff46tEsS9HPnwLCrZSvE7fcyMtNoXJWRGdT9DtCLxSd/wVs75JxANUBCiPC+cGq/LkA hgoH4m7QBYm0aJDQ5/Ax7NREat7abm6On+0dSgsAlta26gMUb1FRYuP0Xne5eDaOiOpJYFoQN I4838RfgC5jXEGNps1KcQMfGySIQwgJl1qSpgaoNOqSv7uTWcIiAXugAED4NzRQQqb1IDKSMM ph0cmeKz9iPkNRRbp1jOBDMdGxq1piywEcISVT6I6geL2mXN998InugvBGZbad6l7lu2I0FGA gs935twcMRr2kWR9Aq79hVU4N0iZqJu4xpqA7z2aYBPg2L4l0EwSOFz+tWgp6v8bGiONJaYhR wMbrMtosYvHoUgoupNVKFFLjTYiuyEbk8qWCRlbQEgy4rMIKp/t0W0wGpyOop1M8Gh758Kfi6 Tuwaxtup9P4o5a4SHNVLQ02V7C/RJlCdpQDktjzxCpCjO07ESzeGhnTxXZDV7/ILX56PnfOLD NMW7DHBOQ1tuinXxcYvXEwRLWyznb62e568SNi7Pew== Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Helge Deller The hppa architectures provides an own output for the emulated /proc/cpuinfo file. Some userspace applications count (even if that's not the recommended way) the number of lines which start with "processor:" and assume that this number then reflects the number of online CPUs. Since those 3 architectures don't provide any such line, applications may assume "0" CPUs. One such issue can be seen in debian bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1024653 Avoid such issues by adding a "processor:" line for each of the online CPUs. Signed-off-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1c42df651801..55d53b344b84 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8232,11 +8232,17 @@ static int open_cpuinfo(CPUArchState *cpu_env, int fd) #if defined(TARGET_HPPA) static int open_cpuinfo(CPUArchState *cpu_env, int fd) { - dprintf(fd, "cpu family\t: PA-RISC 1.1e\n"); - dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n"); - dprintf(fd, "capabilities\t: os32\n"); - dprintf(fd, "model\t\t: 9000/778/B160L\n"); - dprintf(fd, "model name\t: Merlin L2 160 QEMU (9000/778/B160L)\n"); + int i, num_cpus; + + num_cpus = sysconf(_SC_NPROCESSORS_ONLN); + for (i = 0; i < num_cpus; i++) { + dprintf(fd, "processor\t: %d\n", i); + dprintf(fd, "cpu family\t: PA-RISC 1.1e\n"); + dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n"); + dprintf(fd, "capabilities\t: os32\n"); + dprintf(fd, "model\t\t: 9000/778/B160L - " + "Merlin L2 160 QEMU (9000/778/B160L)\n\n"); + } return 0; } #endif From patchwork Sat Feb 4 16:08:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128756 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 691C5C61DA4 for ; Sat, 4 Feb 2023 16:09:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5t-0005Ff-VC; Sat, 04 Feb 2023 11:08:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5q-0005Cb-HB for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:48 -0500 Received: from mout.kundenserver.de ([217.72.192.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5o-0006xM-ME for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:46 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MV5KC-1pDzmm26I2-00S4yJ; Sat, 04 Feb 2023 17:08:42 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Laurent Vivier Subject: [PULL 17/22] linux-user: Improve strace output of personality() and sysinfo() Date: Sat, 4 Feb 2023 17:08:25 +0100 Message-Id: <20230204160830.193093-18-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:5ub0z4qieGImvYnch3nUWUbLXig7P1ruyKLLApSuJaoJ4Y575Zg UxZy4ksqD83eaD4zBEPQu5LevT3wSRdcHUj39mZQ9Kuj2+mrryhI5S/1+uGxPpvrpqyPQHa 51FKeR7XAzFde01dgHn8Mm6PHAE7UiqEx9wOkzz/0WgmJDR7tO9r9uWPr4ArbMRZfaxgeI8 +LTUjzOup16saINM7mlUQ== UI-OutboundReport: notjunk:1;M01:P0:qN2MgOJK2PM=;7PZwp8T9OFu6ZL/YjXbM8nfuA5g lF3KHwzwKjFTZILDfaQSMCvglXSLdE6P4hKzBVf5SQSnSx7vowO2Hgs9dLdjbHhOBBL8AYS74 SAPxd4T6kBH/Wu75SU9QZQTjqKmJeSqZrofKkWyatiI/LyDjjWFWXVtBTLulgxGDV4c2leC2e jIsHpH+M9EiPUwUiUaRVtQ8ELmtcTYu/H1nRdeee2To6aMCbNWfRv2o2QEXmeKk9R8dTowdTN uJeHycTQCDILPxHAecOWgqXbZqkBiHVzToldtTTaMYTmzubyyYz9kDATbnlJvKecZm/2FQ6MW zLDcWxCUtpLX7C9nAGrxQKlXW/PsY/ifpFxs20/YTQmimOs/3bGC44nIR2PaaHIr6FErxw5TU gCtfzfjUXSrz8YPhrimsYynWnVOsCVtgENqxBfpytYJXCq0fCTQWGCxMRUd8IXQILAFlnAW/N PtqIGJ1nZMlbCgywRWn8Ecsc0V6vt1jjZ0oEIJ9vurr7kD3PchDqAsVBeDpcdQVgWy21ziksy f8LNc0wMGRJx1WvQwJbU3tZH5BGQQG7o7fXx4wJ+lAYByc6lI9YICa7Hj88oWlmp6fFnBvnEB ZrnY/1I7a+TwwvLiqkkCFspE4OlcFmDoFueSnxEqLdi14SHuSXKqbhus0ER6Jn61gdXImQIWQ AOc4/Rdejs8ADJkZd94nt6r4uJnMgS3/bvS1jf89lQ== Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Helge Deller Make the strace look nicer for those two syscalls. Signed-off-by: Helge Deller Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: Signed-off-by: Laurent Vivier --- linux-user/strace.list | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linux-user/strace.list b/linux-user/strace.list index cf291d02edfe..3a1f61803a39 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1049,7 +1049,8 @@ { TARGET_NR_perfctr, "perfctr" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_personality -{ TARGET_NR_personality, "personality" , NULL, NULL, NULL }, +{ TARGET_NR_personality, "personality" , "%s(0x"TARGET_ABI_FMT_lx")", NULL, + print_syscall_ret_addr }, #endif #ifdef TARGET_NR_pipe { TARGET_NR_pipe, "pipe" , NULL, NULL, NULL }, @@ -1504,7 +1505,7 @@ { TARGET_NR_sysfs, "sysfs" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_sysinfo -{ TARGET_NR_sysinfo, "sysinfo" , NULL, NULL, NULL }, +{ TARGET_NR_sysinfo, "sysinfo" , "%s(%p)", NULL, NULL }, #endif #ifdef TARGET_NR_sys_kexec_load { TARGET_NR_sys_kexec_load, "sys_kexec_load" , NULL, NULL, NULL }, From patchwork Sat Feb 4 16:08:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 82496C636CC for ; Sat, 4 Feb 2023 16:10:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5z-0005Qy-N1; Sat, 04 Feb 2023 11:08:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5u-0005Fp-6u for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:50 -0500 Received: from mout.kundenserver.de ([212.227.17.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5s-0006yi-6e for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:49 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MiIlc-1oiyT6482Q-00fV8N; Sat, 04 Feb 2023 17:08:43 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Ilya Leoshkevich , Laurent Vivier Subject: [PULL 18/22] linux-user: Add emulation for MADV_WIPEONFORK and MADV_KEEPONFORK in madvise() Date: Sat, 4 Feb 2023 17:08:26 +0100 Message-Id: <20230204160830.193093-19-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:0PJVmYugrpL6sj84cTTodUdppOXI1jCI6CmO1lzfVLHDyU8fytD 1igHbKQYCus8wPYqnkN44id5mhhjJS7K19YGjy2TNBBu9XxYWvyDbriL+4J2LmKjMTWK/RC imi1eBVLnt+FnbsvmU73CmsDbIwuQNNNitX6uOrdGlZwUeTxTo+XVfyhpZ4sZFwpt0aOzBl AonGAUIUZHa+708zrPpfA== UI-OutboundReport: notjunk:1;M01:P0:bFC3L7TPPmM=;DQNkNOZEQMARrO48hcbjWHzv00W RRTxPo4YcyByLQ9Yh7ovrf7C4xWq+ygg/XTA7/UoEiLenQjOnDgI0tetVk44HJCAIa9/JG6Zw QPnJAOe9JHOK7neC5e1modvjmZI4zpekyQWZkGXGSR7W/qFfCHptJoDO5n5i9fIgVfT2UBHfK 8GNbVcsv+xRZN3/RGAplPY4xR1zmvW7Z1z7FDJ5khau2R06rKuPI38UdyroXvCIVbNhKm7sq3 0l53QAkYBujSaZctpxgr0zXwsbto8l8jF0/wHx9YvKpbRqCE9418W2ZsozIxZbSU+I9X6A3qC K6Se5BdTYKenenr3YU21A/3/+CvxETyb5OYnKvOGO71WshiaJTeHAxpZgT2TFaE86lERob7yW z1f2hAF8f6TSR7wxwhnG8oYXCjTZO1wCGfi+ah5uxH3JTwwukKUV7B+R9FmP6YRZGpPO7PWhf SVhYH/V2XccE9sORJy4QtYjqSgKKQzUWtZOyhWettC65I5cGJRP0wbhOYjerFAX9hnxEzEkhG qm6HjqCKa87+MThbfS6dMqz7dosflY0JmknjCUapxzBPUS3iu4sguOFkX3ZgjC9/mpJ89EI1F en8FWhgidzTmwCIXK9DjYBuyNl+qNUtMRNymqlQg5cBv4tCXg2w24djJ7XmT3P2mulzRM4ycw 5GSY4NP7IrVpfkPIw7ZIENpIQzji1j9MQMgR06GFAQ== Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Helge Deller Both parameters have a different value on the parisc platform, so first translate the target value into a host value for usage in the native madvise() syscall. Those parameters are often used by security sensitive applications (e.g. tor browser, boringssl, ...) which expect the call to return a proper return code on failure, so return -EINVAL if qemu fails to forward the syscall to the host OS. While touching this code, enhance the comments about MADV_DONTNEED. Tested with testcase of tor browser when running hppa-linux guest on x86-64 host. Signed-off-by: Helge Deller Acked-by: Ilya Leoshkevich Reviewed-by: Laurent Vivier Message-Id: Signed-off-by: Laurent Vivier --- linux-user/mmap.c | 56 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 10f5079331c3..28135c9e6aa9 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -857,7 +857,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, return new_addr; } -static bool can_passthrough_madv_dontneed(abi_ulong start, abi_ulong end) +static bool can_passthrough_madvise(abi_ulong start, abi_ulong end) { ulong addr; @@ -901,23 +901,53 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice) return -TARGET_EINVAL; } + /* Translate for some architectures which have different MADV_xxx values */ + switch (advice) { + case TARGET_MADV_DONTNEED: /* alpha */ + advice = MADV_DONTNEED; + break; + case TARGET_MADV_WIPEONFORK: /* parisc */ + advice = MADV_WIPEONFORK; + break; + case TARGET_MADV_KEEPONFORK: /* parisc */ + advice = MADV_KEEPONFORK; + break; + /* we do not care about the other MADV_xxx values yet */ + } + /* - * A straight passthrough may not be safe because qemu sometimes turns - * private file-backed mappings into anonymous mappings. + * Most advice values are hints, so ignoring and returning success is ok. + * + * However, some advice values such as MADV_DONTNEED, MADV_WIPEONFORK and + * MADV_KEEPONFORK are not hints and need to be emulated. * - * This is a hint, so ignoring and returning success is ok. + * A straight passthrough for those may not be safe because qemu sometimes + * turns private file-backed mappings into anonymous mappings. + * can_passthrough_madvise() helps to check if a passthrough is possible by + * comparing mappings that are known to have the same semantics in the host + * and the guest. In this case passthrough is safe. * - * This breaks MADV_DONTNEED, completely implementing which is quite - * complicated. However, there is one low-hanging fruit: mappings that are - * known to have the same semantics in the host and the guest. In this case - * passthrough is safe, so do it. + * We pass through MADV_WIPEONFORK and MADV_KEEPONFORK if possible and + * return failure if not. + * + * MADV_DONTNEED is passed through as well, if possible. + * If passthrough isn't possible, we nevertheless (wrongly!) return + * success, which is broken but some userspace programs fail to work + * otherwise. Completely implementing such emulation is quite complicated + * though. */ mmap_lock(); - if (advice == TARGET_MADV_DONTNEED && - can_passthrough_madv_dontneed(start, end)) { - ret = get_errno(madvise(g2h_untagged(start), len, MADV_DONTNEED)); - if (ret == 0) { - page_reset_target_data(start, start + len); + switch (advice) { + case MADV_WIPEONFORK: + case MADV_KEEPONFORK: + ret = -EINVAL; + /* fall through */ + case MADV_DONTNEED: + if (can_passthrough_madvise(start, end)) { + ret = get_errno(madvise(g2h_untagged(start), len, advice)); + if ((advice == MADV_DONTNEED) && (ret == 0)) { + page_reset_target_data(start, start + len); + } } } mmap_unlock(); From patchwork Sat Feb 4 16:08:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C7F4BC636CC for ; Sat, 4 Feb 2023 16:10:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5v-0005H5-8o; Sat, 04 Feb 2023 11:08:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5s-0005Cg-2D for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:48 -0500 Received: from mout.kundenserver.de ([212.227.17.24]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5q-0006yB-Hl for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:47 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MJEpp-1p4L8J1ZeN-00Kfzg; Sat, 04 Feb 2023 17:08:44 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Laurent Vivier Subject: [PULL 19/22] linux-user: Show 4th argument of rt_sigprocmask() in strace Date: Sat, 4 Feb 2023 17:08:27 +0100 Message-Id: <20230204160830.193093-20-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:tOI2mju7NIAhX6hl2kuEotCFKSmkVA/JtAdz85PuDtJNEEc8IJU ceZVUAB3cyMvDBQmyMrWOQADUzNNiWSYyzd9mb4CYthc/2DWeApAg+yZ6NoUOMVl979W4jI ZDks3/DNBs0EnGfhNkmW3SzPsR+ylU0HQY1zfm9g/3CaH9Mh9Esp+k5ShfiBemGmsbCvL4a DMY9/sX7m+X2eCtmJZgRQ== UI-OutboundReport: notjunk:1;M01:P0:nTAo7mFKjY4=;osCQhXIfTQjjTq0IkowqAcSDCM8 7X/dMwcWYqnOI2VRyXGkMapp6uaeoNcx4PRU+6uPuIt0taZvQkKOO76ojh+YbsVnrIBxKZNYK G9ITC4HJ8sgYN98gevOYD9aKwTSwrkfVxv2HxqPr1vBgOs4WzMjwn8rlFIIlr0jsSRA+eFjNx luCiHPFfUOUhirNcC3E+5YzH9gw61pbaLaUGA1U9dPhXuhsqo1nJtANaTI2aaJn2Qaeyc2MtE lI+hD9z79FaIE/CWvQXpA2SvDj17M8PjP5hfnh+YKeTiFqulACqvo8prktCeaXTfLgPU2UMFY w/+CV6zNA8QpWWWYhYCjEDxTxE9h7uiTeOZUuVvUe+Sm9rX5rIoheoYs8KkvPKMmUnxYbmmCi r8Qe3zhuQcqgPAPvj6cajEbYJlypJPpTiMdgFzIq+de/YHcojlBlPixpZ10R9bCLsyK9vYr+E gxrUPcB12FLvaueCOvzPW+JEg5h7so5vchGSDVQzneSSgaoPEV5SodbCbLByMz9IrFceDagbS kN50fMaLvWU46nppwU+5Pwn2rRhd26htX4eGE55XPzBD6Ih0IXOEdpO0iR4RcUKoSmaT2Z8uY MQn0zJQMA+WR740mzSC6eabTgNFfyKqBYSg19vMNuIAgUMqwT11tM9Lf1a607wJ02qVGRFKnU 0q2zraBOxWShJU5xtkiZkezlV6uQNETOBVPfBpGyvQ== Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Helge Deller Add output for the missing 4th parameter (size_t sigsetsize). Signed-off-by: Helge Deller Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: Signed-off-by: Laurent Vivier --- linux-user/strace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index f38227ba5db5..340010661c4f 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -3224,7 +3224,8 @@ print_rt_sigprocmask(CPUArchState *cpu_env, const struct syscallname *name, } qemu_log("%s,", how); print_pointer(arg1, 0); - print_pointer(arg2, 1); + print_pointer(arg2, 0); + print_raw_param("%u", arg3, 1); print_syscall_epilogue(name); } #endif From patchwork Sat Feb 4 16:08:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8863C61DA4 for ; Sat, 4 Feb 2023 16:10:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5y-0005P5-Nu; Sat, 04 Feb 2023 11:08:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5t-0005FU-MO for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:49 -0500 Received: from mout.kundenserver.de ([217.72.192.74]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5r-0006yU-Dr for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:49 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N3KDM-1ofkxq3Pu6-010JCP; Sat, 04 Feb 2023 17:08:45 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier Subject: [PULL 20/22] linux-user: Enhance strace output for various syscalls Date: Sat, 4 Feb 2023 17:08:28 +0100 Message-Id: <20230204160830.193093-21-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Js93xtHuDvVGovJlC6+GReXXsj0E6Ed8IhOo/iiHUmiruR1jNFU IabvCtp/7CbceOVozbbJe0l8pl4Y/G1c/fobQLh/QH6Yjk+U1PSnhA/HYqJDsFWcKnxZ3Iz hVOVCbZj8WfHN2R/J0fpUum7/zT+WJsi4jf0JUEhpe8TjdnCuoteY9J6FHVqepb/p+bCstT 4l+6IMCf/DN4xydOf0oSw== UI-OutboundReport: notjunk:1;M01:P0:p4imyttATcY=;segpLpIWud+dmXsCyHyfKsjLONv i37NCukwhY9nn6lhkG5YHHX6dwAGu5MgZQYya9Bt7TSpXMyAeMkLpCc1NoZaU0lxtm86/59fM Ul6VV+HXGnrFFXBrIIolQdosT+eAIY4M/QNMbOCyEGlo0KABSRfPCTGFxivIWGc6AGR45qqnp oBVE3VxqMnzWnFTKcBWfFKRhU4a2ffPX1QTCRi/s5Xn5S4r1bCPOx50sqF7iViqYre69aq64+ rUwNnAQtcjuRPUnhi9F6lrSnBHEl2aYKplIIwr4sznu51I8kQAXGd3/CGTj119KgTAiKGeCcJ lL7eTswo8Rdx+6/lN50/QKHfAn1AtuiK0sUru2+Ksq8OGw4e5kQ+mNGatxmLyNgX0DVyLocj2 BfntP2gpLyx11PyYYGI7bIt5jAcHvLRZOnGOaTLgC399t4Nrp2McrjN0crI0xJCJ09V012rg0 sONoYcH9K2krsuBeGNqUAFtw1Sf6Z+TwKaG2oVIkv5YbDeeP0wcdo4k1chj82kucZhrCLdySU 4DXy2q1T3ty97Zn+UnIxRWJttYRGa6hdwy+eKP9d6Ss2BEKvLVs44ywh0n+egzpIhE5hlR97x K3Pxefn743MkFQ4ofO0zrdwOtEARt3kEvT/R//0UYG7sl6mlMwL6YmGsmLtvgD+CpA7flxccL 3yUyDGZJdRk47C9jS1mcchwmFIDKcSxfSDLFpSkKUw== Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Helge Deller Add appropriate strace printf formats for various Linux syscalls. Signed-off-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Message-Id: Signed-off-by: Laurent Vivier --- linux-user/strace.list | 43 ++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/linux-user/strace.list b/linux-user/strace.list index 3a1f61803a39..d8acbeec6093 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -343,7 +343,7 @@ { TARGET_NR_getpagesize, "getpagesize" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getpeername -{ TARGET_NR_getpeername, "getpeername" , NULL, NULL, NULL }, +{ TARGET_NR_getpeername, "getpeername" , "%s(%d,%p,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_getpgid { TARGET_NR_getpgid, "getpgid" , "%s(%u)", NULL, NULL }, @@ -367,19 +367,19 @@ { TARGET_NR_getrandom, "getrandom", "%s(%p,%u,%u)", NULL, NULL }, #endif #ifdef TARGET_NR_getresgid -{ TARGET_NR_getresgid, "getresgid" , NULL, NULL, NULL }, +{ TARGET_NR_getresgid, "getresgid" , "%s(%p,%p,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_getresgid32 { TARGET_NR_getresgid32, "getresgid32" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getresuid -{ TARGET_NR_getresuid, "getresuid" , NULL, NULL, NULL }, +{ TARGET_NR_getresuid, "getresuid" , "%s(%p,%p,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_getresuid32 { TARGET_NR_getresuid32, "getresuid32" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getrlimit -{ TARGET_NR_getrlimit, "getrlimit" , NULL, NULL, NULL }, +{ TARGET_NR_getrlimit, "getrlimit" , "%s(%d,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_get_robust_list { TARGET_NR_get_robust_list, "get_robust_list" , NULL, NULL, NULL }, @@ -391,10 +391,10 @@ { TARGET_NR_getsid, "getsid" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_getsockname -{ TARGET_NR_getsockname, "getsockname" , NULL, NULL, NULL }, +{ TARGET_NR_getsockname, "getsockname" , "%s(%d,%p,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_getsockopt -{ TARGET_NR_getsockopt, "getsockopt" , NULL, NULL, NULL }, +{ TARGET_NR_getsockopt, "getsockopt" , "%s(%d,%d,%d,%p,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_get_thread_area #if defined(TARGET_I386) && defined(TARGET_ABI32) @@ -1059,10 +1059,10 @@ { TARGET_NR_pivot_root, "pivot_root" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_poll -{ TARGET_NR_poll, "poll" , NULL, NULL, NULL }, +{ TARGET_NR_poll, "poll" , "%s(%p,%u,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_ppoll -{ TARGET_NR_ppoll, "ppoll" , NULL, NULL, NULL }, +{ TARGET_NR_ppoll, "ppoll" , "%s(%p,%u,%p,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_prctl { TARGET_NR_prctl, "prctl" , NULL, NULL, NULL }, @@ -1131,7 +1131,7 @@ { TARGET_NR_reboot, "reboot" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_recv -{ TARGET_NR_recv, "recv" , NULL, NULL, NULL }, +{ TARGET_NR_recv, "recv" , "%s(%d,%p,%u,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_recvfrom { TARGET_NR_recvfrom, "recvfrom" , NULL, NULL, NULL }, @@ -1191,7 +1191,7 @@ { TARGET_NR_rt_sigqueueinfo, "rt_sigqueueinfo" , NULL, print_rt_sigqueueinfo, NULL }, #endif #ifdef TARGET_NR_rt_sigreturn -{ TARGET_NR_rt_sigreturn, "rt_sigreturn" , NULL, NULL, NULL }, +{ TARGET_NR_rt_sigreturn, "rt_sigreturn" , "%s(%p)", NULL, NULL }, #endif #ifdef TARGET_NR_rt_sigsuspend { TARGET_NR_rt_sigsuspend, "rt_sigsuspend" , NULL, NULL, NULL }, @@ -1203,16 +1203,19 @@ { TARGET_NR_rt_tgsigqueueinfo, "rt_tgsigqueueinfo" , NULL, print_rt_tgsigqueueinfo, NULL }, #endif #ifdef TARGET_NR_sched_getaffinity -{ TARGET_NR_sched_getaffinity, "sched_getaffinity" , NULL, NULL, NULL }, +{ TARGET_NR_sched_getaffinity, "sched_getaffinity" , "%s(%d,%u,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_sched_get_affinity { TARGET_NR_sched_get_affinity, "sched_get_affinity" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_sched_getattr -{ TARGET_NR_sched_getattr, "sched_getattr" , NULL, NULL, NULL }, +{ TARGET_NR_sched_getattr, "sched_getattr" , "%s(%d,%p,%u,%u)", NULL, NULL }, +#endif +#ifdef TARGET_NR_sched_setattr +{ TARGET_NR_sched_setattr, "sched_setattr" , "%s(%p,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_sched_getparam -{ TARGET_NR_sched_getparam, "sched_getparam" , NULL, NULL, NULL }, +{ TARGET_NR_sched_getparam, "sched_getparam" , "%s(%d,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_sched_get_priority_max { TARGET_NR_sched_get_priority_max, "sched_get_priority_max" , NULL, NULL, NULL }, @@ -1227,7 +1230,7 @@ { TARGET_NR_sched_rr_get_interval, "sched_rr_get_interval" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_sched_setaffinity -{ TARGET_NR_sched_setaffinity, "sched_setaffinity" , NULL, NULL, NULL }, +{ TARGET_NR_sched_setaffinity, "sched_setaffinity" , "%s(%d,%u,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_sched_setatt { TARGET_NR_sched_setatt, "sched_setatt" , NULL, NULL, NULL }, @@ -1360,23 +1363,23 @@ { TARGET_NR_setreuid32, "setreuid32" , "%s(%u,%u)", NULL, NULL }, #endif #ifdef TARGET_NR_setrlimit -{ TARGET_NR_setrlimit, "setrlimit" , NULL, NULL, NULL }, +{ TARGET_NR_setrlimit, "setrlimit" , "%s(%d,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_set_robust_list -{ TARGET_NR_set_robust_list, "set_robust_list" , NULL, NULL, NULL }, +{ TARGET_NR_set_robust_list, "set_robust_list" , "%s(%p,%u)", NULL, NULL }, #endif #ifdef TARGET_NR_setsid { TARGET_NR_setsid, "setsid" , "%s()", NULL, NULL }, #endif #ifdef TARGET_NR_setsockopt -{ TARGET_NR_setsockopt, "setsockopt" , NULL, NULL, NULL }, +{ TARGET_NR_setsockopt, "setsockopt" , "%s(%d,%d,%d,%p,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_set_thread_area { TARGET_NR_set_thread_area, "set_thread_area", "%s(0x"TARGET_ABI_FMT_lx")", NULL, NULL }, #endif #ifdef TARGET_NR_set_tid_address -{ TARGET_NR_set_tid_address, "set_tid_address" , NULL, NULL, NULL }, +{ TARGET_NR_set_tid_address, "set_tid_address" , "%s(%p)", NULL, NULL }, #endif #ifdef TARGET_NR_settimeofday { TARGET_NR_settimeofday, "settimeofday" , NULL, print_settimeofday, NULL }, @@ -1655,7 +1658,7 @@ { TARGET_NR_vserver, "vserver" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_wait4 -{ TARGET_NR_wait4, "wait4" , NULL, NULL, NULL }, +{ TARGET_NR_wait4, "wait4" , "%s(%d,%p,%d,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_waitid { TARGET_NR_waitid, "waitid" , "%s(%#x,%d,%p,%#x)", NULL, NULL }, @@ -1679,7 +1682,7 @@ { TARGET_NR_sync_file_range2, "sync_file_range2", NULL, NULL, NULL }, #endif #ifdef TARGET_NR_pipe2 -{ TARGET_NR_pipe2, "pipe2", NULL, NULL, NULL }, +{ TARGET_NR_pipe2, "pipe2", "%s(%p,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_pidfd_open { TARGET_NR_pidfd_open, "pidfd_open", "%s(%d,%u)", NULL, NULL }, From patchwork Sat Feb 4 16:08:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 422F4C61DA4 for ; Sat, 4 Feb 2023 16:09:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5w-0005JR-0F; Sat, 04 Feb 2023 11:08:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5s-0005Dn-QF for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:48 -0500 Received: from mout.kundenserver.de ([217.72.192.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5q-0006yF-Rt for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:48 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MPoPd-1p29HS14ol-00Mrqm; Sat, 04 Feb 2023 17:08:45 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 21/22] linux-user: Implement SOL_ALG encryption support Date: Sat, 4 Feb 2023 17:08:29 +0100 Message-Id: <20230204160830.193093-22-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:lQd1o3aGuBgKlcDge8bZJ98/pcNRPbnqyRTXsUGS+brH4F20YDK jXJXcQXS7dQyvxOwVyEEKcBQwmA8fSwTi1GVyDR9FrmLn/gDtLlpDraqUUAfhGov+Yc1cFq eAfmRcI7tfsHVppyhSTY/djjRPV3g1U16KNLhMJizrFcd33uOOlN/Nw32BCSR7CrlnVYvFw Ee9xbcSdFdVlQCzEQdM6w== UI-OutboundReport: notjunk:1;M01:P0:MHSzIqsyP9M=;Vyqtid8HkLc7urRCVq005zFzJQj loYYnH+C1RYcLpP5WYU6ceVHpOM5BpNmfSVjcap8Qm9kcjjUOGPjwFI2xv0sdjVayKZNA1aI/ na2/dS2YwnEdnoTs8KbeZy3tBgXheDTDc2TOUbiI3ToYfi0shCAkHcQQ2CoHZgBTb+xoWx1jk +hPASazwJvChXNK10pyCHEhYRzfmUWiM2EZcm4njATz8b5vjy6fmQY8MhsNpA/W/DTeqKVZ1W Wkw0qEOhwChHfPcvIF72GYIorb3ApysswdxpoEqHhdPWxMQWuhnUjcqLfctznnWiNcPVlJlit k6+pFGTOkUOiedPPpPA92QirtYZ6pAouCDcM4fJ3rEm7Eqt7rcAcvEtoboTIZotlDTyz3D2SK kAXRHNYiUkpUk1SkzezoEO9U/rFiV52OYERpH2/OELbVavay2CTdijd3+jFlggA74+lnSCNN+ 6Fi/lSahfc3Uk/B2KJDDYn+FxMjl1rZgZ93CVoksgVuyo4YKphlLcfMQQYi2i2nuA8lh5zNh6 G0V0yRnWxzczraowd6s1Rdu5CFCGeWIltl5v2ojqorYiLKkUBcJQfj9RtgH+RBUwT/7YuFuhA 2/DXIaCw0K6BVcm930DJbYKVrt/4PotAmVExV2JJslBlPCs1x//iMFa1N+sUzOmEdoULuR9VC TFrHceBkxhQxgCE+6KT36RmOg9mhSB277RZr5DX9Qw== Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Helge Deller Add suport to handle SOL_ALG packets via sendmsg() and recvmsg(). This allows emulated userspace to use encryption functionality. Tested with the debian ell package with hppa guest on x86_64 host. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20221212173416.90590-1-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 55d53b344b84..a0d2beddaa4e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1829,6 +1829,14 @@ static inline abi_long target_to_host_cmsg(struct msghdr *msgh, __get_user(cred->pid, &target_cred->pid); __get_user(cred->uid, &target_cred->uid); __get_user(cred->gid, &target_cred->gid); + } else if (cmsg->cmsg_level == SOL_ALG) { + uint32_t *dst = (uint32_t *)data; + + memcpy(dst, target_data, len); + /* fix endianess of first 32-bit word */ + if (len >= sizeof(uint32_t)) { + *dst = tswap32(*dst); + } } else { qemu_log_mask(LOG_UNIMP, "Unsupported ancillary data: %d/%d\n", cmsg->cmsg_level, cmsg->cmsg_type); From patchwork Sat Feb 4 16:08:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13128771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF626C636CC for ; Sat, 4 Feb 2023 16:11:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5x-0005MH-W5; Sat, 04 Feb 2023 11:08:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5t-0005FC-Al for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:49 -0500 Received: from mout.kundenserver.de ([217.72.192.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5r-0006yN-95 for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:49 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MadGG-1omGFb2lBq-00cCkH; Sat, 04 Feb 2023 17:08:45 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 22/22] linux-user: Allow sendmsg() without IOV Date: Sat, 4 Feb 2023 17:08:30 +0100 Message-Id: <20230204160830.193093-23-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:HwvZlHgdhGj0FPAZJbKBy4hIYt7gRR3TZfLWTInBGZUPZbM6GIf nDT+FvsPhPc7+Zt18j3xwS4EyX3svmPhomp7Cibegmtss1PuPcLlisorM+ywpy0EzLbDxKp YFNFiCZV1y5VYWhb+wshE3s6VGpQRvrwR6PdriAzk2itpDmHbP1ttRkKxDZEmJaWyC6qxe+ BMgCNY/VW+cEEog9crlYg== UI-OutboundReport: notjunk:1;M01:P0:3GJYaYXgG18=;mhcPZ89ojWj0PRKW3fuSxACYuSs yh6XKMktozDIWcP8C5VHhbH9bdepucZpGkJzgFQf87AwXCk5ZFzYJOLZalCNPmlOt8GaVG9bD E3YrzQoWvtggDIHhWrH48/2IKt9Uy6JgMSAv5tl9nyLe4y9UZMFnX8VdJZ9OVHmKN8ZzKfMrt G/rHxxBPSUob/CdA9ejD1H5C2bTWABdpusJeS50jZCLGCbbWhkvHqldmEU0B8JxjTef9GWgDC Q5J7d7cpXNb1NaXW/MNuL2ywolj+LFKjFW4VU+o1yK56OiAmB5KFGjdjdtKnxD7tQp0U9ncSU brDxWNTMNrwkFpr6raPdOi0ahZeO0FSsF9ocRAPvcDQEQxOqFqwPnE9K/ZkDMCY3eIC1i4EzY uBbB99yAeZOIVODoGmee3/l5EYQXHTtrlqVR8QQd1g0QUEUfgFHZ8JA7UHXOl2Hke2UdGqfku 9lGkx7a07ITp+DxfpxGigVZPMxA3s9Ey3ZGWqhvoFlBcM3us7S6GJD8El7RT109C/3c7KcgDk tajisre8N39IDY6N+Jzx91RP7AF031qGEL5yc9VN9mTesumFYcOYIGCVlU+San+q9YlDisUma dwSvJtbrveQNHxSR5x1KS3W6UNw1+DZg+3V5cP8fzj2qAuRQK8PTN3g0NWm7gOdMoFnrEcdny mP0hYi+ZJGtp0beXdsCRA3bPyVaz0SZV8YDndZS/VQ== Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Helge Deller Applications do call sendmsg() without any IOV, e.g.: sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=NULL, msg_iovlen=0, msg_control=[{cmsg_len=36, cmsg_level=SOL_ALG, cmsg_type=0x2}], msg_controllen=40, msg_flags=0}, MSG_MORE) = 0 sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="The quick brown fox jumps over t"..., iov_len=183}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_ALG, cmsg_type=0x3}], msg_controllen=24, msg_flags=0}, 0) = 183 The function do_sendrecvmsg_locked() is used for sndmsg() and recvmsg() and calls lock_iovec() to lock the IOV into memory. For the first sendmsg() above it returns NULL and thus wrongly skips the call the host sendmsg() syscall, which will break the calling application. Fix this issue by: - allowing sendmsg() even with empty IOV - skip recvmsg() if IOV is NULL - skip both if the return code of do_sendrecvmsg_locked() != 0, which indicates some failure like EFAULT on the IOV Tested with the debian "ell" package with hppa guest on x86_64 host. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20221212173416.90590-2-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a0d2beddaa4e..1e868e9b0e27 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3293,7 +3293,10 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp, target_vec, count, send); if (vec == NULL) { ret = -host_to_target_errno(errno); - goto out2; + /* allow sending packet without any iov, e.g. with MSG_MORE flag */ + if (!send || ret) { + goto out2; + } } msg.msg_iovlen = count; msg.msg_iov = vec; @@ -3345,7 +3348,9 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp, } out: - unlock_iovec(vec, target_vec, count, !send); + if (vec) { + unlock_iovec(vec, target_vec, count, !send); + } out2: return ret; }