From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486258288421.6875949639025; Fri, 10 Mar 2023 14:10:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvg-0008AU-VL; Fri, 10 Mar 2023 17:09:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvf-00089u-E2 for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:35 -0500 Received: from mout.kundenserver.de ([217.72.192.74]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvd-0002ya-CZ for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:35 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M4JVv-1paTwe1TRB-000N6w; Fri, 10 Mar 2023 23:09:29 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller Subject: [PULL 01/28] linux-user: Fix access to /proc/self/exe Date: Fri, 10 Mar 2023 23:09:00 +0100 Message-Id: <20230310220927.326606-2-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:eguOYkggVnjq5Jx6mjXFOKPtbiBYoniwkFyt4Db/y09kIFHGMVl o0iazAzfs5+b2BIrkbYFkazesGwsIW1y+dPwXqM1inADYj0yXm3puSsyvFOUAJxqEKilYDv EEfv5TdfdSnoWSwbSQjkSEoP2S1TTIwHThd3l4CEvkDRxgSck2vLJ+dK6tiZtNJiqSrjrxL iTtjczf7IYSpu8V9bUIJg== UI-OutboundReport: notjunk:1;M01:P0:US87ns4qjoU=;ThuHwj5BSDwGkVky2zXQb0gVdJE 80KqV2yNMxRZeZg+AQiRlO2X7VDDdTgaLrwES7OFDlQgJa+0HdkH6wteJxx2UICKuKWprmelR 9qsRtIFWH1r/0QVILIZ7euU9RD5OyRpZJt41qTfyNU1LlZHrKF+HFDMJlQB71Az23DwnDNRaD UcVuwgJsosT35aEesZDqnmU/ndL6GmZKFRtXDOObcKc8A9jLX41iiKQS0m7WVj0GHaKWyx33t IxYpfmKjPGbsncYT2fmy6kvKb+qMn1Ny2AH7xWu9SOqSZhcGOMitdd7k6Tk+7jiI+rhZjde07 JqiyW7yrVHnWGepx7L8lD0CtpGKJ924SzlZ0evaGqgXjpIcD+1qOQTfqsX+LxIT12Dmsai7ae 91HNlnV4GSNBUbpRUzpmhb6KtKqqiaLj2N41JvSO7Ww+1E7n4E0lP9rCfYOTgu+zBXzZ5Ny7v 84dDf+6HyeIyqcM4l1VSY4KL9in9NJx0uOugOIUg4cMRuNXkmUQFYIHBnrPoyqupyeq8S5XUG +1ySp8p7/h7eaMm3jd4DAot4+LrFEYW3zLW5B/dOhCgXfw1ewWaSf/FT+nB5fsQBrDqe8oDB7 uK5jbcc9cGk2kXLXx+7o+RRt6tmu4vALTG/+fKPBL3eJtAx3o8A/NRXi5VQSVKOLPAxPQqDTE HCo1VA2aWTSn5QWKH8YwFUUPJOsrm4kJefvenaRVBw== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486259266100005 Content-Type: text/plain; charset="utf-8" From: Helge Deller When accsssing /proc/self/exe from a userspace program, linux-user tries to resolve the name via realpath(), which may fail if the process changed the working directory in the meantime. An example: - a userspace program ist started with ./testprogram - the program runs chdir("/tmp") - then the program calls readlink("/proc/self/exe") - linux-user tries to run realpath("./testprogram") which fails because ./testprogram isn't in /tmp - readlink() will return -ENOENT back to the program Avoid this issue by resolving the full path name of the started process at startup of linux-user and store it in real_exec_path[]. This then simplifies the emulation of readlink() and readlinkat() as well, because they can simply copy the path string to userspace. I noticed this bug because the testsuite of the debian package "pandoc" failed on linux-user while it succeeded on real hardware. The full log is here: https://buildd.debian.org/status/fetch.php?pkg=3Dpandoc&arch=3Dhppa&ver=3D2= .17.1.1-1.1%2Bb1&stamp=3D1670153210&raw=3D0 Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20221205113825.20615-1-deller@gmx.de> Signed-off-by: Laurent Vivier --- linux-user/main.c | 6 ++++++ linux-user/syscall.c | 38 ++++++++++++++------------------------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 4ff30ff98066..798fdc0bce8e 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -65,6 +65,7 @@ #endif =20 char *exec_path; +char real_exec_path[PATH_MAX]; =20 int singlestep; static const char *argv0; @@ -739,6 +740,11 @@ int main(int argc, char **argv, char **envp) } } =20 + /* Resolve executable file name to full path name */ + if (realpath(exec_path, real_exec_path)) { + exec_path =3D real_exec_path; + } + /* * get binfmt_misc flags */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a6c426d73cfe..cc650d4ccbd6 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9989,18 +9989,13 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, /* Short circuit this for the magic exe check. */ ret =3D -TARGET_EINVAL; } else if (is_proc_myself((const char *)p, "exe")) { - char real[PATH_MAX], *temp; - temp =3D realpath(exec_path, real); - /* Return value is # of bytes that we wrote to the buffer.= */ - if (temp =3D=3D NULL) { - ret =3D get_errno(-1); - } else { - /* Don't worry about sign mismatch as earlier mapping - * logic would have thrown a bad address error. */ - ret =3D MIN(strlen(real), arg3); - /* We cannot NUL terminate the string. */ - memcpy(p2, real, ret); - } + /* + * Don't worry about sign mismatch as earlier mapping + * logic would have thrown a bad address error. + */ + ret =3D MIN(strlen(exec_path), arg3); + /* We cannot NUL terminate the string. */ + memcpy(p2, exec_path, ret); } else { ret =3D get_errno(readlink(path(p), p2, arg3)); } @@ -10021,18 +10016,13 @@ static abi_long do_syscall1(CPUArchState *cpu_env= , int num, abi_long arg1, /* Short circuit this for the magic exe check. */ ret =3D -TARGET_EINVAL; } else if (is_proc_myself((const char *)p, "exe")) { - char real[PATH_MAX], *temp; - temp =3D realpath(exec_path, real); - /* Return value is # of bytes that we wrote to the buffer.= */ - if (temp =3D=3D NULL) { - ret =3D get_errno(-1); - } else { - /* Don't worry about sign mismatch as earlier mapping - * logic would have thrown a bad address error. */ - ret =3D MIN(strlen(real), arg4); - /* We cannot NUL terminate the string. */ - memcpy(p2, real, ret); - } + /* + * Don't worry about sign mismatch as earlier mapping + * logic would have thrown a bad address error. + */ + ret =3D MIN(strlen(exec_path), arg4); + /* We cannot NUL terminate the string. */ + memcpy(p2, exec_path, ret); } else { ret =3D get_errno(readlinkat(arg1, path(p), p2, arg4)); } --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167848635098195.54426959125567; Fri, 10 Mar 2023 14:12:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvj-0008CY-Sk; Fri, 10 Mar 2023 17:09:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvi-0008Bf-IL for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:38 -0500 Received: from mout.kundenserver.de ([212.227.17.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvg-000313-T6 for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:38 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MEmpp-1pku4f0FSt-00GKMC; Fri, 10 Mar 2023 23:09:30 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Mathis Marion Subject: [PULL 02/28] linux-user: fix timerfd read endianness conversion Date: Fri, 10 Mar 2023 23:09:01 +0100 Message-Id: <20230310220927.326606-3-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:vZDUNLPbEX0Y9qm+03pl5iXrUthIvM4z1NHlwukAYefAVlWrNRH LPu54NqOQuGAgZmdZ3wwI1bpuS1qTFUtMBoYBwClrcQby46NYE2T3f8Scx8JTLuCP2x8wbi /XOnKHuhdakDTayW9M3MrS+jxQMc3G6fLrNVnmwsF3w0KblyXNdrcQHPf9uhAi1hicJn7yz 1MigRnoJnej48zFSENn/w== UI-OutboundReport: notjunk:1;M01:P0:x9piBhp1/C8=;bRuHmchImxSYVV71P1Y5SKTNb8C jUtuYV32JskBDpxoui7vxez1jRBd+dM22aaNGBH4mVFG6BEI1TNIFpGSGLh9VY+1QAnYo/ev0 vlZ5sWAxtNFlTtFv1x/GiYD1J3m7XQYpVDVk6OLa3sN5JHoNqhI/g84yoivkFEjCpf/Ik7Z6P 6wTHOAcLMPi8w2qSerkfhKs7XBoCh7vr8clh9OVMNJZOaLOZlOg3goRkr5mX+OD0u8fv+Eaah FD3ydXV3ElH/y4DmFgvfMO7NZ+Vj8Y9L43/yE4n8Z1fS4g+VQNlysNf8quFz5hNItzXtbfk6i M72NEWZNMxILuRdtrziV7UlubO/FKnkxbm4JtllZSHOr3C9AAIBvqFRbM8x463Hugt8ZEwaZy qudBx1/p0mmTtR+IzFjakPz+09L/1RBaGGK86eitR1KnQfvSLLm39e8SbGoPcEOS2ufeeSP2B i/0ZcNJ4cxe008gzbIhYTklsAt7a4CDLfyaJV/URzn17AF92qAJeThdWYhrS8zpVH/tR+gZcw UVjmpveI2HwxuCLdaD7qV6lL1DwvDJ9ebgKeI8Wt9rv903nVOYq9K7tMPwqb2/lguLNiggobk 4HUWL5annmQNIyZMI/c+n18GfPnqzmc2kkHshTam/xHNEKDakW0S4hcjhRLbekc9uT3vZyNRh uvlYliSpQanpsVg4atk9f5sjF6vwRrsb4vJMyAsb7g== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486351639100002 Content-Type: text/plain; charset="utf-8" From: Mathis Marion When reading the expiration count from a timerfd, the endianness of the 64bit value read is the one of the host, just as for eventfds. Signed-off-by: Mathis Marion Reviewed-by: Laurent Vivier Message-Id: <20230220085822.626798-2-Mathis.Marion@silabs.com> Signed-off-by: Laurent Vivier --- linux-user/fd-trans.c | 10 +++++++--- linux-user/fd-trans.h | 1 + linux-user/syscall.c | 8 ++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c index 7b25468d0208..146aaaafaa13 100644 --- a/linux-user/fd-trans.c +++ b/linux-user/fd-trans.c @@ -1622,7 +1622,7 @@ TargetFdTrans target_signalfd_trans =3D { .host_to_target_data =3D host_to_target_data_signalfd, }; =20 -static abi_long swap_data_eventfd(void *buf, size_t len) +static abi_long swap_data_u64(void *buf, size_t len) { uint64_t *counter =3D buf; int i; @@ -1640,8 +1640,12 @@ static abi_long swap_data_eventfd(void *buf, size_t = len) } =20 TargetFdTrans target_eventfd_trans =3D { - .host_to_target_data =3D swap_data_eventfd, - .target_to_host_data =3D swap_data_eventfd, + .host_to_target_data =3D swap_data_u64, + .target_to_host_data =3D swap_data_u64, +}; + +TargetFdTrans target_timerfd_trans =3D { + .host_to_target_data =3D swap_data_u64, }; =20 #if defined(CONFIG_INOTIFY) && (defined(TARGET_NR_inotify_init) || \ diff --git a/linux-user/fd-trans.h b/linux-user/fd-trans.h index 1b9fa2041c06..910faaf237cc 100644 --- a/linux-user/fd-trans.h +++ b/linux-user/fd-trans.h @@ -130,6 +130,7 @@ extern TargetFdTrans target_netlink_route_trans; extern TargetFdTrans target_netlink_audit_trans; extern TargetFdTrans target_signalfd_trans; extern TargetFdTrans target_eventfd_trans; +extern TargetFdTrans target_timerfd_trans; #if (defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)) || \ (defined(CONFIG_INOTIFY1) && defined(TARGET_NR_inotify_init1) && \ defined(__NR_inotify_init1)) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index cc650d4ccbd6..64b71b1ff94b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -13108,8 +13108,12 @@ static abi_long do_syscall1(CPUArchState *cpu_env,= int num, abi_long arg1, =20 #if defined(TARGET_NR_timerfd_create) && defined(CONFIG_TIMERFD) case TARGET_NR_timerfd_create: - return get_errno(timerfd_create(arg1, - target_to_host_bitmask(arg2, fcntl_flags_tbl))); + ret =3D get_errno(timerfd_create(arg1, + target_to_host_bitmask(arg2, fcntl_flags_tbl))); + if (ret >=3D 0) { + fd_trans_register(ret, &target_timerfd_trans); + } + return ret; #endif =20 #if defined(TARGET_NR_timerfd_gettime) && defined(CONFIG_TIMERFD) --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486258217982.8894082651502; Fri, 10 Mar 2023 14:10:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvk-0008DC-HV; Fri, 10 Mar 2023 17:09:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvi-0008Bh-Kh for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:38 -0500 Received: from mout.kundenserver.de ([217.72.192.74]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvg-00030y-P9 for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:38 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MPXQi-1pwHwu3HsI-00MYZ7; Fri, 10 Mar 2023 23:09:30 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Mathis Marion , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 03/28] linux-user: add target to host netlink conversions Date: Fri, 10 Mar 2023 23:09:02 +0100 Message-Id: <20230310220927.326606-4-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:7u9fPsOHMczQ1uHtUIC1c6eobBN3i240rVKUv0g31zfib4OKhsQ EHunIvbGGEI0JF6/iVW6HZBQAlQx5ioGdnfVOHIkhFabLgzehkDv4Ib0bu3CQJvMTNkG+dF UJBkvwb6PCWg/eSwOjkJsQtaxOIAFTYzeGRqE3rBDzGsvWHXtTy/5Ed/7pxPQn10XdTBWNU 83K4LsCP3dtoUAL8BPLGA== UI-OutboundReport: notjunk:1;M01:P0:gldgVdujYKk=;xJXCfLfZLrexAAmW2OS+lB7u4Ez El01VXUTaslnAM2ae60Rn14m/qbX2Y4fAvGaarYT1G5ns4hqGBZhhhv/Vs7qAp+k6W7u8Y1/A hdkT1awe8lXW/aN1L44q8scEwpCY2Fwyt+EezXRnBngCLn6R2MOtdFsDFmQ+F5fn2uo08+Icc QPcv014etowqZiZi/remXaDGMDqgEXuSBISQ9zXUlz7xOfuxeDXDvjQSyXcsO/IS/6CzdeXIG 0SdWzQGHhB8f7PvYi/00P4qFeAeqJ5QZXT9+HrJQ0WRk4eYv8q7XLQKLuiNb7VsaGREVqQEHO hUV8SvqUwA9IT2D+Rro6UFcKKwnh93DHkpN2ajryWyDk3ft9KeCHZHhi1zH49MT3ScVY/ZB2K ZP0chUN7GT/Q5zfK4ArQ/+J0N9WBqYBJ+ZpMEX6CvecwFKfxmKDcH7oip6wMDL8SJGYNQoG6F rPiWGM4OVu+pIbrgV9pPZV32InN+g8UjQWfJHCq3mkfti3PLPeid4wvsREB3Y1MBYgdQhevBA Ys0e/SemyovuP6HPR57zv7AjdDRKj3zPbi8nrG/GKUzB/sPSyXefTjd99wb7AdtOraeixKqGL CLFXwrZ7JgpKjvP/7xjCof/4kj+YhMFsVP8vSMETk28QCR6Ke47dYwrirKwNl7Q9jCxQwYEcE xyP6SMsM+4gq/uwkVqa3Q/ebFaicAqiRay1egPFaUA== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486259246100003 From: Mathis Marion Added conversions for: - IFLA_MTU - IFLA_TXQLEN - IFLA_AF_SPEC AF_INET6 IFLA_INET6_ADDR_GEN_MODE These relate to the libnl functions rtnl_link_set_mtu, rtnl_link_set_txqlen, and rtnl_link_inet6_set_addr_gen_mode. Signed-off-by: Mathis Marion Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Laurent Vivier Message-Id: <20230220085822.626798-4-Mathis.Marion@silabs.com> Signed-off-by: Laurent Vivier --- linux-user/fd-trans.c | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c index 146aaaafaa13..4852a75d9dcc 100644 --- a/linux-user/fd-trans.c +++ b/linux-user/fd-trans.c @@ -1284,6 +1284,49 @@ static inline abi_long host_to_target_nlmsg_route(st= ruct nlmsghdr *nlh, return host_to_target_for_each_nlmsg(nlh, len, host_to_target_data_rou= te); } =20 +static abi_long target_to_host_for_each_nlattr(struct nlattr *nlattr, + size_t len, + abi_long (*target_to_host_n= lattr) + (struct nlattr *)) +{ + unsigned short aligned_nla_len; + abi_long ret; + + while (len > sizeof(struct nlattr)) { + if (tswap16(nlattr->nla_len) < sizeof(struct rtattr) || + tswap16(nlattr->nla_len) > len) { + break; + } + nlattr->nla_len =3D tswap16(nlattr->nla_len); + nlattr->nla_type =3D tswap16(nlattr->nla_type); + ret =3D target_to_host_nlattr(nlattr); + if (ret < 0) { + return ret; + } + + aligned_nla_len =3D NLA_ALIGN(nlattr->nla_len); + if (aligned_nla_len >=3D len) { + break; + } + len -=3D aligned_nla_len; + nlattr =3D (struct nlattr *)(((char *)nlattr) + aligned_nla_len); + } + return 0; +} + +static abi_long target_to_host_data_inet6_nlattr(struct nlattr *nlattr) +{ + switch (nlattr->nla_type) { + /* uint8_t */ + case QEMU_IFLA_INET6_ADDR_GEN_MODE: + break; + default: + qemu_log_mask(LOG_UNIMP, "Unknown target AF_INET6 type: %d\n", + nlattr->nla_type); + } + return 0; +} + static abi_long target_to_host_for_each_rtattr(struct rtattr *rtattr, size_t len, abi_long (*target_to_host_r= tattr) @@ -1314,16 +1357,35 @@ static abi_long target_to_host_for_each_rtattr(stru= ct rtattr *rtattr, return 0; } =20 +static abi_long target_to_host_data_spec_nlattr(struct nlattr *nlattr) +{ + switch (nlattr->nla_type) { + case AF_INET6: + return target_to_host_for_each_nlattr(NLA_DATA(nlattr), nlattr->nl= a_len, + target_to_host_data_inet6_nl= attr); + default: + qemu_log_mask(LOG_UNIMP, "Unknown target AF_SPEC type: %d\n", + nlattr->nla_type); + break; + } + return 0; +} + static abi_long target_to_host_data_link_rtattr(struct rtattr *rtattr) { uint32_t *u32; =20 switch (rtattr->rta_type) { /* uint32_t */ + case QEMU_IFLA_MTU: + case QEMU_IFLA_TXQLEN: case QEMU_IFLA_EXT_MASK: u32 =3D RTA_DATA(rtattr); *u32 =3D tswap32(*u32); break; + case QEMU_IFLA_AF_SPEC: + return target_to_host_for_each_nlattr(RTA_DATA(rtattr), rtattr->rt= a_len, + target_to_host_data_spec_nla= ttr); default: qemu_log_mask(LOG_UNIMP, "Unknown target QEMU_IFLA type: %d\n", rtattr->rta_type); --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486262909366.7855544504953; Fri, 10 Mar 2023 14:11:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvl-0008EL-U0; Fri, 10 Mar 2023 17:09:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvj-0008CD-Gt for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:39 -0500 Received: from mout.kundenserver.de ([217.72.192.73]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvh-00031G-D6 for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:39 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M5PRT-1pbaPO1Gz7-001TZe; Fri, 10 Mar 2023 23:09:31 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Ilya Leoshkevich , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 04/28] linux-user: Fix unaligned memory access in prlimit64 syscall Date: Fri, 10 Mar 2023 23:09:03 +0100 Message-Id: <20230310220927.326606-5-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:WYvTP3MN+h/87DYEYmctzb+Y+Wr5Nyg4ZS6k1BcHnU1tEsj+Bs4 h7dH/CXM2Lxo4T7i55Q7t9d8+Qf9hFsstAGBGnsuyGSNhRDUBqG+ZVONW9RbXO2aEG8oD2R DzK4nonefvmHtCEb5v1KNJdxDTEJZu7BJT8HkETJCPWxbzgn+a+Td9a5WEcwn3QOV2Z1BXQ 4sRhzNEHp4PjIUpp+mbTw== UI-OutboundReport: notjunk:1;M01:P0:KpfpXM890dk=;7En5hx4hHTw6svSM55F26rzneiZ zAzin8kaiPPAQ90cmkQkW6lDvux5dRwJluD5d42M/BdOWMgMtlQZ+GaS1borzPVUKOLrN1oZY 0e8XQCYbYvWeKO+cKOc3jT8Ow1NhThz42jQ3C/zpEvbsvBZvTxiyz4IoE7z2zETY/vGNEyoWU 0DK0W279M5/j11TXdgzDVlfofBv/SXBTTyqDT8kW27Ns626B7Stmd3SZbhQ168MlAuvkxKUMP ln6OiilJwlMHQDhEUGF4NpVdheaRWjN6oZqf1R5AHblpWsOt5HMxGBbYMIt6RQtgXvZanl4aq I9it5iQTJDTPyRneHso7pCTFCKg62W4RG3277zqTgy0HkoN7NQX/3LsRzX9xTLOo/jBo3DIfQ xXtAIDYafDChyKx0IQUL0emTV93RdsHErh75D5oBpjfL3hA2/TPWtHBgU1f2fn0/D80ZDyKTK zmvpLvzSKqZUAaN2nN3+PRGUsjmWCTCWnHjlpc+n5p/N+2CJdvrClH5fiYLjbdy6LQE6ZZbFB RlkqlBe3Q/OSuxOlkDFSH5aISjVbbcWhUX7G66FscKhufW/JQT6inAjPBXSkPi4KD8FwYt478 p929j6vfG6mxUoaDwncE8rDvSQHZxHorFlxCopxSVF63AJ2YojjWkRZkjXoh4xmMoiueu/t16 Ea+1a5eS9E8+I+iYRuSlpx2B1mVrQkbLPvhsezrhCQ== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486263317100001 From: Ilya Leoshkevich target_rlimit64 contains uint64_t fields, so it's 8-byte aligned on some hosts, while some guests may align their respective type on a 4-byte boundary. This may lead to an unaligned access, which is an UB. Fix by defining the fields as abi_ullong. This makes the host alignment match that of the guest, and lets the compiler know that it should emit code that can deal with the guest alignment. While at it, also use __get_user() and __put_user() instead of tswap64(). Fixes: 163a05a8398b ("linux-user: Implement prlimit64 syscall") Reported-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Laurent Vivier Message-Id: <20230224003907.263914-2-iii@linux.ibm.com> Signed-off-by: Laurent Vivier --- linux-user/generic/target_resource.h | 4 ++-- linux-user/syscall.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/linux-user/generic/target_resource.h b/linux-user/generic/targ= et_resource.h index 539d8c46772e..37d3eb09b3b3 100644 --- a/linux-user/generic/target_resource.h +++ b/linux-user/generic/target_resource.h @@ -12,8 +12,8 @@ struct target_rlimit { }; =20 struct target_rlimit64 { - uint64_t rlim_cur; - uint64_t rlim_max; + abi_ullong rlim_cur; + abi_ullong rlim_max; }; =20 #define TARGET_RLIM_INFINITY ((abi_ulong)-1) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 64b71b1ff94b..69cc4b6e4219 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -12876,8 +12876,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, if (!lock_user_struct(VERIFY_READ, target_rnew, arg3, 1)) { return -TARGET_EFAULT; } - rnew.rlim_cur =3D tswap64(target_rnew->rlim_cur); - rnew.rlim_max =3D tswap64(target_rnew->rlim_max); + __get_user(rnew.rlim_cur, &target_rnew->rlim_cur); + __get_user(rnew.rlim_max, &target_rnew->rlim_max); unlock_user_struct(target_rnew, arg3, 0); rnewp =3D &rnew; } @@ -12887,8 +12887,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, if (!lock_user_struct(VERIFY_WRITE, target_rold, arg4, 1)) { return -TARGET_EFAULT; } - target_rold->rlim_cur =3D tswap64(rold.rlim_cur); - target_rold->rlim_max =3D tswap64(rold.rlim_max); + __put_user(rold.rlim_cur, &target_rold->rlim_cur); + __put_user(rold.rlim_max, &target_rold->rlim_max); unlock_user_struct(target_rold, arg4, 1); } return ret; --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486337500365.5275802393322; Fri, 10 Mar 2023 14:12:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvj-0008CB-7f; Fri, 10 Mar 2023 17:09:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvh-0008Ah-2P for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:37 -0500 Received: from mout.kundenserver.de ([212.227.17.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvf-00030S-9p for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:36 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N8nrc-1qfDYb2wPG-015pYD; Fri, 10 Mar 2023 23:09:31 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Max Filippov Subject: [PULL 05/28] linux-user: add support for xtensa FDPIC Date: Fri, 10 Mar 2023 23:09:04 +0100 Message-Id: <20230310220927.326606-6-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:ZouFUeU7XVhD6UfZr07DfvEy61Uhggok1KwuvV18q+UcVNDlbi1 kBn3vpAJqb2fYd3vZUBqypogoIusN0ox1RqPUyIOA+w9tPrmM8Y8UWMRhehGQGevn0F95jx XiDcxuriNaoeJMv7wOwIFfuMCA6NX+f71ksn+PEqtl1ui8dSljH/iyJxPViIJk9vyUujera aK2WU88o9HSuSb8Nj7Thg== UI-OutboundReport: notjunk:1;M01:P0:bpDUbaImUSg=;+K2+CKuYya4g2utNYTpqXR2B1Bn 5DwjGJYH7FMJbAopsEjNnhZnv6kzKCaywym2/puuOCLqLf6IgURVgB4Ez9hsPFTGvtGXrPBw6 sBnXS69v401qGIhPuPtKIIcPEqdVVz5cPdmK1sbbAagNHtWE33Rk6/LKzqtKoU31azzZC7EAh H3YDxsLZDDhfg9pcL/Xoi0Vqy/GoWhPaQKEerIzfr4d/h0toAX8SN6WqBuZuuepFGZbX597iJ elgjz+qn+GXtlq2u6tEO3NC7TEplbTwIBzuwMyXAKr69tz01Co3DhinRMsMoo0EU6m/kCUfEE DptcVMY9sb+ud1hfMpmepohon6zZ57XuW2rk+KoDLpKULfIny73BSz/7FZC4uITJJ4OwF32KJ jqmNrQBAdYcEOONl4YAG9yh/7xmNdBwQm2aakRgBUb6qHMyICNCd9zwXqCwonb6xte/mq/IIb r9lJgqJI6dXGBsMg8FKKftDK/+VWFHbmM4574+0BeInatWCo6Pqko3BmDLQWm6i0MvFgbvF1x TaRnfq7Ovdv/Jnj1oMjvNmRAnrBchOYRBf4h7qJCwKUWJAjCVboNQf6oPcNvfjslzUsUTXg8K 7FtRVx9wVr1+lNaAOPaNqc1ThqIbRI55lKe0JbRLr1v8aSbMNVM/85sTAIwsC9oXTAeLjTo7u +LnDqMwmh37fpKvX6dJP8dwQmrqCNN9bPZ/DyyXw9w== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486339619100007 Content-Type: text/plain; charset="utf-8" From: Max Filippov Define xtensa-specific info_is_fdpic and fill in FDPIC-specific registers in the xtensa version of init_thread. Signed-off-by: Max Filippov Message-Id: <20230205061230.544451-1-jcmvbkbc@gmail.com> Signed-off-by: Laurent Vivier --- include/elf.h | 1 + linux-user/elfload.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/elf.h b/include/elf.h index 8bf1e72720d5..e8bfe38a9fbd 100644 --- a/include/elf.h +++ b/include/elf.h @@ -1619,6 +1619,7 @@ typedef struct elf64_shdr { #define ELFOSABI_MODESTO 11 /* Novell Modesto. */ #define ELFOSABI_OPENBSD 12 /* OpenBSD. */ #define ELFOSABI_ARM_FDPIC 65 /* ARM FDPIC */ +#define ELFOSABI_XTENSA_FDPIC 65 /* Xtensa FDPIC */ #define ELFOSABI_ARM 97 /* ARM */ #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) applicati= on */ =20 diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 5928c14dfc97..150d1d450396 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1748,6 +1748,15 @@ static inline void init_thread(struct target_pt_regs= *regs, regs->windowstart =3D 1; regs->areg[1] =3D infop->start_stack; regs->pc =3D infop->entry; + if (info_is_fdpic(infop)) { + regs->areg[4] =3D infop->loadmap_addr; + regs->areg[5] =3D infop->interpreter_loadmap_addr; + if (infop->interpreter_loadmap_addr) { + regs->areg[6] =3D infop->interpreter_pt_dynamic_addr; + } else { + regs->areg[6] =3D infop->pt_dynamic_addr; + } + } } =20 /* See linux kernel: arch/xtensa/include/asm/elf.h. */ @@ -2207,11 +2216,16 @@ static void zero_bss(abi_ulong elf_bss, abi_ulong l= ast_bss, int prot) } } =20 -#ifdef TARGET_ARM +#if defined(TARGET_ARM) static int elf_is_fdpic(struct elfhdr *exec) { return exec->e_ident[EI_OSABI] =3D=3D ELFOSABI_ARM_FDPIC; } +#elif defined(TARGET_XTENSA) +static int elf_is_fdpic(struct elfhdr *exec) +{ + return exec->e_ident[EI_OSABI] =3D=3D ELFOSABI_XTENSA_FDPIC; +} #else /* Default implementation, always false. */ static int elf_is_fdpic(struct elfhdr *exec) --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486272626936.4884824639945; Fri, 10 Mar 2023 14:11:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvk-0008Ck-60; Fri, 10 Mar 2023 17:09:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvh-0008Ag-2O for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:37 -0500 Received: from mout.kundenserver.de ([212.227.17.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvf-00030M-14 for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:36 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M2wbS-1pZeSm0fIC-003OJb; Fri, 10 Mar 2023 23:09:32 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Andreas Schwab Subject: [PULL 06/28] linux-user: fill out task state in /proc/self/stat Date: Fri, 10 Mar 2023 23:09:05 +0100 Message-Id: <20230310220927.326606-7-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:zZNYbCpF0r2BGRB37Nbzx89tz/Ied2/S6Jlj3hSpvunw3X6pgad rrEnzK4ajF5BM3jy+UW1bMdXdWUPilTihCkkLydQSLstq5ZmfjxrdplYwFddaxLpEOhCaAD 5s1mmW0Dfqo5E7TaLy3GfGv7X+tcITchvzgNQ2rKYaA7JhhKj1vUgo1DD26J4B2nPK3xCnC WVnZCV2MPEmiRI7HqFomw== UI-OutboundReport: notjunk:1;M01:P0:/HZSFq5qN+s=;HgS8MTUZJ1S01RgL3OI/vnwORFt aON5tPmYG0MSSjdG80ynWKPUo7YUhOo3SEiXJZzOryy4bBveHX0QM4k+gwME/iq1i5g2x/f7A gxUNRvCVEgMgDA4+u7+C8sa0zfkolM4fpIQMKG50qblRYJ963QfKnGUrfK+MCWAO8jyinGlSm eiYoKo8+Q7MhSU/tc+H0mwdT2EXSHe2a0bMNyERQCS0FEOgBVRG4hwxk+5cjaZkvbSvJwieHs SosgtqqGVD7ZgUcOZgK33ioVDVaoqa+EjFKin6Kls2Ybj3n7SJ3kcZ/GEgGvHzxpv0aq1y+A2 PZcTxVsYz25mf0aV1AhbZwlyGDxepPf4Q8Qs0C4fwXoPSnHbZHG4CqBaMizHVnGNqwLIPdACo /F7rTSWKMH0AnatZXdeMfJznZHpgtMasAlepqCx1hRINJgUduX5lKV0l/9rlad//iMsKibe7c UAZ8xPwas2EuQ7lSUQiFrHjM/yfnhmlNJ5JPcQf9e7J8MbFo7ghwZmuCLwV4lTqLCoTyUUdnr apmSPKGGAtm58bhyWTAIdVms6Ho8Hu58yU2Eeyr8bEXWq1sF4UFfRX9inYL86sIk6uf9c773J YACMip1la9WvlR6wcd/+dYSwyaQm9Kmt5P/OKFlAxl+aFCCLOloGeO/ttd5+CFMPtR484MNmt YqZyKwx3OQZw31jz1fErps5cMzMtBvt/3wVqtdRuXw== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486273328100001 Content-Type: text/plain; charset="utf-8" From: Andreas Schwab Some programs want to match an actual task state character. Signed-off-by: Andreas Schwab Reviewed-by: Laurent Vivier Message-Id: Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 69cc4b6e4219..49a4fee89918 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8079,6 +8079,9 @@ static int open_self_stat(CPUArchState *cpu_env, int = fd) gchar *bin =3D g_strrstr(ts->bprm->argv[0], "/"); bin =3D bin ? bin + 1 : ts->bprm->argv[0]; g_string_printf(buf, "(%.15s) ", bin); + } else if (i =3D=3D 2) { + /* task state */ + g_string_assign(buf, "R "); /* we are running right now */ } else if (i =3D=3D 3) { /* ppid */ g_string_printf(buf, FMT_pid " ", getppid()); --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486356456841.9751642254449; Fri, 10 Mar 2023 14:12:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvi-0008Bc-HS; Fri, 10 Mar 2023 17:09:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvg-0008AD-LX for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:36 -0500 Received: from mout.kundenserver.de ([217.72.192.73]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakve-00030H-Od for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:36 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N6LIF-1qcBPx2Ja5-016e5y; Fri, 10 Mar 2023 23:09:32 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller Subject: [PULL 07/28] linux-user: Fix brk() to release pages Date: Fri, 10 Mar 2023 23:09:06 +0100 Message-Id: <20230310220927.326606-8-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:8pGh/K99GwQonSx2gI0q1Eek1Pl7mg0AJB4Tcx/qMdxdB0+1QtI CHbpRTZD4zEXClsmErfb1ZoZn+y1cA0Y3n4YOsf8hZMAkHn23Zt7+DTGKVBgUyBFmmeW+rZ s8Vrw9wx7DpdHgzGoRpbZEt+z4F/12nywO9gqSfRH2tGBCIbGkx4JPpu6PXbkXCle2qUSnG dPdIY79w0zFXovrFtH4Zg== UI-OutboundReport: notjunk:1;M01:P0:p3CulZuH4CE=;ljofvFwCft21YqJBajlUyQuF8a/ jG0x1HxAM4a4ehvvad8Tv37qmrWJQSSytfs0fzxt01NB6wd5jTAOFGqUcMWGU2DiF0tMHQEiR tqBQOboHegxDTHKpMyKnXBCoXhJqx2M6U8+rBSMNpd3DNLHOQ9LXztRZO6jSP6dblfbuHcHwe ghAzQRHe7KmDbGmEHXghDRANqypvlSaDO12Bw8y/m0RtHiMYpk96iXCrRX++wMiK/QP9uHGoe coMNRmStqQ1VAA1hdZXFNa8s4joMFWPeGJSpB0pqGClex//5PiCxz68/VETwkEXeMbKwbI0U/ CuCwCik7SwX++krn/KUnGOmroQaXjtU9Dd7pBGjSF5efeNohugw8Lwf5NtpkhgU43vORQOKJH Y5xQgbCZ5gEWuzBqRcuPWHqFnRQa/Hqwobjj7ZFgCl+t5klZ3kLRNMp0GVo3c8V7Y7xL9YKb+ +zvi7+g1NvJrCjv5YjxoL5Hh950KkeAXjMr8aZDgWQ+b8FFReHmBPcgCqP8jjZ/UP9f5Ybf1r J7m+4vUjCg9LH0Pqbii7ll3OT15IElp7E5y2B17c44aWm9jsk/zQJ0Z3Qh9QPbOXjpl853A9Z VoqfwCbs56b3n3ZkhoAtJyxAXkVuLxEsS2IwXRhX8BkPasgpQs89sumoq52R0KHC6f1LQTcDn 8nimnXiz5hXdNiVnq+nuSXiQUY5fLdWjjoijyE9hwQ== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486357704100005 Content-Type: text/plain; charset="utf-8" From: Helge Deller The current brk() implementation does not de-allocate pages if a lower address is given compared to earlier brk() calls. But according to the manpage, brk() shall deallocate memory in this case and currently it breaks a real-world application, specifically building the debian gcl package in qemu-user. Fix this issue by reworking the qemu brk() implementation. Tested with the C-code testcase included in qemu commit 4d1de87c750, and by building debian package of gcl in a hppa-linux guest on a x86-64 host. Signed-off-by: Helge Deller Message-Id: Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 69 ++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 49a4fee89918..931f9db47552 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -795,49 +795,52 @@ static inline int host_to_target_sock_type(int host_t= ype) } =20 static abi_ulong target_brk; -static abi_ulong target_original_brk; static abi_ulong brk_page; =20 void target_set_brk(abi_ulong new_brk) { - target_original_brk =3D target_brk =3D HOST_PAGE_ALIGN(new_brk); + target_brk =3D new_brk; brk_page =3D HOST_PAGE_ALIGN(target_brk); } =20 -//#define DEBUGF_BRK(message, args...) do { fprintf(stderr, (message), ## = args); } while (0) -#define DEBUGF_BRK(message, args...) - /* do_brk() must return target values and target errnos. */ -abi_long do_brk(abi_ulong new_brk) +abi_long do_brk(abi_ulong brk_val) { abi_long mapped_addr; abi_ulong new_alloc_size; + abi_ulong new_brk, new_host_brk_page; =20 /* brk pointers are always untagged */ =20 - DEBUGF_BRK("do_brk(" TARGET_ABI_FMT_lx ") -> ", new_brk); - - if (!new_brk) { - DEBUGF_BRK(TARGET_ABI_FMT_lx " (!new_brk)\n", target_brk); + /* return old brk value if brk_val unchanged or zero */ + if (!brk_val || brk_val =3D=3D target_brk) { return target_brk; } - if (new_brk < target_original_brk) { - DEBUGF_BRK(TARGET_ABI_FMT_lx " (new_brk < target_original_brk)\n", - target_brk); + + new_brk =3D TARGET_PAGE_ALIGN(brk_val); + new_host_brk_page =3D HOST_PAGE_ALIGN(brk_val); + + /* brk_val and old target_brk might be on the same page */ + if (new_brk =3D=3D TARGET_PAGE_ALIGN(target_brk)) { + if (brk_val > target_brk) { + /* empty remaining bytes in (possibly larger) host page */ + memset(g2h_untagged(target_brk), 0, new_host_brk_page - target= _brk); + } + target_brk =3D brk_val; return target_brk; } =20 - /* If the new brk is less than the highest page reserved to the - * target heap allocation, set it and we're almost done... */ - if (new_brk <=3D brk_page) { - /* Heap contents are initialized to zero, as for anonymous - * mapped pages. */ - if (new_brk > target_brk) { - memset(g2h_untagged(target_brk), 0, new_brk - target_brk); - } - target_brk =3D new_brk; - DEBUGF_BRK(TARGET_ABI_FMT_lx " (new_brk <=3D brk_page)\n", target_= brk); - return target_brk; + /* Release heap if necesary */ + if (new_brk < target_brk) { + /* empty remaining bytes in (possibly larger) host page */ + memset(g2h_untagged(brk_val), 0, new_host_brk_page - brk_val); + + /* free unused host pages and set new brk_page */ + target_munmap(new_host_brk_page, brk_page - new_host_brk_page); + brk_page =3D new_host_brk_page; + + target_brk =3D brk_val; + return target_brk; } =20 /* We need to allocate more memory after the brk... Note that @@ -846,10 +849,14 @@ abi_long do_brk(abi_ulong new_brk) * itself); instead we treat "mapped but at wrong address" as * a failure and unmap again. */ - new_alloc_size =3D HOST_PAGE_ALIGN(new_brk - brk_page); - mapped_addr =3D get_errno(target_mmap(brk_page, new_alloc_size, + new_alloc_size =3D new_host_brk_page - brk_page; + if (new_alloc_size) { + mapped_addr =3D get_errno(target_mmap(brk_page, new_alloc_size, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, 0, 0)); + } else { + mapped_addr =3D brk_page; + } =20 if (mapped_addr =3D=3D brk_page) { /* Heap contents are initialized to zero, as for anonymous @@ -861,10 +868,8 @@ abi_long do_brk(abi_ulong new_brk) * then shrunken). */ memset(g2h_untagged(target_brk), 0, brk_page - target_brk); =20 - target_brk =3D new_brk; - brk_page =3D HOST_PAGE_ALIGN(target_brk); - DEBUGF_BRK(TARGET_ABI_FMT_lx " (mapped_addr =3D=3D brk_page)\n", - target_brk); + target_brk =3D brk_val; + brk_page =3D new_host_brk_page; return target_brk; } else if (mapped_addr !=3D -1) { /* Mapped but at wrong address, meaning there wasn't actually @@ -872,10 +877,6 @@ abi_long do_brk(abi_ulong new_brk) */ target_munmap(mapped_addr, new_alloc_size); mapped_addr =3D -1; - DEBUGF_BRK(TARGET_ABI_FMT_lx " (mapped_addr !=3D -1)\n", target_br= k); - } - else { - DEBUGF_BRK(TARGET_ABI_FMT_lx " (otherwise)\n", target_brk); } =20 #if defined(TARGET_ALPHA) --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486257332313.12700658052074; Fri, 10 Mar 2023 14:10:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvh-0008B1-Sq; Fri, 10 Mar 2023 17:09:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvg-0008AB-Kk for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:36 -0500 Received: from mout.kundenserver.de ([212.227.17.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakve-00030I-UM for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:36 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N2mWA-1qZ91642Sy-0135ip; Fri, 10 Mar 2023 23:09:33 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller Subject: [PULL 08/28] linux-user: Provide print_raw_param64() for 64-bit values Date: Fri, 10 Mar 2023 23:09:07 +0100 Message-Id: <20230310220927.326606-9-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:cLQw+6F0QVWslnEYmBa94mKlYnGFaj6RNn/MUzW8KWo1GQJ8dQT paUyBuJOTa7xp6A/AUJotrBdIeu1eSJxmXQs5aQNvpIX4hCaCKCedrc4qg/ChavHPHqg+yj ktTRc/num54S4WLfAkYYgx1qUYnNrprhNmTK6KNcWOv9NznNa1vWojYcfM085BMKADMi462 /doTTKq3vdC0kjWtgVnmw== UI-OutboundReport: notjunk:1;M01:P0:qTLLBIi1yxA=;t5jj+lZf7kAsjeFe/IZXaDDFFEx OuSgYCZA3BancerKQMGEhayNqsWegWnkwMWIaZ6uL8PX+LAj3C5/wX3Qs9c38l7TH5q9eAFHK HaIP6F4kKar2/Te1JxA2M2fI0liLoElxVegi+UiCZqpxDYaG8Iu07g5Oj5Pwf+rPS2T3mIk/s V1hdUPqAKv9qhpgfCPb55BqnU6Uer6888SOdV447PPFBYOCTK44cKSH0adL0zLt/X+fzVglf/ dFERvYBF0ptn9j1QxZMnVAyuKet3rMu9lKMpsD3qpWgkgX+q6w9zvvMPxAwIrCl9Uzfw3gV5/ QBc33THpwhcYRMAzwpXGeNOV+Dcdjfi9LTnj9MmT8AbAAFx5hykhVeBqUQ94EL/n3byi3tAaW JFhwJ5jnWin8olp8/eZswk4+zcaOPfxeb45mqZbwsSR/QnVrArePVWgR+APcQS+SO7e2IkuYm BgjSaF5+rn1QP6NB3CGAs5CvJLkcoYv2R5IMVE58FcXCQPU0wqf79VTd6sfBD3YWguaxgsK5S 2sep/qZQ9lFoBq8dKLKUy1wHukTtfJ7VcmOCtLCcDjjUgpytVKD+S2nFArK/A+ksV3BTY7zqR ZJ9xrtC7JLEqY5In/ajs2TyjuXF1tEmJKQ+tHV0stUxgh/VvXsUzg47hysOBfqlsejk9+WWDI aLETc+MIr/g+laGKbOljMDS0z8ocr+EeD8CPOECPcw== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486259258100004 Content-Type: text/plain; charset="utf-8" From: Helge Deller Add a new function print_raw_param64() to print 64-bit values in the same way as print_raw_param(). This prevents that qemu_log() is used to work around the problem that print_raw_param() can only print 32-bit values when compiled for 32-bit targets. Additionally convert the existing 64-bit users in print_timespec64(), print_rlimit64() and print_preadwrite64() over to this new function and drop some unneccessary spaces. Suggested-by: Laurent Vivier Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: [lvivier: remove print_preadwrite64 and print_rlimit64 part] Signed-off-by: Laurent Vivier --- linux-user/strace.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 340010661c4f..5218e3fc33ac 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -81,6 +81,7 @@ UNUSED static void print_syscall_epilogue(const struct sy= scallname *); UNUSED static void print_string(abi_long, int); 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_raw_param64(const char *, long long, int last); UNUSED static void print_timeval(abi_ulong, int); UNUSED static void print_timespec(abi_ulong, int); UNUSED static void print_timespec64(abi_ulong, int); @@ -1642,6 +1643,19 @@ print_raw_param(const char *fmt, abi_long param, int= last) qemu_log(format, param); } =20 +/* + * Same as print_raw_param() but prints out raw 64-bit parameter. + */ +static void +print_raw_param64(const char *fmt, long long param, int last) +{ + char format[64]; + + (void)snprintf(format, sizeof(format), "%s%s", fmt, get_comma(last)); + qemu_log(format, param); +} + + static void print_pointer(abi_long p, int last) { @@ -1718,10 +1732,8 @@ print_timespec64(abi_ulong ts_addr, int last) print_pointer(ts_addr, last); return; } - qemu_log("{tv_sec =3D %lld" - ",tv_nsec =3D %lld}%s", - (long long)tswap64(ts->tv_sec), (long long)tswap64(ts->tv= _nsec), - get_comma(last)); + print_raw_param64("{tv_sec=3D%" PRId64, tswap64(ts->tv_sec), 0); + print_raw_param64("tv_nsec=3D%" PRId64 "}", tswap64(ts->tv_nsec), = last); unlock_user(ts, ts_addr, 0); } else { qemu_log("NULL%s", get_comma(last)); --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486227554454.83825866630855; Fri, 10 Mar 2023 14:10:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvr-0008IE-Te; Fri, 10 Mar 2023 17:09:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvj-0008CE-KX for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:39 -0500 Received: from mout.kundenserver.de ([217.72.192.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvh-000319-DN for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:39 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MlO5j-1qHCcq1aXd-00lpx8; Fri, 10 Mar 2023 23:09:33 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller Subject: [PULL 09/28] linux-user: Add strace for prlimit64() syscall Date: Fri, 10 Mar 2023 23:09:08 +0100 Message-Id: <20230310220927.326606-10-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:KXbMiml4WG1RJOmDDrU29IxOZZNm+sbE5x2P6nPS6k4nL6XVUJP RaYAXub2jTWHrGyOyVGpGr7C5RIMQy3mHUCTg2Sq4T5C6Tarmjg2BxtjYyRKUzNcBzQraGm rEcgNhm/kfhJGV/uJU458/3/8Sg10Db/cb8UJrU3gerv5I4yzmz1RU6qOc0aGuaSLluq+x3 SwLxP4A5GtdVGsdGMlGRA== UI-OutboundReport: notjunk:1;M01:P0:7ehI6Yq6nEI=;SyAQ5vmlTWtNYiks/pjdhyTTvRC qX/os3zb2o/lqzRHcQZv1cwDaGgTy9ynwZolWIqLUOo0Uj+m8VZpOZLTUMLrG8Tm56p6AqkIS vf/ElvdRcsWug1Owg9IGU0jJSfhWlxErrBDICpmkQVqdpGOinBvlXJGeh/A2lpZUkBit/uHxU MObi0s5CUl/At39KTFttHmTcmt+MBpTQOBNFSGSwvbLwyOKRRGY58enDXflW7ikSFLu4JDqCj iFblu5XF3Llxle3Hkm+c9ZYj1RSiBdXpDTsoZwVaEcfEDcIrOcATJ7upDjoaRJ90CWHWijjyf 5U7Ka2K+snQyBx171zAR6NtMtG0ji6TIqjBUlZpNQjteoid+zENYLpLySpBBhuuFFVgILPodT BIvCYmVUCoT/OPHlKjH8mfhjBbA/7+jY00a181vW5vXlnPir6Oe43MgdZtpmtvNJJnPF8H2uk eWlqD0EVumVNH0o5nhEXQLBDIfg/nSYblK3sWC3idm3NYETQQIWw+fuOu89zeucnqP33dbfiW r3XiSo71WcFeyJAnCmn1xON6sAdAvYlZACntLL7JCbcc064a4bCFFAWL8yA1nV4VJ02odqYdm MDaNEAEw9KsVdeO3g+RvnXZonrMhrDQqb0tnZPP11vgf/QcGL/LIRe3Cf9ERLyyE9aO1eUq0C pzOqQWq9gwDpJT55H1REtH9+D9QHBD1vlCAU4A2Xqw== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486229222100001 Content-Type: text/plain; charset="utf-8" From: Helge Deller Add proper prlimit64() strace output. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20221222190639.124078-1-deller@gmx.de> [lvivier: use print_raw_param64()] Signed-off-by: Laurent Vivier --- linux-user/strace.c | 88 ++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 3 +- 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 5218e3fc33ac..e08bd53afb48 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -3866,6 +3866,94 @@ print_futex(CPUArchState *cpu_env, const struct sysc= allname *name, } #endif =20 +#ifdef TARGET_NR_prlimit64 +static const char *target_ressource_string(abi_ulong r) +{ + #define RET_RES_ENTRY(res) case TARGET_##res: return #res; + switch (r) { + RET_RES_ENTRY(RLIMIT_AS); + RET_RES_ENTRY(RLIMIT_CORE); + RET_RES_ENTRY(RLIMIT_CPU); + RET_RES_ENTRY(RLIMIT_DATA); + RET_RES_ENTRY(RLIMIT_FSIZE); + RET_RES_ENTRY(RLIMIT_LOCKS); + RET_RES_ENTRY(RLIMIT_MEMLOCK); + RET_RES_ENTRY(RLIMIT_MSGQUEUE); + RET_RES_ENTRY(RLIMIT_NICE); + RET_RES_ENTRY(RLIMIT_NOFILE); + RET_RES_ENTRY(RLIMIT_NPROC); + RET_RES_ENTRY(RLIMIT_RSS); + RET_RES_ENTRY(RLIMIT_RTPRIO); +#ifdef RLIMIT_RTTIME + RET_RES_ENTRY(RLIMIT_RTTIME); +#endif + RET_RES_ENTRY(RLIMIT_SIGPENDING); + RET_RES_ENTRY(RLIMIT_STACK); + default: + return NULL; + } + #undef RET_RES_ENTRY +} + +static void +print_rlimit64(abi_ulong rlim_addr, int last) +{ + if (rlim_addr) { + struct target_rlimit64 *rl; + + rl =3D lock_user(VERIFY_READ, rlim_addr, sizeof(*rl), 1); + if (!rl) { + print_pointer(rlim_addr, last); + return; + } + print_raw_param64("{rlim_cur=3D%" PRId64, tswap64(rl->rlim_cur), 0= ); + print_raw_param64("rlim_max=3D%" PRId64 "}", tswap64(rl->rlim_max), + last); + unlock_user(rl, rlim_addr, 0); + } else { + qemu_log("NULL%s", get_comma(last)); + } +} + +static void +print_prlimit64(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) +{ + const char *rlim_name; + + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + rlim_name =3D target_ressource_string(arg1); + if (rlim_name) { + qemu_log("%s,", rlim_name); + } else { + print_raw_param("%d", arg1, 0); + } + print_rlimit64(arg2, 0); + print_pointer(arg3, 1); + print_syscall_epilogue(name); +} + +static void +print_syscall_ret_prlimit64(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); + if (arg3) { + qemu_log(" ("); + print_rlimit64(arg3, 1); + qemu_log(")"); + } + } + qemu_log("\n"); +} +#endif + #ifdef TARGET_NR_kill static void print_kill(CPUArchState *cpu_env, const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index d8acbeec6093..f776c73fa04c 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1074,7 +1074,8 @@ { TARGET_NR_preadv, "preadv" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_prlimit64 -{ TARGET_NR_prlimit64, "prlimit64" , NULL, NULL, NULL }, +{ TARGET_NR_prlimit64, "prlimit64" , NULL, print_prlimit64, + print_syscall_ret_prlimit64 }, #endif #ifdef TARGET_NR_process_vm_readv { TARGET_NR_process_vm_readv, "process_vm_readv" , NULL, NULL, NULL }, --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486322645832.8030552065034; Fri, 10 Mar 2023 14:12:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvq-0008I0-Ew; Fri, 10 Mar 2023 17:09:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvp-0008Gm-1D for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:45 -0500 Received: from mout.kundenserver.de ([212.227.17.24]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvm-00034B-QY for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:44 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MPGiR-1pvSjY3UjN-00Pa2I; Fri, 10 Mar 2023 23:09:34 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Mathis Marion , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 10/28] linux-user: fix sockaddr_in6 endianness Date: Fri, 10 Mar 2023 23:09:09 +0100 Message-Id: <20230310220927.326606-11-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:RSC8l9Pchs9wsuCzh8EcgVNvxm1rOk+ZyjLPuTMz9Ek+83Q++Hu gL6gDRJOGfVT9Gf4+MgvIE42Bk2CkOpkz8cZd1Sf2lEheRuoVAjOJSWpPMA3DGU8UX2Y2cX v42tgCtgpSmVO5Hp97HeGE644kJcKf0tLhLH+OTu4q0QId4E1agoQsRQWLnRSzeyF1rIHvZ YHa4Qc5HoM0o8X9MWUIug== UI-OutboundReport: notjunk:1;M01:P0:hw8pl3uBGzE=;I/hsQAZC0H6xdCSIyJo0OEEwnZZ 1ZOTLbA2YGmSpYqEF4ZElN2SATb11bO9Q13XZgu81HC/WRSDB+5/mXKNrTlpdmv48OPtosrkn eUXXPgdnyuyOLbNf7kTev0XTpCNt7/8CvCeMu80KQQs5sXoaKLmQC6xQZyKMBnHfzOV2FFucm cBQscujBCZOV7w8FJp0zmd6vfwqYJfGlwT/f05ccms96+8HSBjJZ2HP/1IjIoEjYIl3qfyi41 9urzJomxgEziXGq0/8UxVvDUzkU4EtKlvznzNJC5iBj+otCm2EXGy8hWx68M7AeeMUhWcBZVc Ar6WIQRf6A8jNIFaL38godVOrXMGwJFstOWYLmfTgInqSqMXGzUi5WdLBeoZXL2zKuzm3yKsk W2SgqAwMtq35ccMOROGHSa1AZlIl9igm0qkYEgx1mSBQoq/uwTQBr8mtRdCtWSd1NbEsNO3UF kjDIv/RU1dfdXf9m/QDGqDdtG4xAZEhrO94L9x1tXSgHDONI9b6ndWlG6sMjBF6yZd3Vc/iio YjF+e1E98pcSXv+T3UPs6W4M6PP5hZTrNxmQboDrQ4+nHh7AiwAqLmWf62BfWQ3K65ISglkUU cIPttDI83Swfx0F6pvXpWMsFkar3uUr2ogwYJbnaz3v827f7fYy0IZx1VvLSKPpRm1YrPG4ms UINF8oTEnOsLGfgKcnUIE9tKURi/7iJ4RsWRWepe/Q== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486323505100001 From: Mathis Marion The sin6_scope_id field uses the host byte order, so there is a conversion to be made when host and target endianness differ. Signed-off-by: Mathis Marion Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20230307154256.101528-2-Mathis.Marion@silabs.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 931f9db47552..05c81079e745 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1714,6 +1714,11 @@ static inline abi_long target_to_host_sockaddr(int f= d, struct sockaddr *addr, lladdr =3D (struct target_sockaddr_ll *)addr; lladdr->sll_ifindex =3D tswap32(lladdr->sll_ifindex); lladdr->sll_hatype =3D tswap16(lladdr->sll_hatype); + } else if (sa_family =3D=3D AF_INET6) { + struct sockaddr_in6 *in6addr; + + in6addr =3D (struct sockaddr_in6 *)addr; + in6addr->sin6_scope_id =3D tswap32(in6addr->sin6_scope_id); } unlock_user(target_saddr, target_addr, 0); =20 --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486381348623.1582541767744; Fri, 10 Mar 2023 14:13:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvs-0008IG-01; Fri, 10 Mar 2023 17:09:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvk-0008Dk-Tl for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:40 -0500 Received: from mout.kundenserver.de ([217.72.192.74]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvj-00032C-36 for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:40 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MLQgv-1prb7l0wcd-00IRxY; Fri, 10 Mar 2023 23:09:34 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Mathis Marion Subject: [PULL 11/28] linux-user: handle netlink flag NLA_F_NESTED Date: Fri, 10 Mar 2023 23:09:10 +0100 Message-Id: <20230310220927.326606-12-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:CRvJM6iFhsc9wQqUF8EMgLJGVTPuGWpYGWi2cg81Vs4hSu5RyTk 5wJprq4pAkFXWGpB5SJECcZjh91OLgqGrZV2k3SDenY4LLfJ8KTQmyCQWG5mKIzmiOChjxK wosgBl79UwKmW2/LPzy0EGpMLGpzKtkNJd5esy70bcyWIsh7/5DUPju2deqbJIcdNQVkSB6 eTQ73yX/TzM3NktigibPA== UI-OutboundReport: notjunk:1;M01:P0:tQjUsDQc4SE=;n0AiKdjPWNQuRAuoWAiDsPNb1K2 NoPpqf54AoaTU+SFi7b+S6fOBNeMnvgYLeJA62qx+H+0vi+hemJkkjtMKzlAOw+nAF80Hte5b AM0EDsm3YLgbMM63poCQ3nrWHUGdIJE+d09OhmotFfiypeGwFC7BaC/R/RuptnRe3bu0fgd76 WQU0dc++nDpMUsxTi8TYnXoC0Ax/wPInXVmvqz419Tz3XHvXIGdWW/zHxolsCfj+on33niZvf dFUHyLcqDBfRl0lD5NMpHnwRf2dPE5SJITcZ5VNGHfkUjp9sdNUjHVhZ7Z23wIsjua2eg9D2W /JdYxXnlNM3vxAWPBD2ndf336p13qzkM1E7bkYsxeJCDYWVva6uTvBWgZ6vxYV2agQU/cld5i Lo5SOSVuRPOsV1Hza8YMuL144Tnx4GK0lklnzPdnGjq0ciQK0WOM/fAa5SXCgQMXbrhsnfpnC +w8Oiy9nyog6WHsa1YH3HZwrSGE3Rzvr54nYsv+Y6IjAtI3sJLp6Vlv/jgO0/ipHXAAKGMXpj FWTeFiAYW0JqqaeCZgAPZcpjWu+kSh7voYvazcvPQj+/cloMcR49k7eS6/aUOTI4GyBrQNbCs C4oLlImTyFHywZUVVRe4arqGV+cTLZzm2zQZRWYBwlvoAppj0HzWzjPXN9+BiH3DJQDVu5gbU Q+N4ToVKKXPEIgsH4RSQRjXC8GTeXlJkxOuqK/MgrQ== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486381701100001 Content-Type: text/plain; charset="utf-8" From: Mathis Marion Newer kernel versions require this flag to be present contrary to older ones. Depending on the libnl version it is added or not. Typically when using rtnl_link_inet6_set_addr_gen_mode, the netlink packet generated may contain the following attribute: with libnl 3.4 {nla_len=3D16, nla_type=3DIFLA_AF_SPEC}, [ {nla_len=3D12, nla_type=3DAF_INET6}, [{nla_len=3D5, nla_type=3DIFLA_INET6_ADDR_GEN_MODE}, IN6_ADDR_GEN_MODE_= NONE] ] with libnl 3.7 {nla_len=3D16, nla_type=3DNLA_F_NESTED|IFLA_AF_SPEC}, [ {nla_len=3D12, nla_type=3DNLA_F_NESTED|AF_INET6}, [{nla_len=3D5, nla_type=3DIFLA_INET6_ADDR_GEN_MODE}, IN6_ADDR_GEN_MODE_= NONE]] ] Masking the type is likely needed in other places. Only the above cases are implemented in this patch. Signed-off-by: Mathis Marion Reviewed-by: Laurent Vivier Message-Id: <20230307154256.101528-3-Mathis.Marion@silabs.com> Signed-off-by: Laurent Vivier --- linux-user/fd-trans.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c index 4852a75d9dcc..c04a97c73a31 100644 --- a/linux-user/fd-trans.c +++ b/linux-user/fd-trans.c @@ -1359,7 +1359,7 @@ static abi_long target_to_host_for_each_rtattr(struct= rtattr *rtattr, =20 static abi_long target_to_host_data_spec_nlattr(struct nlattr *nlattr) { - switch (nlattr->nla_type) { + switch (nlattr->nla_type & NLA_TYPE_MASK) { case AF_INET6: return target_to_host_for_each_nlattr(NLA_DATA(nlattr), nlattr->nl= a_len, target_to_host_data_inet6_nl= attr); @@ -1375,7 +1375,7 @@ static abi_long target_to_host_data_link_rtattr(struc= t rtattr *rtattr) { uint32_t *u32; =20 - switch (rtattr->rta_type) { + switch (rtattr->rta_type & NLA_TYPE_MASK) { /* uint32_t */ case QEMU_IFLA_MTU: case QEMU_IFLA_TXQLEN: --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486209851581.0436367824379; Fri, 10 Mar 2023 14:10:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvk-0008Dg-SZ; Fri, 10 Mar 2023 17:09:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvi-0008BH-5a for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:38 -0500 Received: from mout.kundenserver.de ([212.227.17.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvg-00030s-8d for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:37 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N5FMB-1qb4xf2ZYj-011Ays; Fri, 10 Mar 2023 23:09:34 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller Subject: [PULL 12/28] linux-user: Add translation for argument of msync() Date: Fri, 10 Mar 2023 23:09:11 +0100 Message-Id: <20230310220927.326606-13-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:xoKc1/G9qkiGxEHqSkJfWemSWhV2+lraHV6df/FPgXB8fn8vDMk tSK2Un7+nPR9dDuFYZmRqcceW20aVBag6dcRoYccVLSDlblkU46U4igfbePyEteWEQUiLJb QgF5acV3t2f7sjCr5gBEJz/fJaSkeljJdX6KPFLy7lF8gB2E1Ufaa/XvhSGdfXYSGPxBRkV 3BgGQ1WlqILn2Prh66dZA== UI-OutboundReport: notjunk:1;M01:P0:IKGrArqErXk=;TCLsdlCT/0Wgceu4Gb+d/VAL7i5 4vQaPcIIuq5jZ/No9h2VgAfdbQSg1+G6K2EsSQpy47tAH65nVE4k4XXqUQ6ZbxOXvoCZN558d u+XAxEQjHANmOMmIw7UUcZT411eRfkDFJqXVjiH8A0uayHAjM8lBZDK81woXR2LmfPlxqRVsx RNx7gu9KkjQtAqIB3I1BAMOl7BmyTSSh/uVDTBRXkAODO+kCPsr/Dwj7RUR+pAgy+bNOPViiZ tuxsuvemshRCIRd7PVh7YPnsVkewI4F2FDVtQF9jS5+GsnMB6Q3Lw7KCc7qvOO8flQx0+/IQ/ oQRsR+Am8nxw4D/uygrRIEis72oGmsgz4dwIKEhKnlX7ppgOtKV1bFqgktC1iw8cUbSuKgm2+ vYWYYjtp0OXD12Winiqabjf6PflFPnWQA1aTt79SisB4ITdAxVnozh2NRHV9oTm8pE2+ni7Eu CmjI1NxOiIpMZ6EDabZBnM1ulaXLcBuVbCJ8eJ+HRyZ2++pwH/Qq7tt2lzKM3PcfqRz7VqiKF 4PEPcPzGCUYxU5QYg1coPw2H0L1KG9Da5Bh9jp5GKc2U/D0Q6Wy2mgWVajypqLIGk6spR4p2V +c08AggPqGOP4YHdqx/hOFUHBhkvriYPyrzdC+5rc94vE59+uUvtpzfRlTSwPzhYOh/pRY6RQ PKw2Pmd4kY8nyHb5ZftEn/Esml0LRWCyE3QQdnvtoA== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486212277100003 Content-Type: text/plain; charset="utf-8" From: Helge Deller msync() uses the flags MS_ASYNC, MS_INVALIDATE and MS_SYNC, which differ between platforms, specifcally on alpha and hppa. Add a target to host translation for those and wire up a nicer strace output. This fixes the testsuite of the macaulay2 debian package with a hppa-linux guest on a x86-64 host. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: Signed-off-by: Laurent Vivier --- linux-user/alpha/target_mman.h | 4 ++++ linux-user/generic/target_mman.h | 13 +++++++++++++ linux-user/hppa/target_mman.h | 4 ++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 12 +++++++++++- 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/linux-user/alpha/target_mman.h b/linux-user/alpha/target_mman.h index cd6e3d70a604..051544f5abd8 100644 --- a/linux-user/alpha/target_mman.h +++ b/linux-user/alpha/target_mman.h @@ -3,6 +3,10 @@ =20 #define TARGET_MADV_DONTNEED 6 =20 +#define TARGET_MS_ASYNC 1 +#define TARGET_MS_SYNC 2 +#define TARGET_MS_INVALIDATE 4 + #include "../generic/target_mman.h" =20 #endif diff --git a/linux-user/generic/target_mman.h b/linux-user/generic/target_m= man.h index 1436a3c54308..32bf1a52d07e 100644 --- a/linux-user/generic/target_mman.h +++ b/linux-user/generic/target_mman.h @@ -89,4 +89,17 @@ #define TARGET_MADV_DONTNEED_LOCKED 24 #endif =20 + +#ifndef TARGET_MS_ASYNC +#define TARGET_MS_ASYNC 1 +#endif + +#ifndef TARGET_MS_INVALIDATE +#define TARGET_MS_INVALIDATE 2 +#endif + +#ifndef TARGET_MS_SYNC +#define TARGET_MS_SYNC 4 +#endif + #endif diff --git a/linux-user/hppa/target_mman.h b/linux-user/hppa/target_mman.h index 66dd9f79414e..f9b6b9703255 100644 --- a/linux-user/hppa/target_mman.h +++ b/linux-user/hppa/target_mman.h @@ -10,6 +10,10 @@ #define TARGET_MADV_WIPEONFORK 71 #define TARGET_MADV_KEEPONFORK 72 =20 +#define TARGET_MS_SYNC 1 +#define TARGET_MS_ASYNC 2 +#define TARGET_MS_INVALIDATE 4 + #include "../generic/target_mman.h" =20 #endif diff --git a/linux-user/strace.list b/linux-user/strace.list index f776c73fa04c..c7808ea118f9 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -656,7 +656,7 @@ { TARGET_NR_msgsnd, "msgsnd" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_msync -{ TARGET_NR_msync, "msync" , NULL, NULL, NULL }, +{ TARGET_NR_msync, "msync" , "%s(%p,%u,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_multiplexer { TARGET_NR_multiplexer, "multiplexer" , NULL, NULL, NULL }, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 05c81079e745..dad2c3312032 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -22,6 +22,7 @@ #include "qemu/path.h" #include "qemu/memfd.h" #include "qemu/queue.h" +#include "target_mman.h" #include #include #include @@ -7612,6 +7613,14 @@ static inline int target_to_host_mlockall_arg(int ar= g) } #endif =20 +static inline int target_to_host_msync_arg(abi_long arg) +{ + return ((arg & TARGET_MS_ASYNC) ? MS_ASYNC : 0) | + ((arg & TARGET_MS_INVALIDATE) ? MS_INVALIDATE : 0) | + ((arg & TARGET_MS_SYNC) ? MS_SYNC : 0) | + (arg & ~(TARGET_MS_ASYNC | TARGET_MS_INVALIDATE | TARGET_MS_SYN= C)); +} + #if (defined(TARGET_NR_stat64) || defined(TARGET_NR_lstat64) || \ defined(TARGET_NR_fstat64) || defined(TARGET_NR_fstatat64) || \ defined(TARGET_NR_newfstatat)) @@ -10128,7 +10137,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, /* ??? msync/mlock/munlock are broken for softmmu. */ #ifdef TARGET_NR_msync case TARGET_NR_msync: - return get_errno(msync(g2h(cpu, arg1), arg2, arg3)); + return get_errno(msync(g2h(cpu, arg1), arg2, + target_to_host_msync_arg(arg3))); #endif #ifdef TARGET_NR_mlock case TARGET_NR_mlock: --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167848636167136.89209563939539; Fri, 10 Mar 2023 14:12:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvn-0008FA-8u; Fri, 10 Mar 2023 17:09:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvl-0008Dv-6K for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:41 -0500 Received: from mout.kundenserver.de ([212.227.17.24]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvj-000328-Bg for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:40 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MxVbb-1qTPyY05Rx-00xoOI; Fri, 10 Mar 2023 23:09:35 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller Subject: [PULL 13/28] linux-user: Emulate CLONE_PIDFD flag in clone() Date: Fri, 10 Mar 2023 23:09:12 +0100 Message-Id: <20230310220927.326606-14-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:GvON6A3EF/oi0Cbxf72sNTEAcsDhL6RbOybPA4GkObzkQmVPmKf WPE6Xtzl7BLjrInpSHDp4tjMxFkh8V1jolZH9xHto2J6jJHtMRBdyf9ZYFRC2PQlKf6cgIx Jwh/M1CUNUT1OtjtoSlZJ2pt1iC0nJ0fu56lsuBLSbSClCiDlq1H9SJQX+eNaqjhYhujsoM V63oi7yHxPKHbTiEeNldQ== UI-OutboundReport: notjunk:1;M01:P0:9ZMAy8/KItI=;JKHdV4aIQD+KMEaKWrHoR8AzjrB 2diKdykXgM3JPmEs2UMWATVsEkeanqitxwAF8BYG71MUsCYOMIzF6QuPJARdNjS0jUcPdgN4l wWloxeDP3mFh3YG+h4GMIZeU1psleMPsGn1NrkSCrf1tLNpDAPukwfFciChdIHX1prjtqWaTO 8Ln7BT9OtwWIdBdvf1MCI2Zbw9puYqtI8meG30xnJw/xt26j81Wu5K4xou7HuDoD8Oa5IVuuv mT6XaCOSyuaYCgUDyE482GiveoMHtsV9H6Q5+kc/8Ox3NBsn2LBh4swwmJB9s22rnSmr9AwnT 4NPqcJLbR9vB+j23Cy2Y7qHRS/sT66E4c4FGmM6WjXxlLds5wVrAYqqKhX9gGNQ/GX8oJ7Qfx Lf6nRpR5pB8vrevEfc0BtEuCtBl8dUfdZd8BiHfk827lJiKNO88i+shYTZvG8dx2bUAsjpCOB cc0jCVZeqaCmvA6B+M2hsRqs/FiWEp6081G0y4gE+BpBtAQoAWrPVZOBX2wkEYzVLkuJ89ltP HVoQU9/Y8fzY8n6ox1c+khQtRteU+IT9hmIc8kq5QaaIbLtFGHNhPyvgg5CaQ/sTZ71eiDUEi p4gPFtFUHHhjjxf8PzjI4XTMJQ3MuExyto75I39JSyN7elzu+68sqIPlb9UDj+wLhwurAm/64 8ofgKN/ApM5mENKKgISeihHzdW8EO69R/WCbIN49Mg== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486363657100003 Content-Type: text/plain; charset="utf-8" From: Helge Deller Add emulation for the CLONE_PIDFD flag of the clone() syscall. This flag was added in Linux kernel 5.2. Successfully tested on a x86-64 Linux host with hppa-linux target. Can be verified by running the testsuite of the qcoro debian package, which breaks hard and kills the currently logged-in user without this patch. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: [lv: define CLONE_PIDFD if it is not] Signed-off-by: Laurent Vivier --- linux-user/strace.c | 5 +++++ linux-user/syscall.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index e08bd53afb48..aad2b62ca416 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1111,11 +1111,16 @@ UNUSED static const struct flags mmap_flags[] =3D { FLAG_END, }; =20 +#ifndef CLONE_PIDFD +# define CLONE_PIDFD 0x00001000 +#endif + UNUSED static const struct flags clone_flags[] =3D { FLAG_GENERIC(CLONE_VM), FLAG_GENERIC(CLONE_FS), FLAG_GENERIC(CLONE_FILES), FLAG_GENERIC(CLONE_SIGHAND), + FLAG_GENERIC(CLONE_PIDFD), FLAG_GENERIC(CLONE_PTRACE), FLAG_GENERIC(CLONE_VFORK), FLAG_GENERIC(CLONE_PARENT), diff --git a/linux-user/syscall.c b/linux-user/syscall.c index dad2c3312032..24cea6fb6a63 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -169,9 +169,13 @@ #define CLONE_IGNORED_FLAGS \ (CLONE_DETACHED | CLONE_IO) =20 +#ifndef CLONE_PIDFD +# define CLONE_PIDFD 0x00001000 +#endif + /* Flags for fork which we can implement within QEMU itself */ #define CLONE_OPTIONAL_FORK_FLAGS \ - (CLONE_SETTLS | CLONE_PARENT_SETTID | \ + (CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_PIDFD | \ CLONE_CHILD_CLEARTID | CLONE_CHILD_SETTID) =20 /* Flags for thread creation which we can implement within QEMU itself */ @@ -6730,6 +6734,17 @@ static int do_fork(CPUArchState *env, unsigned int f= lags, abi_ulong newsp, return -TARGET_EINVAL; } =20 +#if !defined(__NR_pidfd_open) || !defined(TARGET_NR_pidfd_open) + if (flags & CLONE_PIDFD) { + return -TARGET_EINVAL; + } +#endif + + /* Can not allow CLONE_PIDFD with CLONE_PARENT_SETTID */ + if ((flags & CLONE_PIDFD) && (flags & CLONE_PARENT_SETTID)) { + return -TARGET_EINVAL; + } + if (block_signals()) { return -QEMU_ERESTARTSYS; } @@ -6757,6 +6772,20 @@ static int do_fork(CPUArchState *env, unsigned int f= lags, abi_ulong newsp, ts->child_tidptr =3D child_tidptr; } else { cpu_clone_regs_parent(env, flags); + if (flags & CLONE_PIDFD) { + int pid_fd =3D 0; +#if defined(__NR_pidfd_open) && defined(TARGET_NR_pidfd_open) + int pid_child =3D ret; + pid_fd =3D pidfd_open(pid_child, 0); + if (pid_fd >=3D 0) { + fcntl(pid_fd, F_SETFD, fcntl(pid_fd, F_GETFL) + | FD_CLOEXEC); + } else { + pid_fd =3D 0; + } +#endif + put_user_u32(pid_fd, parent_tidptr); + } fork_end(0); } g_assert(!cpu_in_exclusive_context(cpu)); --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486294512586.1957104665927; Fri, 10 Mar 2023 14:11:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvn-0008Ey-72; Fri, 10 Mar 2023 17:09:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvj-0008CC-Gw for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:39 -0500 Received: from mout.kundenserver.de ([212.227.17.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvh-00031W-MQ for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:39 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MSLlu-1pyyr11yZ6-00SeRP; Fri, 10 Mar 2023 23:09:35 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 14/28] linux-user/sparc: Tidy syscall trap Date: Fri, 10 Mar 2023 23:09:13 +0100 Message-Id: <20230310220927.326606-15-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:cV4az+v6TnksWP2sepxsrOEm3GVw2zULcW4XLllXVNMC8MZQQx8 2Z7SfrSJfvyULyNZTqDI/4z0eyHAFWbZa8C2+RlDRLnyenNexYsfyJceJsQhwrbExidWXIJ CRS4g7XVG7o6Bm+swKigGZV31/8ISh28cJWgGaQdR9wi9mWDk/Yb+qTgMoajTAgWD3OKnE/ maAOIieomHrAD/Hnt2CHw== UI-OutboundReport: notjunk:1;M01:P0:RxtEefxb2Pc=;mdZ5smiUfc+Tra9V+37J+JWQEZu Wntycb9iD/AbHfJKVy5KIjs2wRkpW2uOGHxvO5pW061K7fsBtNjWIpUlGVnnycuyRb1xS3Www NTicx6/kn4N6q4jzPE0LUmRKCIS8JZLNfNFpyq02WXYQbb7k4ay2u1GCkxtwTDzgR+34qAnaF Zhtm5b9mcXPJ25rlDZIPdFHjNMC1SvMnYFW4lXeYvcQ0eldK0Viy/2iqOvyYUMtLTSWMggnTr Ved3RFLW85oE48mrUoANPJwi3IM3Im9YT/Wod+LUBeN3CgSfwVT9CNRKf3eomqM58yZKu0zLl 2kZCR1ZTpF8bhrdZcLlWYLafUm07HRqtaeCMCAnFb5zywumEqHz3waaEf4W2c1dV4SQbkGU4w tbPu7wYlIFXf1/VMeyteykDtnExgQag7FG6t1hUxpnL4HNQHx5KBiZFa+vcnIaPgddsL9dtAU bEyoH3Q8sFamJI8wtGihmjtrmn/Br776kh4mKDV1Vb/wqPiFFzcjmHdG00M9trgIDv41cgXlI KDT7zJSm+HYXU/nNXGtUg0MgF2Gv7ZhLe8STNzaowMveO6sGwScrXdLrQsrk4W8p0GwVUDrT0 c6JZLrdBV5FNUyVIV/9Nzrp9yStq16BeQcCJrxP/pFf3gmGd8AiOfUz7HhIyAUSzB0pm4V0ib OvVGYeXFga2qHgoaZlxv+MvisM9Cp3e3+ILGN4a9YA== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486295400100001 From: Richard Henderson Use TT_TRAP. For sparc32, 0x88 is the "Slowaris" system call, currently BAD_TRAP in the kernel's ttable_32.S. For sparc64, 0x110 is tl0_linux32, the sparc32 trap, now folded into the TARGET_ABI32 case via TT_TRAP. For sparc64, there does still exist trap 0x111 as tl0_oldlinux64, which was replaced by 0x16d as tl0_linux64 in 1998. Since no one has noticed, don't bother implementing it now. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20230216054516.1267305-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index c120c422786a..d31ea057dba1 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -149,6 +149,12 @@ static void flush_windows(CPUSPARCState *env) #endif } =20 +#ifdef TARGET_ABI32 +#define TARGET_TT_SYSCALL (TT_TRAP + 0x10) /* t_linux */ +#else +#define TARGET_TT_SYSCALL (TT_TRAP + 0x6d) /* tl0_linux64 */ +#endif + void cpu_loop (CPUSPARCState *env) { CPUState *cs =3D env_cpu(env); @@ -167,13 +173,7 @@ void cpu_loop (CPUSPARCState *env) } =20 switch (trapnr) { -#ifndef TARGET_SPARC64 - case 0x88: - case 0x90: -#else - case 0x110: - case 0x16d: -#endif + case TARGET_TT_SYSCALL: ret =3D do_syscall (env, env->gregs[1], env->regwptr[0], env->regwptr[1], env->regwptr[2], env->regwptr[3], --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486336576487.9333612110353; Fri, 10 Mar 2023 14:12:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvl-0008ED-Jr; Fri, 10 Mar 2023 17:09:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvj-0008CS-Ph for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:39 -0500 Received: from mout.kundenserver.de ([212.227.17.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvh-00031Z-P1 for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:39 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mgf8s-1qD80h3ak0-00h6r1; Fri, 10 Mar 2023 23:09:36 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson Subject: [PULL 15/28] linux-user/sparc: Tidy syscall error return Date: Fri, 10 Mar 2023 23:09:14 +0100 Message-Id: <20230310220927.326606-16-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:v2ycuPT5K9GEMqKTx4WI/iMX712RbjVyoHQstA4VfDsXM++Z/G5 WDFCW0n9DyN10rmyPOJ2uLPRZzTm0injlNiDC3lVoOc9S8UpNh40KnmfjsdA3Qd/0clfgxk LjEHjopgDo+5Ykeb4mqLFvDLlPeFguYg5HRxZY0J89AjBc4a6/0lq4cbDTbZ/Gqpjg8y1Yz +XVgTCJgyKuhEpFPxLc+g== UI-OutboundReport: notjunk:1;M01:P0:3JooTipO/gc=;xj8khNPqcJ6jUSMLEYETv34vxk2 N2JMK1jbUpFNwfOngGHvDWzLJx9+mX5d1S402m3jZuCqSlC2yCt+iyhLBSo0CdhVro/F9+hsD PQiO+6aNppxZckd+Tw+UGTLb07eZzgV9lVI5xLnGy9S2wD+toOgA9FT4FnOvrT8mw+sWTOJ/r AG1ragLUhO2+jMifx0yWiAuYzpbEwtgPhPvcyMMoUrOHkedY04u+VqUAHwGw4B+siI4VJ+RnB wcN98/ty8lFz8e3+H1Qcw0XsHtQ+IJdHrdrwqX67wbW5wxb9PxMYtzoCqmyvAhtzxnl2tqKn1 RbH2KUycteYfzTip3jCLISCT4SQXbQXSgvqD46hlVWWuVNfKIoqB30KDBZbbDK4Li01r8SMzm vNzWkfe+A4UQn6of1s4gGiNWGsNyMUyBY19tVNizLbBDrP7SrNr3etbZTUZLyzGki47nvaGm1 Ef9BM8ZxAVDF/4c4GkV1jZCT2RPLxKJ3RRVWebHqR/Jyba+mtUps23vUGBgVEOikI9u4YpPkH B5jNNv++0giH+yJM4JqUs7xZeTqe6QI3jts7sfG5xJNleCQSxLwYKAxTRrg/n1vr9MKbAsY+r vB3SMusfNd7uzNM9PQ8BGKYFVOPP4ryEHy9tCnwTpEJItkLd7xA6qC0H15UK/JdzIbUyM4VHu cqThf/h2IyQrL1vLxO4sqwpW2jeOi58+kdyv2JtPgg== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486337553100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Reduce ifdefs with #define syscall_cc. Signed-off-by: Richard Henderson Message-Id: <20230216054516.1267305-4-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index d31ea057dba1..051a292ce520 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -149,10 +149,13 @@ static void flush_windows(CPUSPARCState *env) #endif } =20 +/* Avoid ifdefs below for the abi32 and abi64 paths. */ #ifdef TARGET_ABI32 #define TARGET_TT_SYSCALL (TT_TRAP + 0x10) /* t_linux */ +#define syscall_cc psr #else #define TARGET_TT_SYSCALL (TT_TRAP + 0x6d) /* tl0_linux64 */ +#define syscall_cc xcc #endif =20 void cpu_loop (CPUSPARCState *env) @@ -183,18 +186,10 @@ void cpu_loop (CPUSPARCState *env) break; } if ((abi_ulong)ret >=3D (abi_ulong)(-515)) { -#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) - env->xcc |=3D PSR_CARRY; -#else - env->psr |=3D PSR_CARRY; -#endif + env->syscall_cc |=3D PSR_CARRY; ret =3D -ret; } else { -#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) - env->xcc &=3D ~PSR_CARRY; -#else - env->psr &=3D ~PSR_CARRY; -#endif + env->syscall_cc &=3D ~PSR_CARRY; } env->regwptr[0] =3D ret; /* next instruction */ --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16784863833041010.4471162878566; Fri, 10 Mar 2023 14:13:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvs-0008J2-Gm; Fri, 10 Mar 2023 17:09:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvk-0008Cj-3C for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:40 -0500 Received: from mout.kundenserver.de ([217.72.192.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvi-00031r-EC for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:39 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N1PLB-1qXDKd1EBH-012oL2; Fri, 10 Mar 2023 23:09:36 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 16/28] linux-user/sparc: Use TT_TRAP for flush windows Date: Fri, 10 Mar 2023 23:09:15 +0100 Message-Id: <20230310220927.326606-17-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:3osgtKUSUE42GHakZ8Boh8BAVEX/rtvPKEe1eY0917jIuWA4uHj R65dZrqQR/7c7w66SR0utsCOPurnt2TQh4bUVDecxuQDAxR1wxXLDBGIgeqkXKNrReRtBPM qbMtL0g3TAx/ZrR8ovxNwXQM8ZOfoEkrOmabhbVkkgdQejUWZbITkO4IALqwkUIXTsUjBCx ZGkE+nGyRnc7ZO51msdCg== UI-OutboundReport: notjunk:1;M01:P0:3bvzu7Ljdl4=;DeIoEthcNAO7UbFpNjB7U730qEn H7MR6iNdmASDXuGVEaT4pHWlZ+gdZibCdtF6CVQ6vtpRfhyhfkMKMpwD8bP80MWtXGkEjZQl3 wNRHCjvm7Zt7QNp54g5SLoajlX3PEzrXhPMZt+I7Cb0vz8+PFPLxpC6rC98ihDq7y4vLTZ40J vRI8Yrc5/JsSci8Tmc9QR2Odf0ZVCHy5iWrWCWWbepE5SzA1GIwNur2+EeDEwfTDEctzEKbOM 5FyP0iZ/R0b9kaXRJIUHAeF1LilAE2t3ThhTBmeUZKYneWJh16Ptv4xzVx/VFwQPEX32nz10B /RDeviqdRBMmN+BNKcqKsv8zMjSrd3VcvirpKSD49DzePneiCcXRB5qtY+c99Qj0PnnHXBj6B QiQf505DWccPV5tTsvaOn1fG/mxJUEcMvr/TZZj55NdPpxUtwasbkFZtHDlLJl9xxBzFNkIuL kObx2vgWIpEEk9ZhlcP55yE/639dBQ2SlU/xtlwDEPnvOiz0BvXF8Ij6ljwiD3RLZ7laHDIzr jIBdS9H+OhFyavz7hZE14sV/sNNB4/FuuW1CHxsqq8NdMiON42RpWT/3of2zwxyF9OduXD3bM 5rxYo4uG9mLqaBeGC+Jn36lzDOWxeikf2f1eYZI2BRkBHNKLAKI6gPs2/RnjUtV2UWYUYtxyF bTzbf8V3dHMSJTPcEdxz/5F52WkaaVal+JvzXmjZqg== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486383849100005 From: Richard Henderson The v9 and pre-v9 code can be unified with this macro. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20230216054516.1267305-5-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 051a292ce520..e1d08ff2045c 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -196,15 +196,14 @@ void cpu_loop (CPUSPARCState *env) env->pc =3D env->npc; env->npc =3D env->npc + 4; break; - case 0x83: /* flush windows */ -#ifdef TARGET_ABI32 - case 0x103: -#endif + + case TT_TRAP + 0x03: /* flush windows */ flush_windows(env); /* next instruction */ env->pc =3D env->npc; env->npc =3D env->npc + 4; break; + #ifndef TARGET_SPARC64 case TT_WIN_OVF: /* window overflow */ save_window(env); --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486355988999.869047000212; Fri, 10 Mar 2023 14:12:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvm-0008Ef-KA; Fri, 10 Mar 2023 17:09:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvk-0008DR-M5 for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:40 -0500 Received: from mout.kundenserver.de ([217.72.192.73]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvi-000323-Rw for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:40 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MadGG-1q73Tm3BIQ-00cAdN; Fri, 10 Mar 2023 23:09:36 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 17/28] linux-user/sparc: Tidy window spill/fill traps Date: Fri, 10 Mar 2023 23:09:16 +0100 Message-Id: <20230310220927.326606-18-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:QKXZmhRh7Ff57c68Uxrbc8j4mgAps2R99gyUwljWVZHe4DuKx/n Gav/ZM+dowHOq6tg/uO/vKWwgD6B113qNc3wHcJiAoZLZHnC0cjjhgy+t5xIPqd+S5LJwej EuPThXIu61LHrSpUL8xT/nW99LQGKGEqZGUKr5RwPugZ5wG0mlUAwHBLFIVERyDQdedWnuw V9jUelLhySZZ9MUADbzqA== UI-OutboundReport: notjunk:1;M01:P0:+w9c/4tFQXg=;++KJsyfqjG+gJNv1HaGAJ5UYO1Y eZBHOHdCdS/ma26lpKH80QAINYQO+Eqi9y1NaAjWIjO3BjyAL3DT4u6YXb9EUK+BrcuBB8kQv PbGvyQG+6FVFWkOgtIvIugiMuxa4ln887gzUxDsj2wruo1B+jVWr/l48LqyNAUTR01jZ+ASSK sF/jObxrJa448j+xL3ZYs+CpSFJPFn7pUDjiq0HPao66VK0qV/uJRb4zpqwrozG8uqLAhjlfL y1AiguqGm7B0luUasjJjnHBvGtdcNJdN4TEF7s/fQjOAj3VPE6xZVJ5BShTVC5+YXc/B0Ex0V /t2cbNAY4n9ykR6biLRnNBGayftrLobTJZ3kgClp4j3BvBrJKXkyWU3kk2ycgpxmaUz1yWhcL 8dtozJ+crhEcXqb1wkDIsWNNBnxb5ot271std4c3LqfvmHmydsADkAYhD8mSSYNwCAkuGlFIX BnjDvTWyrRv2YUK+8HowXmoSySUYYlXK1DFSZqJTk45gIHP1Rj83+BkRcQQSr1YuR59OnlLz/ pa9ZT59r01KY+1qm2oarqyt7gXVrauz3C3Bb0bTmNUwwe88BRd1ZraTnhxNqCYvp5HVguC4pQ 24b5anJxUyOoYqaFUx8XUahnBYcLhZ3sTC3dfEBoCvwOOdRMgQ6wwRhRDRJMi84VKafp9QT9h gGxaqm2nDBRw3DjZLB3da5eYkHVnbXkXhb+Ki/KnvQ== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486357685100004 From: Richard Henderson Add some macros to localize the hw difference between v9 and pre-v9. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20230216054516.1267305-6-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index e1d08ff2045c..2bcf32590fa1 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -158,6 +158,15 @@ static void flush_windows(CPUSPARCState *env) #define syscall_cc xcc #endif =20 +/* Avoid ifdefs below for the v9 and pre-v9 hw traps. */ +#ifdef TARGET_SPARC64 +#define TARGET_TT_SPILL TT_SPILL +#define TARGET_TT_FILL TT_FILL +#else +#define TARGET_TT_SPILL TT_WIN_OVF +#define TARGET_TT_FILL TT_WIN_UNF +#endif + void cpu_loop (CPUSPARCState *env) { CPUState *cs =3D env_cpu(env); @@ -204,20 +213,14 @@ void cpu_loop (CPUSPARCState *env) env->npc =3D env->npc + 4; break; =20 -#ifndef TARGET_SPARC64 - case TT_WIN_OVF: /* window overflow */ - save_window(env); - break; - case TT_WIN_UNF: /* window underflow */ - restore_window(env); - break; -#else - case TT_SPILL: /* window overflow */ + case TARGET_TT_SPILL: /* window overflow */ save_window(env); break; - case TT_FILL: /* window underflow */ + case TARGET_TT_FILL: /* window underflow */ restore_window(env); break; + +#ifdef TARGET_SPARC64 #ifndef TARGET_ABI32 case 0x16e: flush_windows(env); --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486272380314.1474752702146; Fri, 10 Mar 2023 14:11:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvn-0008FX-Vn; Fri, 10 Mar 2023 17:09:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvl-0008Dn-23 for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:41 -0500 Received: from mout.kundenserver.de ([212.227.17.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvj-00032G-4b for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:40 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MLhwM-1psQL30eEy-00Hcsd; Fri, 10 Mar 2023 23:09:37 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson Subject: [PULL 18/28] linux-user/sparc: Fix sparc64_{get, set}_context traps Date: Fri, 10 Mar 2023 23:09:17 +0100 Message-Id: <20230310220927.326606-19-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:69K/jYCgXPORz8wGvUZOLXHUrD1vBufjW2pwVwb/vk2qscrHw01 Fvnj8dj2VCxOeaeNGSixKk6OagguznlN2SwM+ph243ukEd4O7oGseHVitBN7qdXsvZ0pAnp L8AiFqg7gNdPm4m1jLkoEeqKbkP8oPMvAa0sNqgZt92nD3RFlww6x9Xq4CWGAgZcE5MkwGt fgCUrcVDzdd1ocDfKhXJQ== UI-OutboundReport: notjunk:1;M01:P0:wsY8nqk0a7I=;+yzeElQtxfv66R9pRSxHxpXj/l2 HgtwlO/dimfAERn1FM59ocUvsv56tnfSuwqSdKw8ap/ZYxXMd21kN7dXWBhrIQR166CggpFxy ZDIt1Fe5+c479c7OmiSLZJzPHdEwu61CEjU36bi9rjC4cK6/NRfN+BDQ0AGYax7OfaxRgRO/S 3vJQ0KoQ1lf+kfjLzqyRVUHYgBVFWVYN4RPmILqIQmesbiA3sfUzbjtjdudbv6Bii/+0Gwo7j DjJW81B5UGfS8tdrdLvsU68wYgGqn3WPQY+X1n6jLdBL9MJ+I9exqfyAKD3Weyf+iKiodIUEM aspK0fx8GVrQtm2qFk78fMNm/SxNg+FuFUzv1pah132F0QXFKtJj82O0+h94Sj4pVmLeYGtYI hEEPeIgrxfTGrELW/arOQwwdBF2hRUGi9tZ1KzVdfVKkpgLqixoYgPmH3id6zfP4Y3kPTS5r7 84eE1f03cFNe5p29RozhI9HfikqNHEguNMsNB/a9c2PnAPYpljYMVMKV7fe1vLKHlKrAEDU5l Uh5z2d+kY//NY8aQC8fdV2xQfSxVjRFQxgdP7fR6S957oHJtEUHks9sjcq3nuqY67t3kHkB/F YSGfd54MK15qGM8VHz6KGTCrsun/8NLus+GXHAUg5k/FGqESuEQmvHFQojGQExKHuy3ThmBZV oFJ3X1aIggTdzDT1N3awLKuc3YsPDqJ76tEHJAyY7g== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486273333100002 Content-Type: text/plain; charset="utf-8" From: Richard Henderson These traps are present for sparc64 with ilp32, aka sparc32plus. Enabling them means adjusting the defines over in signal.c, and fixing an incorrect usage of abi_ulong when we really meant the full register, target_ulong. Signed-off-by: Richard Henderson Message-Id: <20230216054516.1267305-7-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 21 ++++++++++----------- linux-user/sparc/signal.c | 36 +++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 2bcf32590fa1..edbc4f3bdcbf 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -213,25 +213,24 @@ void cpu_loop (CPUSPARCState *env) env->npc =3D env->npc + 4; break; =20 - case TARGET_TT_SPILL: /* window overflow */ - save_window(env); - break; - case TARGET_TT_FILL: /* window underflow */ - restore_window(env); - break; - #ifdef TARGET_SPARC64 -#ifndef TARGET_ABI32 - case 0x16e: + case TT_TRAP + 0x6e: flush_windows(env); sparc64_get_context(env); break; - case 0x16f: + case TT_TRAP + 0x6f: flush_windows(env); sparc64_set_context(env); break; #endif -#endif + + case TARGET_TT_SPILL: /* window overflow */ + save_window(env); + break; + case TARGET_TT_FILL: /* window underflow */ + restore_window(env); + break; + case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ break; diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index b501750fe0f1..2be9000b9e04 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -503,7 +503,23 @@ long do_rt_sigreturn(CPUSPARCState *env) return -QEMU_ESIGRETURN; } =20 -#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) +#ifdef TARGET_ABI32 +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp =3D lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp !=3D NULL); + + default_sigreturn =3D sigtramp_page; + install_sigtramp(tramp, TARGET_NR_sigreturn); + + default_rt_sigreturn =3D sigtramp_page + 8; + install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} +#endif + +#ifdef TARGET_SPARC64 #define SPARC_MC_TSTATE 0 #define SPARC_MC_PC 1 #define SPARC_MC_NPC 2 @@ -575,7 +591,7 @@ void sparc64_set_context(CPUSPARCState *env) struct target_ucontext *ucp; target_mc_gregset_t *grp; target_mc_fpu_t *fpup; - abi_ulong pc, npc, tstate; + target_ulong pc, npc, tstate; unsigned int i; unsigned char fenab; =20 @@ -773,18 +789,4 @@ do_sigsegv: unlock_user_struct(ucp, ucp_addr, 1); force_sig(TARGET_SIGSEGV); } -#else -void setup_sigtramp(abi_ulong sigtramp_page) -{ - uint32_t *tramp =3D lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); - assert(tramp !=3D NULL); - - default_sigreturn =3D sigtramp_page; - install_sigtramp(tramp, TARGET_NR_sigreturn); - - default_rt_sigreturn =3D sigtramp_page + 8; - install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn); - - unlock_user(tramp, sigtramp_page, 2 * 8); -} -#endif +#endif /* TARGET_SPARC64 */ --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486350484829.8888691537812; Fri, 10 Mar 2023 14:12:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvo-0008Fr-7O; Fri, 10 Mar 2023 17:09:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvm-0008EX-DO for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:42 -0500 Received: from mout.kundenserver.de ([212.227.126.134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvk-000331-Ol for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:42 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MAOa3-1pgUDh1yLj-00BxOH; Fri, 10 Mar 2023 23:09:38 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson Subject: [PULL 19/28] linux-user/sparc: Handle software breakpoint trap Date: Fri, 10 Mar 2023 23:09:18 +0100 Message-Id: <20230310220927.326606-20-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:uinLufA9+QpEWx0rvu0QzlvVtOyW5M/ZpPMPDssj6w3j2U8+/Nd lvV84qdaMRnaUVxmCMYAKkZPd5thDkzNJZYmZDuFsGiIgAZG1iGYmpOhJWGd5zRZeB1B/Xb Pc33dbQdlio7XkKY/zVecwCOZRMRz2q5j8qWapLJ2Nkwv1/CnKkMPgNAJGF9wtX2onkdQ2F uqGbk0ErITuDGqwRk+o3w== UI-OutboundReport: notjunk:1;M01:P0:xdQqFgzZDHw=;CMDBuahdiGdndJ+3eP6z3YhNoA+ luUtUXUSGE1xK2MFiRCwj4yPaUlLxW/Ws8fHDxAq7fRsXxSDRiV/0Z1QlAmbrX+uGixkXA38Z JBKUqFm0VCBtUFFEJkzusiui6ZCGnCpzJiwWP2rsAwchRFXtG6WokDBUAnHOjaUcrJkoKt37/ xxwZb9xzSxpd/BWfKN5F0cerwykI27ZQKLFrfEahdAHZ0dtjCDB4xa5ao+biYt5Iz8uZXxXC1 1migLNT8Gg1it1T+6++bZADeoZGWdNQNDcntEjC5kkDOvCb3EXXdsl82jXp4V3koqHKinOmMD FKi4Aao14gllsAdSaH4GLkd3JY+tQyOUmsUQ3uvoTJeNs9u8j1HXxgzvebuIVKsMIdmpxwh2W skvjq49Z1czTYs5fq2Tu1gVmSKWuESLckpysZvLnwOvSTqN28Xc130eXTSWxkTYCExGXcSqvN OyNM+YIVbY8alpNA5nij1khx2kabzxjcBmTBIHAoJ3AhCYWPZHRIvEmhDAiO3ttTOH3irRg1l xGnFYC+WC4zmkE1nfyHW5DKgnRO8FVKijdacyLJYtpAU92xm4dcdKpeqNlru7aGe5Tdto+OiR tIrNct4NoeXIY6W+0jkp5qq4twdRyzjydl1Q3DcBz5s630YFUco7bVV5ILM+CqnOy4RYOrzPz 77C2zh9lQl9QD+U1XeKhvy3LP3dkdzO8MHXOA1JB6w== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.126.134; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486351625100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This is 'ta 1' for both v9 and pre-v9. Signed-off-by: Richard Henderson Message-Id: <20230216054516.1267305-8-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index edbc4f3bdcbf..c14eaea16370 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -206,6 +206,11 @@ void cpu_loop (CPUSPARCState *env) env->npc =3D env->npc + 4; break; =20 + case TT_TRAP + 0x01: /* breakpoint */ + case EXCP_DEBUG: + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); + break; + case TT_TRAP + 0x03: /* flush windows */ flush_windows(env); /* next instruction */ @@ -237,9 +242,6 @@ void cpu_loop (CPUSPARCState *env) case TT_ILL_INSN: force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->pc); break; - case EXCP_DEBUG: - force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); - break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); break; --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486356525745.5439287751552; Fri, 10 Mar 2023 14:12:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvo-0008GV-SF; Fri, 10 Mar 2023 17:09:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvm-0008EY-Df for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:42 -0500 Received: from mout.kundenserver.de ([212.227.126.133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvk-00033C-Rp for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:42 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mr8zO-1qNY8q3bTq-00oHwe; Fri, 10 Mar 2023 23:09:39 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson Subject: [PULL 20/28] linux-user/sparc: Handle division by zero traps Date: Fri, 10 Mar 2023 23:09:19 +0100 Message-Id: <20230310220927.326606-21-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:o2groeTZ8+ZVcXX/xdZJp5rwLZURwetlvvjb05fhozql/0czbYv 5h1hK0x9wncC5Z9xcQysK8IUCvSITmoq1Qe4Yseduvc5k0DdJZizm5wB8selnKc0DLgaqVh 81+W5GkcIp/HKW+P6Qyl3LydKaSlleOHnKVCknKkWpJOl1cWe777hjs0FqDY3XUxyfJhK4O lAtJhjUJRU7Kk0Tqvt0Pg== UI-OutboundReport: notjunk:1;M01:P0:ah29MGxD33I=;a6SswT9F2eocKXfWVFmZIJLsrTc m7GlqVp73QhJ6IvZ+IKc3nvYEc0dx1DbNlmjMpwYNwDjLAMf59bcN70NL7V0AXQ9JMSmFWI+7 6ZoLnfH7kZtiKpl3J/3AXjemxND/EMwJuB0+/n7gMI+aTQCxy6p8//TCedMyOyl7w872lakRK WUuUiSJoZPbQCBonVAheRuRyfFmhF4eIPTwCsIvPBL/Jn6+LL0pEJK/XEZ+GT2O+xUfl/Degv ThLfEyy/f0X5siv4hD3ztUnF2KUfXjIX+rvQt/nFPddbwWgDntVeegLILytCA9E6mOHskCdic LEN2PTucJZ/kUfW6bDse7+ya85Crhfm+t8yE0JhAJfXeeGr7VmMZZLa4TuUxcKoyWsQNRFIZU lZEW62TnK/dpSKnx5Q2JVY86N3o3XU+trY9lxDQ5+DRxV/DsacReqX1JKBwDTbz198AjCyj8T 8ts/9Hbm8nBf5aOrUgLwX9vNcHxo+m70IP61552POXwiWPgwkLtceDYhjvSmva3UEUvwUbcIy fLnkTkJvYhEkclGByDj6nL7YfYn1PHfj2ydPBe0s9tkfILalz6EZMbw4TVfKqg0/8gnqy/J0S ZlcgZP5uve3AJTYE5a2pYm1jm+DNNPNs/w24Ngn6ERTaLyPdwgWazTKP/bMx3uhBMY//b/vcM qNg/a0DmY8oco4Biqi8tnS3CDNYE62Us9ZpIaAxN1A== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.126.133; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486357679100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson In addition to the hw trap vector, there is a software trap assigned for older sparc without hw division instructions. Signed-off-by: Richard Henderson Message-Id: <20230216054516.1267305-9-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index c14eaea16370..e04c84286769 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -211,6 +211,11 @@ void cpu_loop (CPUSPARCState *env) force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); break; =20 + case TT_TRAP + 0x02: /* div0 */ + case TT_DIV_ZERO: + force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTDIV, env->pc); + break; + case TT_TRAP + 0x03: /* flush windows */ flush_windows(env); /* next instruction */ --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486419057785.0878536196466; Fri, 10 Mar 2023 14:13:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvr-0008I9-62; Fri, 10 Mar 2023 17:09:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvn-0008FR-QF for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:43 -0500 Received: from mout.kundenserver.de ([212.227.126.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvl-00033M-Ja for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:43 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N3KkM-1qZhEf117q-010L9g; Fri, 10 Mar 2023 23:09:39 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson Subject: [PULL 21/28] linux-user/sparc: Handle getcc, setcc, getpsr traps Date: Fri, 10 Mar 2023 23:09:20 +0100 Message-Id: <20230310220927.326606-22-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:VHzsuxxPPKWyfOtCIGXTKlpnoif4oOTx6r8dnvKBJsoUhW/Xib1 iUBCnfxLEAB5zq2fxl8UrwrwRrHTsHO/eboCQ0wg/X5/MeHKYRPjqcDVfuqmGWFpw/95Hpa jVEFKrsGWnTh1KRRE2xItM2STRJb6pfzwBao/7pw8Selb7Twc3BUGKLk1MqaqKif3sdg3Zz qBbHwPoTUQ7oEgbECz8lw== UI-OutboundReport: notjunk:1;M01:P0:iP4dggLz/Ho=;RqsK83/RCo/DQMua3FTulhXvx0E IBDNR4R3l9x/iVB9CB5guzZzBjspHrNWvj0QgeimnHUekrpJDBGS15lbDrZ61PCobGP6qrXTN bDoM/lbVhzEho9DNgnZGc4bAZe1aqFQ1z/u/fxPEyL9gwOBHxNGJC+md6wdwoaQf4A+KuIaKU xzyqsl4Lc4JuEOOo+o4mxdvwgBpMkbVSmkLMfYA1LZxbHof4e/seUEEC09Hb0JXoaaO9CULfO bM+OPHsQBe6XfmH68plLb/55kzPAjRLDEeEBVZuKQip5U4/Kj7OTobazLtz6r2Nmx7mwx1BE5 Y0MrJQUI59OnRbekWerdPnW5SMkz3PlWRl3bzb64fU/W9fxzOBYq7Vp5XpeVaI2h583lxTSbl cqfH5mv0SkiYAS2LsZG2nzsL1qyShCHTYsP13UNXtOJR1nrXjcFCOfcNPRIaeo9UEdAWSFYp2 /4eRw2NnamAkkouV8PX+Zta7OSqENXI/VH4ZDBhmrD1i+hLeDZ//55UnEKTY1QWbjbxgfiVjk ee0tPBCjt5x35b8Ca2DsYJIxdOPkEznHH4XQu0MJXfipPlJ4C6PyGT7EdTGm0iCNbSw/t60UR qdwQuytc7iUuumNnFCqX6TZuoxVq7IqSm/gATRQ30YXMpmyoNYd+IfrQM8o/HwSoeEW0A0NC5 iLSBvUvuez1lCWaR9RsGaGWoflWG53Uj6NNOw6fjzA== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486420029100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson These are really only meaningful for sparc32, but they're still present for backward compatibility for sparc64. Signed-off-by: Richard Henderson Message-Id: <20230216054516.1267305-10-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 62 +++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index e04c84286769..a3edb353f6fd 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -149,6 +149,51 @@ static void flush_windows(CPUSPARCState *env) #endif } =20 +static void next_instruction(CPUSPARCState *env) +{ + env->pc =3D env->npc; + env->npc =3D env->npc + 4; +} + +static uint32_t do_getcc(CPUSPARCState *env) +{ +#ifdef TARGET_SPARC64 + return cpu_get_ccr(env) & 0xf; +#else + return extract32(cpu_get_psr(env), 20, 4); +#endif +} + +static void do_setcc(CPUSPARCState *env, uint32_t icc) +{ +#ifdef TARGET_SPARC64 + cpu_put_ccr(env, (cpu_get_ccr(env) & 0xf0) | (icc & 0xf)); +#else + cpu_put_psr(env, deposit32(cpu_get_psr(env), 20, 4, icc)); +#endif +} + +static uint32_t do_getpsr(CPUSPARCState *env) +{ +#ifdef TARGET_SPARC64 + const uint64_t TSTATE_CWP =3D 0x1f; + const uint64_t TSTATE_ICC =3D 0xfull << 32; + const uint64_t TSTATE_XCC =3D 0xfull << 36; + const uint32_t PSR_S =3D 0x00000080u; + const uint32_t PSR_V8PLUS =3D 0xff000000u; + uint64_t tstate =3D sparc64_tstate(env); + + /* See , tstate_to_psr. */ + return ((tstate & TSTATE_CWP) | + PSR_S | + ((tstate & TSTATE_ICC) >> 12) | + ((tstate & TSTATE_XCC) >> 20) | + PSR_V8PLUS); +#else + return (cpu_get_psr(env) & (PSR_ICC | PSR_CWP)) | PSR_S; +#endif +} + /* Avoid ifdefs below for the abi32 and abi64 paths. */ #ifdef TARGET_ABI32 #define TARGET_TT_SYSCALL (TT_TRAP + 0x10) /* t_linux */ @@ -218,9 +263,20 @@ void cpu_loop (CPUSPARCState *env) =20 case TT_TRAP + 0x03: /* flush windows */ flush_windows(env); - /* next instruction */ - env->pc =3D env->npc; - env->npc =3D env->npc + 4; + next_instruction(env); + break; + + case TT_TRAP + 0x20: /* getcc */ + env->gregs[1] =3D do_getcc(env); + next_instruction(env); + break; + case TT_TRAP + 0x21: /* setcc */ + do_setcc(env, env->gregs[1]); + next_instruction(env); + break; + case TT_TRAP + 0x22: /* getpsr */ + env->gregs[1] =3D do_getpsr(env); + next_instruction(env); break; =20 #ifdef TARGET_SPARC64 --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486273616894.8984611428789; Fri, 10 Mar 2023 14:11:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvq-0008I8-NO; Fri, 10 Mar 2023 17:09:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvn-0008FP-NQ for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:43 -0500 Received: from mout.kundenserver.de ([212.227.126.134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvl-00033Z-Jw for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:43 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MMGAg-1psyZR2eFK-00JGYq; Fri, 10 Mar 2023 23:09:39 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson Subject: [PULL 22/28] linux-user/sparc: Handle priviledged opcode trap Date: Fri, 10 Mar 2023 23:09:21 +0100 Message-Id: <20230310220927.326606-23-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:P4ONyuy7N0jy4CWnfH799ipb6/iB8eLiOxaqw5I/3U0l8KdcpMB MLP7pf/taNgSwnLq1zhXx3YTrqm6j6r50T0NG0l/KFc1CXgdaOE61SSxClimcFMVt/sHYpu oCe56XVJj6X9/XuG1ZO7h4M8fjFaDGXWQxjeUDd9hAx0+5l2weljiKVoLwFyj+rFmR+BlDs t4y7JL/m2VlYyflIilkZw== UI-OutboundReport: notjunk:1;M01:P0:+348JhsZYXg=;m3VI980DQbhz2WEZJ7A+hs6emRy l/h8YK4c1UU1Y0XPxUe2796kOheZCxiJImTIDktRY0VnjjKSgaiYfrZ4bsECtDrAAp7qBvCEI CPiOuKjrcCTSFw4vZO1z2RoCQC1m8NRdNQFwaHs4BrjRt7PiIxmRHJaA9EKfGEsuvdR4yUU1n UZjTwvyp6JMMxJ6zEoQ2OKIS67gl6Ux78ribOuVN7TJSC9KLGTy6NsYTOYv/BlYJjuHsvXq6M 1g+cVLuzwsrbVeAPABvTIvflwIthvf/TschlODbWeYryAHTa04EpBcHGsrhafWtqRBvTELW8U dSfNO97SHjGHFBQokYYRjdno4Qn54K3QnYh7tfSQBTF07UHgsHIVmxuWiwH/o/kIYYsPyfqIv M5jx7Tkn3Ozuq/jMx0uyivk08kAgodpzCEFYGmsTa9kP2FAoum+UgaKlyrO54z6zvsa4xIGoe wiwqkIGFub2U3bnxbtlNIn8BK2W0JtRH6SfesJwKQj3feNZ/up5RZTdOCg1tBKOXwF9VuEsGv TPx08kGXCaT9p3efiXgmj+cvAJ3pD1apzXUTFetJGazvtp+0DNNOmPykmmXgQhUq/OeTbnqym UYTesNyzaCyvHLelrRhZPIYXlej+NXrT1d0RW8w/Hc1SWV9s/bnL1alDTqEJ7LUwoArVfasQ9 BLr76MiDQ9KQ5n1FVYSJ2k6b3mKpvGUvEjAcem8PGQ== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.126.134; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486275300100009 Content-Type: text/plain; charset="utf-8" From: Richard Henderson For the most part priviledged opcodes are ifdefed out of the user-only sparc translator, which will then incorrectly produce illegal opcode traps. But there are some code paths that properly raise TT_PRIV_INSN, so we must handle it. Signed-off-by: Richard Henderson Message-Id: <20230216054516.1267305-11-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index a3edb353f6fd..61b6e81459be 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -303,6 +303,9 @@ void cpu_loop (CPUSPARCState *env) case TT_ILL_INSN: force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->pc); break; + case TT_PRIV_INSN: + force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, env->pc); + break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); break; --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486314366437.779318393691; Fri, 10 Mar 2023 14:11:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvt-0008Jb-8K; Fri, 10 Mar 2023 17:09:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvn-0008FQ-PB for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:43 -0500 Received: from mout.kundenserver.de ([212.227.126.135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvm-00033r-2a for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:43 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N63mC-1qcSOi05G4-016NpG; Fri, 10 Mar 2023 23:09:40 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson Subject: [PULL 23/28] linux-user/sparc: Handle privilidged action trap Date: Fri, 10 Mar 2023 23:09:22 +0100 Message-Id: <20230310220927.326606-24-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:8BJjg9GKKN+ZES0CWZFB+QptCwjTaxKXKEC9uK8uWe86U9qn6Yp /0KQaVY0+BljQGzMJYPVdAW/XJ/k6gqqnkgr8RhAFQnh8jjhqmseg8s1LsLxlDgPc+87tQm VAqwGzFigomyHwids9Keu0Z/MN0zoApz5oTKbBoVOCbq+hPxIMgrDvt9Orbb8N5qyTAqY0T F+VSphYSizgN028kBVaFA== UI-OutboundReport: notjunk:1;M01:P0:n72FCPrgKjY=;nY8N0nOPS5Gz/yab84uSjm34wFZ YcUZ0/ClylupTDuSly4cq+Rh4LiBz0sy9wLcU4FjllUQC6695LQamCpCvS1wYvFzVeWlEmP+z kRH9pv8Pq+nvaLPsG7M74NiY0GaT7PU1Xd1VEWSkIaXS5CMcWgQF5va4ORcZV7LcsRoK8L7zO CpeIHXvk+u+9vciprDqGnIrBZ3Qmdoj1BFC03he2QR4mXISVnoqaaMSB1FtAXojMYfbfJeVb5 S0Vbh68Rs0w3SoPSIMAFbc88IV0MS7R/ziaeguSW3LSyVk2tGQbVhV+qIj6mqcYlw322nKHoI 2CEe0bjccHcn8IzHEzRix1puz/VtjCD1OfendHo/U1dbwaAvBaOMdx5NEn2qERK5QQWdhCGcK sizsmZT8lSIdKSWTzf27gii/05Ssq8GWP6MZFsYQiG6AW646jlXlwZGFQP8e5awlOnir3YhLF 0w0rq7QQLzk7qAxxx0eVtAbVaFOe/smBfQHp0YA+Yt3Bon8fBgX16tHUCTCagqDOmho+YSZ6y X93PcYEilcMWR4iLIjzuQn776I6skufqmzY1UI7K965NLSDeqrBRUg7Srf7LjTBjbQjkobaqz p89sPgw5TSqG4eSFRhshvkVvzQ3iHcn5x5QK3jDqsB7/CnBhmD/DIIGlALupI4tx+8HH72ZGR f/pOAG6JJLqcsgpp8QMbPQOsTGKD5nY3b0jvn4O+Og== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.126.135; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486315511100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This is raised by using an %asi < 0x80 in user-mode. Signed-off-by: Richard Henderson Message-Id: <20230216054516.1267305-12-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 61b6e81459be..43f19fbd9141 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -306,6 +306,12 @@ void cpu_loop (CPUSPARCState *env) case TT_PRIV_INSN: force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, env->pc); break; +#ifdef TARGET_SPARC64 + case TT_PRIV_ACT: + /* Note do_privact defers to do_privop. */ + force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, env->pc); + break; +#endif case EXCP_ATOMIC: cpu_exec_step_atomic(cs); break; --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167848639630233.9309654150353; Fri, 10 Mar 2023 14:13:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvr-0008IA-9Q; Fri, 10 Mar 2023 17:09:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvo-0008Ff-0Y for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:44 -0500 Received: from mout.kundenserver.de ([212.227.126.135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvm-000343-Aw for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:43 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MT9v5-1pzG5j1liJ-00UaAb; Fri, 10 Mar 2023 23:09:40 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson Subject: [PULL 24/28] linux-user/sparc: Handle coprocessor disabled trap Date: Fri, 10 Mar 2023 23:09:23 +0100 Message-Id: <20230310220927.326606-25-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:9TX+eZuuOY4xjQjv8PKaO/zt5j3kT7yGZMA2ZGRHc9IMReKSOsE VzB3Jro5JzhD5wnEff/kQATHeJzSLnbZ8lsjhi2xUkmsreMvQyCd+pKqP1eYA4GXo9S3pzr fdTecH+DOmHkq3Xgp+AokrTJIKOf6SV+kTpYolli0WFZEIc6lsyY3TXJ6iaD3HohR3hPSMx aJFTg9cHqVoYWY+2h4hKQ== UI-OutboundReport: notjunk:1;M01:P0:1PMoYEuiGq0=;OBE+Hn38qeorioRzNk85qvoC0zc G++hIYmXenpSdgTIj5NTGIS969lZ7nGIht6mN/Pf+xyvVF9Q7Raz5Olgdf9jRPj1lC5OmyM4F vpPovjdZJSkLVEx8ohSauG8fDJqTnKSgZBa3NMmOJTXupgLu/qt7yFFhYir/Of8HFZOxMRAOo 4I8s5gPu0u3Sr0Sd9FrAwZeqjZwpJn68J9KUmRj35rUYLL5f3TCtkr1336CHq1PUV4i0IavPt +6DP560z27ij1c9VCBjIREyB9MC1n0kVSXC98MfMhCj3bLHpk4jBvtoEMA4CFZe7NJg3kmdBZ Das6MOPaHGpHt0ph3s/Tb7fzTTVi65o6/v6ZENwGRRiRIRfQITS1s46syWnpGq+I8M1I3DqpE nVEd4zb2OYhILYstdWqqoM7iNyQENORxKuOCfh8uo7O3lcuCEwuV4OOwgKOsq0DvBEEMwQcML 96p2w11FbvyOOYQunqfX+Jpnsecucj8GnrdQ79kr7gr4vKGZeGXg2YAwNQi4xOGO5uRFJtg0s ZcTWNReF+dn01IwWpBY9yA6ijafJQRSIsmQpQEKKSlV09EYxaokBVGDMAMAyiTDgnsnD8J4jb fiAgk5NaH9Afo7flVauHxZCKf13x1gg4QqeaNBWbNVUMBgNqcNCrepfQAKMB7sxJRe8pHtdCe hR4EwyqWkqu8F3sfBaYnSF4ydM4vtbZ8dvwLCE7mng== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.126.135; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486397915100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Since qemu does not implement a sparc coprocessor, all such instructions raise this trap. Because of that, we never raise the coprocessor exception trap, which would be vector 0x28. Signed-off-by: Richard Henderson Message-Id: <20230216054516.1267305-13-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 43f19fbd9141..bf7e10216fe1 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -311,6 +311,10 @@ void cpu_loop (CPUSPARCState *env) /* Note do_privact defers to do_privop. */ force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, env->pc); break; +#else + case TT_NCP_INSN: + force_sig_fault(TARGET_SIGILL, TARGET_ILL_COPROC, env->pc); + break; #endif case EXCP_ATOMIC: cpu_exec_step_atomic(cs); --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486369924416.43691139853036; Fri, 10 Mar 2023 14:12:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvs-0008JF-MC; Fri, 10 Mar 2023 17:09:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvp-0008Gp-2I for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:45 -0500 Received: from mout.kundenserver.de ([212.227.126.134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvm-00034E-RY for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:44 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MZCrZ-1q5KdR3Q0X-00V74J; Fri, 10 Mar 2023 23:09:40 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson Subject: [PULL 25/28] linux-user/sparc: Handle unimplemented flush trap Date: Fri, 10 Mar 2023 23:09:24 +0100 Message-Id: <20230310220927.326606-26-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:qBqa4sXS9ldltBNv57y74uGX6DZK3Y4mUJFJkHx4S5tYcPav4Kb z0tykp8ghHjv2pKPOtGi02uko6sAV9afc/+cLEJZq5GrwOHFGij1I3sl6sLjIk9vrnZlxw2 248VA2d+ZQMJO1SZQODd8gJ+uhlqxG0ymvCfIncRb5XXYBQ3U0lIHjLmGm3nzudlm7ZcGnY yZPY3zcpBA51/HmqDvopw== UI-OutboundReport: notjunk:1;M01:P0:9jYbuyek/ew=;X+RIAcT83fDjR9narXVEUlQ6uoj q5VNhwwGtPWjaf9NeoqObJH4CNHPFLuYPC95w/qHFNJ9S6gn0LGOSm1+7G1JFvQUx1l6L3G9j BLwnyX/drFgw8g6aSa39aP8zvWj91mi9d4bOzVyC0KwiLfYTQtsQ0ZtHvdJ7azB1h07hYwLTS x4r1aqNOhWT4KsJ5LN7jfWCnYnCXKzAddWuRm8U5oeJwHYIRKcayHGhYgTW5PBmt0y3UtpvaF lM+K82OH6Ghg3GF+tpRN7SvHWkwiBkvVxT3pyk5fXfZwRShoBtjE4SJUkQ2ZJB+xx3DVOQ3Jb VE/aMeE+bAjIgJkZstE4oPN4H4N6o4xWDYirHdFPeVWDszNMBMyiSuJZfDxbi9CrOlcEIBLvv sbp39K8AGw38wEy8vHsBGtzqTp5rrE6iVabqTv8trHZZKHBIRrMmTW1ldOzK4jDeABBrDggOe TAZqmiciBGR5o69u1eVHFKDT80wUWdM/8m4uGq6w7rsl6SDbDyoVeq0H6g3HWg5bJdO9uGvC7 u0max07kYx+1G+I/KgqUSwUIRUBru3/h5SIazwJsWjYaghJMUfFFmtmoZz6OFPEKHgDAV8Y5Z wE8/KIjlCghv37gCcy7QOcUIDECDIR+V33OB6ix4ST8R210gxetQDcLr++WJYaKgBhOcgn302 idn2jOBmUaUwiS4wd3gU2oDJTRVF+wbZytvGfiYEpg== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.126.134; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486371691100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson For sparc64, TT_UNIMP_FLUSH =3D=3D TT_ILL_INSN, so this is already handled. For sparc32, the kernel uses SKIP_TRAP. Signed-off-by: Richard Henderson Message-Id: <20230216054516.1267305-14-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index bf7e10216fe1..093358a39a4a 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -315,6 +315,9 @@ void cpu_loop (CPUSPARCState *env) case TT_NCP_INSN: force_sig_fault(TARGET_SIGILL, TARGET_ILL_COPROC, env->pc); break; + case TT_UNIMP_FLUSH: + next_instruction(env); + break; #endif case EXCP_ATOMIC: cpu_exec_step_atomic(cs); --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486426257305.9487852375171; Fri, 10 Mar 2023 14:13:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvs-0008JH-N3; Fri, 10 Mar 2023 17:09:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvp-0008Gq-31 for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:45 -0500 Received: from mout.kundenserver.de ([212.227.126.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvn-00034M-4x for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:44 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MvKGv-1qRD3k0ter-00rET9; Fri, 10 Mar 2023 23:09:41 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson Subject: [PULL 26/28] linux-user/sparc: Handle floating-point exceptions Date: Fri, 10 Mar 2023 23:09:25 +0100 Message-Id: <20230310220927.326606-27-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:4P9Zsn7G8HSfHDsvdt0KtNizKfMoOCm/eELvFsgqzdfKLA5o1tg Ir5k8FDWW8vRgIEQxdT3grF5Q40hUyvir+wrWCVO2DUEl/Ml9EUHGYcmgR9eTZemVriZU0x 3iAF+fEcA5LjebEWODkbkyvZWG2W40uAEBjTAbVW4E9de/AWATdaiObMH1jCMQqhr8OUIhS 6ZbSVYPhecQwdzkQAuKkA== UI-OutboundReport: notjunk:1;M01:P0:T2yJJb6gBZg=;fOqjSSzcPA0hnDQqZUY3FYNbwvS SaC8GvjHFs61FHeXh+EYovzAqcet0VlG+FqRY8ySRbJYO/yGuH8T0kNfcTOU62gHuldjhqTZv 0Sb4ymrjmJUMcTLumv8oE8d5KHqNiWTmwpChfpqtG5YUdYhyO1QQJMD+FFOEwHUmkfh2I9MnS xUDUTWwtSgapDX04/5vxuYBYzQU/GqXl1qm/gmzeNozIPwgK4z+pg5cEMQ8P0AVlXFu2CgGjo o6Rsko4CnDmPORyiMzIBR2dwaVTL6bNt93ATwUl7RETtCUCWVNw+RkbKyUYNKtzns+aGTWxyZ UGHuKxZklVKGKLNEP85AkNmR1rCKSluSyEepNZk2ub+6CIyQSvIzEwnLGnT+J0fO3WhIjgGeB per3Y7P/ZOSRTsIs66zKAdxRtn3q0QVAvLNDpzRTF1AiIfMWNxKKThhZXO29VPvaxQfIIjSsK H4/HlnhLBeWPGb1vj8zs/GDFj8q2b9d1ej5sMzhoAq+ZICd6MEjVFMRFugljSTjG3wFGw75Zm s4TEoTYz0p2bUaPgywD9TErByC//80A6YFnxq+KIyUw/xyZzhcJXtoO1VjwnbGLr5xXiy0SmE X4NF96hQ72gTpYnz0dH5y0MXBuwVDgW5wnlYUa6JxXRvW//wmmw0hY614WDYoAW5Q9V8ObUi8 B45MHw5zZ3bmFlX8Prg3Av4dNEcpo7ZSwuYBD0lrmQ== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486428043100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Raise SIGFPE for ieee exceptions. The other types, such as FSR_FTT_UNIMPFPOP, should not appear, because we enable normal emulation of missing insns at the start of sparc_cpu_realizefn(). Signed-off-by: Richard Henderson Message-Id: <20230216054516.1267305-15-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 22 ++++++++++++++++++++++ target/sparc/cpu.h | 3 +-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 093358a39a4a..5a8a71e976bc 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -297,6 +297,28 @@ void cpu_loop (CPUSPARCState *env) restore_window(env); break; =20 + case TT_FP_EXCP: + { + int code =3D TARGET_FPE_FLTUNK; + target_ulong fsr =3D env->fsr; + + if ((fsr & FSR_FTT_MASK) =3D=3D FSR_FTT_IEEE_EXCP) { + if (fsr & FSR_NVC) { + code =3D TARGET_FPE_FLTINV; + } else if (fsr & FSR_OFC) { + code =3D TARGET_FPE_FLTOVF; + } else if (fsr & FSR_UFC) { + code =3D TARGET_FPE_FLTUND; + } else if (fsr & FSR_DZC) { + code =3D TARGET_FPE_FLTDIV; + } else if (fsr & FSR_NXC) { + code =3D TARGET_FPE_FLTRES; + } + } + force_sig_fault(TARGET_SIGFPE, code, env->pc); + } + break; + case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ break; diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index ed0069d0b196..fb98843dad53 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -197,8 +197,7 @@ enum { #define FSR_FTT2 (1ULL << 16) #define FSR_FTT1 (1ULL << 15) #define FSR_FTT0 (1ULL << 14) -//gcc warns about constant overflow for ~FSR_FTT_MASK -//#define FSR_FTT_MASK (FSR_FTT2 | FSR_FTT1 | FSR_FTT0) +#define FSR_FTT_MASK (FSR_FTT2 | FSR_FTT1 | FSR_FTT0) #ifdef TARGET_SPARC64 #define FSR_FTT_NMASK 0xfffffffffffe3fffULL #define FSR_FTT_CEXC_NMASK 0xfffffffffffe3fe0ULL --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486386219726.2066306545564; Fri, 10 Mar 2023 14:13:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvr-0008ID-SJ; Fri, 10 Mar 2023 17:09:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvp-0008Hq-KF for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:45 -0500 Received: from mout.kundenserver.de ([212.227.126.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvn-00034c-RS for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:45 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N1g3U-1qY2Xt2XtY-012074; Fri, 10 Mar 2023 23:09:41 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson Subject: [PULL 27/28] linux-user/sparc: Handle tag overflow traps Date: Fri, 10 Mar 2023 23:09:26 +0100 Message-Id: <20230310220927.326606-28-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:OcfT3VyEztuO+dGE7DGlwnBMGNK02Fiqz9rjRj6prHOlyNKK0hK /8zByGLU+59nK4N5YQ+E5zMcVNtHYgevCjroLEyxNKkOyehqwBMlTxBZrWieg6u2BLSMOM1 LynNX9dopUT9q15GfKPXpT2iENu4sj5KaofJu/4LcStpqnX9cDSvr7iml5w2OLyWa5zW77T 5lfuSBuaxNhN9XuG28QlA== UI-OutboundReport: notjunk:1;M01:P0:EW9VIB3n9YM=;Q72xUPAAtKMJ5xERba8/38J7DXv gCmGx5FZxDBnSVmDbnAyHc2rrfslZFw5xahoH6hnAKsRcXTcB8hv3VRwTIezPv6HT+BcIrRUT uYWp4nKQ9MGKHjlsmUwXDUM5OxTPUF/VykptXd4Tdin4dchX8i/5PUoe+44B0u5YqaE++vYl8 wjwu/qTHdMJnukU6GShyrcF4KGFyP1RHf/CJ6mLE+Jo+S2ytOCIhGwuWvE6sP7sxgaXCQEDA8 4g9+lxqBe11xGxVtiTyiiPCXJL4Gej9RkxI3vLaOsPdUz9eR3Bme3j0kk6tICH6Aahv7ySo7k qEkqwGrhUxpTsC46x/VbCeJM0LmC1/f4aKRVq1Z33pH77r/yoquugu1Xpgh46cxS7VrDfaBGI mJ4Bn0b7qv76TrsXKDf59WfIKgYk+R5dms/1661PuuYffSiYD/hekKoJRU96NtIZYLxEYKkcU vIyfq83uIREhyelBVUPhT8lVtwPQlcs529DynY7f3SuUAWr+XN8QllmCJavOCqEfJq/qtiorJ gqsXbwzfK6XhwoXh+2vI2s+aPdlv8NTGeJISjAlLZeJqy6lrSaTy+v4jVtnITnhoni23qlTT0 Fkfev0r4WlfvFWR694yMCumz+FoMTjzvUVTTeuCY3taW48YHlUiqDwFjkLH7ncOpZ5EvmcZ1w 9ggO7B37mM3s3/YvrxI0FKU0QaQz3u8sRaZ85HlSCQ== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.126.130; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486387924100011 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This trap is raised by taddcctv and tsubcctv insns. Signed-off-by: Richard Henderson Message-Id: <20230216054516.1267305-16-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 3 +++ linux-user/sparc/target_signal.h | 2 +- linux-user/syscall_defs.h | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 5a8a71e976bc..b36bb2574b94 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -328,6 +328,9 @@ void cpu_loop (CPUSPARCState *env) case TT_PRIV_INSN: force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, env->pc); break; + case TT_TOVF: + force_sig_fault(TARGET_SIGEMT, TARGET_EMT_TAGOVF, env->pc); + break; #ifdef TARGET_SPARC64 case TT_PRIV_ACT: /* Note do_privact defers to do_privop. */ diff --git a/linux-user/sparc/target_signal.h b/linux-user/sparc/target_sig= nal.h index 87757f0c4e76..f223eb4af6a5 100644 --- a/linux-user/sparc/target_signal.h +++ b/linux-user/sparc/target_signal.h @@ -8,7 +8,7 @@ #define TARGET_SIGTRAP 5 #define TARGET_SIGABRT 6 #define TARGET_SIGIOT 6 -#define TARGET_SIGSTKFLT 7 /* actually EMT */ +#define TARGET_SIGEMT 7 #define TARGET_SIGFPE 8 #define TARGET_SIGKILL 9 #define TARGET_SIGBUS 10 diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 77864de57fb6..614a1cbc8e3a 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -717,6 +717,11 @@ typedef struct target_siginfo { #define TARGET_TRAP_HWBKPT (4) /* hardware breakpoint/watchpoint = */ #define TARGET_TRAP_UNK (5) /* undiagnosed trap */ =20 +/* + * SIGEMT si_codes + */ +#define TARGET_EMT_TAGOVF 1 /* tag overflow */ + #include "target_resource.h" =20 struct target_pollfd { --=20 2.39.2 From nobody Sun Dec 22 06:17:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678486234153297.4226318349722; Fri, 10 Mar 2023 14:10:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pakvz-0008MD-Bh; Fri, 10 Mar 2023 17:09:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvy-0008M2-3l for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:54 -0500 Received: from mout.kundenserver.de ([212.227.126.187]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pakvw-00036X-Bk for qemu-devel@nongnu.org; Fri, 10 Mar 2023 17:09:53 -0500 Received: from quad ([82.64.211.94]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MG9To-1pmpkR16oG-00Gc5K; Fri, 10 Mar 2023 23:09:43 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , "fanwj@mail.ustc.edu.cn" Subject: [PULL 28/28] linux-user: fix bug about incorrect base addresss of gdt on i386 and x86_64 Date: Fri, 10 Mar 2023 23:09:27 +0100 Message-Id: <20230310220927.326606-29-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310220927.326606-1-laurent@vivier.eu> References: <20230310220927.326606-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:3XJKxqtEkm1gEjnf04IlYzo9UetJwh8unQiZlSpIEDTY8mZu5l0 oDAVglJmNyRG5Seu68didFFEIuxLvG73Gpv7YpifpbtRwkx3aAwWhulNTVKTA3CAFJpa3e2 df2rltyDc1JPfSCzfbujFiVT2Uupvq3rnEv6WRpQTU/gMQeD6nZnUBGsRN2MlQeTbbENKLy fSCeMno4zfkfM6PW3ntMg== UI-OutboundReport: notjunk:1;M01:P0:A4492zbpkIs=;eisQV6cS4y6l70sd5zGoJzL0xOq +SuoPoa1hYD2Ok/BybL3AcVr7sMJI4FYTH1bgzrLzHGTW4PqU+mm3oxFWBCMaZRzfkmagm0vb pUD1Li6AoPWCYzNF2z4Nnrp/t5X+zMC1+0CrC4TEG3vdSQoHjMacFTLhLKSt6Eg5pA7GEKS// n1ic5b3+544gOEHYXFU6TxZQBuqkUkgEQNsX0NlbPkMAsB62jlXLFwlLPKjzGNvaKvOIiGp+M kld6M0Gu9CkCegfUh51ZxAPi2dg9CD/WRE2Da7d38de3utRBMjSFC3pjTZhW1jSJIKDpiHxM7 Nu2H6nuyRoH+4NWto5Qvwqs02Q1iK83qm2QvMpOiycMjnlIvKuqp3QyAhKKnxY/VgoOFRMCRI edUBvKg0GzjVanRnp1wBVtolPyLPsJNxd/PiDwAyLTB0Sc+fQmzzU+gYDfQX/WCXRaCbhmATd 42aZsOD0r5uXGpJMWqxR2K5/OaO1d/0kS8PQL/aki0qTxcwT3hjZ6D473ZSRmGAKOQAFiGH2+ 9irA7s07SMFiIN9SlnuGQrizaiKxhFUcXxdQX6a2iqDspRe49vBuYk+gBIJU+XhJ1rul5TMpH xoH8HgUCPzQNJZ5u5Nif7fA0lObRRJzhzC3T8PhpRoXud+stUuGHBvN0CXJNbekO8GC/8PJ2V Z+lvadsKo24wZndjLfZPA4XA97meWuC3mKF6ajodug== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.126.187; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678486235274100001 Content-Type: text/plain; charset="utf-8" From: "fanwj@mail.ustc.edu.cn" On linux user mode, CPUX86State::gdt::base from Different CPUX86State Objects have same value, It is incorrect! Every CPUX86State::gdt::base Must points to independent memory space. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1405 Signed-off-by: fanwenjie Message-Id: <4172b90.58b08.18631b77860.Coremail.fanwj@mail.ustc.edu.cn> [lv: remove unnecessary casts, split overlong line] Signed-off-by: Laurent Vivier --- linux-user/i386/cpu_loop.c | 9 +++++++++ linux-user/main.c | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c index 865413c08f07..2d0918a93ff6 100644 --- a/linux-user/i386/cpu_loop.c +++ b/linux-user/i386/cpu_loop.c @@ -314,8 +314,17 @@ void cpu_loop(CPUX86State *env) } } =20 +static void target_cpu_free(void *obj) +{ + CPUArchState *env =3D ((CPUState *)obj)->env_ptr; + target_munmap(env->gdt.base, sizeof(uint64_t) * TARGET_GDT_ENTRIES); + g_free(obj); +} + void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { + CPUState *cpu =3D env_cpu(env); + OBJECT(cpu)->free =3D target_cpu_free; env->cr[0] =3D CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK; env->hflags |=3D HF_PE_MASK | HF_CPL_MASK; if (env->features[FEAT_1_EDX] & CPUID_SSE) { diff --git a/linux-user/main.c b/linux-user/main.c index 798fdc0bce8e..47b0c0fc4394 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -238,6 +238,14 @@ CPUArchState *cpu_copy(CPUArchState *env) =20 new_cpu->tcg_cflags =3D cpu->tcg_cflags; memcpy(new_env, env, sizeof(CPUArchState)); +#if defined(TARGET_I386) || defined(TARGET_X86_64) + new_env->gdt.base =3D target_mmap(0, sizeof(uint64_t) * TARGET_GDT_ENT= RIES, + PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + memcpy(g2h_untagged(new_env->gdt.base), g2h_untagged(env->gdt.base), + sizeof(uint64_t) * TARGET_GDT_ENTRIES); + OBJECT(new_cpu)->free =3D OBJECT(cpu)->free; +#endif =20 /* Clone all break/watchpoints. Note: Once we support ptrace with hw-debug register access, make su= re --=20 2.39.2