From nobody Thu May 16 11:50:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165882945836292.30301222327137; Tue, 26 Jul 2022 02:57:38 -0700 (PDT) Received: from localhost ([::1]:54110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGHJo-0001Fm-9R for importer@patchew.org; Tue, 26 Jul 2022 05:57:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGH7U-0004Xa-F8 for qemu-devel@nongnu.org; Tue, 26 Jul 2022 05:44:53 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:42077) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGH7Q-0001Bf-W3 for qemu-devel@nongnu.org; Tue, 26 Jul 2022 05:44:52 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mn2Fb-1nnlvv0Lkl-00kC7M; Tue, 26 Jul 2022 11:44:44 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller , Peter Maydell Subject: [PULL 1/3] linux-user/hppa: Fix segfaults on page zero Date: Tue, 26 Jul 2022 11:44:40 +0200 Message-Id: <20220726094442.4452-2-laurent@vivier.eu> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220726094442.4452-1-laurent@vivier.eu> References: <20220726094442.4452-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:XXxmPxTHhgxbbEDCLBQD6X7qk1FoEnMPD++qcBHz2DayfS8jT2A zdiFPhmD2eQF0f4cBYeYG27F9DYshcA44zrf+udcMR+Xb0LfNJihXcaytRyTCUpO61qzoLl VThBp5CRm0iFQ+tcMm4lYfGhID4s3j5Ep9RagOneF6lJvNVGDqGod37BeR5Lw7CdXnd1MJV se2ha6ZvpENHng7R8LgmA== X-UI-Out-Filterresults: notjunk:1;V03:K0:ypWP8l/fv4I=:rkrgAEIaYa/74erB1yBOoJ IK+CgHR3wkR8f25Xpr6wTjwfaxpNCt3YZM9UqohoACSV0S6qesp8ILQzVy8uBmqp0b0U4cDmK SIRoSpsJoGYXiB4Oqp5SEBDbVvWfsBle3Y2UjcIgcyE765BVXDUmxuFWFcfiA6GUwcnq07WGU FZ+xq3We8L/wiuJeCkAywt2cxHlRfiJh69ddtn2vdc5Phxzq+s9/dyWnIdL5P7SKmU5qBsu54 vFnN0rLe59So9NxnJ6T3AWUU32pC1daPihbRf00EWWTszc1TJWq3yAEi8VditIB6nCCTbCdRl GbnfKknH6BeKKHTTm06mnHQdlOLgpD6ejsEoTXppxxQsrDQ5e979QuTfmurzaPBuSxOueboev wmzD4IluCeGXlVpW6ojIdzbSPf7qU0r5s/yy9s+P/yuNgYndpz3IJaA7YmQysqvD196dCi4Mi gYDr31rybv0lgjEDwU+j4/HgpDggTO1VpwPzHA5duO9QIPfVbjOs1AlBMS5sX5GgYN97HZnqU ApYITWBb5p/TrimZTawcSgt4OI8+QokQTOmlDSy4RHmQTjSbN4hcj0Ttnjk/AhA0+XsZhuSNI TCXlyUN/KblvFCYdduk0fqAJEV3yzPdM2xvKFlhewNNfTY/NdjoVVyiASXA9S6Uhw9WiVSQ8o +M1BhJcqDg/stLoA9oKEW9qkWa9g+ioOgPKPSpv+HklZ4f1oCMlkoVvyIcrksGKDDWfneF5/x eMcEVUTBepFrHMjYWyVjQW6OEWRUuN51m11amA== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1658829459328100001 Content-Type: text/plain; charset="utf-8" From: Helge Deller This program: int main(void) { asm("bv %r0(%r0)"); return 0; } produces on real hppa hardware the expected segfault: SIGSEGV {si_signo=3DSIGSEGV, si_code=3DSEGV_MAPERR, si_addr=3D0x3} --- killed by SIGSEGV +++ Segmentation fault But when run on linux-user you get instead internal qemu errors: ERROR: linux-user/hppa/cpu_loop.c:172:cpu_loop: code should not be reached Bail out! ERROR: linux-user/hppa/cpu_loop.c:172:cpu_loop: code should not b= e reached ERROR: accel/tcg/cpu-exec.c:933:cpu_exec: assertion failed: (cpu =3D=3D cur= rent_cpu) Bail out! ERROR: accel/tcg/cpu-exec.c:933:cpu_exec: assertion failed: (cpu = =3D=3D current_cpu) Fix it by adding the missing case for the EXCP_IMP trap in cpu_loop() and raise a segfault. Signed-off-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: Signed-off-by: Laurent Vivier --- linux-user/hppa/cpu_loop.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c index a576d1a249fd..64263c3dc406 100644 --- a/linux-user/hppa/cpu_loop.c +++ b/linux-user/hppa/cpu_loop.c @@ -143,6 +143,9 @@ void cpu_loop(CPUHPPAState *env) env->iaoq_f =3D env->gr[31]; env->iaoq_b =3D env->gr[31] + 4; break; + case EXCP_IMP: + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, env->iaoq_= f); + break; case EXCP_ILL: force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->iaoq_f); break; --=20 2.37.1 From nobody Thu May 16 11:50:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658829703425699.529053080205; Tue, 26 Jul 2022 03:01:43 -0700 (PDT) Received: from localhost ([::1]:57636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGHNl-0003rb-5F for importer@patchew.org; Tue, 26 Jul 2022 06:01:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGH7U-0004Xl-I2 for qemu-devel@nongnu.org; Tue, 26 Jul 2022 05:44:53 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:36531) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGH7S-0001CR-GU for qemu-devel@nongnu.org; Tue, 26 Jul 2022 05:44:52 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MQdtO-1nsfjG2KGs-00NfEf; Tue, 26 Jul 2022 11:44:44 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller , Peter Maydell Subject: [PULL 2/3] linux-user: Unconditionally use pipe2() syscall Date: Tue, 26 Jul 2022 11:44:41 +0200 Message-Id: <20220726094442.4452-3-laurent@vivier.eu> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220726094442.4452-1-laurent@vivier.eu> References: <20220726094442.4452-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:+Ovr0/76oUH/hG6+og+GRiO3VEqbLUKfsSkyxQDBuFg9eoNjQGg 8QiXjbjYJcaHd7WTlSyEP9PYwJEJh34h+/yoO9jekAYKap1yo0wZ4VCDZUxN0yq7NUJiCSv qNSlP7mmkghMR7WsoYMFAbQtFhaiEDw4WONnx7pUkH/RcC7IJ2fyFROUm+YpsOVuka+Ilf7 UZjpK2COJeIdlc5dZMBGw== X-UI-Out-Filterresults: notjunk:1;V03:K0:XQawUWV7wuk=:i5qp53y5nHaHIqFIYgtxoI tebL7qAbBm6xS8K5NMAdY/wsj4CwM5X/LFScDnFqUiuEjMRgJI0YH3QKXTk6EWadb6hH8MEE5 +mDKVNgCCv4pcyn3KKHlDEzoQr6ljmaVkshsYAPal5amPHr1qytzFTyYChH2XHJG5kISdzWFz 6RRsv4VxtTCJsKWgNkYSS3tib/o/OTXm0pBwrRn3TkdXb/pUN657hkJrmaV9xSV7qRVRd8vbs tHnxzn9/RUl0XqQf1G25R8q8CsQrYA40tc5YSi2jMsWUOVhA/OBV/ScwAX52QpajO17HeToEN 57KumYnmInUXkd+zrZWTAaIY1e1JjoIB0mOrFT1khblksAJOzbBfNSOgOyrlS6x7+iCIsdJeg Uj4PeSiBhHQi2ei4tNUql8FjElDp0xjWfEqBPPkI0hYn7v+Jce2jMPsk2f5HmRpccn8ba5Cz3 gNO43HAChzE7Y9BzdM/pjpzh4of/ZL38jSp6YzuSZopd6sgLqrGZ/wy07VtSTS+yEF+etgUv5 dikJvAuBUWTnp+Qdk2p32TY3t+EDrC6oZ0QJEJ89ka2FGqvIsTN4J1TL0U9wLZqSZN5FmKdpG NgPyvELtFcMyU9IAzbiEUU7oJ7fWXzdj9+uwSFfZR3nB2k6QRI4pQCX5t8tzbbStIl/YZaGra p5rmBrSOp1CB0sEd0/k0vgt1e9I9s/2tj716+zvmvZUR2/5AQnHP829QAshz1uIOOyQUd51S2 WJZtAIO8YqJWjWqDUt8bDZA+/4fdRFQ/fvCBBA== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1658829704076100001 Content-Type: text/plain; charset="utf-8" From: Helge Deller The pipe2() syscall is available on all Linux platforms since kernel 2.6.27, so use it unconditionally to emulate pipe() and pipe2(). Signed-off-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 11 +---------- meson.build | 9 --------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 991b85e6b4dd..4f89184d0585 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1586,21 +1586,12 @@ static abi_long do_ppoll(abi_long arg1, abi_long ar= g2, abi_long arg3, } #endif =20 -static abi_long do_pipe2(int host_pipe[], int flags) -{ -#ifdef CONFIG_PIPE2 - return pipe2(host_pipe, flags); -#else - return -ENOSYS; -#endif -} - static abi_long do_pipe(CPUArchState *cpu_env, abi_ulong pipedes, int flags, int is_pipe2) { int host_pipe[2]; abi_long ret; - ret =3D flags ? do_pipe2(host_pipe, flags) : pipe(host_pipe); + ret =3D pipe2(host_pipe, flags); =20 if (is_error(ret)) return get_errno(ret); diff --git a/meson.build b/meson.build index 8a8c415fc1f8..75aaca8462e8 100644 --- a/meson.build +++ b/meson.build @@ -2026,15 +2026,6 @@ config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.lin= ks(gnu_source_prefix + ''' #else int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh,= 0); } #endif''')) -config_host_data.set('CONFIG_PIPE2', cc.links(gnu_source_prefix + ''' - #include - #include - - int main(void) - { - int pipefd[2]; - return pipe2(pipefd, O_CLOEXEC); - }''')) config_host_data.set('CONFIG_POSIX_MADVISE', cc.links(gnu_source_prefix + = ''' #include #include --=20 2.37.1 From nobody Thu May 16 11:50:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165882926930834.181200782725455; Tue, 26 Jul 2022 02:54:29 -0700 (PDT) Received: from localhost ([::1]:48838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGHGm-0005y8-0l for importer@patchew.org; Tue, 26 Jul 2022 05:54:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGH7T-0004Vq-8K for qemu-devel@nongnu.org; Tue, 26 Jul 2022 05:44:51 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:54395) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGH7Q-0001Br-HD for qemu-devel@nongnu.org; Tue, 26 Jul 2022 05:44:50 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MLRDv-1nxuv808jz-00IS2G; Tue, 26 Jul 2022 11:44:45 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller , Richard Henderson Subject: [PULL 3/3] linux-user: Use target abi_int type for pipefd[1] in pipe() Date: Tue, 26 Jul 2022 11:44:42 +0200 Message-Id: <20220726094442.4452-4-laurent@vivier.eu> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220726094442.4452-1-laurent@vivier.eu> References: <20220726094442.4452-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:ei6CBTuZ+9iJ1vettyhZqKCyodmjUuvBYLs+pyLcc/0cMy4vLtA RXgwLRUPIzosp4AQm51lCotQQs17rxTWHsA220KvVJ8R6y3jTFDZlxALZSeWC8/fCWmkrvo Vy/7pkWnwkbGk+uDhpTQQhIei6IENKaLL7lisBQ0WTR/b0OTQY0Cf2iXKkvBz/XRg4S3K+R BtJCd5F3ymhFR0ikVzFYw== X-UI-Out-Filterresults: notjunk:1;V03:K0:HtKUKB076gg=:P1eop1lKu4wltJExXiOfZT 8nbqswSXD8c6tW3BHxPA0xiglTvVksrGob8Ygr5qRU7sQDVy37JzVYC7HaKgp6fS2RL5zue5e S+KBhnRsgIwsae46Re4hQ/RGnIKIA1XNVM+oAdjkozpuqrpvtwItv0qLeQjRrlfWwjULVkBdU Me6sZVm6IMJEJEK5DoluT50nlKZeMW1rVUPMZdftXJ7ZvYEBmfWV2B3yEIjEkdmp9f5Wma9DT yK3h6IY+AkZLQQihpSuvQegapp2mdpxozE+5X0C3q+e48Lu2N5U/Qkh0jEqCirDMpNnZ+bEzB zSHB59H7rRShsHi80ytaLm8flLmd8h250MOpYwoDdwqujDXdgkS7yS+UfOOfei6r+x4iBIQQx laMKnCNc2fyQOaKcazNm7u0ShYxPSMSrk/TbmEJhJ1bTJVYxjvoUQiWaGpEfe962pbCQhAS1G dhMFqqNtv2r+opi4elVKHEbki2ho49qeu5rUYVoMCk6Zo+VG8wXAogTmeoKTEtRPjkjk7GpCH /JPEC8DD/ALFn/qojxGyoY3cwf7Aow1fco8NMDWUXa51quhMhijRwq9O91p2Okw3f7oCpQI2I WwFzOYm00yDnJE6I8hvdJDXER59MLUz93D97eNM8mTK6sOqb1XKpUEueiDlFgCTHOLYKPC9Zh B0F7wRn+saIpuScEUu1a+VeKhrnu0PevqK+ekIafhZcA0MVIWYbkkTwP1HfjxyOFALoaP+Ejn kOwiRRNMAxwcUF2CzIDuslKY69g7z5x2JpW3+g== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1658829270147100001 Content-Type: text/plain; charset="utf-8" From: Helge Deller When writing back the fd[1] pipe file handle to emulated userspace memory, use sizeof(abi_int) as offset insted of the hosts's int type. There is no functional change in this patch. Signed-off-by: Helge Deller Reviewed-by: Richard Henderson Message-Id: Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4f89184d0585..b27a6552aa34 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1615,7 +1615,7 @@ static abi_long do_pipe(CPUArchState *cpu_env, abi_ul= ong pipedes, } =20 if (put_user_s32(host_pipe[0], pipedes) - || put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0]))) + || put_user_s32(host_pipe[1], pipedes + sizeof(abi_int))) return -TARGET_EFAULT; return get_errno(ret); } --=20 2.37.1