From patchwork Mon Dec 19 22:29:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 13077207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6ECCAC4332F for ; Mon, 19 Dec 2022 22:30:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7Odk-0008AP-3m; Mon, 19 Dec 2022 17:29: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 1p7Odi-00089l-Q4 for qemu-devel@nongnu.org; Mon, 19 Dec 2022 17:29:42 -0500 Received: from mout.gmx.net ([212.227.17.22]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p7Odh-0007EH-43 for qemu-devel@nongnu.org; Mon, 19 Dec 2022 17:29:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1671488976; bh=oFLv9u7tOQe+h4ZbQx3aX0DPJILTcZD6gWhdJFBFTHQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=tCjAZBR/n68zIuRYmizInelKVes3r7FDoXBuhzzo/9r6n3sFFHSeyIK2fpcrUXTJ0 aJ7aBHoISgRQa/moivg0rEv4cnXDfcyMIXhLmb7WxUyoXvtzG9kkTUzeBrhg6JlEBl JCvw4+qmzdezlWYtTwmAHhUiss7yAjLP6Ym91x89wBl2kmD9uK1XJjG5cxPU7ijlgE /COiDCXk+v+s1MfiKWTFIjxw6FPHhFXGS4C+LhrKGWaW1XWylBzHqIO0I6iuqHSP7t l19RRvG45/rNUEAxgAdmtdYQOxqy7FHh61CtR4VFcdJmN7CptRVVmS1xxqmzOBizWE WT+FUP9Eq1EhQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from p100.fritz.box ([92.116.151.196]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N1fmq-1oixuS0hkO-011xGq; Mon, 19 Dec 2022 23:29:36 +0100 From: Helge Deller To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Richard Henderson , Helge Deller Subject: [PULL 1/2] target/hppa: Generate illegal instruction exception for 64-bit instructions Date: Mon, 19 Dec 2022 23:29:34 +0100 Message-Id: <20221219222935.284704-2-deller@gmx.de> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219222935.284704-1-deller@gmx.de> References: <20221219222935.284704-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:ysyqZuqhbNoNUM3v1nL4Ci3gBF22o9y4BByCdQyzDTpMyKzFVe5 O55Ud6EI4Q2mVopvim93vmtmLA12jqE97H2EoBtsNwTF5rBLgRa1xiGcN8YT6SXOwZBOvLC AA8swjX3kSHyWASI+Db8qjTgfGI0jlCVjBM3mdwBFgAIJPj0gLBtWodoH0pJPzsjKVQZ5zF oJ8VMqK7tMt/eSMobB4sA== UI-OutboundReport: notjunk:1;M01:P0:VqBiWbZhPaE=;GrchB+KG7PRwGwp//p+JLdMCaoF SMJCCU292cw5zWafdL4fqRUJZ12ouALVQxcV0oSAFIpySColp0bXMZ9AcXpyUWVcrorUqXar9 b2DCKsKNpLvYHk3U9T0EyiuIRj4WV5xuK1qz4YygFQjKDu8lKhACcW9GzHmkCHkhMlvAPc0TT DcvASNMEWwkIPGoin2FbbYS9Cs20fSAYtYoNcpoVHq4WeLm7sar9n6v80l79m4CusIORv7jzt ctUR2QFp6d/R8bHKto+FI+Ej9cRG3GeuB72CMj9tXzZb4lcK30FihOYmX9jT6JNRILoVMQFDN UEEQ2xOEN0y7eRPwZGpovipZ2JiygLijSDCZdtScR+AIo8BTLm7+DmlvNNIqJzMG7ge3wpvyu N6isW5oXG5FNC4BEZiqsxjIRTmks1//NjYAID9LUPY/lDyi6mQI1BXTI1DvSeqIl0IZR6Qemg z8MXF3dJK3yb9pm7uMhGmWHL096LeF1RGrLwDCFa7fjOqxjUmy3xv4T6dAqIYROB0bjgZHsg9 SXvrWwmvNMjkFGP05x0XIPhUME6Fq9/PRvDnEAUmete4U3NOE4WyGLJRYEi0T2xjPJcZHoAzT QNLMFOBdJKyHv77KfBcTLfVOjnTk6MdQgT++zhdJWE1bFtC/FVeRJXF17j1w1kCd5rzLrmsMO Hb1EFz/32/ip0Q8OxhOYWFEN55TPeF8Iy4pNJW3hIWqu8alMt8LD5yJMZrBQTNlgWuU/2IZ6L 7gbbtvSon8QnUF1sWN2eTRktbvGuVRvmd1RZ8k6cciVxvfPbtnz5o3uOJggxL/151myhS2wLI YAPAkFXHeXfB7CAfQwlbwlw2MBCr0TygdWnOBpo6LnqeIKjnTyH0q8jrOeF3+IS7oOry1Wgrr z0vmjcoky9FIbTHqnuw4gJwR03GrpJqe2N6c0EjqlVk6Xpx4Dl/ropDchitjOz4FzHa7bIocU Vs1oOKSiLVPTrXty/5ZRKPUQK7E= Received-SPF: pass client-ip=212.227.17.22; envelope-from=deller@gmx.de; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Qemu currently emulates a 32-bit CPU only, and crashes with this error when it faces a 64-bit load (e.g. "ldd 0(r26),r0") or a 64-bit store (e.g. "std r26,0(r26)") instruction in the guest: ERROR:../qemu/tcg/tcg-op.c:2822:tcg_canonicalize_memop: code should not be reached Add checks for 64-bit sizes and generate an illegal instruction exception if necessary. Signed-off-by: Helge Deller Reviewed-by: Richard Henderson --- target/hppa/translate.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.38.1 diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 1af77473da..d15b9e27c7 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2899,14 +2899,22 @@ static bool trans_cmpiclr(DisasContext *ctx, arg_rri_cf *a) static bool trans_ld(DisasContext *ctx, arg_ldst *a) { - return do_load(ctx, a->t, a->b, a->x, a->scale ? a->size : 0, + if (unlikely(TARGET_REGISTER_BITS == 32 && a->size > MO_32)) { + return gen_illegal(ctx); + } else { + return do_load(ctx, a->t, a->b, a->x, a->scale ? a->size : 0, a->disp, a->sp, a->m, a->size | MO_TE); + } } static bool trans_st(DisasContext *ctx, arg_ldst *a) { assert(a->x == 0 && a->scale == 0); - return do_store(ctx, a->t, a->b, a->disp, a->sp, a->m, a->size | MO_TE); + if (unlikely(TARGET_REGISTER_BITS == 32 && a->size > MO_32)) { + return gen_illegal(ctx); + } else { + return do_store(ctx, a->t, a->b, a->disp, a->sp, a->m, a->size | MO_TE); + } } static bool trans_ldc(DisasContext *ctx, arg_ldst *a) From patchwork Mon Dec 19 22:29:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 13077206 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 853EAC4332F for ; Mon, 19 Dec 2022 22:30:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7Odh-00089J-NM; Mon, 19 Dec 2022 17:29: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 1p7Odg-00088n-B0 for qemu-devel@nongnu.org; Mon, 19 Dec 2022 17:29:40 -0500 Received: from mout.gmx.net ([212.227.17.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p7Ode-0007E3-IL for qemu-devel@nongnu.org; Mon, 19 Dec 2022 17:29:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1671488976; bh=U8DC5Fd6BpgVxj/XU1DU03+aQGVtmjh4bK8voYGFtfk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=HElbOQ4uk9vXA1TZanJPY/FZuoi9KhOb8wfzcBvrr9eYCanFImPB6sqHisfw/N/CV 5mQRRu+PHK2N3vbtuWEKBd0amNOk5n7gYD1PyeQNsDuQcukvmBhPdru2xQyfizmRd4 jJbINVToWyjwVt8iMBRBpggKEtZtGcaiVHjUZxe/LxIFhlr7YnDgG369gTjPGbFHID VhVZhICtPjlB54ELbOooOEuPT2IT1wFpDr1VfehSsPJkZLqXt+xP6+rytZf12yYif5 JlakDakqRxZzsfGSbis/IbLTJDMnpYOW1QHaY2TBYxYZeWsJleFtdrAxYCK+oM0pD0 p5OW/Xk8UFQZA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from p100.fritz.box ([92.116.151.196]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MXp9Y-1pNoVA1I9E-00Y6Ae; Mon, 19 Dec 2022 23:29:36 +0100 From: Helge Deller To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Richard Henderson , Helge Deller Subject: [PULL 2/2] target/hppa: Fix fid instruction emulation Date: Mon, 19 Dec 2022 23:29:35 +0100 Message-Id: <20221219222935.284704-3-deller@gmx.de> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219222935.284704-1-deller@gmx.de> References: <20221219222935.284704-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:p20dXiVCopYrwaoFqtQEiUhlayW+0jXae5n3de9QVr70o7X2ybB AxiIsRmdKtm+GDSjvCMm8xaURYQnLZ7yxj7rLMYiIo74xHZ5q1Jg55AxUYt8fMk+DwWVkJs N6AMhcsGLdpMgtRSucy2sdzRgkCC+cga8qaBbjSfHcFACchbW3xMjOo3B0a1mvOnuIufYi4 ZzP2JvNolEBkJh0gmMo5A== UI-OutboundReport: notjunk:1;M01:P0:ZQVw3/5UfHQ=;sIp1jtXqcO/hB8f+z1FK11YjzOK 79es0Vpj6OYh8dsYwC4vZ7xZNnB3TXMqStsKS0v/uPC6/q0ijD7gfdb5uT9NvGpXx+l3UUH6F MCUI2V1MNlvPn4fSKpgbcypqGMrTmJtysL0VM9+meocuf59ZnRk34DhMwufjH9yCcJZ40bKEx kpNsrOqepFnEskH449y9IOR0mA55bHYz8hiiG3N3nVXhNKCBFQKgpMG5hS8GPFpofLue6ByLr 85nymi4auWeh9tZpzG2QrgBooWZ1xXAMF0qvpNP5ZTpRR452SyNRuxLpls+rVefHYdw7eB6jX e1LmrQoZXn9cLVg1tRyxj2qFfv4Cmkz0PIRptk6mFnlT07ZI6Vvp4DPXj5nSVxMw3hp2U+GGR sOKfonXYcNN/XPSMaUMofc1mxfYGl0rSKDnvBjvqd/ADDLcYlAJ+oHpr+H4kBA55YTcGEotmn QnX7HoaVhqzKtmqudh8Qo73zPsGGV4GnvX+bgQc8OG+d3qqqOr0zkPedYTouri49GJCXt6kiH ClbRV5mrlHn3Lah5vUjq4tBvAtTKadqzwNKmXODzPLa7BfyioTAtjLgBuPLjqv8sBKcpk9F3L t65CHB0HSWgTLIMDVqsvq42H/n9f3e2SK6BuQDicX8AGdvsfSEybA8nYfsxdUFyBOId12awoI UWIxRJpCwBgioydjkUYwJgaG4bLSJxrNABaQnYBxmwOFj2PguDrgeVKH8JJdzjD48pJvlm7T5 29vplHQloI7ZQ4CNbZQTa4h6v+GJRyEAnBEUsxDKg0ukva1gsFF0dcE9Fprkj5bplH4RkYiSN chUtR5Pj/J7Eo8ubC46mOhD+8uqDXI+45i/mn17xme/0DcGxpOs5ztBOnXBgGZ2HFt+IFEeVF Tm1LhXO02vZw3W3CoL65mnNGT5UNvwYdAmZj2Kxg93CtyIMWQQg6lNH9dDUSFDp0wsO47R8Oz CSVQ3g== Received-SPF: pass client-ip=212.227.17.21; envelope-from=deller@gmx.de; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The fid instruction (Floating-Point Identify) puts the FPU model and revision into the Status Register. Since those values shouldn't be 0, store values there which a PCX-L2 (for 32-bit) or a PCX-W2 (for 64-bit) would return. Noticed while trying to install MPE/iX. Signed-off-by: Helge Deller Reviewed-by: Richard Henderson --- target/hppa/insns.decode | 5 +---- target/hppa/translate.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) -- 2.38.1 diff --git a/target/hppa/insns.decode b/target/hppa/insns.decode index c7a7e997f9..27341d27b2 100644 --- a/target/hppa/insns.decode +++ b/target/hppa/insns.decode @@ -388,10 +388,7 @@ fmpyfadd_d 101110 rm1:5 rm2:5 ... 0 1 ..0 0 0 neg:1 t:5 ra3=%rc32 # Floating point class 0 -# FID. With r = t = 0, which via fcpy puts 0 into fr0. -# This is machine/revision = 0, which is reserved for simulator. -fcpy_f 001100 00000 00000 00000 000000 00000 \ - &fclass01 r=0 t=0 +fid_f 001100 00000 00000 000 00 000000 00000 fcpy_f 001100 ..... ..... 010 00 ...... ..... @f0c_0 fabs_f 001100 ..... ..... 011 00 ...... ..... @f0c_0 diff --git a/target/hppa/translate.c b/target/hppa/translate.c index d15b9e27c7..981f8ee03d 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -3622,6 +3622,17 @@ static void gen_fcpy_f(TCGv_i32 dst, TCGv_env unused, TCGv_i32 src) tcg_gen_mov_i32(dst, src); } +static bool trans_fid_f(DisasContext *ctx, arg_fid_f *a) +{ + nullify_over(ctx); +#if TARGET_REGISTER_BITS == 64 + save_frd(0, tcg_const_i64(0x13080000000000ULL)); /* PA8700 (PCX-W2) */ +#else + save_frd(0, tcg_const_i64(0x0f080000000000ULL)); /* PA7300LC (PCX-L2) */ +#endif + return nullify_end(ctx); +} + static bool trans_fcpy_f(DisasContext *ctx, arg_fclass01 *a) { return do_fop_wew(ctx, a->t, a->r, gen_fcpy_f);