From patchwork Wed Sep 28 08:14:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992043 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 8F797C04A95 for ; Wed, 28 Sep 2022 10:04:28 +0000 (UTC) Received: from localhost ([::1]:46444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odTvX-00010u-4l for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:04:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE5-00087k-Vy for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:30 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:33311) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE3-00089t-No for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:29 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MDQmW-1oU8pd2npO-00ASW9; Wed, 28 Sep 2022 10:15:19 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier Subject: [PULL 01/38] linux-user: use 'max' instead of 'qemu32' / 'qemu64' by default Date: Wed, 28 Sep 2022 10:14:40 +0200 Message-Id: <20220928081517.734954-2-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:e345ae5atdF0YMpk8asE0ffRIPJ41+q9N1OBzYNeq2TVkT/qDtD aAMSB0wWLtGvXA4OFt16C53Ii9BGXwHrOprOgmVynbMaXJ6JqWTHQjpEtpa+uDNzZHr2Ycc MwoS8qiczEvaU7eY5KeaAy6EGq4wL4YBb2zPf+Rmkn6lBqaljy2ti+CQoHQ4f8ivTNqkATD KSVgqK/BkG00PTEDgKsXg== X-UI-Out-Filterresults: notjunk:1;V03:K0:pCR6V7K3E4Y=:RhM5zCHz0wNSjQIpTbM2lo GDYtafErBtIw23zYgZERSxjVty8P2uRxjEiWxjGmHBMf21hOWCrOh9ss+Jtc4V5bS/9buq6BC L/7a0ChlHZKoNOoclh0U8LhAzUAAL5P6u7JOQOAiJAaOgZU3c1GS0ZcPwhFMa6FuvkDplYNkd yZDYUj9mo7w4ZMUt6ho7VJ/m4eCE21RSf1P1u7pawMFQo1th4xKnZ26W7KvciTCYMX91fA283 Wyj71UgB7h+8A7vhCnamSn09mqTJgrzYUMb1IEucUww0KN7FHE+l5DcTv18ZWkTpL+HZgXSXt PdgPLiGxANFbmvTH+VjcvFSVzW9jF2ZzW9r2al62JWBmSRvvbrNjIHgwAhT4xghAG2+qYr5zQ Dtmq99WalzPaOvP+dxUJqfnwxPnjQS1QbKyBP+i+EuP2zfgTVHZ3OJIeAJ1naxTiNflc1Xgka ooopCmb5gbRo0lcEKm3T9sLH38J7bg3yyMFsjXTd+E9jHSVKM8cN1jU6MTDxwirb2p1VvJ4p/ 5qtsXDj8CBJbsG8Gs5q4h3fIOhDRDYoWWRiaDG0SA7DwBYrieau6t6FddcRLoS6CiOz30amQu VogokSMhyB285Knxw6i6n6uqvY0L78iUZrW/woGleTHW352iHGsozWUSmd2ysu00dPhdUQrA0 OeIjpucf9/rWowO5Yu4MioqCCqZjiMmZO2JbSYx+dYWZBXzgssIyA/6SeANLCxYSYO/Yyu/+g L/elFKHU5FF1IAjjBUcJvyaVE4cFaxa98gKCQ0gQ2EoqIry6DcKc4T8QdGM//PUMlmfOqZCqL xoj2fzX 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Daniel P. Berrangé The 'qemu64' CPU model implements the least featureful x86_64 CPU that's possible. Historically this hasn't been an issue since it was rare for OS distros to build with a higher mandatory CPU baseline. With RHEL-9, however, the entire distro is built for the x86_64-v2 ABI baseline: https://developers.redhat.com/blog/2021/01/05/building-red-hat-enterprise-linux-9-for-the-x86-64-v2-microarchitecture-level It is likely that other distros may take similar steps in the not too distant future. For example, it has been suggested for Fedora on a number of occasions. This new baseline is not compatible with the qemu64 CPU model though. While it is possible to pass a '-cpu xxx' flag to qemu-x86_64, the usage of QEMU doesn't always allow for this. For example, the args are typically controlled via binfmt rules that the user has no ability to change. This impacts users who are trying to use podman on aarch64 platforms, to run containers with x86_64 content. There's no arg to podman that can be used to change the qemu-x86_64 args, and a non-root user of podman can not change binfmt rules without elevating privileges: https://github.com/containers/podman/issues/15456#issuecomment-1228210973 Changing to the 'max' CPU model gives 'qemu-x86_64' maximum compatibility with binaries it is likely to encounter in the wild, and not likely to have a significant downside for existing usage. Most other architectures already use an 'any' CPU model, which is often mapped to 'max' (or similar) already, rather than the oldest possible CPU model. For the sake of consistency the 'i386' architecture is also changed from using 'qemu32' to 'max'. Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Daniel P. Berrangé Message-Id: <20220923110413.70593-1-berrange@redhat.com> Signed-off-by: Laurent Vivier --- linux-user/i386/target_elf.h | 2 +- linux-user/x86_64/target_elf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/i386/target_elf.h b/linux-user/i386/target_elf.h index 1c6142e7da0d..238a9aba738a 100644 --- a/linux-user/i386/target_elf.h +++ b/linux-user/i386/target_elf.h @@ -9,6 +9,6 @@ #define I386_TARGET_ELF_H static inline const char *cpu_get_model(uint32_t eflags) { - return "qemu32"; + return "max"; } #endif diff --git a/linux-user/x86_64/target_elf.h b/linux-user/x86_64/target_elf.h index 7b76a90de880..3f628f8d6619 100644 --- a/linux-user/x86_64/target_elf.h +++ b/linux-user/x86_64/target_elf.h @@ -9,6 +9,6 @@ #define X86_64_TARGET_ELF_H static inline const char *cpu_get_model(uint32_t eflags) { - return "qemu64"; + return "max"; } #endif From patchwork Wed Sep 28 08:14:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992082 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 5717BC32771 for ; Wed, 28 Sep 2022 10:44:47 +0000 (UTC) Received: from localhost ([::1]:56676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUYX-0007MN-Nv for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:44:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE4-00085y-Hc for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:28 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:54657) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE1-00089H-BL for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:27 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M8QJq-1oZ4VE0ZZA-004T2F; Wed, 28 Sep 2022 10:15:20 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Jameson Nash , Laurent Vivier Subject: [PULL 02/38] linux-user: fix readlinkat handling with magic exe symlink Date: Wed, 28 Sep 2022 10:14:41 +0200 Message-Id: <20220928081517.734954-3-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:dKIcFdxvcq8+kkyyuZxnYokDGGDmh9Fl8qSNLx43uBQuAaavcZP cmA30rrindKYENiBa3xlhcWR0rco314nS8M37XJ67Bmu6TFXdadZSxCmHGkpUcZgmI5OFkM F0rmD3B8SaWqidmZUc0XvuPooZXpD2TyxASXUTXTDWaKFSPS7YRLmWtodieHhHPSRnhWSNg s4Rok00VSQWny/ejxVcVQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:euF2N9/6ybc=:rdWjt5tBdJCNSCQ/cDzDmA ST+EYqHtwMZSL7MDz1cUdjw2VDO8gDkzvxLuZHZKVHCx875w7cuGsdV+XKlVqE1GEA12+rl38 jJ61Eno9+fnfn2DFxrAKCG1g2eGtJZkVv9XnCpC6+KFF+tutns59m5Tf6mM1CGPEFiyWmoT9t g/UjxCq/XJoeoblDk9f9s167OmayWj1cEgBo0MttkbYTxJESW2Hmawe1+xgv7RN2FTp35IL2M RL1UlcenwB8AA+gO2tRgX9UaNPVKUV25MFp1AZ20soLLTKgvKxxakoGI60I5S1Me+2Oe0jkff 9BqivrNFeTxT4nvrfgVHpdjN9jFhTWDPI7nsQbUpv9O8MxrHQb24UUgVmbN7vld090pElu2zC Lc1T8TDMgaa4c+5ZMIV25NczyJgZptXuBa0x38/YUwaOXcAeadiZx+JrmbCK8LWjjJ7chHFxf GU2VHJbN2Cu6lJ9jMrrXx8Z/oSX9oBDa4Btf2Pxx9hyMF/am6xTHVmhju/f6QorUvvEO0XimL iz6al9aW9HjFAHS4tehPIgwKCNai/LPMTAb5+w+W9xXa+M59dpuF24cTctj7iu4mb93WkRO6z 9ivqR1ARAo4olzhenYFY2rOYiZaMuonEpMog/1hv/IwIR7umgfu+9yrTHIHmvSVAwEozTFARX 5nwq7QM0JP7/CN5NMEckb8CzM2sTBwHoQ4jWknUCZJ/ce4A7LV483e7C8HdZguKfnonCiHKJO oRdZKXf3JA/dqclR/EG6TyTSxpPbIZv6regdO9Uk/X5Y3C5WQxTjzVAGNx2is667092HIhn67 jxuCccw 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" From: Jameson Nash Exactly the same as f17f4989fa193fa8279474c5462289a3cfe69aea before was for readlink. I suppose this was simply missed at the time. Signed-off-by: Jameson Nash Reviewed-by: Laurent Vivier Message-Id: <20220808190727.875155-1-vtjnash@gmail.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f4091212027c..abf82bab2a18 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9912,11 +9912,22 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, p2 = lock_user(VERIFY_WRITE, arg3, arg4, 0); if (!p || !p2) { ret = -TARGET_EFAULT; + } else if (!arg4) { + /* Short circuit this for the magic exe check. */ + ret = -TARGET_EINVAL; } else if (is_proc_myself((const char *)p, "exe")) { char real[PATH_MAX], *temp; temp = realpath(exec_path, real); - ret = temp == NULL ? get_errno(-1) : strlen(real) ; - snprintf((char *)p2, arg4, "%s", real); + /* Return value is # of bytes that we wrote to the buffer. */ + if (temp == NULL) { + ret = get_errno(-1); + } else { + /* Don't worry about sign mismatch as earlier mapping + * logic would have thrown a bad address error. */ + ret = MIN(strlen(real), arg4); + /* We cannot NUL terminate the string. */ + memcpy(p2, real, ret); + } } else { ret = get_errno(readlinkat(arg1, path(p), p2, arg4)); } From patchwork Wed Sep 28 08:14:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992079 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 4AE6EC04A95 for ; Wed, 28 Sep 2022 10:41:18 +0000 (UTC) Received: from localhost ([::1]:54964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUVB-0001fj-8P for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:41:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE1-00083g-JB for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:25 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:33613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSDy-000893-FJ for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:24 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MYNS0-1oiWS22F9O-00VRoj; Wed, 28 Sep 2022 10:15:20 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 03/38] linux-user: Add missing signals in strace output Date: Wed, 28 Sep 2022 10:14:42 +0200 Message-Id: <20220928081517.734954-4-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:MLnAivncBADC0ZE41ncCBvsFpLYjI1w75tR8VXErhKn4+fs+O5E wci898I0JbVSRkk48o4zqRm7xvriIzHAvFUfS3q/I11j6e9jvO6Jr71EpQQ7aXlnR9/ob9Y BUN0WEOUlY8x1tbiyrO8Po4Z4qVQTUwZBiA1bZ1l1iPFnLdahD9e6s1iGybdKaUrNDHtmku vmbfwNvGpdAdzUmrk4Vew== X-UI-Out-Filterresults: notjunk:1;V03:K0:EBFbcqmieSY=:U70A1OO0wpDFXJeywX/7Gw LxFR2+qmbrLFtVbkXxn6l918czvBHjXjunN0K7vi+czNmnc5tXisBUxESrEz/99w5n/5LZcXI wjUHbzeX+NHSheGYhTUe8E9ap6iaIQQiuxAMo/fDslTSB7C8hUGS05PPUowRDa3vHA9DcX4uS dgK7d9FXLIYeYgT+5FEZ9mFn43zmXT6zr7uQyLvmRI4BodQCbJmD5146GNPdW8n7aMt5Aaex0 CVNIzUz5+uaLbvLX8oDUygIF2WzPX8/deP5WBKPofn6bhEF9DaeIS1m1ykB3tRCM9yplHr6lQ vGGAMJPnJnoT7AO7EWHrDLvOU+PSNSQ24ZekicEMDZoYGQVUnU1FeTQ8HLmD3WuFmx0cQSbvn sIqyZ9EzoGPVb1wMM5np22lqx0tsyQfIx3p8XvZvhHR2h6mruKSeOuEXvCLDCRE1imtCemg5Q Eg6dEzbZqBZjMVQKDO2W6aLI00fvcEjdYglsEsINObjeGhweZPk2BTCaBvl7zEqTy2Rymxoh8 70gGERkweeJQW05LYwMg4LVJ6XTUKo2MxIkUYNm/GiyQkwBM6tkE/I5zqhDWiPCBU49gP7trs js8DjOjGS5Q5ijtuK7bBfVObo6NWR59eh3tAm87pBvJuFao/5KxbO941yPvHrz0hJnM5JkYCQ QupxgfSt2uzhn2mzBb69pMdl/WHN1io/Nem0C1ceC1Ww53saP+WumVCT2g4eHVfiGmojt6LKu 6aTDEi7mjT6BZAtAUIC+6KtRGQrAn8paMbqP5jJcQrGwDFfyzA+pFYWRgoPKz7vCVNtZNgnJV K38vJmD 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Helge Deller Some of the guest signal numbers are currently not converted to their representative names in the strace output, e.g. SIGVTALRM. This patch introduces a smart way to generate and keep in sync the host-to-guest and guest-to-host signal conversion tables for usage in the qemu signal and strace code. This ensures that any signals will now show up in both tables. There is no functional change in this patch - with the exception that yet missing signal names now show up in the strace code too. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20220918194555.83535-2-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/signal-common.h | 46 ++++++++++++++++++++++++++++++++++++++ linux-user/signal.c | 37 +++--------------------------- linux-user/strace.c | 30 +++++++++---------------- 3 files changed, 60 insertions(+), 53 deletions(-) diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index 6a7e4a93fc13..3e2dc604c2fb 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -118,4 +118,50 @@ static inline void finish_sigsuspend_mask(int ret) } } +#if defined(SIGSTKFLT) && defined(TARGET_SIGSTKFLT) +#define MAKE_SIG_ENTRY_SIGSTKFLT MAKE_SIG_ENTRY(SIGSTKFLT) +#else +#define MAKE_SIG_ENTRY_SIGSTKFLT +#endif + +#if defined(SIGIOT) && defined(TARGET_SIGIOT) +#define MAKE_SIG_ENTRY_SIGIOT MAKE_SIG_ENTRY(SIGIOT) +#else +#define MAKE_SIG_ENTRY_SIGIOT +#endif + +#define MAKE_SIGNAL_LIST \ + MAKE_SIG_ENTRY(SIGHUP) \ + MAKE_SIG_ENTRY(SIGINT) \ + MAKE_SIG_ENTRY(SIGQUIT) \ + MAKE_SIG_ENTRY(SIGILL) \ + MAKE_SIG_ENTRY(SIGTRAP) \ + MAKE_SIG_ENTRY(SIGABRT) \ + MAKE_SIG_ENTRY(SIGBUS) \ + MAKE_SIG_ENTRY(SIGFPE) \ + MAKE_SIG_ENTRY(SIGKILL) \ + MAKE_SIG_ENTRY(SIGUSR1) \ + MAKE_SIG_ENTRY(SIGSEGV) \ + MAKE_SIG_ENTRY(SIGUSR2) \ + MAKE_SIG_ENTRY(SIGPIPE) \ + MAKE_SIG_ENTRY(SIGALRM) \ + MAKE_SIG_ENTRY(SIGTERM) \ + MAKE_SIG_ENTRY(SIGCHLD) \ + MAKE_SIG_ENTRY(SIGCONT) \ + MAKE_SIG_ENTRY(SIGSTOP) \ + MAKE_SIG_ENTRY(SIGTSTP) \ + MAKE_SIG_ENTRY(SIGTTIN) \ + MAKE_SIG_ENTRY(SIGTTOU) \ + MAKE_SIG_ENTRY(SIGURG) \ + MAKE_SIG_ENTRY(SIGXCPU) \ + MAKE_SIG_ENTRY(SIGXFSZ) \ + MAKE_SIG_ENTRY(SIGVTALRM) \ + MAKE_SIG_ENTRY(SIGPROF) \ + MAKE_SIG_ENTRY(SIGWINCH) \ + MAKE_SIG_ENTRY(SIGIO) \ + MAKE_SIG_ENTRY(SIGPWR) \ + MAKE_SIG_ENTRY(SIGSYS) \ + MAKE_SIG_ENTRY_SIGSTKFLT \ + MAKE_SIG_ENTRY_SIGIOT + #endif diff --git a/linux-user/signal.c b/linux-user/signal.c index 8d29bfaa6b5c..61c6fa3fcf12 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -53,40 +53,9 @@ abi_ulong default_rt_sigreturn; QEMU_BUILD_BUG_ON(__SIGRTMAX + 1 != _NSIG); #endif static uint8_t host_to_target_signal_table[_NSIG] = { - [SIGHUP] = TARGET_SIGHUP, - [SIGINT] = TARGET_SIGINT, - [SIGQUIT] = TARGET_SIGQUIT, - [SIGILL] = TARGET_SIGILL, - [SIGTRAP] = TARGET_SIGTRAP, - [SIGABRT] = TARGET_SIGABRT, -/* [SIGIOT] = TARGET_SIGIOT,*/ - [SIGBUS] = TARGET_SIGBUS, - [SIGFPE] = TARGET_SIGFPE, - [SIGKILL] = TARGET_SIGKILL, - [SIGUSR1] = TARGET_SIGUSR1, - [SIGSEGV] = TARGET_SIGSEGV, - [SIGUSR2] = TARGET_SIGUSR2, - [SIGPIPE] = TARGET_SIGPIPE, - [SIGALRM] = TARGET_SIGALRM, - [SIGTERM] = TARGET_SIGTERM, -#ifdef SIGSTKFLT - [SIGSTKFLT] = TARGET_SIGSTKFLT, -#endif - [SIGCHLD] = TARGET_SIGCHLD, - [SIGCONT] = TARGET_SIGCONT, - [SIGSTOP] = TARGET_SIGSTOP, - [SIGTSTP] = TARGET_SIGTSTP, - [SIGTTIN] = TARGET_SIGTTIN, - [SIGTTOU] = TARGET_SIGTTOU, - [SIGURG] = TARGET_SIGURG, - [SIGXCPU] = TARGET_SIGXCPU, - [SIGXFSZ] = TARGET_SIGXFSZ, - [SIGVTALRM] = TARGET_SIGVTALRM, - [SIGPROF] = TARGET_SIGPROF, - [SIGWINCH] = TARGET_SIGWINCH, - [SIGIO] = TARGET_SIGIO, - [SIGPWR] = TARGET_SIGPWR, - [SIGSYS] = TARGET_SIGSYS, +#define MAKE_SIG_ENTRY(sig) [sig] = TARGET_##sig, + MAKE_SIGNAL_LIST +#undef MAKE_SIG_ENTRY /* next signals stay the same */ }; diff --git a/linux-user/strace.c b/linux-user/strace.c index 7d882526da03..a4eeef7ae1ca 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -17,6 +17,7 @@ #include "qemu.h" #include "user-internals.h" #include "strace.h" +#include "signal-common.h" struct syscallname { int nr; @@ -141,30 +142,21 @@ if( cmd == val ) { \ qemu_log("%d", cmd); } +static const char * const target_signal_name[] = { +#define MAKE_SIG_ENTRY(sig) [TARGET_##sig] = #sig, + MAKE_SIGNAL_LIST +#undef MAKE_SIG_ENTRY +}; + static void print_signal(abi_ulong arg, int last) { const char *signal_name = NULL; - switch(arg) { - case TARGET_SIGHUP: signal_name = "SIGHUP"; break; - case TARGET_SIGINT: signal_name = "SIGINT"; break; - case TARGET_SIGQUIT: signal_name = "SIGQUIT"; break; - case TARGET_SIGILL: signal_name = "SIGILL"; break; - case TARGET_SIGABRT: signal_name = "SIGABRT"; break; - case TARGET_SIGFPE: signal_name = "SIGFPE"; break; - case TARGET_SIGKILL: signal_name = "SIGKILL"; break; - case TARGET_SIGSEGV: signal_name = "SIGSEGV"; break; - case TARGET_SIGPIPE: signal_name = "SIGPIPE"; break; - case TARGET_SIGALRM: signal_name = "SIGALRM"; break; - case TARGET_SIGTERM: signal_name = "SIGTERM"; break; - case TARGET_SIGUSR1: signal_name = "SIGUSR1"; break; - case TARGET_SIGUSR2: signal_name = "SIGUSR2"; break; - case TARGET_SIGCHLD: signal_name = "SIGCHLD"; break; - case TARGET_SIGCONT: signal_name = "SIGCONT"; break; - case TARGET_SIGSTOP: signal_name = "SIGSTOP"; break; - case TARGET_SIGTTIN: signal_name = "SIGTTIN"; break; - case TARGET_SIGTTOU: signal_name = "SIGTTOU"; break; + + if (arg < ARRAY_SIZE(target_signal_name)) { + signal_name = target_signal_name[arg]; } + if (signal_name == NULL) { print_raw_param("%ld", arg, last); return; From patchwork Wed Sep 28 08:14:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992020 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 60A2CC04A95 for ; Wed, 28 Sep 2022 09:49:39 +0000 (UTC) Received: from localhost ([::1]:53140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odThC-000693-EB for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 05:49:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE3-00085Z-Lz for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:28 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:58873) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSDz-000896-IQ for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:26 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N8GEY-1pHJEn073Q-014EbX; Wed, 28 Sep 2022 10:15:21 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 04/38] linux-user: Add missing clock_gettime64() syscall strace Date: Wed, 28 Sep 2022 10:14:43 +0200 Message-Id: <20220928081517.734954-5-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:IqbgRMHNNF80mZqvlCiw/z50h1nvgJDbFtYTzgvXNw1avV1dA3D 9sGtDbAL1GRsxiEsY0HmuwJjWkeilrz8x+QWQfmUpinbigeytUzGIRzIsajQKNsmFJZKy0D DktW4YQVI42VF7B1fGfhMSIgypb+VoUtVfoFNxGTDTisQr5vK4fRsezgfh6DsLxIE/9BPzS hL83EUR2B2M+bThX1gknw== X-UI-Out-Filterresults: notjunk:1;V03:K0:9w71wlwQ+kU=:pAGHC6l08XctY4yH8JBWzy 4EqY8TCYym2dx3tfl5vbxxsqkgzYNtPxBaGxkTrbULKtri5J43Svdn8r/H6md4qC30Sp0AJPL Uk1myjaRvqlfMPg4GcI+VFMXDvGaqJwD8W7gvWhB2IFWMctEC1OSaAA8748svMIWPmJWVUUqb OtuUmE5MmkQ0VRU7XswBzqRVakDOBhYnGs6J02RzGP+nmAbEft4/VrgxtPpu/8fFbJFTSMbgq N7cJZwrXmIuA1dUAfilOsAvbaoenP/9KhMpBRuX+mvH/s29VHb0/GcEPYT5SjfqDANj2JeEMJ sfCSH7VdP3PLwmuIzVhztAZaiOPgzBs1lK49gjy705p3TZt4L5UyWLk+ha9xlX2y4kgz6yTxl vktZkE5SP2elcyzgdUEQ0liFcpGLfJt0ZWII7HiOywUzqsELprae/fXgLtb5++UcfUoG42688 4J1ctnRbF0pVjI/ti1Uq0TC+r+UOyfog34gsREaleukBde9RRVCxJir4Wcn8E9i4OMzVVrq9h CRBCnzhUWI/TODzBMHg+RguVOBWRzj+WTFEZWGDzjkUybwGShdJePeb+gV/rcwoH2baNcSsvS dHAX2l+xGJE5t3S7oSTTRMGixUWKkVA0sJzyRsCmNZMrEkwLX9e44/XyRXxcPcUsuAVPT+RrH LwoeD9BVvY7igkAyWd/WDbvkhL284cEFwiid6CIVULtVqzE9bpRrhhPrUBEjFrHz2zezNET3l Kg+ynxPncYWgPZp/JcVucKyy0n9o1M9hkR9cW6ux1mKVo0jWn8id1K9D9N8Sz0fVxxik11vLr nzddzZD 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_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Helge Deller Allow linux-user to strace the clock_gettime64() syscall. This syscall is used a lot on 32-bit guest architectures which use newer glibc versions. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20220918194555.83535-3-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 53 ++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 4 ++++ 2 files changed, 57 insertions(+) diff --git a/linux-user/strace.c b/linux-user/strace.c index a4eeef7ae1ca..816e67999539 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -82,6 +82,7 @@ UNUSED static void print_buf(abi_long addr, abi_long len, int last); UNUSED static void print_raw_param(const char *, abi_long, int); UNUSED static void print_timeval(abi_ulong, int); UNUSED static void print_timespec(abi_ulong, int); +UNUSED static void print_timespec64(abi_ulong, int); UNUSED static void print_timezone(abi_ulong, int); UNUSED static void print_itimerval(abi_ulong, int); UNUSED static void print_number(abi_long, int); @@ -795,6 +796,24 @@ print_syscall_ret_clock_gettime(CPUArchState *cpu_env, const struct syscallname #define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime #endif +#if defined(TARGET_NR_clock_gettime64) +static void +print_syscall_ret_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name, + abi_long ret, abi_long arg0, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg4, + abi_long arg5) +{ + if (!print_syscall_err(ret)) { + qemu_log(TARGET_ABI_FMT_ld, ret); + qemu_log(" ("); + print_timespec64(arg1, 1); + qemu_log(")"); + } + + qemu_log("\n"); +} +#endif + #ifdef TARGET_NR_gettimeofday static void print_syscall_ret_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name, @@ -1652,6 +1671,27 @@ print_timespec(abi_ulong ts_addr, int last) } } +static void +print_timespec64(abi_ulong ts_addr, int last) +{ + if (ts_addr) { + struct target__kernel_timespec *ts; + + ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1); + if (!ts) { + print_pointer(ts_addr, last); + return; + } + qemu_log("{tv_sec = %lld" + ",tv_nsec = %lld}%s", + (long long)tswap64(ts->tv_sec), (long long)tswap64(ts->tv_nsec), + get_comma(last)); + unlock_user(ts, ts_addr, 0); + } else { + qemu_log("NULL%s", get_comma(last)); + } +} + static void print_timezone(abi_ulong tz_addr, int last) { @@ -2267,6 +2307,19 @@ print_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name, #define print_clock_getres print_clock_gettime #endif +#if defined(TARGET_NR_clock_gettime64) +static void +print_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_enums(clockids, arg0, 0); + print_pointer(arg1, 1); + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_clock_settime static void print_clock_settime(CPUArchState *cpu_env, const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 72e17b1acf00..a78cdf3cdfef 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1676,3 +1676,7 @@ #ifdef TARGET_NR_copy_file_range { TARGET_NR_copy_file_range, "copy_file_range", "%s(%d,%p,%d,%p,"TARGET_ABI_FMT_lu",%u)", NULL, NULL }, #endif +#ifdef TARGET_NR_clock_gettime64 +{ TARGET_NR_clock_gettime64, "clock_gettime64" , NULL, print_clock_gettime64, + print_syscall_ret_clock_gettime64 }, +#endif From patchwork Wed Sep 28 08:14:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992077 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 125B7C32771 for ; Wed, 28 Sep 2022 10:37:15 +0000 (UTC) Received: from localhost ([::1]:46158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odURG-0006O3-Rx for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:37:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE4-00085t-2Q for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:28 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:33477) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSDz-000899-IU for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:27 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MWAWq-1okjND1pBC-00Xdfp; Wed, 28 Sep 2022 10:15:21 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 05/38] linux-user: Add pidfd_open(), pidfd_send_signal() and pidfd_getfd() syscalls Date: Wed, 28 Sep 2022 10:14:44 +0200 Message-Id: <20220928081517.734954-6-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:BX9J1p5IKcxeXxyXtJZHW9LN5He5NpdyFI16PYTCO0az/Ojis49 vysosB0l71qFH+ER3DUdbC+L4fU5jnSxzztEfU/lJ2S9rGUalcaDKDJ3dqsE9VSi47HQi2a 5tOnhgbezOzu7VAbO/tLPzU1NQ6HPfjgnWWIFUl6wHNfQBHYtRLgo85iop4BrRqve4LRzyi LTadu/6OoFuw+afvCBcBw== X-UI-Out-Filterresults: notjunk:1;V03:K0:SIvB0uZQUc4=:gCCUQjjQwqzMlhFPbRDkTM IWq1nQFbKIsa/7Xk+UGpsfq/U7viCe7LYCfOD3QyNS1481qboZcUjzEbvbr0uR+pYXjOdsORr 3J8SL7W3ajRjXgQbNS21hG56lSr69/JULSgMEjFktquCFPeBTNpcP1n91sLyaBlqDehft+vnW eYCC2Zwm/LpjWdbhaMqRICgq5VDOMS+/xTbBg7Gdkp/c6+xhEVnHO7J9RmpHP5mhb/2xSzgLc p1U0tFKQKtHGpX3iYXThU7k//NBuohk6gUsAG/pWCBHiHOkz0UFva6/YYZ+npzSsCkg7k9j59 tzTYBqvlYrtrv6gCcpSbifXHWRCfzoP9+PsJvUwWg3n7BPuwHRjbr8dCwS29W+GQJ3hPXyIWD U27lW4ndhtsK0QC10/WxBF8HKCNXcz+oyWeSD1m9hqpVSAthNOmBP2eaZ/DAcD8nC9UpI3N7B Z47YQgUlaLtQ3uNf2XB+xxFKJH/zfhnfnYZbTJb7nFq78Tx071WnZeoPaDu71cdeEazDS1QYA x3WJW2k0UbhiB4cvG/RVG0lAkZsKAM6qPgEqoB1+hXyWM8+KmZK4boVSS5oHPnWCmz9U1tn3r oUhZOaGTo2WyzFtoBsCFsQPvkgwBiF3tei6K4/tTjpqmGQWperqktx8E7iT/uqHnpaGxopS0r BwGhfNXyjdCFy/TUYxq1u2EHvGdb65rA6K5qm7s28D9uwsKnywoQKnDCdD1c9T6zsEYFJK9zz TzRBN5KGkqLYcY23xM7L2GqyVS2dn8s0U/a4Agm/d4kyQ96RqZ3Yj1S/1DdvSROagJW0r/oKs YD+OQFq 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_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Helge Deller I noticed those were missing when running the glib2.0 testsuite. Add the syscalls including the strace output. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20220918194555.83535-4-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 28 ++++++++++++++++++++++++++++ linux-user/strace.list | 9 +++++++++ linux-user/syscall.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) diff --git a/linux-user/strace.c b/linux-user/strace.c index 816e67999539..5ac64df02b85 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -3317,6 +3317,34 @@ print_openat(CPUArchState *cpu_env, const struct syscallname *name, } #endif +#ifdef TARGET_NR_pidfd_send_signal +static void +print_pidfd_send_signal(CPUArchState *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + void *p; + target_siginfo_t uinfo; + + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + print_signal(arg1, 0); + + p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1); + if (p) { + get_target_siginfo(&uinfo, p); + print_siginfo(&uinfo); + + unlock_user(p, arg2, 0); + } else { + print_pointer(arg2, 1); + } + + print_raw_param("%u", arg3, 0); + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_mq_unlink static void print_mq_unlink(CPUArchState *cpu_env, const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index a78cdf3cdfef..4d8b7f6a5e0c 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1664,6 +1664,15 @@ #ifdef TARGET_NR_pipe2 { TARGET_NR_pipe2, "pipe2", NULL, NULL, NULL }, #endif +#ifdef TARGET_NR_pidfd_open +{ TARGET_NR_pidfd_open, "pidfd_open", "%s(%d,%u)", NULL, NULL }, +#endif +#ifdef TARGET_NR_pidfd_send_signal +{ TARGET_NR_pidfd_send_signal, "pidfd_send_signal", NULL, print_pidfd_send_signal, NULL }, +#endif +#ifdef TARGET_NR_pidfd_getfd +{ TARGET_NR_pidfd_getfd, "pidfd_getfd", "%s(%d,%d,%u)", NULL, NULL }, +#endif #ifdef TARGET_NR_atomic_cmpxchg_32 { TARGET_NR_atomic_cmpxchg_32, "atomic_cmpxchg_32", NULL, NULL, NULL }, #endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index abf82bab2a18..850410c9b553 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -346,6 +346,16 @@ _syscall6(int,sys_futex,int *,uaddr,int,op,int,val, _syscall6(int,sys_futex_time64,int *,uaddr,int,op,int,val, const struct timespec *,timeout,int *,uaddr2,int,val3) #endif +#if defined(__NR_pidfd_open) && defined(TARGET_NR_pidfd_open) +_syscall2(int, pidfd_open, pid_t, pid, unsigned int, flags); +#endif +#if defined(__NR_pidfd_send_signal) && defined(TARGET_NR_pidfd_send_signal) +_syscall4(int, pidfd_send_signal, int, pidfd, int, sig, siginfo_t *, info, + unsigned int, flags); +#endif +#if defined(__NR_pidfd_getfd) && defined(TARGET_NR_pidfd_getfd) +_syscall3(int, pidfd_getfd, int, pidfd, int, targetfd, unsigned int, flags); +#endif #define __NR_sys_sched_getaffinity __NR_sched_getaffinity _syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len, unsigned long *, user_mask_ptr); @@ -8683,6 +8693,30 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, ret = do_open_by_handle_at(arg1, arg2, arg3); fd_trans_unregister(ret); return ret; +#endif +#if defined(__NR_pidfd_open) && defined(TARGET_NR_pidfd_open) + case TARGET_NR_pidfd_open: + return get_errno(pidfd_open(arg1, arg2)); +#endif +#if defined(__NR_pidfd_send_signal) && defined(TARGET_NR_pidfd_send_signal) + case TARGET_NR_pidfd_send_signal: + { + siginfo_t uinfo; + + p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1); + if (!p) { + return -TARGET_EFAULT; + } + target_to_host_siginfo(&uinfo, p); + unlock_user(p, arg3, 0); + ret = get_errno(pidfd_send_signal(arg1, target_to_host_signal(arg2), + &uinfo, arg4)); + } + return ret; +#endif +#if defined(__NR_pidfd_getfd) && defined(TARGET_NR_pidfd_getfd) + case TARGET_NR_pidfd_getfd: + return get_errno(pidfd_getfd(arg1, arg2, arg3)); #endif case TARGET_NR_close: fd_trans_unregister(arg1); From patchwork Wed Sep 28 08:14:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12991884 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 60DDBC32771 for ; Wed, 28 Sep 2022 09:05:33 +0000 (UTC) Received: from localhost ([::1]:58064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odT0W-0000Zt-8K for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 05:05:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE7-000893-7P for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:33 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:36299) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE5-0008Aa-F3 for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:30 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MIdaF-1oPUGS3p6D-00EbO6; Wed, 28 Sep 2022 10:15:22 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 06/38] linux-user: Log failing executable in EXCP_DUMP() Date: Wed, 28 Sep 2022 10:14:45 +0200 Message-Id: <20220928081517.734954-7-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:wZbqebJkWTWdpG5fB3c1lZG7gH2IX05p7dI0bk4pYO6PaX4GpD8 rwJwSeoQiX1jLRQ7RSqQARtVeCZs5+0JMl17KSHjvCeuxbdyA9TlwsaKga58BVLW03Fjfvi rW7MpGkYqEXsnV9WFs1l8gYtY0W9wO7fIphikNTokddYvfDPqm7iMWvUAdaqq5JNnk4EjCX md+FPuzchaH6mJ0s/g8bQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:jCxnW7UMzKY=:HjgOSwqvRxuhCwBdaHXM7n bfZ98ElRwJxnMsWO2NDZ1+vTp95uJ+GoHZYnjE1vCisuDmas4gbQv9Ca4Quv0RBlutR5JfEz8 L2ZcpyUBwFJoZ0ORZnzwLa/bTDgf6kNEQb0jXPILNBuuO78OXTzgW0+bD7HldafNg3TglS50i oj+X7YSE6OrBlq8cVUyKgHxyFvoCRgoN14+NxxkZVxRRoNx3XTpSB+0uiBqPToHOi18y6AxBV xRPu5mjEdudMar1aExxY7aMs29XF5O5uVYurHsgjED+Om8CZ9PRkPFAbWx2nebR3Wo1KpLZyi oKOZAt1l956UCS4JUBbgJNruFTWty0QMDx2tpuMIVYOZwUOE5YT6QWuxr3/IW+Ev0AaoEN8Nk UiIBJ5sHm2Fcmw4mIeHA2gvewDVU+he9XFgn9qVKgW+MPWW6kuzKH3nElWsIp+YPvpeW5UhQw r+/Bng5ym1M/UW+/8g/FmYFx63LZFLdly+6THwJsseh0uDc/iFd5l5l013evLK/VC16SA+CSR t1SFvIJN2rv5m0ZJDoB1qBqLt78wAWmvlO6LLkRg3qZFro236xSLJ4Y5F0HjlN0sg1YYfCQIf Hq4ZMuR5w4cXN3pcn+fUoo0VK8+YIiidliU4FVBlztXgtDj3w5zgk1UkBeGwm9g+aIVVun6wB 13BeIxqtNwA34n3ykiz2vMiaC/HYsfmm5T1qGnUcYSAREdoH9/jVG2coPGCl1OG7NTE6MjVl/ hsO/MXGFFKrP+RB3TtH/eE3ePEb26zPN+ttoehmMWjdNuWOUN04vY6uAHVM/y7W/KVLG3pdLI 4NSdvhj 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_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Helge Deller Enhance the EXCP_DUMP() macro to print out the failing program too. During debugging it's sometimes hard to track down the actual failing program if you are e.g. building a whole debian package. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20220918194555.83535-5-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/cpu_loop-common.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/cpu_loop-common.h b/linux-user/cpu_loop-common.h index dc0042e4de35..36ff5b14f2a7 100644 --- a/linux-user/cpu_loop-common.h +++ b/linux-user/cpu_loop-common.h @@ -27,9 +27,11 @@ do { \ CPUState *cs = env_cpu(env); \ fprintf(stderr, fmt , ## __VA_ARGS__); \ + fprintf(stderr, "Failing executable: %s\n", exec_path); \ cpu_dump_state(cs, stderr, 0); \ if (qemu_log_separate()) { \ qemu_log(fmt, ## __VA_ARGS__); \ + qemu_log("Failing executable: %s\n", exec_path); \ log_cpu_state(cs, 0); \ } \ } while (0) From patchwork Wed Sep 28 08:14:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992080 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 5CEE5C32771 for ; Wed, 28 Sep 2022 10:42:14 +0000 (UTC) Received: from localhost ([::1]:52916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUW5-0003tn-Fr for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:42:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE4-00085w-Fz for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:28 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:56399) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE1-00089G-Az for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:27 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M8yoa-1oYWXU1OiM-0066vZ; Wed, 28 Sep 2022 10:15:22 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 07/38] linux-user/hppa: Use EXCP_DUMP() to show enhanced debug info Date: Wed, 28 Sep 2022 10:14:46 +0200 Message-Id: <20220928081517.734954-8-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:dcozIl1eKKzdXmr6gojm9kew86deK7bmN6zH/PznQTo7Vj/US0L Q96IVymaJFYzM8T0g0CfyIZaW0RvvFqhEQ+40nx5q8ahtWQBd7q0Dtu6CpAicUia/nyjaTs zI5BRi3H+kFlpUDmN14HPQgO3ERekKzY9IyTjjgglNgw1sKxdEpb6Xyx5Mufai5/3fu4xki wlHwalPbuQQPuFs0AKO5g== X-UI-Out-Filterresults: notjunk:1;V03:K0:5d2J+cT4hdk=:6+SbzBzyO2CcjH0lOD60YN g9aDGV8MpZZPS0b3ViVzK3+iwaeExtC7IoFvt7w49VI8D2Ln3g7Clfx6ZR66cuO6jWvQNXPVz uiHXonrpwqsKl9gMIkWoitGPRiuBcvctffMLmy6iUFboInQv8df81wB7X/rRrOJu/PSE6tRAo SQFAtjcuv99zi6GwB9yF1CWNhTE0L7HbM+QCifSvz4ybuaGQzPqgtdElhfrCWeoG3DTZIj2z4 ljKxKbSedYHxxo3OXHQYvyXItm7Nm8cltifoANjg/hxg//ZaROPDc8cB8/V+2xhXzHTIpM3mz NgMdIc/6xOcBxKomBwuORVAldD2o61RWjWS3zQyZcd3BsgWrnm1uqzp8dWJnOQy3JVzE3CK8A ytsL3VwhTzYusNW4AVb7dxgEvpUSSZ066YRTtE3UL437W3iFADC8aL2JYYdBAJth84NSxrvuX FopcjHp/bTdtGGYqR6DzCN8yvTdQc9UOEYRga8JXhfQVWsqhZ7UzLTTOeE9cz7IUnoKrvKgjF rbseWki1Sgoz1+nOfgB/JWl2MVjCthCOqEAYeV0qtnr8AwgGQkXz/hZzQ+uJKv70S+8t5Outb 5DUweBXtG2J4kT9oQiOBkkbiJUjOMc1bVitXq11ToMPx3PqroaFiBZVQVHtUkHzV046/GCSAC LWjzxngXh0aGnJN4zFqLcO2kOgRyg8oHRa1hTz/sUhawBBe5XzBb/Qg7aCgh245dv0aKuKwqo te43M6eCuWuaGkaU0/Nb9CKtsz7dqIUzJn9X+kQMHEEpERHn/GgvHIXKKq4yHazsN+MOzZRfP /j3Q5sB 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" From: Helge Deller Enhance the hppa linux-user cpu_loop() to show more debugging info on hard errors. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20220918194555.83535-6-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/hppa/cpu_loop.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c index 64263c3dc406..1ef3b461911c 100644 --- a/linux-user/hppa/cpu_loop.c +++ b/linux-user/hppa/cpu_loop.c @@ -147,12 +147,15 @@ void cpu_loop(CPUHPPAState *env) force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, env->iaoq_f); break; case EXCP_ILL: + EXCP_DUMP(env, "qemu: got CPU exception 0x%x - aborting\n", trapnr); force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->iaoq_f); break; case EXCP_PRIV_OPR: + EXCP_DUMP(env, "qemu: got CPU exception 0x%x - aborting\n", trapnr); force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, env->iaoq_f); break; case EXCP_PRIV_REG: + EXCP_DUMP(env, "qemu: got CPU exception 0x%x - aborting\n", trapnr); force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVREG, env->iaoq_f); break; case EXCP_OVERFLOW: @@ -171,7 +174,8 @@ void cpu_loop(CPUHPPAState *env) /* just indicate that signals should be handled asap */ break; default: - g_assert_not_reached(); + EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr); + abort(); } process_pending_signals(env); } From patchwork Wed Sep 28 08:14:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12991873 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 5E453C32771 for ; Wed, 28 Sep 2022 08:57:42 +0000 (UTC) Received: from localhost ([::1]:59588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odSsv-0003Ej-4R for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 04:57:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE5-00087a-NC for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:30 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:39059) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE3-00089w-OH for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:29 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MS3vJ-1opOD33KoN-00TUns; Wed, 28 Sep 2022 10:15:22 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 08/38] linux-user/hppa: Dump IIR on register dump Date: Wed, 28 Sep 2022 10:14:47 +0200 Message-Id: <20220928081517.734954-9-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:P+eHJAuG0u3qJteTmtcoh3mfe530qxlmOcKH73U3m62AqgkXvtK aJCgCjW+EcbzV4v9B3Nd/nXvMIQlOHP8PvSO/RwMBrngLhsx+Rpt622LjTf92ZOo86gicLX CAcpr8rIHOmbfNUuR/DazOOPlMIGEsU219QeGUEhuJEnpTaiKX3MU4yTFw+Ld9v2Pf4V5PG v4rZSXoMj/yB0YYdPy7fQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:/3D1NtuUK10=:HooqMHjW+akNLrvP5bRiBB QQzKLq8nRbPe+X7+mtEfc0NJN+GNLr7Axn4BrUNuZZQg9uhRDHs3yPTddbrr/Q5i5sQLOaPWI j3wwnqpiI3SkL/DRftGFnwGLJUgdqUt43I2QsohAarBEJmb+oAC2P93+eBGkdUutRnIoex0ZN qzHurO14C2EjcB7U1lhV6C74WzQrDHrh2u7JO5ceVy6ceSSqqlmm9Myq4bs63mQ7Ss3AWcsj+ pcBBNRr0HhXJ+xxWUeREjBm4EEaEXvNS+k5M7UwNvum76kxZXVRJn/h+yNyGAJdkWHK7Zsql/ ddi5SZgevd/QvQP08Q/UNtnikV7w80rwMMzmP73H3GkhXGYIwrhAl7DruZqrfCW3DKV4GA6Lw 8eid6QRJnNJTqVzTNAiYr12tmocrUDwW3Xx/am9wkAC5R1ByYz/RIwS7KtDt4ewfntU6VcTBp U6dw2EN9d8DLHsoQM/bIMWkapmKKVGGGcVIhw87je9r6pjDn09BHTv1DXvgW3xI9Hd938PHSC 1ng15bfy385b0eJTx9nCk0u9h3lbK1+w5roy1mL5VSCx/sq1ycvNNvBPGevTL4E9RG0wItNl7 nm/FiKKRYjxE1ul1imu5P0tahmdSYDXl4No8Umnx7hY9/DIlpZ6QKaIydUcTG6iy0mD9zJX/p dNJZ8VFlMaZH+wahktJw6EN11/QdLUhmgbbU1hnBX0f1FdmklDD20qHp3dcxxmRm3Hf/+dYnS yMQn8wieMLI/S5cPkFyn+cws4ynLTrHUdaJ6KKyuNkatpcr0N0/o9VpYEA4W8puwu7yRr5zTu VbiTmp9 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" From: Helge Deller Include the IIR register (which holds the opcode of the failing instruction) when dumping the hppa registers. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20220918194555.83535-7-deller@gmx.de> Signed-off-by: Laurent Vivier --- target/hppa/helper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/target/hppa/helper.c b/target/hppa/helper.c index e2758d8df380..74b8747083f9 100644 --- a/target/hppa/helper.c +++ b/target/hppa/helper.c @@ -85,9 +85,11 @@ void hppa_cpu_dump_state(CPUState *cs, FILE *f, int flags) char psw_c[20]; int i; - qemu_fprintf(f, "IA_F " TARGET_FMT_lx " IA_B " TARGET_FMT_lx "\n", + qemu_fprintf(f, "IA_F " TARGET_FMT_lx " IA_B " TARGET_FMT_lx + " IIR " TREG_FMT_lx "\n", hppa_form_gva_psw(psw, env->iasq_f, env->iaoq_f), - hppa_form_gva_psw(psw, env->iasq_b, env->iaoq_b)); + hppa_form_gva_psw(psw, env->iasq_b, env->iaoq_b), + env->cr[CR_IIR]); psw_c[0] = (psw & PSW_W ? 'W' : '-'); psw_c[1] = (psw & PSW_E ? 'E' : '-'); From patchwork Wed Sep 28 08:14:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12991858 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 87741C32771 for ; Wed, 28 Sep 2022 08:49:05 +0000 (UTC) Received: from localhost ([::1]:55352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odSka-0005X6-Db for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 04:49:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE5-00087j-Vk for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:30 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:47301) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE3-00089v-O9 for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:29 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MKsf5-1owVk6190n-00LHKE; Wed, 28 Sep 2022 10:15:23 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 09/38] linux-user: Fix strace of chmod() if mode == 0 Date: Wed, 28 Sep 2022 10:14:48 +0200 Message-Id: <20220928081517.734954-10-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:wW157dSxuI13Lk7itxP3LXL55v3ZsD3RLA6W1kNLy42PoMm7fAC 5i6/+VB9lmFjdeO6gCX4NNV7yRl/V2UOVJbjaSpXY6IvrntRGJFzqx4wRiJo8rx66Os4718 rJZ7+ZVt+VZo2HIHfxBe1XhSNu0l/xSqKE+aD2GiDjDLeFn1HlTN/vtE7/G3J6RGEboBba7 XcHngg8y7kwEFDM4SKkQQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:wZjjziwp3Pc=:eaq13rPcZesd89pSyIo6PR Vnr1qA9QSAQUT0R+L1nxrPvmh8u/iQ+cd/YvQB/o2Cj0RJ6UfR2cEZ3A+nm2NqHx6xG3k4VYS PISi8SiyyvdWYCm/uSTo0bn57ANRMIFIraaLy9eV1wbTtSgP3NdHayfqzKWrPmI0NrYFMD9nq Dbk9E3hJlotPeTdvUL+rZDHgDtxCa/QYfa4b4/v8DPVZrHa4xk+TaGw9gu17N7MlYZNKEImSQ XOf5699cFwzUngMrupC6biS/936Z+lTjzKg6UBVlTVNv1LVi/iHnX9IFN2DFV0hq8x0RPLpYi fLHX8yj9UU+ZRnRRQ5ORrOfxGqJnDyQ7ows9eNmtToLuIwNICqHL7eOmPIcoBqsKV0rLA1M9m 7KDsOk1Ei12CuTgI/GX2RePVGCnx3wtzg8Uv4BeEggiJSrbLV3awNLRn2ZyUpj6o3/xx5D3DZ Zhzt99A9RCBSNbNizk6RUDrV7DCtcnWhum6Erhun5Ci4AboDnFDggpD5IfpJ4W537PMvAYUBc 8S4Zjh7H/pXzLoQqQq6A2JosRqv3J5A2C7AQiePnVrqXmrzStYfk7y81uxiMSBhDP9aT3IdB5 zOiRPgINnadFSjGwg7WpJCKbG6iztHlONwja6oKc6KloRkKu3V1ASNZsPhotBw7rt+r1JDLgu x19AHGtsppU+nZormUj9TIq7ys4LNrGD8tbkMEm5kI6BQKFU5lRMwAcZR1FL6ZuSNljhR9iC9 GDcBklrfUqCWk2DtRLgqVdpUslEK8mUloOS62FsBJ/ut6KsjHxac8+yNBMr8ywSkcMbXdO7Vk 3ToRFxG 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" From: Helge Deller If the mode parameter of chmod() is zero, this value isn't shown when stracing a program: chmod("filename",) This patch fixes it up to show the zero-value as well: chmod("filename",000) Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20220918194555.83535-8-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-user/strace.c b/linux-user/strace.c index 5ac64df02b85..2f539845bb90 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1505,6 +1505,11 @@ print_file_mode(abi_long mode, int last) const char *sep = ""; const struct flags *m; + if (mode == 0) { + qemu_log("000%s", get_comma(last)); + return; + } + for (m = &mode_flags[0]; m->f_string != NULL; m++) { if ((m->f_value & mode) == m->f_value) { qemu_log("%s%s", m->f_string, sep); From patchwork Wed Sep 28 08:14:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992039 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 E3179C04A95 for ; Wed, 28 Sep 2022 09:58:07 +0000 (UTC) Received: from localhost ([::1]:46118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odTpO-0003dp-U0 for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 05:58:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE4-00085x-H5 for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:28 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:57237) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE1-00089R-Ir for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:27 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MaIzb-1oh9fq2tVd-00WGlO; Wed, 28 Sep 2022 10:15:23 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 10/38] linux-user/hppa: Set TASK_UNMAPPED_BASE to 0xfa000000 for hppa arch Date: Wed, 28 Sep 2022 10:14:49 +0200 Message-Id: <20220928081517.734954-11-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:T1eV7LRVxdD7n/uwqAe50bzBcFYHuls4iERktTuxqu1NmF2wpg4 7+tAGOzN8Kd7Oz4M3ZngMoiVPpIlLV4JYIYWil5Y+EiLp3JYgyrC/SIebbdIZ0ggzuoiJ8g wDvupiXCt+T3gjVBhQNO1f1WIdZtIPTNBQidUSWARzrpzH6mN1Ax0YdvndHx4ItbL8/2XyM /S8u7tsBUP2dAj6teTfbw== X-UI-Out-Filterresults: notjunk:1;V03:K0:aV2DD5YMc4w=:UfW1hEYo/E4v++AqwMlYD+ L0uiUtMuOg5UtPl6KOHTaczxcPlpDzXJLOhS/VX/yy+K/v55lHMr4AEX1OLth+sIAjiPkO/Tx A9MwlAlLYFHuQVt9q+GvCVIITnlUZr5GY52PT6Owx6bBK4/HRtKgkBdF52Ord5FQwRL9F1gC1 0OxQfFDCSil19SsSX35k/r5jY+hGejOw4YvLT3sGY0LZy3vadLixGsPj0WCqV141DEHWfy4l+ /8tiYj+Jv34SBJWLlWAK9DBSPeD5rsxu2t1xUD9hgdWY2H9QlQnfxOwM6X4hcBuwGrOGppj55 xl/DDhFU7E4XoHBiLR15qoz9nyoy8viPnHVV0xxwhNDq2e3BosdqdqJ991uVI77zUqJRLlO13 KT/9aD4W842A6qfAjwOz0jhz7eOV/nsJz19Qr7wRKjHZ2LMashz2kULKFczOsPnqk72DKD8aB CsMo5Bw+vV9AGBcf0zGbNyn/Et5YRxbxWs+ccBnz5YY+V9jLY0UQt39pvP072b1WwUxepnOYr BFahHoXSoxA12sOEH+WKvAz9/z06nXk4AylJ7++wUJrJZu+ZgMnS7ebfhNvv4atrX5txkrJLD YhmJV7KbOfm8LV7s6oO4sLXFK1/Ap1UgalYI1XQnFbAru4k/yeJjtKBHeL/oXkH+1D0Vmfs5/ NK5CopbCEjdOFBbhfAf+oGL4MmGqanf5Dny511PlAYhxsV+wgSgKsUjT7fQGPVJexRQCUQFPx 6tQbmzrebyvel//fphzTPFK4cqMT43J0cnyFjJLBLnBGRQm/ZR2qqLSh+BSklZnwn+5DKWbc7 yMuHERH 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" From: Helge Deller On the parisc architecture the stack grows upwards. Move the TASK_UNMAPPED_BASE to high memory area as it's done by the kernel on physical machines. Signed-off-by: Helge Deller Message-Id: <20220918194555.83535-9-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/mmap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 6a828e8418a7..83fdae7034ea 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -253,8 +253,12 @@ static int mmap_frag(abi_ulong real_start, # define TASK_UNMAPPED_BASE (1ul << 38) #endif #else +#ifdef TARGET_HPPA +# define TASK_UNMAPPED_BASE 0xfa000000 +#else # define TASK_UNMAPPED_BASE 0x40000000 #endif +#endif abi_ulong mmap_next_start = TASK_UNMAPPED_BASE; unsigned long last_brk; From patchwork Wed Sep 28 08:14:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992089 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 B30D6C32771 for ; Wed, 28 Sep 2022 10:48:54 +0000 (UTC) Received: from localhost ([::1]:47952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUcX-0001K6-J9 for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:48:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE4-000861-K4 for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:28 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:56601) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE1-00089W-Uj for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:28 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Ml6du-1p58Xg0hKe-00lRA3; Wed, 28 Sep 2022 10:15:24 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 11/38] linux-user: Add strace for clock_nanosleep() Date: Wed, 28 Sep 2022 10:14:50 +0200 Message-Id: <20220928081517.734954-12-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:yWeQiDY9fwlIG1OG2ayCuDT52r8Vqc8bD2I9Kf1Fh4vPBNGh0cx KRnmvlHk44GCKp/iEnvmO+qyVgHJ+mdwiov0izreuRvTfid3GNMcVrKia4ZG2ZXR7uNJkP3 P29pJBVdvbcdjOazWh8dd4VbLLc7TQsB43BwdnSyJhV0rmDZxgdHRdJY5Zcw5VppkzuCNcf 0O35b2yLd3bHx5r6Gw+3Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:p/cL610Ro18=:yQn7TpbuA5XEBEXg7lqXnA 9RH2zTie2iNZM5LiQkpZdT42rrQk/XLgAxAty5AW34oO8iQELsIKZzmg6vM/9E/jNx+Ogjga4 yb+/9Dk8mZryojTqe3neE3XjijLoPCug/jyusMzSSpyou/AJ43pEFU2dbOh0Nfm0evXAo3HoN /nK+x3AM8V1/MfHNN/PYQ3vXSDP5WnAT+M9IINlsNkuCgmQOMXvRhEaBp0FubwIB0LYAILdJA tjmMEZ7kEH+vQM7zh5qJXNoRavmatiCIingCTMV6VaBKwGUAY6qLEdAECG4LhTgP1FiaXgx3f GHtytMjXHBP5A1QPmvU5F8U9RPpYm1W3DCSC0eOUGNCAWZkHbtRliaNiRSKZZ5zEYWt8ZbrzU Onbz5ChmaMVU+SORW2/lKTsjhUfNUOqXSzu1ssC4fnbNYfQxS51wf+sxqNK4uHFxruapwSSQW 8dcs3MqXGUV5cZhGN70TIzU9BehRX5Epu8/6yMcuElTEve8F4eNGLL4hPkopTxjSI6PyjwzVE EoQc9Q/nn1FzafIF92D3SD5z2x/cKW1Hy6f3v3dDWlqH79rSKtold3TG3Yt9MIyv9BVr8Bdyz SefinKH9N7YcwgmEnI5EMe6P2Na9hvGvSbTFy2u4aNjxeEOQjSZSaOrsVBcBUzlIVP+GWYOP0 G3rVipV99KXTlMAce5w+rsnKraK9gsD++FYKq/mS2bc9Vaq+xvEjUTCosylMDJfURucjRLGVa SvUoNQFr84EYCUiDTvdGP0uvbK62Wyck86WxGXbY1TJESdNOmrB1cqXyTsQbM6DF7DUSWq4ca hcIQfi9 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" From: Helge Deller Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20220918194555.83535-10-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 15 +++++++++++++++ linux-user/strace.list | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 2f539845bb90..6f818212d529 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -3567,6 +3567,21 @@ print_unshare(CPUArchState *cpu_env, const struct syscallname *name, } #endif +#ifdef TARGET_NR_clock_nanosleep +static void +print_clock_nanosleep(CPUArchState *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_enums(clockids, arg0, 0); + print_raw_param("%d", arg1, 0); + print_timespec(arg2, 0); + print_timespec(arg3, 1); + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_utime static void print_utime(CPUArchState *cpu_env, const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 4d8b7f6a5e0c..215d971b2aea 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -91,7 +91,8 @@ print_syscall_ret_clock_gettime }, #endif #ifdef TARGET_NR_clock_nanosleep -{ TARGET_NR_clock_nanosleep, "clock_nanosleep" , NULL, NULL, NULL }, +{ TARGET_NR_clock_nanosleep, "clock_nanosleep" , NULL, print_clock_nanosleep, + NULL }, #endif #ifdef TARGET_NR_clock_settime { TARGET_NR_clock_settime, "clock_settime" , NULL, print_clock_settime, NULL }, From patchwork Wed Sep 28 08:14:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992098 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 97E86C32771 for ; Wed, 28 Sep 2022 10:53:51 +0000 (UTC) Received: from localhost ([::1]:52544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUhK-00076w-Nv for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:53:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE5-00086m-9X for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:29 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:53089) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE2-00089a-MD for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:28 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N4yyQ-1pKb1s2R6K-010ugF; Wed, 28 Sep 2022 10:15:24 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 12/38] linux-user: Show timespec on strace for futex() Date: Wed, 28 Sep 2022 10:14:51 +0200 Message-Id: <20220928081517.734954-13-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:YCIWjKB32DrXlkcm2dsq1/E+ckxuGL7JG976qLGBHtUsdXuS/iO k4TZK2c5NjLxz+xEkpt6pg0RLk+IquElg9s0eHsXz1LLlBDLn+M9MoIK3AIm5kZyLu1R1Xr KVH2eIfLOkOc+0XDHX13TUh/adrgdES6pggZG48eghpg1SEUGW7O09KxWmaKDRRrRNfuuFW z1ccwHohf/BxzrcRI3IgA== X-UI-Out-Filterresults: notjunk:1;V03:K0:RPLGkX36y0I=:flP6Tu5gSxCQ8+Mg+DF0iO x/Nbf0dRz8C6AjLkQSd2xFcocpCPH2ngHpLmOT0koAMSSuWZr1O6rhgXhZvlRlNtIVJu1I3o1 aNootu6+th0eC4YqeSWkJgxT455Ecdyqk4esbL9bJcBGZx5A1nNpUTuGwvCql+aCsDGYiXapo tyPMG7YOM6a42N7F06UZ1BnTk5sSY3QrRie3G+pfZRjHwhKXLUuWSV1KScTKowSfgA20s7eG8 QwjY8YWIQ29GQurAmB072JoN5HALch9UX5FyT03oP2llMn0y2Mq96vlNUqqxU+Gi1ZfTyHvwd /NsGNw92FvIDoegTZZADC17mtfobUCNWC6XusYmDtHzBIhQDMXLkjcGbzksgEyswSBYi+iXfr QKFX1s4bSah11gFgI71FfsCEx6omhuCGnJ1iSu/bla2xphq+kBKXlu28PJ0K/IGqOBgH+laqn d7zF3+T2RAZrlR5rKp8K5EB6vvvATlzcYo7nrUZLouFG8FyYuLqr2kqOIJZCZ8e/bs3nRSYS6 4zLBGn6246pBZ8lO3Bme2PCNsp2YHMpyrMXKGDYZ0h3YZ/50o685+8womt7dShZhaCT/3O7Ev HnMXSV2AIHCcY0wYSPRd3LBm+z6Li29/YXORuuI8Gn+O9ymEn45eefFXBuTXX40jCTHlEwnG9 zplx82+LwAZwsZOGi2Ge4yfRJBmg+s/PkP9BiKovk+TOio1givz1XPPQRRWBMS29MasavhZQZ cBR86+MtCuQbVEIi9XUcvoUuEJVVy0Pt82wgkaHiMRY3gi3ayfup79ioAHoOBLkgldCJEu0U0 1x7Bp6W 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" From: Helge Deller Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20220918194555.83535-11-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 6f818212d529..b6b9abaea466 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -3714,11 +3714,20 @@ print_futex(CPUArchState *cpu_env, const struct syscallname *name, abi_long arg0, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5) { + abi_long op = arg1 & FUTEX_CMD_MASK; print_syscall_prologue(name); print_pointer(arg0, 0); print_futex_op(arg1, 0); print_raw_param(",%d", arg2, 0); - print_pointer(arg3, 0); /* struct timespec */ + switch (op) { + case FUTEX_WAIT: + case FUTEX_WAIT_BITSET: + print_timespec(arg3, 0); + break; + default: + print_pointer(arg3, 0); + break; + } print_pointer(arg4, 0); print_raw_param("%d", arg4, 1); print_syscall_epilogue(name); From patchwork Wed Sep 28 08:14:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992097 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 DCE5EC6FA82 for ; Wed, 28 Sep 2022 10:52:45 +0000 (UTC) Received: from localhost ([::1]:36394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUgG-0004wp-Lz for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:52:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE9-0008Ap-NQ for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:33 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:36183) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE5-0008Ai-NL for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:32 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MgNpJ-1pALKM0Qc3-00huW8; Wed, 28 Sep 2022 10:15:25 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Richard Henderson , Laurent Vivier Subject: [PULL 13/38] linux-user: Provide MADV_* definitions Date: Wed, 28 Sep 2022 10:14:52 +0200 Message-Id: <20220928081517.734954-14-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:iB3EV6V9xPhCjkl/TgXl2lZp9T+3s1ps2p5pDe7mjNTNVFDCBTO Z7FUzD3cznLM/9wHhrqUg6jUHZjwppboeoDpbUUgT+arcb6EjKU6WmqifhmLeLZ7AxB0+J+ cJutOJkxyV6dmzQPLSxRA69nOzxcWGoeqfbfY5yslW2wh2+7U6su2yf1vLn63ZO4jIL4PoB j5wl47U57Yy+PtCgq9EKg== X-UI-Out-Filterresults: notjunk:1;V03:K0:bQ5z94ZKgfI=:kIXTlm38shq8h0xZBv83TW 1SXzudUXJ3XZAfPZNYmeVzY9hih5Xvx7DhCUyJYqLudGjf1xRvRBmctzX/5enRjAbKoFhaiQq 10wOn7PHM9RCWoxjWDxc6ZXYU6HIK8eZoIkX49qyVfC3PN9QbHjq6vfdaJUk3NZHBnjV3zoIz cKvJZDKZTg+ZK2iX8m9JXdNsClp0q9F2DACJDcdUNrEIjpdlANX36P2DNNujDzy4iI6V992HO tJURZ+MCeeQHYJe1y5hPgQwaGWxnDx1au5qEtZoFFV1Rexa+pvNsIiP9HzdTMQdHBH8VVO0pu eJm/y6bnDwmzOtR+7LnZJnL7jxnrI4bQ3CYFjB8+bI/WmpZBQMfQjAt9XchnoCJU0jHFY3zCD Hi6QD8h+sCFTIPgJEI6xZL3T7Z6ppIqxiiDSjTiVWdNhor1TEK9FIP5L7YjurWe3jwj0Sszlf 8Qu8Fs0GiREKxcMegK8lo1xTPWWJ9JWr8ZCbR34IDfoMQ0qHD5HrqrSRXZ4YuI+oAcq3GmedE TQkurBEtJD8UVm1jy3/t2HGLQaCUdt2qlxacC2LYiV2+BVNCOFAS0+LesXJ60sV6R2zQQIShj nrSuDYBywFY85aXjf3nTO+1gaeJv/68Nna83QOWtkaT3euMEJRlqaib+zx778IjccpugddcM/ Ojraei+8wAj2Hw9gLThjeiBJWdkP+HJ0GCc5caFv+Gi644kfPmWI3CN8bAINO8JPACRGhqwUa WDyjo2um5xWDupqtalZSpv7vqVs7MtBpP0u6g5xpT4uNWjcBLNAUU6qUXADe2O2O2MhXj3HPr fCif5Ba 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Ilya Leoshkevich Provide MADV_* definitions using target_mman.h header, similar to what kernel does. Most architectures use the same values, with the exception of alpha and hppa. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson Message-Id: <20220906000839.1672934-2-iii@linux.ibm.com> Signed-off-by: Laurent Vivier --- linux-user/aarch64/target_mman.h | 1 + linux-user/alpha/target_mman.h | 8 +++ linux-user/arm/target_mman.h | 1 + linux-user/cris/target_mman.h | 1 + linux-user/generic/target_mman.h | 92 ++++++++++++++++++++++++++++ linux-user/hexagon/target_mman.h | 1 + linux-user/hppa/target_mman.h | 15 +++++ linux-user/i386/target_mman.h | 1 + linux-user/loongarch64/target_mman.h | 1 + linux-user/m68k/target_mman.h | 1 + linux-user/microblaze/target_mman.h | 1 + linux-user/mips/target_mman.h | 1 + linux-user/mips64/target_mman.h | 1 + linux-user/nios2/target_mman.h | 1 + linux-user/openrisc/target_mman.h | 1 + linux-user/ppc/target_mman.h | 1 + linux-user/riscv/target_mman.h | 1 + linux-user/s390x/target_mman.h | 1 + linux-user/sh4/target_mman.h | 1 + linux-user/sparc/target_mman.h | 1 + linux-user/x86_64/target_mman.h | 1 + linux-user/xtensa/target_mman.h | 1 + 22 files changed, 134 insertions(+) create mode 100644 linux-user/aarch64/target_mman.h create mode 100644 linux-user/alpha/target_mman.h create mode 100644 linux-user/arm/target_mman.h create mode 100644 linux-user/cris/target_mman.h create mode 100644 linux-user/generic/target_mman.h create mode 100644 linux-user/hexagon/target_mman.h create mode 100644 linux-user/hppa/target_mman.h create mode 100644 linux-user/i386/target_mman.h create mode 100644 linux-user/loongarch64/target_mman.h create mode 100644 linux-user/m68k/target_mman.h create mode 100644 linux-user/microblaze/target_mman.h create mode 100644 linux-user/mips/target_mman.h create mode 100644 linux-user/mips64/target_mman.h create mode 100644 linux-user/nios2/target_mman.h create mode 100644 linux-user/openrisc/target_mman.h create mode 100644 linux-user/ppc/target_mman.h create mode 100644 linux-user/riscv/target_mman.h create mode 100644 linux-user/s390x/target_mman.h create mode 100644 linux-user/sh4/target_mman.h create mode 100644 linux-user/sparc/target_mman.h create mode 100644 linux-user/x86_64/target_mman.h create mode 100644 linux-user/xtensa/target_mman.h diff --git a/linux-user/aarch64/target_mman.h b/linux-user/aarch64/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/aarch64/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/alpha/target_mman.h b/linux-user/alpha/target_mman.h new file mode 100644 index 000000000000..cd6e3d70a604 --- /dev/null +++ b/linux-user/alpha/target_mman.h @@ -0,0 +1,8 @@ +#ifndef ALPHA_TARGET_MMAN_H +#define ALPHA_TARGET_MMAN_H + +#define TARGET_MADV_DONTNEED 6 + +#include "../generic/target_mman.h" + +#endif diff --git a/linux-user/arm/target_mman.h b/linux-user/arm/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/arm/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/cris/target_mman.h b/linux-user/cris/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/cris/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/generic/target_mman.h b/linux-user/generic/target_mman.h new file mode 100644 index 000000000000..1436a3c54308 --- /dev/null +++ b/linux-user/generic/target_mman.h @@ -0,0 +1,92 @@ +#ifndef LINUX_USER_TARGET_MMAN_H +#define LINUX_USER_TARGET_MMAN_H + +#ifndef TARGET_MADV_NORMAL +#define TARGET_MADV_NORMAL 0 +#endif + +#ifndef TARGET_MADV_RANDOM +#define TARGET_MADV_RANDOM 1 +#endif + +#ifndef TARGET_MADV_SEQUENTIAL +#define TARGET_MADV_SEQUENTIAL 2 +#endif + +#ifndef TARGET_MADV_WILLNEED +#define TARGET_MADV_WILLNEED 3 +#endif + +#ifndef TARGET_MADV_DONTNEED +#define TARGET_MADV_DONTNEED 4 +#endif + +#ifndef TARGET_MADV_FREE +#define TARGET_MADV_FREE 8 +#endif + +#ifndef TARGET_MADV_REMOVE +#define TARGET_MADV_REMOVE 9 +#endif + +#ifndef TARGET_MADV_DONTFORK +#define TARGET_MADV_DONTFORK 10 +#endif + +#ifndef TARGET_MADV_DOFORK +#define TARGET_MADV_DOFORK 11 +#endif + +#ifndef TARGET_MADV_MERGEABLE +#define TARGET_MADV_MERGEABLE 12 +#endif + +#ifndef TARGET_MADV_UNMERGEABLE +#define TARGET_MADV_UNMERGEABLE 13 +#endif + +#ifndef TARGET_MADV_HUGEPAGE +#define TARGET_MADV_HUGEPAGE 14 +#endif + +#ifndef TARGET_MADV_NOHUGEPAGE +#define TARGET_MADV_NOHUGEPAGE 15 +#endif + +#ifndef TARGET_MADV_DONTDUMP +#define TARGET_MADV_DONTDUMP 16 +#endif + +#ifndef TARGET_MADV_DODUMP +#define TARGET_MADV_DODUMP 17 +#endif + +#ifndef TARGET_MADV_WIPEONFORK +#define TARGET_MADV_WIPEONFORK 18 +#endif + +#ifndef TARGET_MADV_KEEPONFORK +#define TARGET_MADV_KEEPONFORK 19 +#endif + +#ifndef TARGET_MADV_COLD +#define TARGET_MADV_COLD 20 +#endif + +#ifndef TARGET_MADV_PAGEOUT +#define TARGET_MADV_PAGEOUT 21 +#endif + +#ifndef TARGET_MADV_POPULATE_READ +#define TARGET_MADV_POPULATE_READ 22 +#endif + +#ifndef TARGET_MADV_POPULATE_WRITE +#define TARGET_MADV_POPULATE_WRITE 23 +#endif + +#ifndef TARGET_MADV_DONTNEED_LOCKED +#define TARGET_MADV_DONTNEED_LOCKED 24 +#endif + +#endif diff --git a/linux-user/hexagon/target_mman.h b/linux-user/hexagon/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/hexagon/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/hppa/target_mman.h b/linux-user/hppa/target_mman.h new file mode 100644 index 000000000000..66dd9f79414e --- /dev/null +++ b/linux-user/hppa/target_mman.h @@ -0,0 +1,15 @@ +#ifndef HPPA_TARGET_MMAN_H +#define HPPA_TARGET_MMAN_H + +#define TARGET_MADV_MERGEABLE 65 +#define TARGET_MADV_UNMERGEABLE 66 +#define TARGET_MADV_HUGEPAGE 67 +#define TARGET_MADV_NOHUGEPAGE 68 +#define TARGET_MADV_DONTDUMP 69 +#define TARGET_MADV_DODUMP 70 +#define TARGET_MADV_WIPEONFORK 71 +#define TARGET_MADV_KEEPONFORK 72 + +#include "../generic/target_mman.h" + +#endif diff --git a/linux-user/i386/target_mman.h b/linux-user/i386/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/i386/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/loongarch64/target_mman.h b/linux-user/loongarch64/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/loongarch64/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/m68k/target_mman.h b/linux-user/m68k/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/m68k/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/microblaze/target_mman.h b/linux-user/microblaze/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/microblaze/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/mips/target_mman.h b/linux-user/mips/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/mips/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/mips64/target_mman.h b/linux-user/mips64/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/mips64/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/nios2/target_mman.h b/linux-user/nios2/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/nios2/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/openrisc/target_mman.h b/linux-user/openrisc/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/openrisc/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/ppc/target_mman.h b/linux-user/ppc/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/ppc/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/riscv/target_mman.h b/linux-user/riscv/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/riscv/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/s390x/target_mman.h b/linux-user/s390x/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/s390x/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/sh4/target_mman.h b/linux-user/sh4/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/sh4/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/sparc/target_mman.h b/linux-user/sparc/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/sparc/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/x86_64/target_mman.h b/linux-user/x86_64/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/x86_64/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/xtensa/target_mman.h b/linux-user/xtensa/target_mman.h new file mode 100644 index 000000000000..e7ba6070fe7c --- /dev/null +++ b/linux-user/xtensa/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" From patchwork Wed Sep 28 08:14:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992107 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 66422C32771 for ; Wed, 28 Sep 2022 11:00:26 +0000 (UTC) Received: from localhost ([::1]:39166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUnh-0004Xj-BG for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 07:00:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE9-0008Ao-NQ for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:33 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:45907) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE7-0008BS-0o for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:32 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N95qT-1pH2OA30XH-0169Tk; Wed, 28 Sep 2022 10:15:25 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Richard Henderson , Laurent Vivier Subject: [PULL 14/38] linux-user: Fix madvise(MADV_DONTNEED) on alpha Date: Wed, 28 Sep 2022 10:14:53 +0200 Message-Id: <20220928081517.734954-15-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:YJ2Fz7ylUNUSpktpFd2hCRX88lJktvIAzWgwH94sVjTR5aQDtC1 I7WcOXbE+YbznAjZKKipe/K7cp8nqvX3jHaVixyhRSeiHY083wnsFdHecB9tRfMs/1RuYhB 3ov337uyBwfKhCFpqHJLaeu57skhgImp3EKMioE1XmbqaIoSmgggCnDtjjg1697swqWvFgX 94jG6YNvQi4+8X72vli4g== X-UI-Out-Filterresults: notjunk:1;V03:K0:avgZ+ZqByG4=:6Phr5hOuEiufSsQRuQubvA UUz6QIolkuQa4qzz7CzMBgaoK2jHiHUs18c6SU0bzvhjlNMfnHXnZ+x2GOI3asHOfWkzm35jl tLbsFrkpYYI+RcP+twttZ8KbzLehr4VzHKSVtOiLdkriAqYNWYrhDaZ2pl6O6JBBfpizOqCJI 8w+vvQzPdp1eJAGRAOTb9ahWkMNEEa629vXKudBBWeIycX75aQDgoY19uAg6XNkc3KxZfPJLK lRT22NI7k7y/3oiDoZTMt8HJKQWIDu71wMVsFFi+Ilq644r7OMbtvsgSAtoFy6eCZwUHa/WZu 2PZQGhXjtcVsiSTFjHN0qdxXM9mPfQxGxE6cqHc1PwJeVj6arIQStwCJBNTVw+0xiluLqtivW 7T1L/xyDcm5pESKhMkVBz49uVCbCJTforTplZlO2QjagdXIPM4LDrIyh+6Hi/2W7lI19lqtRJ RpXdI5Y2ROXkxM1FHHMdtNmA5c3Tt9a3jU9Qa0OgXAhwdKRoGzi6wzI1VeId8sOAPSZBUDNC6 5Kn1V7wHxHphYBL64Zc1UFnuSQ5xoE/vEqDA7kEvwne0Dd/ybXAD3ORgOAbFJP8DQdCHaqy8O ma2ro+vudO8ZCH9Rct5jigLHlMAIgMllCn4zZE6OwMVpL7jA5HBbTT9joinRPCUwXz0oXoPiE YWqPv/jydnLy06FOge7P04oHkqonfae7waDd8WtKyEO8NK9zlL8kr/XKI11mcCBcy0hrdLdXR Te950xnxv/QiZeTOnim8/EEirOrGeZGmVH+Ft6RD6TSBVmaqO3njWKM/WkUwFqQNcZoysT6om ozL9hBc 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" From: Ilya Leoshkevich MADV_DONTNEED has a different value on alpha, compared to all the other architectures. Fix by using TARGET_MADV_DONTNEED instead of MADV_DONTNEED. Fixes: 892a4f6a750a ("linux-user: Add partial support for MADV_DONTNEED") Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson Message-Id: <20220906000839.1672934-3-iii@linux.ibm.com> Signed-off-by: Laurent Vivier --- linux-user/mmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 83fdae7034ea..942bec7e8528 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -22,6 +22,7 @@ #include "qemu.h" #include "user-internals.h" #include "user-mmap.h" +#include "target_mman.h" static pthread_mutex_t mmap_mutex = PTHREAD_MUTEX_INITIALIZER; static __thread int mmap_lock_count; @@ -897,7 +898,7 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice) * anonymous mappings. In this case passthrough is safe, so do it. */ mmap_lock(); - if (advice == MADV_DONTNEED && + if (advice == TARGET_MADV_DONTNEED && can_passthrough_madv_dontneed(start, end)) { ret = get_errno(madvise(g2h_untagged(start), len, MADV_DONTNEED)); if (ret == 0) { From patchwork Wed Sep 28 08:14:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992054 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 AD94AC32771 for ; Wed, 28 Sep 2022 10:19:52 +0000 (UTC) Received: from localhost ([::1]:47472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUAR-0004Ht-CR for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:19:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE9-0008Aq-Nt for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:33 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:37727) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE6-0008BD-JJ for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:32 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N63JO-1pJWA20rCy-016QSd; Wed, 28 Sep 2022 10:15:26 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Richard Henderson , Laurent Vivier Subject: [PULL 15/38] linux-user: Implement stracing madvise() Date: Wed, 28 Sep 2022 10:14:54 +0200 Message-Id: <20220928081517.734954-16-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:nDHUuuST60S5LHG25c5IcMxkEmHfXMUq7xrZ8Iks5GXPySc6C19 enWEjdU/DAWbtYksH6o608VAJ6+ryUh/ZxcPiE6R3WbYLUDwv/0lr7a5rN4/5Tl2RjBdzMs cPFDCE9X+jLcvrQF62GNunCsR+bllpj1gQjOpuOllyjtR+h9T06Jr5fgXKMymSRbKh9ai6R OvCOj730QQBvj5q5kd+NQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:5sq+y7gYpX8=:NmDi6G+CEf1P+28Fd5Y53n 9Y+4pXJhg/XcAJMXPDC17nZirOJhYg3BIgC/b6/QWUyOdG6Zs7euT2hDRQw3WuThFZAY0F5LL GNDJwLP2LcMEJWkm8uqSUynD7MQnBH7zIyo5Zu1cGLXz6wxAWrhRTaTLGpqMEKUAjbLLltigT 62yROXfb8kWMqbYNUqoqoGSFpLZ8AZ6yXyq3LOvBkwrJjEwEUPR4gG0YHDrQJ7V/ioLEefMCz 5MZ3/f9myXVZbhJ0TgpgIYe/MiewjArSFiaTakPdVwSY3baSDIHFt1O3BIJRTBRKetJL6t1lS OwPsCuNl4tgGnAQYdikEXwo1bt+59oKecMP2nxqCJOry9+t4Rmf/vZmKzA6Vpr4vQJt8FBcpT r5J89p02UAWcMhujWRFOpX8iWMC01xvkGu7YHp0rZu10KRH7+YyXYgK94g7T3nj6rrJhgQStv O7ewDxAHuobWln3HnQuSGbZvrMe/PK86XguIw033rGRx0zR3WoH+wPRrtPbD9sGTtST4xi6tn Cpny2LIK+6psVB4JZX5v/ygrJurbFtvV+LC83giax/o+BZeCFY5dsdwu5N3WdGSZjWkxwngWY ihG64N7bbDMSLgSZFaPAWZxseKVR5zsWEPzAZWBEslg+NRWJr2EgNUR5uQLffD+/M7Ke0cGPV l81Ol1IUk1cbklgcr8IEm9rn38XehnH5oKFfnH/DBYVehRLvw6iPhDEypu+9WHJvouDPQCO9S p6cwM/gt97u7jx0L3zZAaqRwZQtHXiTAlrfCFPWWcDlBnisqg0uoabWtw1XrKY9jKu/8UbNkk Q8z2UpF 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" From: Ilya Leoshkevich The default implementation has several problems: the first argument is not displayed as a pointer, making it harder to grep; the third argument is not symbolized; and there are several extra unused arguments. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson Message-Id: <20220906000839.1672934-4-iii@linux.ibm.com> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 41 +++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index b6b9abaea466..2deb84a2c106 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -18,6 +18,7 @@ #include "user-internals.h" #include "strace.h" #include "signal-common.h" +#include "target_mman.h" struct syscallname { int nr; @@ -3019,6 +3020,46 @@ print_stat(CPUArchState *cpu_env, const struct syscallname *name, #define print_lstat64 print_stat #endif +#if defined(TARGET_NR_madvise) +static struct enums madvise_advice[] = { + ENUM_TARGET(MADV_NORMAL), + ENUM_TARGET(MADV_RANDOM), + ENUM_TARGET(MADV_SEQUENTIAL), + ENUM_TARGET(MADV_WILLNEED), + ENUM_TARGET(MADV_DONTNEED), + ENUM_TARGET(MADV_FREE), + ENUM_TARGET(MADV_REMOVE), + ENUM_TARGET(MADV_DONTFORK), + ENUM_TARGET(MADV_DOFORK), + ENUM_TARGET(MADV_MERGEABLE), + ENUM_TARGET(MADV_UNMERGEABLE), + ENUM_TARGET(MADV_HUGEPAGE), + ENUM_TARGET(MADV_NOHUGEPAGE), + ENUM_TARGET(MADV_DONTDUMP), + ENUM_TARGET(MADV_DODUMP), + ENUM_TARGET(MADV_WIPEONFORK), + ENUM_TARGET(MADV_KEEPONFORK), + ENUM_TARGET(MADV_COLD), + ENUM_TARGET(MADV_PAGEOUT), + ENUM_TARGET(MADV_POPULATE_READ), + ENUM_TARGET(MADV_POPULATE_WRITE), + ENUM_TARGET(MADV_DONTNEED_LOCKED), + ENUM_END, +}; + +static void +print_madvise(CPUArchState *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_pointer(arg0, 0); + print_raw_param("%d", arg1, 0); + print_enums(madvise_advice, arg2, 1); + print_syscall_epilogue(name); +} +#endif + #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) static void print_fstat(CPUArchState *cpu_env, const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 215d971b2aea..c6f748505a9e 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -542,7 +542,7 @@ { TARGET_NR_lstat64, "lstat64" , NULL, print_lstat64, NULL }, #endif #ifdef TARGET_NR_madvise -{ TARGET_NR_madvise, "madvise" , NULL, NULL, NULL }, +{ TARGET_NR_madvise, "madvise" , NULL, print_madvise, NULL }, #endif #ifdef TARGET_NR_madvise1 { TARGET_NR_madvise1, "madvise1" , NULL, NULL, NULL }, From patchwork Wed Sep 28 08:14:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992106 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 EAB2DC6FA82 for ; Wed, 28 Sep 2022 11:00:18 +0000 (UTC) Received: from localhost ([::1]:34964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUnZ-0004L8-NZ for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 07:00:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEC-0008E9-4s for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:36 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:50021) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE9-0008C1-30 for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:35 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M7sM0-1oZcT62qQ6-005101; Wed, 28 Sep 2022 10:15:26 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Richard Henderson , Laurent Vivier Subject: [PULL 16/38] linux-user: Passthrough MADV_DONTNEED for certain file mappings Date: Wed, 28 Sep 2022 10:14:55 +0200 Message-Id: <20220928081517.734954-17-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:LQ82ZVVfgkO4SbaPem9hFKWDkmY+n/GBDvsj7la4Ul6cIMvAF4O FK3G82QdkeKYXrffTTYNvGjbAZLO2Yj7FsiSm7flLfnmMzOwLqCgx35sddVLmLdBK+YuvYG 4u4aFXAMMPMlvzzPw5LOOC+UDaMJUFnQ3gJL2gvcvU6R8L5Y7xWr7wOG6PGU0AspMweb3uR FNisTq2e2HPFfRfRtqBFQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:1z9D+VJIki0=:gIjIhTpY47nKUgYbXFQiCf JVZmZZEiJ8wflk9Ki/+HzwIEcYp1EXgE2qCU7FU4sToLAnP/sg4xz29aITiSZHsYPgiUYX1uT fp6HP85FUBeg0HIws09XiMCYtg6ipkEHkeI1rvYMbBW65dDjscdR3KmG1JNA6I/SfLzKhhcyP jFj4o2TFPFSjI9fvejcEYWzjARrgA2krjx33Ib0eFMTf5V2x41oVJh04u2Yh1g/jmHShURWEJ nu1obDYcFDTDdWcoxpo6uGDPrwhRU0pT6HaE+fQpGjgd9oNEDYl9XPnAzlaPVftb8tXxqeqHl qzk1EObKsdSfCfKP2j/CNHN/8yHMFplkrI1bgay5Da1fwsTGmFEl49qOQG4PA8nrOMrMzRXcd BjGMNIcStJ/ZLP9pYlne2rHnymdbGGbvljtl+HJndmQ2sYe/PTaprLACiOZcDZ5ugYznxdmBE SoWg5nOGY3bpUr8HsbD0a+Ci1zTl/pxXdjzkQJElMl032vDeOdVSC0KQGGf+IMrvhHs1UvSBu ddYvHaJKb6jQNnoVk7WoVjP1zWokTiVdQ9LzH6z5lhongbfLlKmCWmNNS8y63oZCdjR7Fmos/ E8331xedHwWEMZ6HywM8b7fotf88Id72VYiXRfQrEkNPMXC+dRRdO7n+YvQboK4gCB/0gc6Es EuucaC4uh/HJ93PL6kEfix5Ie76KBaRAZdgPwkQWA+i28pkLZrLEOrhxOCWVsnU7NEBRbhfnf 8T5ohCy4KHMt96Q/R8KVQYMrJacZuFV28drfsqlJH2ZZlWSh7a4jQjNJz/VGTBVdR7YV43jOH KzXGx9o 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" From: Ilya Leoshkevich This is a follow-up for commit 892a4f6a750a ("linux-user: Add partial support for MADV_DONTNEED"), which added passthrough for anonymous mappings. File mappings can be handled in a similar manner. In order to do that, mark pages, for which mmap() was passed through, with PAGE_PASSTHROUGH, and then allow madvise() passthrough for these pages. Drop the explicit PAGE_ANON check, since anonymous mappings are expected to have PAGE_PASSTHROUGH anyway. Add PAGE_PASSTHROUGH to PAGE_STICKY in order to keep it on mprotect(). Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson Message-Id: <20220725125043.43048-1-iii@linux.ibm.com> Message-Id: <20220906000839.1672934-5-iii@linux.ibm.com> Signed-off-by: Laurent Vivier --- accel/tcg/translate-all.c | 2 +- include/exec/cpu-all.h | 6 ++++++ linux-user/mmap.c | 27 ++++++++++++++++++++++----- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index f5e8592d4a47..d71d04d338db 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2258,7 +2258,7 @@ int page_get_flags(target_ulong address) #ifndef PAGE_TARGET_STICKY #define PAGE_TARGET_STICKY 0 #endif -#define PAGE_STICKY (PAGE_ANON | PAGE_TARGET_STICKY) +#define PAGE_STICKY (PAGE_ANON | PAGE_PASSTHROUGH | PAGE_TARGET_STICKY) /* Modify the flags of a page and invalidate the code if necessary. The flag PAGE_WRITE_ORG is positioned automatically depending diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 491629b9ba7a..16b7df41bf5e 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -262,6 +262,12 @@ extern const TargetPageBits target_page; #define PAGE_TARGET_1 0x0200 #define PAGE_TARGET_2 0x0400 +/* + * For linux-user, indicates that the page is mapped with the same semantics + * in both guest and host. + */ +#define PAGE_PASSTHROUGH 0x0800 + #if defined(CONFIG_USER_ONLY) void page_dump(FILE *f); diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 942bec7e8528..e557f3626e5d 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -431,7 +431,8 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, int flags, int fd, abi_ulong offset) { - abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len; + abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len, + passthrough_start = -1, passthrough_end = -1; int page_flags, host_prot; mmap_lock(); @@ -544,6 +545,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, host_start += offset - host_offset; } start = h2g(host_start); + passthrough_start = start; + passthrough_end = start + len; } else { if (start & ~TARGET_PAGE_MASK) { errno = EINVAL; @@ -626,6 +629,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, host_prot, flags, fd, offset1); if (p == MAP_FAILED) goto fail; + passthrough_start = real_start; + passthrough_end = real_end; } } the_end1: @@ -633,7 +638,18 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, page_flags |= PAGE_ANON; } page_flags |= PAGE_RESET; - page_set_flags(start, start + len, page_flags); + if (passthrough_start == passthrough_end) { + page_set_flags(start, start + len, page_flags); + } else { + if (start < passthrough_start) { + page_set_flags(start, passthrough_start, page_flags); + } + page_set_flags(passthrough_start, passthrough_end, + page_flags | PAGE_PASSTHROUGH); + if (passthrough_end < start + len) { + page_set_flags(passthrough_end, start + len, page_flags); + } + } the_end: trace_target_mmap_complete(start); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { @@ -852,7 +868,7 @@ static bool can_passthrough_madv_dontneed(abi_ulong start, abi_ulong end) } for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { - if (!(page_get_flags(addr) & PAGE_ANON)) { + if (!(page_get_flags(addr) & PAGE_PASSTHROUGH)) { return false; } } @@ -894,8 +910,9 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice) * This is a hint, so ignoring and returning success is ok. * * This breaks MADV_DONTNEED, completely implementing which is quite - * complicated. However, there is one low-hanging fruit: host-page-aligned - * anonymous mappings. In this case passthrough is safe, so do it. + * 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. */ mmap_lock(); if (advice == TARGET_MADV_DONTNEED && From patchwork Wed Sep 28 08:14:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12991950 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 8A38AC04A95 for ; Wed, 28 Sep 2022 09:29:07 +0000 (UTC) Received: from localhost ([::1]:37590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odTNK-0001nM-J3 for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 05:29:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEC-0008E2-1y for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:36 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:48769) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE9-0008C0-GL for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:35 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MJmCV-1oxbfi0dFB-00KBOg; Wed, 28 Sep 2022 10:15:27 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Richard Henderson , Laurent Vivier Subject: [PULL 17/38] tests/tcg/linux-test: Add linux-madvise test Date: Wed, 28 Sep 2022 10:14:56 +0200 Message-Id: <20220928081517.734954-18-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:d2Jg5mLWB36vBtez6hhiQ29KTnw5vHmZPZPTV4IiQpDPNFKSmve 11w5PtzLwx0zOkoiq7OPaRC9AYwlcbfYmMr5Mrnf/sLwG/JUyYp5auyKIacrodR0rZFPpmo KqWV9l21/g7GJsVL2IgW/cz9sbsigJp87uHqOSFIg1zecd/OIidpK3CwCEg3RUVkrYmWYyM FxQrs/G4qT9uczZMAukqA== X-UI-Out-Filterresults: notjunk:1;V03:K0:6XwwXc7CQI0=:RBgrlJ1tv8VE+7hC/HLjd4 5ZeFkOPs8tUxe2ne7fXblQSxc6hYLAcoZ+qq3Bzr7NrfPVr+jy+H8DM9wnHtIiOfvBLuoQF1b TVq2lFJfN+T+sczO0ZT9/nDNt8jo7TKai9fdSzQ0sf0IXGyaI4afMXNeKR+1p61SuoOV4hI+0 qW24UXs8mHKkkMaCPdj997efEonmbLT/qc0E0elQTUc74nsujXHk0ViEFLv6+bOPA9xkKFteC uEcPkKFoqVXTuPzS3WJ4MrxzOAT3jl0fTIsVTbxdNeqRHueJOmVJl1Kbzeg/UzsxrKS9LvZ/G gtNjlzc4fOhcVqLHGHgdz+qt2ADo273k0mKSCD6lha1LHovvRasmZ/PLQKluOg4kafaeM4gfs O9RMSI4HV35N7zfCpxrBebABt98/edR6fA2okh9kye0V7p3dwMc/As16o2SAM/dS8n4uFSpBq 8qflKol24hRq4CzdpNyV133bSvcr3lvzV5cwcctysdeZAatmB9aJDic03Lv4blIiwA+taQ/Y3 792UEXt8TJskM1Djz8K3U5errVpTQMuge8eSHVvIwtQwZIJOqASm0U4s75KY1mvUvpCAD/nbS /paxcCFTUIZyq+y0UwCMpMsj1Vv/uCCM0dOuNpO30DAZZimHOaOANJTKS4gfZxLlf3xDP6O10 Go1DWL2oC6O2exsP2IkAXFlmrC038KxDXyHZsuzWdf35f7jCZJr678CZjMMdOwIkw2HhLd9I+ Fznt7K7r+83FO2gWUqgYYcPrEoSyj8hn+gKrucYKH8l/teGqHw6cuBBkGCWbwDU6AbnM852yY fSzyIS8 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Ilya Leoshkevich Add a test that checks madvise(MADV_DONTNEED) behavior with anonymous and file mappings in order to prevent regressions. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson Message-Id: <20220906000839.1672934-6-iii@linux.ibm.com> Signed-off-by: Laurent Vivier --- tests/tcg/multiarch/linux/linux-madvise.c | 70 +++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tests/tcg/multiarch/linux/linux-madvise.c diff --git a/tests/tcg/multiarch/linux/linux-madvise.c b/tests/tcg/multiarch/linux/linux-madvise.c new file mode 100644 index 000000000000..29d0997e687c --- /dev/null +++ b/tests/tcg/multiarch/linux/linux-madvise.c @@ -0,0 +1,70 @@ +#include +#include +#include +#include + +static void test_anonymous(void) +{ + int pagesize = getpagesize(); + char *page; + int ret; + + page = mmap(NULL, pagesize, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + assert(page != MAP_FAILED); + + /* Check that mprotect() does not interfere with MADV_DONTNEED. */ + ret = mprotect(page, pagesize, PROT_READ | PROT_WRITE); + assert(ret == 0); + + /* Check that MADV_DONTNEED clears the page. */ + *page = 42; + ret = madvise(page, pagesize, MADV_DONTNEED); + assert(ret == 0); + assert(*page == 0); + + ret = munmap(page, pagesize); + assert(ret == 0); +} + +static void test_file(void) +{ + char tempname[] = "/tmp/.cmadviseXXXXXX"; + int pagesize = getpagesize(); + ssize_t written; + char c = 42; + char *page; + int ret; + int fd; + + fd = mkstemp(tempname); + assert(fd != -1); + ret = unlink(tempname); + assert(ret == 0); + written = write(fd, &c, sizeof(c)); + assert(written == sizeof(c)); + page = mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE, fd, 0); + assert(page != MAP_FAILED); + + /* Check that mprotect() does not interfere with MADV_DONTNEED. */ + ret = mprotect(page, pagesize, PROT_READ | PROT_WRITE); + assert(ret == 0); + + /* Check that MADV_DONTNEED resets the page. */ + *page = 0; + ret = madvise(page, pagesize, MADV_DONTNEED); + assert(ret == 0); + assert(*page == c); + + ret = munmap(page, pagesize); + assert(ret == 0); + ret = close(fd); + assert(ret == 0); +} + +int main(void) +{ + test_anonymous(); + test_file(); + + return EXIT_SUCCESS; +} From patchwork Wed Sep 28 08:14:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992050 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 09CAAC04A95 for ; Wed, 28 Sep 2022 10:13:27 +0000 (UTC) Received: from localhost ([::1]:56128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odU4E-00076V-RH for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:13:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE7-000892-7D for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:33 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:60415) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE5-0008AR-E3 for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:30 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M4sD3-1odBNI2RB1-001y3c; Wed, 28 Sep 2022 10:15:27 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 18/38] linux-user: Fix TARGET_PROT_SEM for XTENSA Date: Wed, 28 Sep 2022 10:14:57 +0200 Message-Id: <20220928081517.734954-19-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:GLxkgJWXhgl3ka54kgRWUzhl4meyQhHlOcjjabKKVDbluCzIGwb hTRYDGnwW6skUxl448P9upXXI0UFjtERYhoe6wbPQQ6dlE90U4C+WuxzEsTxT3nokWE/zm7 epx33noAxcQXpzsqXB6Sjzc7mLe8Aq495HlAPU4BmM9E4fzsHFsCOh/HYsuP24xZo9kPpB3 POGgLhYGfHSotxdawjuZg== X-UI-Out-Filterresults: notjunk:1;V03:K0:Qsl6msnG2d4=:+PBlDlC0opVABD+OC95r5P A9t9K+SjB86YNcjStuN2XBBGYlBe3LJ7t0CWHvc98G0Hzp78Q+TTsUsvTQpenJa8qOoDXPhd3 tDvPVBf8p4E+efoAbemK3GLJ+7jlpkcz9rniBsuCPSS8cJwC5Cse6uADP1+NdWw7p7Cyt3MUJ eJ40caEmDvGWsLgyU0rhzw0AXPxw0ReqnV/KBrTwid09Q6vqxv/cSLZfwJCsb31IQA2aJmFXZ np7tFfuGkKISmGijjlOVM7x1ofEUQ22C087ndY2hUQhBUT4rGU84wFzs9USvYSRZu7xATHx73 MMLSLx7eha/TK6mwwgw4KoITuDy5TjQ9uRCQGVbLuzuTYiIlrRRp1Xfhs37ya3kIoVL4mnHYd q7A2nwqm5y0cvWRAB8HJihLi3WeZshxKbffnj0ujkBn3h71mAFf/6NNLIm1sLJ6JwAKL9Egxj 12bpZ+EkugJph3W5YBETtOqWDc32ZH3CYvcRyf0l9msfaYpaNY84qS+0fmDHk4jD/KOHeAbe7 pB9sip8/RifG9fko/EEHz/zDqYZaLtBgyquWQw+MqKT+ecal03TByLcNwyAQr356mWFT1a3nw /2gZMODQW7PYhLOiFPLuNaIoPZn7eJ5OhNVLLttOJ4C2co9uNTJZgC5DKpXxjy52jacJF02i7 S4jSQ5yhLvjGBTbDVpwoAvmaBtUAaVWagFcYgiiCFVUryJkDuK9ijdIyYuhUqKNX8zQEPdF7o YYGxoe9QfW98E16jrEuslB6ugpxCLi1NpVG9ivjIjxruv7A5gUXjkLL+aznU582Ug8LXeAwOA mbNsFSj 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Helge Deller The xtensa platform has a value of 0x10 for PROT_SEM. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20220924114501.21767-2-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/syscall_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 85b0f33e91d7..1e3577bfa56f 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1246,7 +1246,7 @@ struct target_winsize { #include "termbits.h" -#if defined(TARGET_MIPS) +#if defined(TARGET_MIPS) || defined(TARGET_XTENSA) #define TARGET_PROT_SEM 0x10 #else #define TARGET_PROT_SEM 0x08 From patchwork Wed Sep 28 08:14:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12991900 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 46165C32771 for ; Wed, 28 Sep 2022 09:13:34 +0000 (UTC) Received: from localhost ([::1]:54676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odT8H-0006gm-9H for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 05:13:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE9-0008At-Nb for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:33 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:60023) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE6-0008BG-N4 for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:32 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MqJZl-1p0Su34AuR-00nOlN; Wed, 28 Sep 2022 10:15:29 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 19/38] linux-user: Add proper strace format strings for getdents()/getdents64() Date: Wed, 28 Sep 2022 10:14:58 +0200 Message-Id: <20220928081517.734954-20-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:sXmInNDon6rnMD6euxiqvLJ6kYD94o+sswb+DUaGQTDIb1MMEOt JhsdfVPX6+Jrz073mdr0C4FaZiC8YLjKL5fU3c96ZELkCzlBZvWdjkXD7XfgE4P6qWreDx9 sScQdX+TKVgxheLO6XnXNX2edH78pNYlp++Ouep8SqXYlljROsgGhbIbCnTgT5uTjNEYVJl 1T+537/DUWiTZx5wgFfnQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:jXBCI8GC7Zc=:NwfyhB7p9GQjxxBmsSFwDI VkeF1w4yLdZnDRK3+nuJN6zlBJCFWX2FPkyRuEE0gxJtoLCzqM9dotWZwixT9KYnOe8j/fQB4 cCZX5y6G13TOR9e84sseeRTtx8BXJGrFhoD0e15M7reN1HWgbT/ecBfhF765tLZVQxT4ZQ6eZ 3CoM1v+yfdAq+a3SHLs45O2X3L4cba69OaFcVHGk4hyeOz4can+bot8HfYJyh3mV1n7QUaKn/ 6T59JLKGXjygiAn7qeA7/87scyFhDbOOH5NvZHA4GtD2ycCeMaMzzmtkairke6xG+vGeSq6vI mO3FJ3Kt3MmccfJiydr2hr4G5vH4uWJKyBDgK9cnZ8mdMqV9XXE8pkLJ/pbyrmKymYQons2ZL FmZirYImWRfjVJ5Fx/pM9sarsJlwVjhBVXNOCT/xtE2XBniLjlCiJQYfRrbC+5regSLvZsZsS n17Cl5sTU6QvrFGioEwceWqh6/BWGABxltM3uV/iE6sTY8PV0Anbpj+mR0t4jvcFIEPXybxTg JNRYb6ZDY7YzvLMpgwX7OegTfiQFZa9jkuXBSCtLseDBlqo9mpx0PnyPCKlnP+ry/3jlvGTr8 Bat6k1t/jGLaXLr3edKF2bPPWoRhhZroYHrS/exk6gal1s9i7kTk0VDsO9YfXB6uMXUWwDVrJ mji30eSyGqgnXvOeH/OmVaDU6YxQ80sK36YvTw5y739bI1Nh6XqfBoApijQs0w08YOag5pktw Bpo3tF5iRcXqAdBorObDBhqTb1tUYqNcTXRwaCbLgDY6sfrzVHJv8mlFJMdOCuNPgc3FDOVin sFawEXN 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" From: Helge Deller Signed-off-by: Helge Deller Message-Id: <20220924114501.21767-3-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/strace.list | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/strace.list b/linux-user/strace.list index c6f748505a9e..f8a771b4f256 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -279,10 +279,10 @@ { TARGET_NR_getcwd, "getcwd" , "%s(%p,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_getdents -{ TARGET_NR_getdents, "getdents" , NULL, NULL, NULL }, +{ TARGET_NR_getdents, "getdents" , "%s(%d,%p,%u)", NULL, NULL }, #endif #ifdef TARGET_NR_getdents64 -{ TARGET_NR_getdents64, "getdents64" , NULL, NULL, NULL }, +{ TARGET_NR_getdents64, "getdents64" , "%s(%d,%p,%u)", NULL, NULL }, #endif #ifdef TARGET_NR_getdomainname { TARGET_NR_getdomainname, "getdomainname" , NULL, NULL, NULL }, From patchwork Wed Sep 28 08:14:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992059 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 45C1BC04A95 for ; Wed, 28 Sep 2022 10:30:12 +0000 (UTC) Received: from localhost ([::1]:50924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUKQ-00026z-T0 for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:30:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEB-0008Dt-OD for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:35 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:40249) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE7-0008BU-6J for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:35 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MX0Xf-1okSWO1gmv-00XOLj; Wed, 28 Sep 2022 10:15:29 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 20/38] linux-user/hppa: Add signal trampoline for hppa target Date: Wed, 28 Sep 2022 10:14:59 +0200 Message-Id: <20220928081517.734954-21-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:GaeCOCjD/AgaZYVitv0iVioUDyII3FBeivX6t5fPpyBc0kZ2HoM OBVxB3oOgiCO/cBi1L3mfkv4tqv/wpO2X/RWNM+hP9d7JQmS24dqOpm6XBZ1la3/skjvf6J d57GrojWzjVzWf9PxL8jG/pHMiYKN5DtzzA2VtvWGd2bUqdc81ZMLGLHTYcgmAULmDUu6IJ jUi6SyPFxMisjDiz/ov1g== X-UI-Out-Filterresults: notjunk:1;V03:K0:Vy6AQ3iG8rk=:8RUSUDZtmEt+/i3sS9M/B3 hItpSpVNV0C52/AfoMPMvCrUpHiU9SEMnRbNJOlqLRUuXJlBWnwN+TttrPd0hW4p8QcTsCjz4 ZhDUH6WdvAL+DS8YUnW4EgaL4Zq5QbA1A5zkyJAe42tbTuXz0fYTYJbcrwAFMG5PYBNhk4WbK 442iuKeaHjHp4P1Pp+l9tS+Z/C800GgvOvDNVzwyZlTnaSoIJwPCgCpGZCl4nUNdDo724R6Sa 8L+2mr7cScH5UQnfXlv0lLc5M2wcEp1VZZy+AlFjFBM2pFolG9aYRHR6bqs2vGxlVogyrnl8v kHusi8f/6Jtw8e22w2fQQyTC1cf/LIu7se231qaSSJvjGggCTnZZ3A2AO8wkSjJ90BQKYIdPy W4w0mOYmrzsVw52XtJuC3In0DRfqImpsvf56GoAulsRNkrqyBgSPmWEPGo5PRz7JpfEr5ae6F d7/TGR5f5XfRRr+10wihFX9WBHineVoHvFBQJr+rOowFbJ9+mCFkc6up7T2KvhCHA28X9BFnx COV9K+6hAUJKmf3xPv8z8kl+dPW5tvZAjtbjdMn41fFpIm+LGZpTEL2sXB/ePlxrfelgmR3BB ym5Z5G490X2IiwcHkgHw3aHwrvyXZKda/mA83TR8zp0z/YoAvC3V/dylpqmGvw4MFWe2BV11y 8wzA5fztOvuk7aWYCEr0W54Jg3cdKfY32L0BGu2C/xt3ZXYXwjD0asB6r8mPgHBwK8JP8VORq YfrCF6/8LIgvJwCGv0bZl7A53pwAf6P51ZZl8LxaZUCBTH7WXIxFfsbzuORm+a1RP1eNeVced kRe7uA2 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_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Helge Deller In Linux kernel v5.18 the vDSO for signal trampoline was added. This code mimiks the bare minimum of this vDSO and thus avoids that the parisc emulation needs executable stacks. Signed-off-by: Helge Deller Message-Id: <20220924114501.21767-4-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/hppa/signal.c | 41 +++++++++++++++++++++++++-------- linux-user/hppa/target_signal.h | 14 +---------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/linux-user/hppa/signal.c b/linux-user/hppa/signal.c index 962f551c0429..396e310dc92d 100644 --- a/linux-user/hppa/signal.c +++ b/linux-user/hppa/signal.c @@ -41,7 +41,7 @@ struct target_ucontext { }; struct target_rt_sigframe { - abi_uint tramp[9]; + abi_uint tramp[2]; /* syscall restart return address */ target_siginfo_t info; struct target_ucontext uc; /* hidden location of upper halves of pa2.0 64-bit gregs */ @@ -101,9 +101,15 @@ static void restore_sigcontext(CPUArchState *env, struct target_sigcontext *sc) __get_user(env->cr[CR_SAR], &sc->sc_sar); } -/* No, this doesn't look right, but it's copied straight from the kernel. */ +#if TARGET_ABI_BITS == 32 +#define SIGFRAME 64 +#define FUNCTIONCALLFRAME 48 +#else +#define SIGFRAME 128 +#define FUNCTIONCALLFRAME 96 +#endif #define PARISC_RT_SIGFRAME_SIZE32 \ - ((sizeof(struct target_rt_sigframe) + 48 + 64) & -64) + ((sizeof(struct target_rt_sigframe) + FUNCTIONCALLFRAME + SIGFRAME) & -SIGFRAME) void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, @@ -118,7 +124,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if ((ka->sa_flags & TARGET_SA_ONSTACK) && !sas_ss_flags(sp)) { sp = (ts->sigaltstack_used.ss_sp + 0x7f) & ~0x3f; } - frame_addr = QEMU_ALIGN_UP(sp, 64); + frame_addr = QEMU_ALIGN_UP(sp, SIGFRAME); sp = frame_addr + PARISC_RT_SIGFRAME_SIZE32; trace_user_setup_rt_frame(env, frame_addr); @@ -139,14 +145,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, setup_sigcontext(&frame->uc.tuc_mcontext, env); - __put_user(0x34190000, frame->tramp + 0); /* ldi 0,%r25 */ - __put_user(0x3414015a, frame->tramp + 1); /* ldi __NR_rt_sigreturn,%r20 */ - __put_user(0xe4008200, frame->tramp + 2); /* be,l 0x100(%sr2,%r0) */ - __put_user(0x08000240, frame->tramp + 3); /* nop */ - unlock_user_struct(frame, frame_addr, 1); - env->gr[2] = h2g(frame->tramp); + env->gr[2] = default_rt_sigreturn; env->gr[30] = sp; env->gr[26] = sig; env->gr[25] = h2g(&frame->info); @@ -197,3 +198,23 @@ long do_rt_sigreturn(CPUArchState *env) force_sig(TARGET_SIGSEGV); return -QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 6*4, 0); + abi_ulong SIGFRAME_CONTEXT_REGS32; + assert(tramp != NULL); + + SIGFRAME_CONTEXT_REGS32 = offsetof(struct target_rt_sigframe, uc.tuc_mcontext); + SIGFRAME_CONTEXT_REGS32 -= PARISC_RT_SIGFRAME_SIZE32; + + __put_user(SIGFRAME_CONTEXT_REGS32, tramp + 0); + __put_user(0x08000240, tramp + 1); /* nop - b/c dwarf2 unwind routines */ + __put_user(0x34190000, tramp + 2); /* ldi 0, %r25 (in_syscall=0) */ + __put_user(0x3414015a, tramp + 3); /* ldi __NR_rt_sigreturn, %r20 */ + __put_user(0xe4008200, tramp + 4); /* ble 0x100(%sr2, %r0) */ + __put_user(0x08000240, tramp + 5); /* nop */ + + default_rt_sigreturn = (sigtramp_page + 8) | 3; + unlock_user(tramp, sigtramp_page, 6*4); +} diff --git a/linux-user/hppa/target_signal.h b/linux-user/hppa/target_signal.h index af6c2fce589d..190bb3d653b6 100644 --- a/linux-user/hppa/target_signal.h +++ b/linux-user/hppa/target_signal.h @@ -70,18 +70,6 @@ typedef struct target_sigaltstack { /* mask for all SS_xxx flags */ #define TARGET_SS_FLAG_BITS TARGET_SS_AUTODISARM -/* - * We cannot use a bare sigtramp page for hppa-linux. - * - * Unlike other guests where we use the instructions at PC to validate - * an offset from SP, the hppa libgcc signal frame fallback unwinding uses - * the PC address itself to find the frame. This is due to the fact that - * the hppa grows the stack upward, and the frame is of unknown size. - * - * TODO: We should be able to use a VDSO to address this, by providing - * proper unwind info for the sigtramp code, at which point the fallback - * unwinder will not be used. - */ -#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 #endif /* HPPA_TARGET_SIGNAL_H */ From patchwork Wed Sep 28 08:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992078 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 D4E22C32771 for ; Wed, 28 Sep 2022 10:39:40 +0000 (UTC) Received: from localhost ([::1]:46080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUTb-0000IZ-W8 for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:39:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEB-0008Dy-Sq for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:36 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:42077) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE8-0008Bd-Sp for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:35 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MStOy-1oo19j3Sjm-00UNPI; Wed, 28 Sep 2022 10:15:30 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 21/38] linux-user/hppa: Drop stack guard page on hppa target Date: Wed, 28 Sep 2022 10:15:00 +0200 Message-Id: <20220928081517.734954-22-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:euHLl19iOYvKmUCvMz0eajucwc3v6x+I35FArQEj2SjwRAWfp66 OEOD0To1/24U2UvrNQIVtQ9VVs7EwCik/n15/Sy4VJzZagK2CVdLjHJBi8qjfg4Cs5SO5jG 4u0LQGpctzeNYlczUMPX3lAK3BpLMSghYsrdBltBaqwu+1CV/RSou/HuH78hzzJnQl/5vnn xhE9cjXQdkra9oKgRoZ3g== X-UI-Out-Filterresults: notjunk:1;V03:K0:G+B8hQ9LEK4=:YbHwHhWE52jQW2ksw/gY4Z vK1kykm2nweZXJk7xa2SEHj/u2BW6xO68mhuTkbCw/wxMEvWd87oEEo1qAibii76h1KS7hpS3 EeYF4TmmowLCIReF2CGAnfc8Kx1OCwvFESyofFG+XWZKCYkLzc5n68wfYTCPhUmxDhTRacoxB FC23Q83oW/ZqWX/HCYtOaLURVHNe9UR1bIxOfffJsxwRBd4udcvVOz4VSNv2DFolT0fWHeJPW RP/IcH0nnFoFwbJzM3Ex9lHaj+BMJ0Zc3w8EV20xBhvp36ha+kuePzLF7rpuHsJw5CRAloyr1 gn0IIe72LWVWUCdqF2no6KZ85QDJ1l8f4LXc/9NCI+y9laM33vpVo2NUUj2nOgL3buJRwS/5O plthQPHv6rFyX8kaFfuLZsPk2gPXBkCg3O9YiLmnNZM4I7SHWE6ffR7EvE1SkArEzp7CTLL5M eRCGucINSlJd2Jwn5uVzjn0Usm2NeDFMlAp2u37sqv9R7Zatg76yzU817rzdCrPVYinMRTLLJ qgNfxYHl/W/iq54aHiK0AoToqH8UBmt/caB/g7vNpnamkoJoxQbJj0K1XTnjwItx6EKT166Bl uV88srrR/MWc1gvFVS27u9cMbbLpmvZLoLa97SKJ1UZPG5FV2MOzl0E/V19G5SxS31wjQkXq4 anv8LDzx8FbLDfu75OnzSytnKW8edICh28MFvLPMhCocxdotkNw7Wn77fY76/mvDs6M7e6cuY xc8q8wg3AqQuel+s8bBvEAJFt4oYwHi/i2ib+lzOSkcc0Qe5LDWN/cEuinGZYn2DYmcC7ntzd c63IPVj 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_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Helge Deller The stack-overflow check when building the "grep" debian package fails on the debian hppa target. Reason is, that the guard page at the top of the stack (which is added by qemu) prevents the fault handler in the grep program to properly detect the stack overflow. The Linux kernel on a physical machine doesn't install a guard page either, so drop it and as such fix the build of "grep". Signed-off-by: Helge Deller Message-Id: <20220924114501.21767-5-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index ba5c4c02e591..c7e3f1d47c16 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2096,9 +2096,15 @@ static abi_ulong setup_arg_pages(struct linux_binprm *bprm, if (size < STACK_LOWER_LIMIT) { size = STACK_LOWER_LIMIT; } - guard = TARGET_PAGE_SIZE; - if (guard < qemu_real_host_page_size()) { - guard = qemu_real_host_page_size(); + + if (STACK_GROWS_DOWN) { + guard = TARGET_PAGE_SIZE; + if (guard < qemu_real_host_page_size()) { + guard = qemu_real_host_page_size(); + } + } else { + /* no guard page for hppa target where stack grows upwards. */ + guard = 0; } prot = PROT_READ | PROT_WRITE; @@ -2118,7 +2124,6 @@ static abi_ulong setup_arg_pages(struct linux_binprm *bprm, info->stack_limit = error + guard; return info->stack_limit + size - sizeof(void *); } else { - target_mprotect(error + size, guard, PROT_NONE); info->stack_limit = error + size; return error; } From patchwork Wed Sep 28 08:15:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992158 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 38576C04A95 for ; Wed, 28 Sep 2022 11:15:06 +0000 (UTC) Received: from localhost ([::1]:47306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odV1t-00005r-4B for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 07:15:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEL-0008F9-Kd for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:52 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:36997) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE9-0008C2-GU for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:40 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mj831-1p7aS70z2b-00f72d; Wed, 28 Sep 2022 10:15:30 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 22/38] linux-user/hppa: Increase guest stack size to 80MB for hppa target Date: Wed, 28 Sep 2022 10:15:01 +0200 Message-Id: <20220928081517.734954-23-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:rCfBcpTyTiThp8DfZDdpolMLOUPn1kzmakqplpIIZwNb6BFxQq5 rrLlfsYlt6WiXyTxFe7BpiCSngYYiYTILckya/4KuTtu2tdx2o+P4StKAzctPkClCjiupT5 WY0+SaaqznJmAv71YfvpOuHNTyr+PEFQ0J7429AA4hLrKN+cUZnKxIpZFu9ajzpMv5zNeu9 XLomPDjAI/OcAe2aurxEA== X-UI-Out-Filterresults: notjunk:1;V03:K0:o8x4gOWl6is=:F756uigWoaOQ8fP0io85W2 BiutCNTBtN9J87t8M3pwB89FGAOlWaRf273siHvKCN8sINOvm8R3bCokwkwy5SxK+4C+gap1K kNPnfuOE27IGC5Y/WNJ78A7PeKbOMEllG4Xjerp2182dPAris0d0r05aytUR9KJBXKuxMUz3z eN24FUIqd4Uf+snpF9CjN4yCM+e12FNzFxiLFcElUpody6TOJgQSpOhM0zgUS1L+Ai2oxa37j +V9I3F/+GYpGg0yoHlNoGjRf7XsMI0Wb4ksOfIUYAOPKl7YDTsnlWbTnn8ZGeYeywz51yt5Gf vVzgdZgfftTW0PQLRLQP5ygWeT5qDwDtg4Pw+ZQVJIB2GuYj7J1/VBN63zpuKnJNfu1MwNsRc Uj5ki39ORsKLaVQFDWQwnZZxkxSanqXOOCX/KV+RcGXJH3a5SlGwLktHDxxg7uOmbsXUZRszY eWH/OkCaIesFQZSF0/1l6oR5I4SA7b3oEru6+D1TqmVhtJf80CXXtFJOjF8VqQVOUjULU7leR 3umB1VgslxJmdITeJeDFHM8pjVH4sA2qgoPmbfh2aXXPIWJRpgJuJoHYOHEObf4YeGmIvSTjM hYxJ3X4g/fNWmBCZhtflioiuF9kdYy50lfoZyxiq8tbl+caLFjr4dGku93nW/JaapGEX2KYpG gG1gknFMIWjvJxtYxot1TTmKHOVZMEcaF6diRRsFYVu5Yu7rKj6VQE6dRic9d4zumor5E3/G7 STJoovJ0LpjrqFlzDqvqR5VhTPFNbboLLDu5bWIbrnQhGVRCc9H0facs1riwEeiMy51pkILi0 Vct1t+3 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Helge Deller The hppa target requires a much bigger stack than many other targets, and the Linux kernel allocates 80 MB by default for it. This patch increases the guest stack for hppa to 80MB, and prevents that this default stack size gets reduced by a lower stack limit on the host. Since the stack grows upwards on hppa, the stack_limit value marks the upper boundary of the stack. Fix the output of /proc/self/maps (in the guest) to show the [stack] marker on the correct memory area. Signed-off-by: Helge Deller Message-Id: <20220924114501.21767-6-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/hppa/target_syscall.h | 2 ++ linux-user/main.c | 9 +++++++-- linux-user/syscall.c | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/linux-user/hppa/target_syscall.h b/linux-user/hppa/target_syscall.h index 4b382c1fcf4a..9a8f8ca62817 100644 --- a/linux-user/hppa/target_syscall.h +++ b/linux-user/hppa/target_syscall.h @@ -26,4 +26,6 @@ struct target_pt_regs { #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 +#define TARGET_DEFAULT_STACK_SIZE 80 * 1024 * 1024UL + #endif /* HPPA_TARGET_SYSCALL_H */ diff --git a/linux-user/main.c b/linux-user/main.c index e44bdb17b853..88fccfe26149 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -124,10 +124,14 @@ static void usage(int exitcode); static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX; const char *qemu_uname_release; +#if !defined(TARGET_DEFAULT_STACK_SIZE) /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so we allocate a bigger stack. Need a better solution, for example by remapping the process stack directly at the right place */ -unsigned long guest_stack_size = 8 * 1024 * 1024UL; +#define TARGET_DEFAULT_STACK_SIZE 8 * 1024 * 1024UL +#endif + +unsigned long guest_stack_size = TARGET_DEFAULT_STACK_SIZE; /***********************************************************/ /* Helper routines for implementing atomic operations. */ @@ -668,7 +672,8 @@ int main(int argc, char **argv, char **envp) struct rlimit lim; if (getrlimit(RLIMIT_STACK, &lim) == 0 && lim.rlim_cur != RLIM_INFINITY - && lim.rlim_cur == (target_long)lim.rlim_cur) { + && lim.rlim_cur == (target_long)lim.rlim_cur + && lim.rlim_cur > guest_stack_size) { guest_stack_size = lim.rlim_cur; } } diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 850410c9b553..f87b36b2491f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8036,7 +8036,11 @@ static int open_self_maps(CPUArchState *cpu_env, int fd) continue; } +#ifdef TARGET_HPPA + if (h2g(max) == ts->info->stack_limit) { +#else if (h2g(min) == ts->info->stack_limit) { +#endif path = "[stack]"; } else { path = e->path; From patchwork Wed Sep 28 08:15:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12991936 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 11D28C32771 for ; Wed, 28 Sep 2022 09:22:50 +0000 (UTC) Received: from localhost ([::1]:44344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odTHE-0004Mt-0E for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 05:22:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEC-0008E1-0d for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:36 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:37057) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE9-0008CJ-Fx for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:35 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MbSXf-1pFH1H2lOD-00bqJf; Wed, 28 Sep 2022 10:15:30 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 23/38] linux-user/hppa: Allow PROT_GROWSUP and PROT_GROWSDOWN in mprotect() Date: Wed, 28 Sep 2022 10:15:02 +0200 Message-Id: <20220928081517.734954-24-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:wIbD77KY6GC0KPfnUEfMvSRwnFhWJwtVnFQfMHZMzrDGHL7QD3e ppZ5l/YPBPp6OFqG1GxuQCWJOPQl0OxAIAiiy2ptZgOz8AF32NoFBVsao6Tx/3vyc/AJ34j yp+K8hI3zllFwf3FqZ4M0yIP/iZzyCOY9O1zpACGP6Ld0ycO3cWYReA6cHSR6tF5TqPwJNj 3eNHu/uaoh8mNlyrg6o+g== X-UI-Out-Filterresults: notjunk:1;V03:K0:tegVOXc4dTk=:sKn+h2bZzOiXlqC0pIlorx zzvTHYmN3bw/7I8jeYjymuLhnlmMGwXTH5Wi/C8uBbw3Be4qHAwBD7hmtuBOFyrcVhgm+CbUC HCqYHy/P2KmUJu6mldKR08lmGR/jlQte2ldHuLKRcfGpU61tlrVQ5XmSZ73qMyBrVytGtOcfl kaGS9QXpXni+0qY+l507VHrTTYwOrPucPs4u9hQZ8Q1HLTy5L+cdwny5HuD5/JaZ6VQgbKMX2 ovNIyA7vzM87cqut8KlBhX+vZTiAWvPCAVvxoiHur8VJoU6gIJ3b9NyZv81k9OWk0LMpD0C/4 E54GkwUpJyo3pzSMdkGXfTKriGEALN8yE2HheTrogIi3wUGKfwa0GlTPF2inCVnXio+FmPEay +LNEbpB7bETXdSd/IVazQ/wf5qYElEwAHKnL7q8L4sRNuMzl283puypd2BzhuGfHRXQmKBkxu 0hLcTrAk2dsGVCPfo9Nv/C2yp/4ta5zm56ZzY81ovmtK6U7x6Z/GI2+sofMbz+FeXZHJlof8R f+D51IE1yEIspi+0TAR+GOdh5deyzSfVKkAmImwtOK2y6pTdUT2GbuMhfgmR1aOGnpF25ZbxL 67sDXLZwx8PjwonTqR0ypi9bf6nfuU4N15J4hu0r0075qTWDMLgcEBI5aMLkm+5omCEpABZys 38720Jv5i0BgiepGtvvw+UQoOcQlORM0rq+GzBT3jX/ZPNTeXjfRY0Rm52VRsT93CaaY4jMvh WMV818MXic0WI9/kSpO+GuJi181lwfFAGIiVA02aisJulZhuflYbL609An0NxzHoyfEX/zlA8 dUhwOxB 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" From: Helge Deller The hppa platform uses an upwards-growing stack and required in Linux kernels < 5.18 an executable stack for signal processing. For that some executables and libraries are marked to have an executable stack, for which glibc uses the mprotect() syscall to mark the stack like this: mprotect(xfa000000,4096,PROT_EXEC|PROT_READ|PROT_WRITE|PROT_GROWSUP). Currently qemu will return -TARGET_EINVAL for this syscall because of the checks in validate_prot_to_pageflags(), which doesn't allow the PROT_GROWSUP or PROT_GROWSDOWN flags and thus triggers this error in the guest: error while loading shared libraries: libc.so.6: cannot enable executable stack as shared object requires: Invalid argument Allow mprotect() to handle both flags and thus fix the guest. The glibc tst-execstack testcase can be used to reproduce the issue. Signed-off-by: Helge Deller Message-Id: <20220924114501.21767-7-deller@gmx.de> [lvivier: s/elif TARGET_HPPA/elif defined(TARGET_HPPA)/] Signed-off-by: Laurent Vivier --- linux-user/mmap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index e557f3626e5d..28f3bc85ed45 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -106,6 +106,8 @@ static int validate_prot_to_pageflags(int *host_prot, int prot) page_flags |= PAGE_MTE; } } +#elif defined(TARGET_HPPA) + valid |= PROT_GROWSDOWN | PROT_GROWSUP; #endif return prot & ~valid ? 0 : page_flags; From patchwork Wed Sep 28 08:15:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992147 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 02E2CC6FA82 for ; Wed, 28 Sep 2022 11:08:59 +0000 (UTC) Received: from localhost ([::1]:34336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUvy-0002UP-Mx for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 07:08:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSED-0008EN-8x for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:43 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:33237) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSE9-0008CT-GY for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:37 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mo7if-1p2fpQ0ZD9-00pbgn; Wed, 28 Sep 2022 10:15:31 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 24/38] linux-user/hppa: Fix setup_sigcontext() Date: Wed, 28 Sep 2022 10:15:03 +0200 Message-Id: <20220928081517.734954-25-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:nyvb0xlTfKgSrLZh0sNx/EtoZdcMLg70Ejf8AFpKn0fcZoepwzG Cf5V0S1BLW1tL4q6fWy8Xfys0RjpDaxWetPa4RgwdbqYsE5R0fU2qvFG0xhi/JhrpVXucrL LA9ombmSQDFT1QGmUjYyT9s3aE7PnpzVgYNl8eee9Hp5olcLGSJxcPSzJDAb11SR96Xkt+y BP5sd+bOpNqvD1LKifeOQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:wyqlZvSCPu4=:nnmB46SSLUAfGsYL7XVoH5 M9vIwEDRo12jYvcgnWBOMsQs6hLJriYysAoIQUWZgXMdCyQWhF/VmE4UdI9uSlhMjpb56F7k/ h9MlmJsyFtjsbAGdFifBHYFSnJlYZFihA8BXwSozDWW45GPvJGfVpjbINvdSj4GIwZK0kPi17 6mbcgYeHZIFAtxjmoH3jTfTbGddlrRWy4zfS0wezswSyWowmg5PhEATkcP6kfajH9bgpSKicD u1hA1bOx3vIzCnxo1k8ta6rHESCohTa/yTfFhPstXVA/Lx9vSRlQrs85SJR6HABuEgXmvwjhR CE9bnssq6U65bWYQ9RkG0x1rVO/KV+9c+HPFBd2guRBEgUKDlhbUt+y+L++DvJRgwjkunN6LY bUrQMxd5qjre2p1GW7XqNLeXxnSrmY0lXyh5ADiKSidOBazZ4UXumvaYXi5n1xPfSosNmVXDa zAa5pOQvRkIdq6CHlQwCXyUaX9m4pwlnzZBNgB+6ecE58si6WAkgsrKPPIjmM+94iyvNVuqcF PR0N+v5+R4QcIBkYHnHN/yqLfTvUf4RH4HsRrhl0TIn94xVwzEoSIVpnY86K+tbPJCB4iWUxQ 5U7rbNimbA4ARzKhX3WLa7qTXJbA9h5+vD+wk5a8vQR0cA4F3MfNS1taCgEDXDitvvl9iZtSP 2WJNIq8RFYSxYSgWgb1789gJIMltoUYJAEODxlTsVOspvQ7EZkrAx3lTc/A8kLJ5fK5INJFfC iTYmzLGqi1w2a6vmuZ7biXmTEW8DNdXKEmr26EduvLx0bvBTf9QckE719UBjQWCiCiwflKSRY 8lCeI/7 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_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Helge Deller We don't emulate a preemptive kernel on this level, and the hppa architecture doesn't allow context switches on the gateway page. So we always have to return to sc_iaoq[] and not to gr[31]. This fixes the remaining random segfaults which still occured. Signed-off-by: Helge Deller Message-Id: <20220924114501.21767-8-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/hppa/signal.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/linux-user/hppa/signal.c b/linux-user/hppa/signal.c index 396e310dc92d..f253a1586461 100644 --- a/linux-user/hppa/signal.c +++ b/linux-user/hppa/signal.c @@ -49,23 +49,13 @@ struct target_rt_sigframe { static void setup_sigcontext(struct target_sigcontext *sc, CPUArchState *env) { - int flags = 0; int i; - /* ??? if on_sig_stack, flags |= 1 (PARISC_SC_FLAG_ONSTACK). */ - - if (env->iaoq_f < TARGET_PAGE_SIZE) { - /* In the gateway page, executing a syscall. */ - flags |= 2; /* PARISC_SC_FLAG_IN_SYSCALL */ - __put_user(env->gr[31], &sc->sc_iaoq[0]); - __put_user(env->gr[31] + 4, &sc->sc_iaoq[1]); - } else { - __put_user(env->iaoq_f, &sc->sc_iaoq[0]); - __put_user(env->iaoq_b, &sc->sc_iaoq[1]); - } + __put_user(env->iaoq_f, &sc->sc_iaoq[0]); + __put_user(env->iaoq_b, &sc->sc_iaoq[1]); __put_user(0, &sc->sc_iasq[0]); __put_user(0, &sc->sc_iasq[1]); - __put_user(flags, &sc->sc_flags); + __put_user(0, &sc->sc_flags); __put_user(cpu_hppa_get_psw(env), &sc->sc_gr[0]); for (i = 1; i < 32; ++i) { From patchwork Wed Sep 28 08:15:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992133 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 D59BBC32771 for ; Wed, 28 Sep 2022 11:02:29 +0000 (UTC) Received: from localhost ([::1]:38896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUpg-0006TY-RQ for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 07:02:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEP-0008Fc-Ff for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:53 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:56369) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEL-0008Im-DQ for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:48 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MmU5P-1p4IeQ3qOP-00iT4t; Wed, 28 Sep 2022 10:15:32 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: fanwenjie , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Laurent Vivier Subject: [PULL 25/38] linux-user: fix bug about missing signum convert of sigqueue Date: Wed, 28 Sep 2022 10:15:04 +0200 Message-Id: <20220928081517.734954-26-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:xfvhM1OdIVIPyXA9xQgjjSyHfK115+hH9/1qYPCGkYdqoiRwPw5 Nt3wLyuni8ACsXkvkEC0Wrv9V6DApKsb2h4erFll5u0FNrpWfvJzTLSQpqNjrlj4k0ZaE+W lA8Ih3O6hnIClEhBCGzYFAZA4PTSJhhU2wMA48UQsEyLIEnqH1kPV5BxoZEGTJFhEJjRDkG kYEpkx9/A9HMKKtiZYv2w== X-UI-Out-Filterresults: notjunk:1;V03:K0:GDh9JVtQKAE=:1qSnC0cGO8KtqPqvHKQCGw TlRKkH2iUSlWIoMcuQsSlwiH47e0tCuDwHawWwf0tWNg1LCllVw9k7wGORGGGKidWC55T8CBd wLzv5mH3jdgteqbVBdLBEuLNoU9F6lF3l8AADuEE/RoJnwA4/U3RfrUM8nvddKzZ9R4tfDoFn QY4KZu3h2ZbdvYWMLT029kwpDgHmLKidf+KzIzj5NArMYNSL2Lk6Qjr9t/LGW4YskTy6t4dBD BFM1a5ess0xQoUr9ZKx7wmD9gn7aqGxyzQGQW/AI1PaDInLcpTe9zYMhPALV8s4r/qyK0VeJY 8lyLlFsm8/qLhn+U8jVA81ZF+kqQEfr0QqsSxypyMgVBy5s3/MedPosC43Ch9Roi0chpnaM92 MFRIKcn8DLMFgWHWel9Lf+UhYczlNNk4EvB1CbpU3jE5KXFcp4Ok0fg8/Ok8W4VT8sedLxoBD 9zNL8TP/VU345GARCW+DkErLRQu4gG1wxlpjcRp4G/tUQFLrrFw0iHnG9oLT8nlSz6GAkos8j K4JfaT0/TZFNuFY81c8xb45twe3txIAT4isQImSQuWKRtE5Y3D/mcumSQf8b1ZFSXXf45cGZ2 LsVcEEPI+vCCdIFYw453gzuR6GdKeQZHQd7ld82XRrSktEYrh4aV1RCVKvPphFc5or3sSDB0E 1O7Ak1NaYjutT7sdLbx6I10bSJSEgKITAUgu3pDDHRHiDEcLYTSauCKHO47zU6vDGqMYG3j4d q82XCTx+BGxIQQVHut3QRnnyVkKbLWGynbaEoYq35FyqV+4Xv/DHUyC3S1mv7qVA1bnaUNDXO cclvHDB 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" From: fanwenjie Fixes: 66fb9763af ("basic signal handling") Fixes: cf8b8bfc50 ("linux-user: add support for rt_tgsigqueueinfo() system call") Signed-off-by: fanwenjie Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f87b36b2491f..54b29f3b406a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9728,7 +9728,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, } target_to_host_siginfo(&uinfo, p); unlock_user(p, arg3, 0); - ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo)); + ret = get_errno(sys_rt_sigqueueinfo(arg1, target_to_host_signal(arg2), &uinfo)); } return ret; case TARGET_NR_rt_tgsigqueueinfo: @@ -9741,7 +9741,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, } target_to_host_siginfo(&uinfo, p); unlock_user(p, arg4, 0); - ret = get_errno(sys_rt_tgsigqueueinfo(arg1, arg2, arg3, &uinfo)); + ret = get_errno(sys_rt_tgsigqueueinfo(arg1, arg2, target_to_host_signal(arg3), &uinfo)); } return ret; #ifdef TARGET_NR_sigreturn From patchwork Wed Sep 28 08:15:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992081 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 7D3B7C32771 for ; Wed, 28 Sep 2022 10:43:31 +0000 (UTC) Received: from localhost ([::1]:52618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUXK-0005rG-Ht for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:43:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEL-0008FB-LE for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:52 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:41871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEB-0008DW-9H for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:40 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MysBI-1pQcdi1kPK-00vxKq; Wed, 28 Sep 2022 10:15:32 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Peter Maydell , Jon Alduan , Laurent Vivier Subject: [PULL 26/38] linux-user: Don't assume 0 is not a valid host timer_t value Date: Wed, 28 Sep 2022 10:15:05 +0200 Message-Id: <20220928081517.734954-27-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Tu/uklV94njT6bMi4+dmALEcFTu6CJq4x+cZNxI9FMT0RZ4r46k rPq2QIgpiy/CprG3R4Dc3e7s4a9tc4k01LyI1WWZ+WPIAIJunFwgJmizwG4JI1de8DJ4m0R 7CJ0pgt9FZi0gYj+c3ZGglgye5ovz2++1SGm/xnEINsJ43HQgtR3BvaXTFMIXm8fKSzcJh8 gp4NiOMwLW8gvqT/+dcBg== X-UI-Out-Filterresults: notjunk:1;V03:K0:B7Ln73FCUJg=:UquRtFbzNcH084GCd/yZU9 ONL5HeM86e1zfUzQfWq16QrYhoxrp5CyCyOR21rINTY5PH/3Z3yRQp45CJU6tmfcdqu7zEqLt PVtf2ufvRZ4dD8Y043lwMBFYFTgs2gRSWlnFSW9yjRQbglWyrxiFsZa+TOAUAGQeGUUZMvQdd TrgMDIFu8z4AeRd6Kfh/EzA7BQr5sJ3zgBqn765kbFVhL4hai4clEhj85GGChqabnxSeB5E6U 4HAACsGLzIyaizx5pL7bhc4pVqayRQKfnodzBbEKBuThu1qsYlQ+O7v6cTc+7Ll+0Jgx4mGEr 3nus7L5pzwzEj/153jjsVjXRD4abkr2Tslz3Q45kcRn+7MLTTseUm+eHEUQbu/Vz+GxZkZ1PS kB1ov6G2E/oNif4tnctcFWxlf3dbs1qZa2Ec5wZs2FFKE2SQlDzlLgRbrgpaoYVEH6ieacgYF BZb9HFhLxWLBTPfJUpYrq0EmcQzZkVqKvD1m1ds3IiifEsxLpTTgkshLNX/IijIjAA6vxs2cV 0Ps7GoJH4Mv9hsSHwEDUYMVlHc0u27nvfUfKWRR8ExyUuVno7PpxMqZDRAW4OjiXpT6E3EIz9 y3eiFtokEroB/CzS/eIdtRtM13Hh4Sp379Ran2uvaKTXfXh26+qNbtqTJ+sPPMoAEzFIiLPd0 +MpzMgyM9b5PEbiR4HCymDNzmqjVYBhmFJXspoV7yJQbx79K9US88PF4Z1k5KRInp5pARPwmN K/1TPcBOLqgdL1duOP7Pa8gL+ybiRDC0ueTxe+TLbG984ZeH/PRgArUPBQ8b+F7MtXAWw/ZSQ fpJRgyy 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_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell For handling guest POSIX timers, we currently use an array g_posix_timers[], whose entries are a host timer_t value, or 0 for "this slot is unused". When the guest calls the timer_create syscall we look through the array for a slot containing 0, and use that for the new timer. This scheme assumes that host timer_t values can never be zero. This is unfortunately not a valid assumption -- for some host libc versions, timer_t values are simply indexes starting at 0. When using this kind of host libc, the effect is that the first and second timers end up sharing a slot, and so when the guest tries to operate on the first timer it changes the second timer instead. Rework the timer allocation code, so that: * the 'slot in use' indication uses a separate array from the host timer_t array * we grab the free slot atomically, to avoid races when multiple threads call timer_create simultaneously * releasing an allocated slot is abstracted out into a new free_host_timer_slot() function called in the correct places This fixes: * problems on hosts where timer_t 0 is valid * the FIXME in next_free_host_timer() about locking * bugs in the error paths in timer_create where we forgot to release the slot we grabbed, or forgot to free the host timer Reported-by: Jon Alduan Signed-off-by: Peter Maydell Message-Id: <20220725110035.1273441-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 54b29f3b406a..e0e0f058121f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -525,20 +525,25 @@ _syscall4(int, sys_prlimit64, pid_t, pid, int, resource, #if defined(TARGET_NR_timer_create) /* Maximum of 32 active POSIX timers allowed at any one time. */ -static timer_t g_posix_timers[32] = { 0, } ; +#define GUEST_TIMER_MAX 32 +static timer_t g_posix_timers[GUEST_TIMER_MAX]; +static int g_posix_timer_allocated[GUEST_TIMER_MAX]; static inline int next_free_host_timer(void) { - int k ; - /* FIXME: Does finding the next free slot require a lock? */ - for (k = 0; k < ARRAY_SIZE(g_posix_timers); k++) { - if (g_posix_timers[k] == 0) { - g_posix_timers[k] = (timer_t) 1; + int k; + for (k = 0; k < ARRAY_SIZE(g_posix_timer_allocated); k++) { + if (qatomic_xchg(g_posix_timer_allocated + k, 1) == 0) { return k; } } return -1; } + +static inline void free_host_timer_slot(int id) +{ + qatomic_store_release(g_posix_timer_allocated + id, 0); +} #endif static inline int host_to_target_errno(int host_errno) @@ -12896,15 +12901,18 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, phost_sevp = &host_sevp; ret = target_to_host_sigevent(phost_sevp, arg2); if (ret != 0) { + free_host_timer_slot(timer_index); return ret; } } ret = get_errno(timer_create(clkid, phost_sevp, phtimer)); if (ret) { - phtimer = NULL; + free_host_timer_slot(timer_index); } else { if (put_user(TIMER_MAGIC | timer_index, arg3, target_timer_t)) { + timer_delete(*phtimer); + free_host_timer_slot(timer_index); return -TARGET_EFAULT; } } @@ -13040,7 +13048,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, } else { timer_t htimer = g_posix_timers[timerid]; ret = get_errno(timer_delete(htimer)); - g_posix_timers[timerid] = 0; + free_host_timer_slot(timerid); } return ret; } From patchwork Wed Sep 28 08:15:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992019 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 B70C5C32771 for ; Wed, 28 Sep 2022 09:48:33 +0000 (UTC) Received: from localhost ([::1]:34804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odTg8-0005cn-Lz for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 05:48:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEL-0008FD-MV for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:52 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:43097) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSED-0008Fi-8E for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:40 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1My3Mv-1pS0kd47ix-00zXJ7; Wed, 28 Sep 2022 10:15:33 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Richard Henderson , Laurent Vivier Subject: [PULL 27/38] linux-user/s390x: Save/restore fpc when handling a signal Date: Wed, 28 Sep 2022 10:15:06 +0200 Message-Id: <20220928081517.734954-28-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:VJd4pE/Ez6uezQQ+HpdqZ5HrIVflV/cv2HmUc81oPrQSt3bipm+ fzf5j3boPCwccRFLFzXsb6ns3tG2NLOk9hotq+7ta183uZBcsAAHdemndK1ANgeBgZ8wtAG VY6Y/PRXpQnVCCcCtNDdn9yR2Vr4wDam3HtX2My8E/tFc7pJ3CIx6sfE5GqPdOH0i234WwY FdiOjLwmxt3PxJIQMgcxg== X-UI-Out-Filterresults: notjunk:1;V03:K0:+2afVwXsjaA=:Kky4eThTtiYveYlDOFOPf4 6Z8hpYusPzjGHUn7SjaH9rXDFpcHHDX2uy6p0ykBNR+3SLcbdXV2h/r2WN/4rGy+sfskJWxb0 aSzCauxTbcQoSc3/vJ1655bHMYUDjg1b3fxl+jPO1Y3mhFGexJLSVl9kLq8V0cDJSp3dONzyf d2GAqMZWRPg0dyoP/yLwyNURJxw8lNEF/OUolF3TD4rdRaR6L7CMF+CvY2td8K5NOlOSjKElF fdef7geu7A77hwUKRU+U8U/5hWRI6O+LD9F/Ro7hqN8wunBgirm9K0RPDapZFIyLBfsC0Jrtj 2rFI0Yp2YCnuBB6NTpCGN9q7IHsQN3UpY9xfPadNb8zdY2lLEAhQeN6kS+/i85WY4xcHDqKeD d6JglbnoFsflfnCV6B6UN9xrt0+HWPTcbg/XMs1Ej217yZvjBi2BtLALFC5DYG79E1tQE2jpM 4gCXzSFpvCNTs0QPVZtKcwmPuFcQvtpfTB9nd4e3lHmkpFfaC6uB8/BKpDa37PHmCf7+Rr5IY LgOLg5j/keLLYZoxpCucXO+CFpzfCLBuquTzOqBMxCPk/KUxGiJhGDZTzrpOwX6jVe2AR3E1V NXDm7OQqRGWX5wIoOjIYTDvPj7PTmQxk7TlB55X29MvvLycyVgVtAAnTEV5A0apKYtE3wvlNA LhEk9+FUNbMwqgAQlLCFU7SinuCSC7Hgesxd+H+VjivY8OwHMrwShUeHnejkKsZR+Swsi+wwA onKcMMfKq5CAnupD5cdj8aNsgWbauxEOk+c9YHxOrIbr8x/Ja2LI/hJEnlYB+RRP5nyu/qIWP +7RmSWJ 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" From: Ilya Leoshkevich Linux kernel does this in fpregs_store() and fpregs_load(), so qemu-user should do this as well. Found by running valgrind's none/tests/s390x/test_sig. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson Message-Id: <20220817123902.585623-1-iii@linux.ibm.com> Signed-off-by: Laurent Vivier --- linux-user/s390x/signal.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c index 4979c4b01791..f72165576f3b 100644 --- a/linux-user/s390x/signal.c +++ b/linux-user/s390x/signal.c @@ -146,6 +146,7 @@ static void save_sigregs(CPUS390XState *env, target_sigregs *sregs) * We have to store the fp registers to current->thread.fp_regs * to merge them with the emulated registers. */ + __put_user(env->fpc, &sregs->fpregs.fpc); for (i = 0; i < 16; i++) { __put_user(*get_freg(env, i), &sregs->fpregs.fprs[i]); } @@ -331,6 +332,7 @@ static void restore_sigregs(CPUS390XState *env, target_sigregs *sc) for (i = 0; i < 16; i++) { __get_user(env->aregs[i], &sc->regs.acrs[i]); } + __get_user(env->fpc, &sc->fpregs.fpc); for (i = 0; i < 16; i++) { __get_user(*get_freg(env, i), &sc->fpregs.fprs[i]); } From patchwork Wed Sep 28 08:15:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992157 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 F1F60C32771 for ; Wed, 28 Sep 2022 11:12:29 +0000 (UTC) Received: from localhost ([::1]:44822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUzM-0004nM-3Z for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 07:12:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEP-0008Fe-Fd for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:53 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:54905) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEL-0008J8-Ch for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:48 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mofx1-1p27rg1xqz-00p3j1; Wed, 28 Sep 2022 10:15:33 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Laurent Vivier Subject: [PULL 28/38] linux-user: Introduce stubs for ELF AT_BASE_PLATFORM Date: Wed, 28 Sep 2022 10:15:07 +0200 Message-Id: <20220928081517.734954-29-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:N0S3xXSTIDeZfn9No4xWPGxR/hrYXhxMVLCj4gRZKt3SQ9FyIh5 FhLLYp142oW+VLB9PwTgliAaFkZDIF0/BZ2wTNAiF2L5UE/MPUysW/jz0TJrudiaJPuPwtM 7CnFhG8BUkA1n6LA7aHeDfrJWFowc8yGZdfEY5KzdOZvV3Px/AZK3PAyy9uV4oekEIWiEJZ XVBbaPCwyA2RHh3ES57Gw== X-UI-Out-Filterresults: notjunk:1;V03:K0:3k46NX3P7OM=:2CMm0x4Aorm0x1h6AM9cQS lko5GLIW5LmsEdhJ2bEv6sqCXVkoeUVbFG5pUYEQ+L8ITH+hZJsjeGp5YqmwnniROGcu5Zb3F 7S/xwOnOzcu1Jqet7ZW+Gz0YStAQwiwYwdsdvcF5910/Kom4wO/a3Mk+syDJ6EAmUsNFOIUbo 46mFgf96FSoIcMEfV89AWKaxeunva4Yx2zOas2iZC1JvGTswPm1W5dLwB1x/saAQmkM+4Qrut cky94gtaEitin7g7FHxz93nWgyTYiTdIjSFwdca4rdGKRP4xfCScbaCPBM9m1TAZsZlO7VXL/ 3C2GEhJLPoFS+a+9z5PLS7hgizy0GNYhVgRiu/EgVEUaeTsnuvAjB0YnpNys2QXzNIBIrZObY S8yHyfsP5M/wDEjk9kNMpJjTl85enKsw6eRTMb5EdOz3JpXtxBEF8sBL5iU8M6rX07w1Xm0HL EXRBDsONEzy/FvNkQ8DTLAUd4SoTLuUBdpY20a1dS4r0mB9BB5joShIccV0CQO5rplTpgV62Q 5evAj+aW5jt9Yato/3gVVK5MKtY9Qr7KBlHjUCPwpPp/VKbn7dCcHtNMyaM18YSXDKWmsex99 f9ZNQ9ZhQDC6YmerC3IbNgQBfxj6PETp/P/jmqgjaST3LNqBozKiMyVt8flmTqqQw9q9f1oU1 s6rDnpgjp8yYX+t8s1P2UwBBPGidX0by1FAIB27MLxrGHsOP2cHVzwxD08UM9YJ195kwDgl+M ROoH8aUvqHntNyUXWjM5ZHHjBvWga8qXezkOmgMQEU/nn9b5bzH6kK/U0nibnXOv9r9B3amNn eaD5xo8 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" From: Jiaxun Yang AT_BASE_PLATFORM is a elf auxiliary vector pointing to a string to pass some architecture information. See getauxval(3) man-page. Signed-off-by: Jiaxun Yang Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20220803103009.95972-2-jiaxun.yang@flygoat.com> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index c7e3f1d47c16..581fbc858b48 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1776,6 +1776,10 @@ static inline void init_thread(struct target_pt_regs *regs, #endif /* TARGET_HEXAGON */ +#ifndef ELF_BASE_PLATFORM +#define ELF_BASE_PLATFORM (NULL) +#endif + #ifndef ELF_PLATFORM #define ELF_PLATFORM (NULL) #endif @@ -2220,8 +2224,8 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, int i; abi_ulong u_rand_bytes; uint8_t k_rand_bytes[16]; - abi_ulong u_platform; - const char *k_platform; + abi_ulong u_platform, u_base_platform; + const char *k_platform, *k_base_platform; const int n = sizeof(elf_addr_t); sp = p; @@ -2243,6 +2247,22 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, } } + u_base_platform = 0; + k_base_platform = ELF_BASE_PLATFORM; + if (k_base_platform) { + size_t len = strlen(k_base_platform) + 1; + if (STACK_GROWS_DOWN) { + sp -= (len + n - 1) & ~(n - 1); + u_base_platform = sp; + /* FIXME - check return value of memcpy_to_target() for failure */ + memcpy_to_target(sp, k_base_platform, len); + } else { + memcpy_to_target(sp, k_base_platform, len); + u_base_platform = sp; + sp += len + 1; + } + } + u_platform = 0; k_platform = ELF_PLATFORM; if (k_platform) { @@ -2284,6 +2304,8 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, } size = (DLINFO_ITEMS + 1) * 2; + if (k_base_platform) + size += 2; if (k_platform) size += 2; #ifdef DLINFO_ARCH_ITEMS @@ -2361,6 +2383,9 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, NEW_AUX_ENT(AT_HWCAP2, (abi_ulong) ELF_HWCAP2); #endif + if (u_base_platform) { + NEW_AUX_ENT(AT_BASE_PLATFORM, u_base_platform); + } if (u_platform) { NEW_AUX_ENT(AT_PLATFORM, u_platform); } From patchwork Wed Sep 28 08:15:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992163 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 5D240C32771 for ; Wed, 28 Sep 2022 11:24:43 +0000 (UTC) Received: from localhost ([::1]:57042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odVBC-0003BU-Fu for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 07:24:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEP-0008Fd-Fo for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:53 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:48621) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEL-0008IW-Cf for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:48 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mo7if-1p2fpW3vKN-00pbgn; Wed, 28 Sep 2022 10:15:34 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Laurent Vivier Subject: [PULL 29/38] linux-user: Set ELF_BASE_PLATFORM for MIPS Date: Wed, 28 Sep 2022 10:15:08 +0200 Message-Id: <20220928081517.734954-30-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:lgaKoIHZWxB3rJzYbmezEhyHyNWXd6l8BaSBVeYOgmv5e6/q8Ar 0LQK1smlGwOwhcTYFq3sP9wX8wUw9//5SXcBxXAYyRKXEf7FB2Rui8szaHAv99OqlDADohd oiCLuxtVIAx/sGpSTWkMivt5hKQyOSH8iRA6mRA3T8VTY007qY1sPfejRW6ddhVUOm9XDfK moEXUCb7x/l6bHZvJjzEg== X-UI-Out-Filterresults: notjunk:1;V03:K0:GXWJgHAUvxQ=:IFIYVTMyry6I0lQjud6HQl cWvWMZuZkJttnBEd148gc43wwGo3PWbSnl5a3usSlGRpOqu8upPzHLjmM1o0Vfu2Jlo8hh/4I uq9XUzHihsc0Lhsnqslvr6pBsiWUHJad9suc8Sx66n1m9Qaa2SIHOtsORuBGSW76VIOGtZD9i XKgEZ6MiCfX+LvMFMWgchXsxXGJUuF1VvJod3ieBsYMRLnVQD5eZ9W/ZkyhOpx2JIMe7RY6p7 JCfKZoo7nwKWc9CxJzxot11KBwm7sIqphqTKbG0zVrLRVI9jQrpo7XcOOmhFkdB0F0PoTR4xF ebCDYJbrt76uYZ+sHBk+P3v+Uhn2r+ABjNS8jr+2uZurv+6cJ66wljYE9sjGS30orQ7LnH/M9 le6AI9/E/lKj1WNaYs+S4rWsf58YDIeQgPhvW3FclhYgbsw5GSTjqbBGhmGT/PD5vFqDPc3Sc od1+gcUdGPBb1Q+VhY74ZoG95P732qEE0uiHmcfGVXUxv6RnHxwM53twCi9Xg/0Vza/YIOw6Y W0JTI4QwxWJ/4hvd8fYHwhYW9q4EgOdJmRJRYswqxmn7VHWyGgKTXn+QJ8wZZp8+f8l1C0l1l 7JS6HLuP5c1v9SR9mq3Fs4fsZg6p3z4JgODbi5B1+DrUjMH5UdvJfqpTPeekM3z5GWoo7DSfi FpM48m5pgkTXGfbm/MFehLhsYeYgEIL8skTOIIztt4c6Bd3Ifhebb/Q31FYgJMFpoyoe+63VJ ZpKHsA120SZvQWgPp6a28VD++Oa1Urpe3KcRJWIezG5Ib8n9Pj493zNf0ZNYUwigWr9EZZtl2 +vDaP3g 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" From: Jiaxun Yang Match most appropriate base platform string based on insn_flags. Logic is aligned with aligned with set_isa() from arch/mips/kernel/cpu-probe.c in Linux kernel. Signed-off-by: Jiaxun Yang Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20220803103009.95972-3-jiaxun.yang@flygoat.com> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 581fbc858b48..20894b633f58 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1080,6 +1080,37 @@ static uint32_t get_elf_hwcap(void) #define elf_check_abi(x) (!((x) & EF_MIPS_ABI2)) #endif +#define ELF_BASE_PLATFORM get_elf_base_platform() + +#define MATCH_PLATFORM_INSN(_flags, _base_platform) \ + do { if ((cpu->env.insn_flags & (_flags)) == _flags) \ + { return _base_platform; } } while (0) + +static const char *get_elf_base_platform(void) +{ + MIPSCPU *cpu = MIPS_CPU(thread_cpu); + + /* 64 bit ISAs goes first */ + MATCH_PLATFORM_INSN(CPU_MIPS64R6, "mips64r6"); + MATCH_PLATFORM_INSN(CPU_MIPS64R5, "mips64r5"); + MATCH_PLATFORM_INSN(CPU_MIPS64R2, "mips64r2"); + MATCH_PLATFORM_INSN(CPU_MIPS64R1, "mips64"); + MATCH_PLATFORM_INSN(CPU_MIPS5, "mips5"); + MATCH_PLATFORM_INSN(CPU_MIPS4, "mips4"); + MATCH_PLATFORM_INSN(CPU_MIPS3, "mips3"); + + /* 32 bit ISAs */ + MATCH_PLATFORM_INSN(CPU_MIPS32R6, "mips32r6"); + MATCH_PLATFORM_INSN(CPU_MIPS32R5, "mips32r5"); + MATCH_PLATFORM_INSN(CPU_MIPS32R2, "mips32r2"); + MATCH_PLATFORM_INSN(CPU_MIPS32R1, "mips32"); + MATCH_PLATFORM_INSN(CPU_MIPS2, "mips2"); + + /* Fallback */ + return "mips"; +} +#undef MATCH_PLATFORM_INSN + static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) { From patchwork Wed Sep 28 08:15:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12991995 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 C4923C6FA82 for ; Wed, 28 Sep 2022 09:39:12 +0000 (UTC) Received: from localhost ([::1]:58866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odTX5-0007jq-CJ for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 05:39:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEI-0008Ef-8a for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:48 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:48711) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEC-0008Eq-Fj for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:38 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MHnZQ-1oPl6e1TNu-00EspI; Wed, 28 Sep 2022 10:15:34 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 30/38] linux-user: Combine do_futex and do_futex_time64 Date: Wed, 28 Sep 2022 10:15:09 +0200 Message-Id: <20220928081517.734954-31-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:SamJiBJS15wz51R/KWLWvc/jxcfEH2F6VLID+yWqWPvWdsSzIEw HGfejNoJvTaq1ExzrUF4kMO24kb9lsa/IGYjAYSk6h4WTkRuUw7xoBx3uqrZOstwdXgAkFn VCy3FWkNNlXJK6XG5NQrwu2/8bZj7aDO9vAghMWFfXrMjrKZ1kiLeEiNeWXGySMYQPpW2Js NxxEXI7qQQXNGiYVfg16w== X-UI-Out-Filterresults: notjunk:1;V03:K0:WtBhKx43KF0=:8BsGNwnM35D+lT0Utjiz3C NzLxxK4SDGduF48NrDbi3Mo4IdBOqzHQerRAvPKSlPYyqcolwLEfNMDP0ZqPm2rPmGyi9W3bx n7bWETMZKkcv4EpHj1JiwdhZ9r18Et9iUPSHEez7ixEObtbFRcE6hN2bokle5zgHd4NCKduIV 7uQtQTmRSjqoJQRimxOtLrHaA73C9rJPS6hOlEAHApszvx5VKXscwEav/1wOyQFKJ0k1Ehwy+ fccxyelPV5ywtr1gUg7M4fIbkpjAzD/DF1PdiWevo5AzYYPfBVVkrkfJdwlOCDT1OrdgLTe11 LYe84iqlcaiyYKAOWjMmRfC37HLN+48ENz8bqZRew35iCaiIpeLtzRgaIR627ZDzkNaArrcG3 DVnm6db6gGGS6gjQeY4/V+1KvcyL5Owu5evAGCxZwp2mz9ilSJOA9B2dz1AAfzelw/eESju/e 9wpD+jISg8a+qLwZ/dlou6SaPH4oxUh4o05FIQTBMivUfX5I2QNCjuDAHWKD2kA01rfn0S4Oy CAN7RVltNu7QRxO6O0K5GcsQ6mYcgrdD4PTTWx5K1sTGIJmfkWLQFGRnYXl/MyqrODSbKYMqB TOvP4WUylgp19TK8LDvEbOZL7VOb0pRzQz76mY/tXADzcRNDFFZd6VA6ECxUdUivmR6r5b5T0 iH/g/W2eaIHO7dOTl9ybo0IWomxKfQUJMUn2lJ0HXkAnr2AKo4LgJM1AYr/yhqWQ6jymLA/l/ htR09ST7zeCbEGqmCU3n52MaGVF1IL75jWRd/6cP8P9fpa4S9eX3ypsngWk6kDfGHt/7PW+JV re8fLiK 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_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Pass a boolean to select between time32 and time64. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220829021006.67305-2-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 67 ++++++++------------------------------------ 1 file changed, 11 insertions(+), 56 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e0e0f058121f..af3a605fc458 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7768,9 +7768,10 @@ static int do_safe_futex(int *uaddr, int op, int val, futexes locally would make futexes shared between multiple processes tricky. However they're probably useless because guest atomic operations won't work either. */ -#if defined(TARGET_NR_futex) -static int do_futex(CPUState *cpu, target_ulong uaddr, int op, int val, - target_ulong timeout, target_ulong uaddr2, int val3) +#if defined(TARGET_NR_futex) || defined(TARGET_NR_futex_time64) +static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, + int op, int val, target_ulong timeout, + target_ulong uaddr2, int val3) { struct timespec ts, *pts; int base_op; @@ -7787,7 +7788,11 @@ static int do_futex(CPUState *cpu, target_ulong uaddr, int op, int val, case FUTEX_WAIT_BITSET: if (timeout) { pts = &ts; - target_to_host_timespec(pts, timeout); + if (time64 + ? target_to_host_timespec64(pts, timeout) + : target_to_host_timespec(pts, timeout)) { + return -TARGET_EFAULT; + } } else { pts = NULL; } @@ -7817,56 +7822,6 @@ static int do_futex(CPUState *cpu, target_ulong uaddr, int op, int val, } #endif -#if defined(TARGET_NR_futex_time64) -static int do_futex_time64(CPUState *cpu, target_ulong uaddr, int op, - int val, target_ulong timeout, - target_ulong uaddr2, int val3) -{ - struct timespec ts, *pts; - int base_op; - - /* ??? We assume FUTEX_* constants are the same on both host - and target. */ -#ifdef FUTEX_CMD_MASK - base_op = op & FUTEX_CMD_MASK; -#else - base_op = op; -#endif - switch (base_op) { - case FUTEX_WAIT: - case FUTEX_WAIT_BITSET: - if (timeout) { - pts = &ts; - if (target_to_host_timespec64(pts, timeout)) { - return -TARGET_EFAULT; - } - } else { - pts = NULL; - } - return do_safe_futex(g2h(cpu, uaddr), op, - tswap32(val), pts, NULL, val3); - case FUTEX_WAKE: - return do_safe_futex(g2h(cpu, uaddr), op, val, NULL, NULL, 0); - case FUTEX_FD: - return do_safe_futex(g2h(cpu, uaddr), op, val, NULL, NULL, 0); - case FUTEX_REQUEUE: - case FUTEX_CMP_REQUEUE: - case FUTEX_WAKE_OP: - /* For FUTEX_REQUEUE, FUTEX_CMP_REQUEUE, and FUTEX_WAKE_OP, the - TIMEOUT parameter is interpreted as a uint32_t by the kernel. - But the prototype takes a `struct timespec *'; insert casts - to satisfy the compiler. We do not need to tswap TIMEOUT - since it's not compared to guest memory. */ - pts = (struct timespec *)(uintptr_t) timeout; - return do_safe_futex(g2h(cpu, uaddr), op, val, pts, g2h(cpu, uaddr2), - (base_op == FUTEX_CMP_REQUEUE - ? tswap32(val3) : val3)); - default: - return -TARGET_ENOSYS; - } -} -#endif - #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) static abi_long do_name_to_handle_at(abi_long dirfd, abi_long pathname, abi_long handle, abi_long mount_id, @@ -12372,11 +12327,11 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_futex case TARGET_NR_futex: - return do_futex(cpu, arg1, arg2, arg3, arg4, arg5, arg6); + return do_futex(cpu, false, arg1, arg2, arg3, arg4, arg5, arg6); #endif #ifdef TARGET_NR_futex_time64 case TARGET_NR_futex_time64: - return do_futex_time64(cpu, arg1, arg2, arg3, arg4, arg5, arg6); + return do_futex(cpu, true, arg1, arg2, arg3, arg4, arg5, arg6); #endif #ifdef CONFIG_INOTIFY #if defined(TARGET_NR_inotify_init) From patchwork Wed Sep 28 08:15:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992099 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 55791C32771 for ; Wed, 28 Sep 2022 10:56:34 +0000 (UTC) Received: from localhost ([::1]:35064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUjx-0000aQ-C9 for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:56:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEL-0008F5-Db for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:52 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:35471) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEC-0008FJ-Q7 for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:38 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MF418-1oSVzy3Jnc-00FRrG; Wed, 28 Sep 2022 10:15:34 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 31/38] linux-user: Sink call to do_safe_futex Date: Wed, 28 Sep 2022 10:15:10 +0200 Message-Id: <20220928081517.734954-32-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:F2vojFSJ83+rfnQq3MwZKPVeQRr+iDu/USOxEHslPkX5PQFRTxP Fmj5oKbjRd7TpUvXjxbGGwKr8TBbUei0onF0B7oBoCPMZrRgliI0JQuh8+t/I8zs9LIb7jx 3VDsfze5KTAPcrxQBnYxVrXrjlWQhsVv+Yz9/xZGJLcaXc0F3HXmL0DlmlT54n8NodiVhG0 VMkayuYT1bl5OJhPTU8cg== X-UI-Out-Filterresults: notjunk:1;V03:K0:GEbEnmnfBrc=:EEquTR23/HKaLJyx9YCf2/ a4bTXfKB2uIyXCEr7pR4IQEP8Oeewy7w/GSwXDPW+ZHbsHuSBdL8abqv2+C+j+saGCzD3YlIC mkSQoP5KUQmUYckhlQcsx3lBZDupACsG2Zypmo9+HcKOyG71apiUI5pxVZm5/khP7bPHBn8Ny q4rErxxPRATX3O1X3Wr6itwmG/Ml/qTcEYzm4RMkcQ9FqjZSSdKHXWKeW47BLRyWN50QRBe2r lo9Yg6vEbfP2Tna9apCg93Cp3haBgOooSlW7OCsML13oBKgUQJqdsyzDpTJatvVpMq9nW3Fzu kBp6HIb/99VNfCsGod3eu52FL93LmrCUEl7E29vMN+BtzYXTw3B2QmDo3ioppCVfHE8xefVQc AzP1pmkDHtPR3JIJLCn999da94b1jJLjL1t5+hFCrunRoCMaLo+B4aQ43GFURSn79NWxCaY+A Bgn5TOiadGivCqxzjmkuIIua3dfUjWRyZbi8Rl03hdjhOAMntIPCIihlxd5K3OPs7+bqOsdW3 b/Ge8MSPcqWPmlMNOKZnv0NWaWCZZ7QJb9gWfNKgThNZDdLdNaTdptde6Fi4cm/im40fR3jla 7CJxBD489ZRXAQ3XcZCFbPdkA4bQx4YRX+e+7VWXIb+rpBTDOOW3BopciZgdwo0XmNolPzZpr B3C/mkXwPwmASOTAVbYG3GOI0bf6waaGp5lN0WCrQBrq6fI24i+nI9lQgWZYLgi4xIBfJ428o So3PbIK+WZwbHgUBhNy5IuS1bDcps90Obwm0N1vQvE1GKiIYoasWsWvn2zwwuKY0CIkIhjwKh m2TLNfT 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" From: Richard Henderson Leave only the argument adjustments within the shift, and sink the actual syscall to the end. Sink the timespec conversion as well, as there will be more users. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220829021006.67305-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 60 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index af3a605fc458..17e17f480456 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7773,11 +7773,11 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, int op, int val, target_ulong timeout, target_ulong uaddr2, int val3) { - struct timespec ts, *pts; + struct timespec ts, *pts = NULL; + void *haddr2 = NULL; int base_op; - /* ??? We assume FUTEX_* constants are the same on both host - and target. */ + /* We assume FUTEX_* constants are the same on both host and target. */ #ifdef FUTEX_CMD_MASK base_op = op & FUTEX_CMD_MASK; #else @@ -7786,39 +7786,41 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, switch (base_op) { case FUTEX_WAIT: case FUTEX_WAIT_BITSET: - if (timeout) { - pts = &ts; - if (time64 - ? target_to_host_timespec64(pts, timeout) - : target_to_host_timespec(pts, timeout)) { - return -TARGET_EFAULT; - } - } else { - pts = NULL; - } - return do_safe_futex(g2h(cpu, uaddr), - op, tswap32(val), pts, NULL, val3); + val = tswap32(val); + break; case FUTEX_WAKE: - return do_safe_futex(g2h(cpu, uaddr), - op, val, NULL, NULL, 0); + timeout = 0; + break; case FUTEX_FD: - return do_safe_futex(g2h(cpu, uaddr), - op, val, NULL, NULL, 0); - case FUTEX_REQUEUE: + timeout = 0; + break; case FUTEX_CMP_REQUEUE: + val3 = tswap32(val3); + /* fall through */ + case FUTEX_REQUEUE: case FUTEX_WAKE_OP: - /* For FUTEX_REQUEUE, FUTEX_CMP_REQUEUE, and FUTEX_WAKE_OP, the - TIMEOUT parameter is interpreted as a uint32_t by the kernel. - But the prototype takes a `struct timespec *'; insert casts - to satisfy the compiler. We do not need to tswap TIMEOUT - since it's not compared to guest memory. */ - pts = (struct timespec *)(uintptr_t) timeout; - return do_safe_futex(g2h(cpu, uaddr), op, val, pts, g2h(cpu, uaddr2), - (base_op == FUTEX_CMP_REQUEUE - ? tswap32(val3) : val3)); + /* + * For these, the 4th argument is not TIMEOUT, but VAL2. + * But the prototype of do_safe_futex takes a pointer, so + * insert casts to satisfy the compiler. We do not need + * to tswap VAL2 since it's not compared to guest memory. + */ + pts = (struct timespec *)(uintptr_t)timeout; + timeout = 0; + haddr2 = g2h(cpu, uaddr2); + break; default: return -TARGET_ENOSYS; } + if (timeout) { + pts = &ts; + if (time64 + ? target_to_host_timespec64(pts, timeout) + : target_to_host_timespec(pts, timeout)) { + return -TARGET_EFAULT; + } + } + return do_safe_futex(g2h(cpu, uaddr), op, val, pts, haddr2, val3); } #endif From patchwork Wed Sep 28 08:15:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992090 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 3A690C32771 for ; Wed, 28 Sep 2022 10:50:20 +0000 (UTC) Received: from localhost ([::1]:45030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUdv-00038u-7K for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:50:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEL-0008FC-M0 for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:52 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:60275) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSED-0008Fe-HP for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:40 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MiZof-1p88Po0xmB-00ff0P; Wed, 28 Sep 2022 10:15:35 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 32/38] linux-user: Implement FUTEX_WAKE_BITSET Date: Wed, 28 Sep 2022 10:15:11 +0200 Message-Id: <20220928081517.734954-33-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:NpZNtQbKCA1kTY97l8yx3W+Jmt0aNr87dA16Lk07ICBAGSvJ94t uSYpo5hQcaSbwW+qHoka07z97/ccXvc+iJI2+i6V438mW8nwiRWrS4x0T0JbfXKxbGIRa8Z O9LtG7PvgQuxebxmOtLw48IH4rrjwNo/JLmM4WtEIiBJ0NbwGhlbEvyrnKz/+wpUm0EfvlS guBL+LpOd8qZ3k0MnAhLw== X-UI-Out-Filterresults: notjunk:1;V03:K0:HeA2M+Tmnx4=:TdDxkzPfdFE44YE0EfI8Ex wUMvmnObwkCScqpQb+VqSXbEkawjCVZ2iL50OKlI5IHoHaHh6mToNhzG4RgSi2DmvoMi9zR19 ySF27To38LN6yonioF6CCleemLCvyTHk7R7pNW6zW0jH0INp5j8WY00MclvKRoiemMU5iZ3Nt 2Ecga2dSa+gCAESfzChnJ9hDDH7pEikKCpB+JWSSE69RIMIux2uayraxjyr0aGd3rswLy24q8 9A0CCKjOmfviEcSCBMb0l0L1bzt2hzOsyTomR9KMeCMkXiuxEL7WAEjkQnjIhYKh4WAuXYUPS 9qnhfs2uxuoMNqdrrE/m5U3ZOYJsWTbF+nFvMgCMmVzPF5YiAjWMtiM8xEyaizLBBVzfMqnRs F5WB8UJlXci5szVzbTHCq4w2E0WTyv8zxPZ2zeHRo5xuUQeQSgJ3cve1ZPX5OqgvywdoHUE/H kL/4EnRRNxa8DxafS8F+zyEz9l83l9r1B4mrDG2OW1M9CqTHAgQGeG5jgZ+G0jG9eje7pyhyQ OD7VvfPZTyInOPbuFjthW2U04Gt1q/25915oW7f1+i7XFWbE5+URfCd9Wmv1ZGiUCdq0Ryt3b blowzwF87EH/Xn2DeHjg8icb1tHEqJBDITc8bxTGKrFWMLddHJNv7eR1xHZp/L5qTMUEQmqy6 9lRS/SG3zMA1YwunU3rYKJunskdxMVjFKmTRaMC07gl2dGG9nMpvqsGdd8iTFciGWiqxOcR5y A2QxOREmVKj5le9blaIeaBPcEUx0WGKQjEzs12e/sCnA/AM89XVwI2yEHodm9b4bwsnR3xNiM vIWEAHj 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" From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220829021006.67305-4-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 17e17f480456..e2b6b564e6cb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7789,6 +7789,7 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, val = tswap32(val); break; case FUTEX_WAKE: + case FUTEX_WAKE_BITSET: timeout = 0; break; case FUTEX_FD: From patchwork Wed Sep 28 08:15:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992162 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 94EA1C04A95 for ; Wed, 28 Sep 2022 11:21:52 +0000 (UTC) Received: from localhost ([::1]:48540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odV8R-00060d-Lb for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 07:21:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEL-0008FA-Kk for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:52 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:54455) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEE-0008G8-Aa for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:43 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MEFCF-1oTryE2ld7-00AEFz; Wed, 28 Sep 2022 10:15:35 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 33/38] linux-user: Convert signal number for FUTEX_FD Date: Wed, 28 Sep 2022 10:15:12 +0200 Message-Id: <20220928081517.734954-34-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:3RAJaY3DtebYhEIu4IehU09BFpQeaT0lT0hcZ11RWkvrE/cQFsa wEyMBPp6rNu4hxk3Hsm/Oc1wDTOjfayGdZwIaI7I4CsjG2Kr51+uSz/80VTOCAAsEngcMEj fEmXGzyI5yd0spRz6HLsg45bmwZLjZmOe7QcUKsfKAPkH/ZMH/b3892Om7RcglDzfOK0lNS iuBSmWqGkbkhaRAhp11Jg== X-UI-Out-Filterresults: notjunk:1;V03:K0:LpcVzUnbprI=:xQnRAUpukqNi71hEwKBelt JcYzrXIJpAVr9KzFd48jtVbpVT11eqcIYGTj+XCmIuHDIlZgdTX8SJnmXMEtGt+aHv+rTrz+O PJjF4jGI45zgcs7zU+L6C8F56l+MPGOsdQkiqKZFqnyptGUwuFqdnuWjUTd+kGo1Ke/9pnQB1 cMOJ5CT6KTe4wk3YAfvsypjZLjsZBrUdpHnbtS41S5pFVsHPvQ+NJSlGVQB4L4UnAW4HsBZ6L +SZRsZYVUKOv1VAe4gT2iS3EDpMbnO0XOh9kVVxNAdvYib2mLtrZ89kK/37IfPmK742J1RjLk /HpV11j5UEf/teIR/klryrDBBl81Ec73yliCTe5loGz3Sgxz+36asK4+3pMKDFayQrC6Upjfw ny+ivHQV5mmS+ilFPSlruDxz+V3muApDl7dnKAWBCeYncf1laBypz0nCqxgEt8bT/Idrlygm0 KHCgaH2j+Hd1Mq6ZA0VO0ZWtjJqWffwFe/unJVYoGXARui7Cy11t1hUOsyEKMHPq3KhFbQ2Jq OygLRtHYkY4KrZfXLwx4dgBagJLuaATK1Ftqz506vpSuYiwU3AdNRpjTT04YRb43Q11myFEU4 B/vdNwSTNJHq1Klby2uHIoPvlQYOGdO060WU37t9ytY2vewR6Yt9er5FoY1/9dNEeH0vD8Kqa VPR3jyu0JWgn+kIGWsXqRBwbemXS8zjEpZB1bOqjMmsAjHFZuNThQKjYW1zgat8GctOld0H4W IYObqhTMb9C+rfK0pzCPETSlIFVsiJxoSRolAkk9vPmZoLdCSRmBLq8v77/93ownX+sqtis7B PHCO8KP 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_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The val argument to FUTEX_FD is a signal number. Convert to match the host, as it will be converted back when the signal is delivered. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220829021006.67305-5-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e2b6b564e6cb..3f144e3c1f5d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7793,6 +7793,7 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, timeout = 0; break; case FUTEX_FD: + val = target_to_host_signal(val); timeout = 0; break; case FUTEX_CMP_REQUEUE: From patchwork Wed Sep 28 08:15:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992038 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 45159C04A95 for ; Wed, 28 Sep 2022 09:57:33 +0000 (UTC) Received: from localhost ([::1]:51688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odToq-0003GT-3t for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 05:57:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEL-0008FE-MK for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:52 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:39337) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEE-0008G4-Ak for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:43 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mrxjf-1oyp0n0Lcj-00nwjH; Wed, 28 Sep 2022 10:15:36 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 34/38] linux-user: Implement PI futexes Date: Wed, 28 Sep 2022 10:15:13 +0200 Message-Id: <20220928081517.734954-35-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:4K+CKP9O1oEKj0MYZ5BWZFjbTXYYxV6lfFCtK1/B14hG+wbPrBA 6Le1oaOcKMted6Kg34LUoShfzbk1TvC8FZRuggEEaMXJOyLyYiKHjv3sBm9of/6qXX/QbRN DNONK5nsUpHN+sJkflElwR/r0Sa/uHSJCymwqAtv7I3TpuKd2R1EpvUWaouiANybIZw+e9b wUov5ysbGMJN8pvhUH1qw== X-UI-Out-Filterresults: notjunk:1;V03:K0:0opjmy1l9dk=:cc/gPryyzukaOuyM5fTJ61 MN4FB0s0PtCWxsLr/4tC3YMBUXq+hNC/y/Ls8aTR/6UgpCLIijbUp/R/u0cHJRJ6OYy8X1w2H 6lzihdZH+5kxfU3KiJNwUfXCVl8QoCrTJ6aVxajdClh5z5dhabqvQWq460N0SacAR9LuV3PB/ puscwuX4WXvFP7jcyzDJP0h9S1XnlHSbOcyIqgxFSXPRYq9TScwSeYkF6kPabs5cchHLPVGn4 eURoKzHHrb4LzAAC0vCkEI9w7Wgk6kdmMO/gB7XnPddc1uDsuSaiclgXCIvJpyBVM1HcLd5+V /eoQqSeRSDno/DKKCmT3F8MgTqeVI6sIFEM4UW6XtAULI6OVmAqpXJHnGaQSUVVfFf5y5ueMP 7t9d5w2DH1vShRx1yyX+2kNpVNTqlsAGvZ6KLY0bmwUqnGL2Oi3Kj4IxcDi/q60Lr3QTWjrZ1 cdvStH+b5i5WIcCqSbZbpOsA4jVe+XKBOgKzJQfh7kHc6hurFcdNkD5cI8v56Wth0UuNY1wID dzRRNrKtXTUczPMl73ypqfg++V7N0X8tsHiBxrXjNwIPZHLOn2MoHUiAr7oZlinIFXOMW3IuR TwElnZe8zvr7lsMMAcnH+qE0Piu7289QopH110RqoMhB/pSE2BDBC8fw8qQsFOVtw0yuAayuK kAOxcqbaq/pm6pIlzFfH3NIRzuhxJ2XEfj1SFSLJgiypWRFoa5sPY83Ge9sLLtgXGyLP/6Tz8 EWTXE80zZUK/XtoafrW/rGnTObrmXpdXjQTelvdWnkklmoAHUnYeYB34530qV0AONKYp2h9Xm UsGEbQ9 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_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Define the missing FUTEX_* constants in syscall_defs.h Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220829021006.67305-6-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 10 ++++++++++ linux-user/syscall_defs.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3f144e3c1f5d..2e954d8dbd9e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7788,8 +7788,17 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, case FUTEX_WAIT_BITSET: val = tswap32(val); break; + case FUTEX_WAIT_REQUEUE_PI: + val = tswap32(val); + haddr2 = g2h(cpu, uaddr2); + break; + case FUTEX_LOCK_PI: + case FUTEX_LOCK_PI2: + break; case FUTEX_WAKE: case FUTEX_WAKE_BITSET: + case FUTEX_TRYLOCK_PI: + case FUTEX_UNLOCK_PI: timeout = 0; break; case FUTEX_FD: @@ -7797,6 +7806,7 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, timeout = 0; break; case FUTEX_CMP_REQUEUE: + case FUTEX_CMP_REQUEUE_PI: val3 = tswap32(val3); /* fall through */ case FUTEX_REQUEUE: diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 1e3577bfa56f..01ee10a88fe0 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2699,6 +2699,9 @@ struct target_drm_i915_getparam { #define FUTEX_TRYLOCK_PI 8 #define FUTEX_WAIT_BITSET 9 #define FUTEX_WAKE_BITSET 10 +#define FUTEX_WAIT_REQUEUE_PI 11 +#define FUTEX_CMP_REQUEUE_PI 12 +#define FUTEX_LOCK_PI2 13 #define FUTEX_PRIVATE_FLAG 128 #define FUTEX_CLOCK_REALTIME 256 From patchwork Wed Sep 28 08:15:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992146 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 BA4ABC04A95 for ; Wed, 28 Sep 2022 11:08:16 +0000 (UTC) Received: from localhost ([::1]:59084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odUvG-000288-8e for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 07:08:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEN-0008FL-KM for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:53 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:45261) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEH-0008H3-3M for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:46 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MORR2-1osOso241W-00PvRM; Wed, 28 Sep 2022 10:15:36 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 35/38] linux-user: Update print_futex_op Date: Wed, 28 Sep 2022 10:15:14 +0200 Message-Id: <20220928081517.734954-36-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:L9lncU1G2iarxIbxOUr1tjTNU6d9JPQrW1TgMl2h/nO2Po/+4R5 vcvnvohdPQOIjTCHbPe6XbOaUBl4KZU841E0ck3Y1ezVfewZldZXaDRGPdQHaFOXJxFxw/z vV0i3bWwc+tYnkHKhhq2Y64o7+qPAnoZbWvMB7r6vOpsDGuSgqHupIfiemjTmXLS6mHpUv5 0GVmNlhJEbXb7XLQVfV0g== X-UI-Out-Filterresults: notjunk:1;V03:K0:a5EujZJU9Ws=:GX7+Fxr4zYZZxJ9GLOMtEE G6rh5BnhaD7FPkckraNPegdeanQnvGe5inOJ4p5e72yA4kvNawIgcE1OplFJlMSXcdLm+vS2T XORjdc27WLxmHgVUk83IQR6Bt3rXNtA8nO9NLp3gV+5YJHhKNhI1KpwJogMIuTM7OoWe7ShPG uuYfLerOnohxruJMT6StHlRry/89LWPhguNxKUlou70N44NaPoYMb5OFF0c1930p0vXOiR7ie 8k/C7SbbXbikDr1NTGcmAcM8p9TFKBS1+KPgIWOHyBxA4Rv6MqiFHG9cJPJ0CknspjyKOUIam QE6xhYKOAR5noj1SQxQ+dkpukn8rd1eeSeyxbeVm9evXBRfa8dfie0odHyeT9Npsrzvpz2Ecm LXXG2uQm9pHTSZf8kFN/K7KnRAKuIifKWTRMNjFrekefELdJTW0I2gBjdh/+cAGRAqnKotDvw 8UA39JgWWik2Uz0uif9C31j2jYMU9c3Ff9HNxGgAauhc6DIHvH4eqGVqm1KGyjcdgOAH9yXmK zZxLEuv35PajYzEwtaMq5m+R9u3pGCf9AeuW/YQw3JqPPMJJ2wfkP1zC/CHtLYHbo2v0UEvji HE7iwwnYE1cHbvDRpO65SZxKnYjFH2IzkLCV4Hzpj5SwGpACOizGS7ZkOqqfCRxpzSeYFQ8sR t5N1qiO9m0ZLISGIJtxB/ofiLNKBfaTw5YYMKfxQJMX34tkD8VjgypRKbQH2RsdfYjy20VHsD xnWnGYa37JEiL1z3A1dCur0erj45+me+tqAokvv0OiPGY5Umi0+0JHG9WsCl90THFlwLPejVu ckLMS9l 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Use a table for the names; print unknown values in hex, since the value contains flags. Signed-off-by: Richard Henderson Message-Id: <20220829021006.67305-7-richard.henderson@linaro.org> [lv: update print_futex() according to "linux-user: Show timespec on strace for futex()"] Signed-off-by: Laurent Vivier --- linux-user/strace.c | 70 +++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 2deb84a2c106..faa733125624 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -3710,44 +3710,37 @@ print_munmap(CPUArchState *cpu_env, const struct syscallname *name, #endif #ifdef TARGET_NR_futex -static void print_futex_op(abi_long tflag, int last) -{ -#define print_op(val) \ -if( cmd == val ) { \ - qemu_log(#val); \ - return; \ -} - - int cmd = (int)tflag; -#ifdef FUTEX_PRIVATE_FLAG - if (cmd & FUTEX_PRIVATE_FLAG) { - qemu_log("FUTEX_PRIVATE_FLAG|"); - cmd &= ~FUTEX_PRIVATE_FLAG; - } -#endif -#ifdef FUTEX_CLOCK_REALTIME - if (cmd & FUTEX_CLOCK_REALTIME) { - qemu_log("FUTEX_CLOCK_REALTIME|"); - cmd &= ~FUTEX_CLOCK_REALTIME; +static void print_futex_op(int cmd, int last) +{ + static const char * const futex_names[] = { +#define NAME(X) [X] = #X + NAME(FUTEX_WAIT), + NAME(FUTEX_WAKE), + NAME(FUTEX_FD), + NAME(FUTEX_REQUEUE), + NAME(FUTEX_CMP_REQUEUE), + NAME(FUTEX_WAKE_OP), + NAME(FUTEX_LOCK_PI), + NAME(FUTEX_UNLOCK_PI), + NAME(FUTEX_TRYLOCK_PI), + NAME(FUTEX_WAIT_BITSET), + NAME(FUTEX_WAKE_BITSET), + NAME(FUTEX_WAIT_REQUEUE_PI), + NAME(FUTEX_CMP_REQUEUE_PI), + NAME(FUTEX_LOCK_PI2), +#undef NAME + }; + + unsigned base_cmd = cmd & FUTEX_CMD_MASK; + + if (base_cmd < ARRAY_SIZE(futex_names)) { + qemu_log("%s%s%s", + (cmd & FUTEX_PRIVATE_FLAG ? "FUTEX_PRIVATE_FLAG|" : ""), + (cmd & FUTEX_CLOCK_REALTIME ? "FUTEX_CLOCK_REALTIME|" : ""), + futex_names[base_cmd]); + } else { + qemu_log("0x%x", cmd); } -#endif - print_op(FUTEX_WAIT) - print_op(FUTEX_WAKE) - print_op(FUTEX_FD) - print_op(FUTEX_REQUEUE) - print_op(FUTEX_CMP_REQUEUE) - print_op(FUTEX_WAKE_OP) - print_op(FUTEX_LOCK_PI) - print_op(FUTEX_UNLOCK_PI) - print_op(FUTEX_TRYLOCK_PI) -#ifdef FUTEX_WAIT_BITSET - print_op(FUTEX_WAIT_BITSET) -#endif -#ifdef FUTEX_WAKE_BITSET - print_op(FUTEX_WAKE_BITSET) -#endif - /* unknown values */ - qemu_log("%d", cmd); } static void @@ -3763,6 +3756,9 @@ print_futex(CPUArchState *cpu_env, const struct syscallname *name, switch (op) { case FUTEX_WAIT: case FUTEX_WAIT_BITSET: + case FUTEX_LOCK_PI: + case FUTEX_LOCK_PI2: + case FUTEX_WAIT_REQUEUE_PI: print_timespec(arg3, 0); break; default: From patchwork Wed Sep 28 08:15:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992172 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 98B23C32771 for ; Wed, 28 Sep 2022 11:29:49 +0000 (UTC) Received: from localhost ([::1]:55322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odVG8-0000NJ-N8 for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 07:29:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEP-0008Ff-HQ for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:53 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:37479) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEL-0008HH-DT for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:48 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MzhWp-1pQLn73msL-00vgUF; Wed, 28 Sep 2022 10:15:37 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 36/38] linux-user: Lock log around strace Date: Wed, 28 Sep 2022 10:15:15 +0200 Message-Id: <20220928081517.734954-37-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:TWXvrr7PU6WcMeI+mKtdiE3jbUWgER8+6r7lUgh/TAqGP5CQGs0 /T380f8LlLO0UdjOd5/cM6g3l7Fdaw+c8cDYAnZ8xuPflft+mKkxd6gghe8LjTwIjwQC8qP UZlNqZxcIbUU6f7QrwTvW4Mp7QGRnzCV5R3tp9EJpfeuLNgBsbgPHQyNlmzNsRnsYFZkeQ0 8W1B9c8gtxY8B0wnHp98Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:7c/b14zdDCg=:hx1cmdsrSQmyEgFoAKy/1a XtipXmOAeWhjj+UvOh9Za0RSOp3H2DTe8DctfTHR7Lg36RP0IWa8mdixDPprgQ4hyxgOnb00B +W18H64eQ0xic88luo/KEkzd1aXm6yb4mIIqhqbGFdJA5+JqC4Eugqk7RCVn9klAua8NTv9/9 jRiMe29VjMlGsQCu1JWt4NZ+Zbrdc0Hyo2mtoaaCD84kna0qxVhDBfxY/3SeDpZS+V2Swv9ku OChp6rsrGq/xJmIqYdZvdnwtriSuTSI0ar9oEitappPjiQpuWVltAFKaXOU8gIiJXWprYitA2 uTgCknPerbGhXb+RCwtWB3j7rQBCA9/ntXQKXtAuVFJgZDtajGyS3Eb16joANY9tQxknHifGo sY0/YihNuWu50jS5B8pPvxoZWdncDWt2lkh/YJU21LY02vmF9il98PNHThPQrTeQEig3Q0siV ZseynwsGZwbrNfQ9DiMZHLSksGY9GR96sQ/bmV3FOjeZtwbno3CrhIn4e/27D9CcqdKcOeT3q pewbbJtfakxP3Fw2z55K3od8yLMgPO7fMT/MYhwmrwScYUnmq8wq2UYK+6xC+QLWiML+ghEty vYNoRTbCDGt3ZToJip0rhRFbqPDWcgOJxx5rfqvlG1ZcbtM83dmHBle6iRXQEG67RAdJFIfwm 0ul5fFgXBBlNbjQ2aAMpR6Ic7/shTyhMJL+Zkl34SomFsyRPFTMsFgfU6FAWKAynLpq2bNZDl 2Xx+/C5nBSNG2TpdJyzqT0/yVxkG3qu/h92gGFzlGk+8y6lWfZ1Zc8oTyoim3PQKFAZqcIP1q Q36uReO 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" From: Richard Henderson Do not allow syscall arguments to be interleaved between threads. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220829021006.67305-8-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 65 ++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index faa733125624..37bc96df9bb6 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -3919,26 +3919,37 @@ print_syscall(CPUArchState *cpu_env, int num, abi_long arg4, abi_long arg5, abi_long arg6) { int i; - const char *format="%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")"; + FILE *f; + const char *format = "%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," + TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," + TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")"; - qemu_log("%d ", getpid()); + f = qemu_log_trylock(); + if (!f) { + return; + } + fprintf(f, "%d ", getpid()); - for(i=0;i X-Patchwork-Id: 12992159 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 BE705C6FA82 for ; Wed, 28 Sep 2022 11:15:31 +0000 (UTC) Received: from localhost ([::1]:34652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odV2H-0000TB-Ae for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 07:15:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEN-0008FM-OU for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:53 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:38067) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEJ-0008Ho-Gj for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:46 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MUGRh-1onBH81P8N-00RLfN; Wed, 28 Sep 2022 10:15:37 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 37/38] linux-user: Log tid for strace Date: Wed, 28 Sep 2022 10:15:16 +0200 Message-Id: <20220928081517.734954-38-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:i5ZY7Coc5Bj5XrtIawWcES17e8izESnLioTNJdl8kUcOFK+ffrM LVnVJ2fUkhZcHkEpU0ZgfCBRJggcQhdi0npW4JSZYz2dSW+A+N3Is3HZrvrBjY+mTmfB9xx Q9c3iFQpm0r6eHGqxAlsRy9g74VgTeCuuq8UxtfHULecuqZtFb62vj1J0HW3k77tOWnOvA0 n+Kfx1xYluqRXoXDvGqKg== X-UI-Out-Filterresults: notjunk:1;V03:K0:xitIvZ3Wpok=:IzuSQAShq3Q9xX//W6QnpV NpuwYNCtgTvxnJDOufjaA6c14plZev65yKJ4rtb7UHrjnAuo5JkvVvP0bqBkECtrcmXAjSAu6 Sc9eH74AQBOXye9qcIAeSqAkQu4Hs7I1ekcCb8xPBxD08PVJUUM3iJ3VgBbsGOZCumb+Rw8Bs GicAU36uwLJ6XnfF2ep55nKCO/dTYT1zyimzC1gCgpRhUSiZfRA2pjJL5YOj6b/JnmwvdkiVZ WJi3KVxa8HeoTctASI+A6xBMsnXQeZSWD4eKv3n+M8V3pvZUYiYFl3wRmou1ndDYcfriFb3iR Z5wAaD29BEWgVTwMUngMbQWPEtp5rBqmZDu9IhHAOaewQoxaOZXyrGKNgaB4A/W00MoPnISyB pU3FPePw7dwdFm7uyxfzyEtQvgRNCmdPp0c6WqhZ8omRN733UxSGWb4d/IaEOKwx8uYA0HSzb UHJ7VD8N4BPots0lFOmq+znyIkK7CWfqGjDBp9Ck2NURYhi3P9wbI9MvZtjikYt6MGulIE4Rv ecK1NfMyxIzMgTcaZmsUk0RapVfhYH1YOKm8tnERWxL99JmR8Y9Dwnvfn9XRj6y/XtDiuA0U4 +DIophvkfUTpWVB0+HJ/6tyvAhOM6SO8W15x+JC/UopsV8zjbl8h1h8gDaF0DPMDi0g0H8ZVL UIPbno9Ag7iGcJ2VKVwyStdHJkO1riti2vKildpGARcDIS7Ik9dAhKUgW3h0826b2+bfzCcQU c77PsQgSShwTQtkDb0O5nlf4xdLs1pEW5P3rReH1gqCyMNTiKJJ7d+UkFrUzYHsAQXogNUtrx XKcbd8Y 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_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Printing the same pid for all threads isn't helpful. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220829021006.67305-9-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 37bc96df9bb6..e02dbc3a7108 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -3928,7 +3928,7 @@ print_syscall(CPUArchState *cpu_env, int num, if (!f) { return; } - fprintf(f, "%d ", getpid()); + fprintf(f, "%d ", gettid()); for (i = 0; i < nsyscalls; i++) { if (scnames[i].nr == num) { From patchwork Wed Sep 28 08:15:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 12992042 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 9E29EC04A95 for ; Wed, 28 Sep 2022 10:04:15 +0000 (UTC) Received: from localhost ([::1]:35696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odTvK-0000kh-Fr for qemu-devel@archiver.kernel.org; Wed, 28 Sep 2022 06:04:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEP-0008Fb-FR for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:53 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:47271) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odSEL-0008IY-DS for qemu-devel@nongnu.org; Wed, 28 Sep 2022 04:15:48 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M7am5-1oaSco0K7R-0085op; Wed, 28 Sep 2022 10:15:39 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Helge Deller , Laurent Vivier Subject: [PULL 38/38] linux-user: Add parameters of getrandom() syscall for strace Date: Wed, 28 Sep 2022 10:15:17 +0200 Message-Id: <20220928081517.734954-39-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928081517.734954-1-laurent@vivier.eu> References: <20220928081517.734954-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:qxYfW9M/8vxAvVkZCNCgOwGj0iqEj08TMs3TTy1j59G6MDjbKKX +kvl1ZPstLA8CTe8LFhYI0oBSORVAmNTuOTZuL8UMLAGoQIJ+Q0q0DZJqC6ygc56dS0lDEA GrT3qXrMROrKFE2Jp+uApsdC+P79r+T0kJIaKj8D69MSWoRXpUhuHCsZRg8oH0taZWaJLNG q9UwHVMKNY/qXNwna10Kg== X-UI-Out-Filterresults: notjunk:1;V03:K0:8ZeePMzc74Y=:b8n9UFZrzlOizOt59zUrY3 CLROptPw3E8bilshS4rkI0El+yLDrq4dlCLjkaQ9j6wPnJZZsRAb1z00835osB5QMCsM6g9eV GA+5jXNCuNVtAUV+bxPp7u8p1oUB0Tl9mD4OfIgLWEl1AAyiu8sRPHpaoCak5NwPiFp72IkE+ 6TNJXzaSugw+OsEl2RQ815A6xG8l3Zu36gdilLb59T7weoVAPTFEBd1bzyjLaZ9rGehMVWMga nU7FSF8oPq2MZKRie718iwPOLRXRh3vZhJdlIES/aNrJxwEqg8CdS9n7uILigZcIp2YjZORO8 SRT6VylwjRpmXZeY6mr2+HX097y7ccOJgavzgNW6VQbahmXZJ/poGUqngyxRvN5DYqlb+mON5 Jdv4/rG5MZQ551CJMILL57+KStl5wy9thb9QK0lW/vCxYLdJgTRdE+uHd5obF1C7kZubaukrT fBmN9z2sUSvHhWwITRqxlWkXxdBni7mYvQRNt5eWXlWWtdVhxCC4k7C521omGMf6WZqnR6sER n/X+kyXUe6M7QrQYza2Mbj4+GYtfPff9530mnm7v1Ls0gFvyMIeen0q0EaD8JFB4+BzZ3Y7ww Fz8OvYkvttPhNc93X4IYV7jzS3elgCb4Niwfhmi5zzh4ofDDroXQ38qAFqqKQ4MIderLWzUFk nnLJy9439kYy+mXFx6gLK3iXpVtbalkj+5JIi9eXOiMEZTAnZtyIC/xD0CBM5ADl1sd/viUrH zXPxx2PA2cn5O29cPEiGnUCP6wPQ0XpCxBQsp67c1UjPljdw565C+u5MwYc8FOQyssTlLNW9l RGEdCc+ Received-SPF: none client-ip=212.227.126.131; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Helge Deller Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20220927093538.8954-2-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/strace.list | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/strace.list b/linux-user/strace.list index f8a771b4f256..a87415bf3d50 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -352,7 +352,7 @@ { TARGET_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL }, #endif #ifdef TARGET_NR_getrandom -{ TARGET_NR_getrandom, "getrandom", NULL, NULL, NULL }, +{ TARGET_NR_getrandom, "getrandom", "%s(%p,%u,%u)", NULL, NULL }, #endif #ifdef TARGET_NR_getresgid { TARGET_NR_getresgid, "getresgid" , NULL, NULL, NULL },