From patchwork Mon Feb 11 18:19:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 10806593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 878E117E0 for ; Mon, 11 Feb 2019 18:20:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77F532B0EB for ; Mon, 11 Feb 2019 18:20:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A4EF2B0F9; Mon, 11 Feb 2019 18:20:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B05982B0EB for ; Mon, 11 Feb 2019 18:20:29 +0000 (UTC) Received: from localhost ([127.0.0.1]:54209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtGBx-0004Do-3Y for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Feb 2019 13:20:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtGBM-0004DF-IB for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:19:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtGBK-0003Te-9A for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:19:51 -0500 Received: from smtp.duncanthrax.net ([2001:470:70c5:1111::170]:44185) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtGBE-0003Nc-Hj for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:19:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From; bh=byNGQR6FZX9WK8L1vRMMsy/a1scPI+b2EK+aHCBdN1E=; b=I5m5wURGKsA8XAC1cSdARykxx9 GgLzbWmavYphRVKbaJDI5UulU70Ja0wuof11ecpS64MWhUSdFOqLZ28A8HPWPZgLLHDR8eBrHfs/z ZEXWNNVxUNU2TOtLwr9N1tNYDtUJ+mntoSnL4THYb2SvnaFr0eMaMxMDQc+UUTiXx6Z8=; Received: from hsi-kbw-109-193-150-175.hsi7.kabel-badenwuerttemberg.de ([109.193.150.175] helo=t470p.stackframe.org) by smtp.eurescom.eu with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1gtGB8-0007Z5-4K; Mon, 11 Feb 2019 19:19:38 +0100 From: Sven Schnelle To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 19:19:03 +0100 Message-Id: <20190211181907.2219-2-svens@stackframe.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:470:70c5:1111::170 Subject: [Qemu-devel] [PATCH 1/5] target/hppa: move GETPC to HELPER() functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: deller@gmx.de, Sven Schnelle , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When QEMU is compiled with -O0, these functions are inlined which will cause a wrong restart address generated for the TB. Signed-off-by: Sven Schnelle Reviewed-by: Richard Henderson --- target/hppa/op_helper.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index 6bf478e7b0..268caaaa20 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -81,10 +81,8 @@ static void atomic_store_3(CPUHPPAState *env, target_ulong addr, uint32_t val, } static void do_stby_b(CPUHPPAState *env, target_ulong addr, target_ureg val, - bool parallel) + bool parallel, uintptr_t ra) { - uintptr_t ra = GETPC(); - switch (addr & 3) { case 3: cpu_stb_data_ra(env, addr, val, ra); @@ -109,20 +107,18 @@ static void do_stby_b(CPUHPPAState *env, target_ulong addr, target_ureg val, void HELPER(stby_b)(CPUHPPAState *env, target_ulong addr, target_ureg val) { - do_stby_b(env, addr, val, false); + do_stby_b(env, addr, val, false, GETPC()); } void HELPER(stby_b_parallel)(CPUHPPAState *env, target_ulong addr, target_ureg val) { - do_stby_b(env, addr, val, true); + do_stby_b(env, addr, val, true, GETPC()); } static void do_stby_e(CPUHPPAState *env, target_ulong addr, target_ureg val, - bool parallel) + bool parallel, uintptr_t ra) { - uintptr_t ra = GETPC(); - switch (addr & 3) { case 3: /* The 3 byte store must appear atomic. */ @@ -151,13 +147,13 @@ static void do_stby_e(CPUHPPAState *env, target_ulong addr, target_ureg val, void HELPER(stby_e)(CPUHPPAState *env, target_ulong addr, target_ureg val) { - do_stby_e(env, addr, val, false); + do_stby_e(env, addr, val, false, GETPC()); } void HELPER(stby_e_parallel)(CPUHPPAState *env, target_ulong addr, target_ureg val) { - do_stby_e(env, addr, val, true); + do_stby_e(env, addr, val, true, GETPC()); } target_ureg HELPER(probe)(CPUHPPAState *env, target_ulong addr, From patchwork Mon Feb 11 18:19:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 10806609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C8C8E922 for ; Mon, 11 Feb 2019 18:23:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8E9F2852C for ; Mon, 11 Feb 2019 18:23:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7458285A3; Mon, 11 Feb 2019 18:23:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EEEDE2852C for ; Mon, 11 Feb 2019 18:23:57 +0000 (UTC) Received: from localhost ([127.0.0.1]:54304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtGFI-0006oL-QX for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Feb 2019 13:23:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtGCM-0004uW-9g for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtGCI-0004XJ-SW for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:54 -0500 Received: from smtp.duncanthrax.net ([2001:470:70c5:1111::170]:54998) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtGCI-00047G-Kt for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=QJeX0cli1IUHWgWpFB/XHIDBbWil5RL48reG8jGdENo=; b=N9/21EyobERoiQlk/jemB3UehR A9REshPLqpRHdKH2rjEAS8lco5O1I8DGdNvkNNW55F6u9r/BMMXtxLBTR/p9YER91pvtV/jyIrMfq GKkSmG7QTaOESKQfDfQVBr9U6KrPqbhvlVnweQJ/CRVv49N9uGO2HwN2/NzBUV3crynI=; Received: from hsi-kbw-109-193-150-175.hsi7.kabel-badenwuerttemberg.de ([109.193.150.175] helo=t470p.stackframe.org) by smtp.eurescom.eu with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1gtGBr-0007Z5-Tl; Mon, 11 Feb 2019 19:20:24 +0100 From: Sven Schnelle To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 19:19:04 +0100 Message-Id: <20190211181907.2219-3-svens@stackframe.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211181907.2219-2-svens@stackframe.org> References: <20190211181907.2219-2-svens@stackframe.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:470:70c5:1111::170 Subject: [Qemu-devel] [PATCH 2/5] target/hppa: fix ' List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: deller@gmx.de, Sven Schnelle , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP These condition include the signed overflow bit. See Page 5-3 of the Parisc 1.1 Architecture Reference manual for details. Signed-off-by: Sven Schnelle --- target/hppa/translate.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 51bfd9849d..0e8cc8117a 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -404,6 +404,11 @@ static DisasCond cond_make_n(void) }; } +static bool cond_need_sv(int c) +{ + return c == 2 || c == 3 || c == 6; +} + static DisasCond cond_make_0(TCGCond c, TCGv_reg a0) { DisasCond r = { .c = c, .a1 = NULL, .a1_is_0 = true }; @@ -910,11 +915,17 @@ static DisasCond do_cond(unsigned cf, TCGv_reg res, case 1: /* = / <> (Z / !Z) */ cond = cond_make_0(TCG_COND_EQ, res); break; - case 2: /* < / >= (N / !N) */ - cond = cond_make_0(TCG_COND_LT, res); + case 2: /* < / >= (N ^ V / !(N ^ V)) */ + tmp = tcg_temp_new(); + tcg_gen_xor_reg(tmp, res, sv); + cond = cond_make_0(TCG_COND_LT, tmp); + tcg_temp_free(tmp); break; case 3: /* <= / > (N | Z / !N & !Z) */ - cond = cond_make_0(TCG_COND_LE, res); + tmp = tcg_temp_new(); + tcg_gen_xor_reg(tmp, res, sv); + cond = cond_make_0(TCG_COND_LE, tmp); + tcg_temp_free(tmp); break; case 4: /* NUV / UV (!C / C) */ cond = cond_make_0(TCG_COND_EQ, cb_msb); @@ -1159,7 +1170,7 @@ static DisasJumpType do_add(DisasContext *ctx, unsigned rt, TCGv_reg in1, /* Compute signed overflow if required. */ sv = NULL; - if (is_tsv || c == 6) { + if (is_tsv || cond_need_sv(c)) { sv = do_add_sv(ctx, dest, in1, in2); if (is_tsv) { /* ??? Need to include overflow from shift. */ @@ -1223,7 +1234,7 @@ static DisasJumpType do_sub(DisasContext *ctx, unsigned rt, TCGv_reg in1, /* Compute signed overflow if required. */ sv = NULL; - if (is_tsv || c == 6) { + if (is_tsv || cond_need_sv(c)) { sv = do_sub_sv(ctx, dest, in1, in2); if (is_tsv) { gen_helper_tsv(cpu_env, sv); @@ -1263,13 +1274,14 @@ static DisasJumpType do_cmpclr(DisasContext *ctx, unsigned rt, TCGv_reg in1, { TCGv_reg dest, sv; DisasCond cond; + int c = cf >> 1; dest = tcg_temp_new(); tcg_gen_sub_reg(dest, in1, in2); /* Compute signed overflow if required. */ sv = NULL; - if ((cf >> 1) == 6) { + if (cond_need_sv(c)) { sv = do_sub_sv(ctx, dest, in1, in2); } @@ -2808,7 +2820,7 @@ static DisasJumpType trans_ds(DisasContext *ctx, uint32_t insn, /* Install the new nullification. */ if (cf) { TCGv_reg sv = NULL; - if (cf >> 1 == 6) { + if (cond_need_sv(cf >> 1)) { /* ??? The lshift is supposed to contribute to overflow. */ sv = do_add_sv(ctx, dest, add1, add2); } @@ -3369,7 +3381,7 @@ static DisasJumpType trans_cmpb(DisasContext *ctx, uint32_t insn, tcg_gen_sub_reg(dest, in1, in2); sv = NULL; - if (c == 6) { + if (cond_need_sv(c)) { sv = do_sub_sv(ctx, dest, in1, in2); } @@ -3409,6 +3421,8 @@ static DisasJumpType trans_addb(DisasContext *ctx, uint32_t insn, tcg_gen_movi_reg(cb_msb, 0); tcg_gen_add2_reg(dest, cb_msb, in1, cb_msb, in2, cb_msb); break; + case 2: + case 3: case 6: tcg_gen_add_reg(dest, in1, in2); sv = do_add_sv(ctx, dest, in1, in2); From patchwork Mon Feb 11 18:19:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 10806607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45E8413B5 for ; Mon, 11 Feb 2019 18:22:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38C8F2B191 for ; Mon, 11 Feb 2019 18:22:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CEA02B18B; Mon, 11 Feb 2019 18:22:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D21422B0DB for ; Mon, 11 Feb 2019 18:22:12 +0000 (UTC) Received: from localhost ([127.0.0.1]:54271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtGDc-0005vB-2c for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Feb 2019 13:22:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtGCL-0004tV-3y for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtGCI-0004XU-Um for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:52 -0500 Received: from smtp.duncanthrax.net ([2001:470:70c5:1111::170]:59183) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtGCI-00048A-Ku for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=eiGbWKkLJoBQtWp3Bm+Z8u0midBMyLppuLtc6WkFQ4k=; b=J8vL5G2rGeXNry1ynODIB4aCMw s5qIF73gJlOBu9c1s/NpObH5g8ndnsNAmT/qTG2fh6GLpB3QFm7viv/I6BPXJ2V30g6Vq533g4GqL dDoso94HjM6ArnJZPaOSIkLZfKB/BH0XbsqrZSJi5jd2LrvgR5QFFX3XhljR+IPnOepE=; Received: from hsi-kbw-109-193-150-175.hsi7.kabel-badenwuerttemberg.de ([109.193.150.175] helo=t470p.stackframe.org) by smtp.eurescom.eu with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1gtGBs-0007Z5-RN; Mon, 11 Feb 2019 19:20:24 +0100 From: Sven Schnelle To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 19:19:05 +0100 Message-Id: <20190211181907.2219-4-svens@stackframe.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211181907.2219-2-svens@stackframe.org> References: <20190211181907.2219-2-svens@stackframe.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:470:70c5:1111::170 Subject: [Qemu-devel] [PATCH 3/5] target/hppa: fix log conditions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: deller@gmx.de, Sven Schnelle , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Now that do_cond() uses sign overflow for some condition matches we need to roll our own version without sign overflow checks. Signed-off-by: Sven Schnelle --- target/hppa/translate.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 0e8cc8117a..bce8773b1a 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -996,12 +996,35 @@ static DisasCond do_sub_cond(unsigned cf, TCGv_reg res, static DisasCond do_log_cond(unsigned cf, TCGv_reg res) { + DisasCond cond; + TCGv_reg tmp; + switch (cf >> 1) { - case 4: case 5: case 6: - cf &= 1; + case 0: /* never */ + cond = cond_make_f(); + break; + case 1: /* = all bits are zero */ + cond = cond_make_0(TCG_COND_EQ, res); + break; + case 2: /* < leftmost bit is 1 */ + cond = cond_make_0(TCG_COND_LT, res); + break; + case 3: /* <= leftmost bit is 1 or all bits 0 */ + cond = cond_make_0(TCG_COND_LE, res); + break; + case 7: /* OD rightmost bit is 1 */ + tmp = tcg_temp_new(); + tcg_gen_andi_reg(tmp, res, 1); + cond = cond_make_0(TCG_COND_NE, tmp); + tcg_temp_free(tmp); + break; + default: break; } - return do_cond(cf, res, res, res); + if (cf & 1) { + cond.c = tcg_invert_cond(cond.c); + } + return cond; } /* Similar, but for shift/extract/deposit conditions. */ From patchwork Mon Feb 11 18:19:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 10806605 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE48013BF for ; Mon, 11 Feb 2019 18:22:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF4212B176 for ; Mon, 11 Feb 2019 18:22:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D384F2B183; Mon, 11 Feb 2019 18:22:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 829EB2B18C for ; Mon, 11 Feb 2019 18:22:01 +0000 (UTC) Received: from localhost ([127.0.0.1]:54253 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtGDQ-0004nD-RE for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Feb 2019 13:22:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtGCC-0004lk-0R for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtGCA-0004NA-3g for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:43 -0500 Received: from smtp.duncanthrax.net ([2001:470:70c5:1111::170]:50060) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtGC2-00048a-2g for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=lSQSYETAdgTS7/gTbxvxDGRRLDZKJWpz4F0pk2QFL6c=; b=Hn3YwvuEvK2jDOGHWfubrrfxHw uxi+H2ojAj3bB91t4xj/UeWAJSnEXGcU3buAfW9DJoDT/b8w/UP13ki5lWXUhhKTxTxp60yxyuZ7V CqIFR54GmDhqnXQWVE0Jy5FSyGmEGaXNzSLc3K8fXLVYpTLpWSYk1VJQvhl4ReR2PmgA=; Received: from hsi-kbw-109-193-150-175.hsi7.kabel-badenwuerttemberg.de ([109.193.150.175] helo=t470p.stackframe.org) by smtp.eurescom.eu with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1gtGBt-0007Z5-Jc; Mon, 11 Feb 2019 19:20:25 +0100 From: Sven Schnelle To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 19:19:06 +0100 Message-Id: <20190211181907.2219-5-svens@stackframe.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211181907.2219-2-svens@stackframe.org> References: <20190211181907.2219-2-svens@stackframe.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:470:70c5:1111::170 Subject: [Qemu-devel] [PATCH 4/5] target/hppa: fix sed conditions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: deller@gmx.de, Sven Schnelle , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Now that do_cond() uses sign overflow for some condition matches we need to roll our own version without sign overflow checks. Signed-off-by: Sven Schnelle --- target/hppa/translate.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/target/hppa/translate.c b/target/hppa/translate.c index bce8773b1a..d858fabd3a 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -1029,20 +1029,32 @@ static DisasCond do_log_cond(unsigned cf, TCGv_reg res) /* Similar, but for shift/extract/deposit conditions. */ -static DisasCond do_sed_cond(unsigned orig, TCGv_reg res) +static DisasCond do_sed_cond(unsigned c, TCGv_reg res) { - unsigned c, f; + DisasCond cond; + TCGv_reg tmp; - /* Convert the compressed condition codes to standard. - 0-2 are the same as logicals (nv,<,<=), while 3 is OD. - 4-7 are the reverse of 0-3. */ - c = orig & 3; - if (c == 3) { - c = 7; + switch(c & 3) { + case 0: /* never */ + cond = cond_make_f(); + break; + case 1: /* = all bits are zero */ + cond = cond_make_0(TCG_COND_EQ, res); + break; + case 2: /* < leftmost bit is 1 */ + cond = cond_make_0(TCG_COND_LT, res); + break; + case 3: /* OD rightmost bit is 1 */ + tmp = tcg_temp_new(); + tcg_gen_andi_reg(tmp, res, 1); + cond = cond_make_0(TCG_COND_NE, tmp); + tcg_temp_free(tmp); + break; } - f = (orig & 4) / 4; - - return do_log_cond(c * 2 + f, res); + if (c & 4) { + cond.c = tcg_invert_cond(cond.c); + } + return cond; } /* Similar, but for unit conditions. */ From patchwork Mon Feb 11 18:19:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 10806603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D3BE922 for ; Mon, 11 Feb 2019 18:22:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F2702B176 for ; Mon, 11 Feb 2019 18:22:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7341A2B18B; Mon, 11 Feb 2019 18:22:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D3A622B184 for ; Mon, 11 Feb 2019 18:22:00 +0000 (UTC) Received: from localhost ([127.0.0.1]:54265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtGDP-0005kY-W2 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Feb 2019 13:22:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtGCA-0004l0-PW for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtGC2-0004Ga-43 for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:38 -0500 Received: from smtp.duncanthrax.net ([2001:470:70c5:1111::170]:43767) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtGC0-00049R-3V for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=vF24kWHgrTMYfUv9NzUXfMuDsGDBl5RneRkUbQ+0S5g=; b=A7+nDej+XlGvcMllUfWnErnKSF NKt3kvUxc636IFfIEM3PZrZO9hcmNFu5GOqe3FvVc0tEhtf4qiIcy+7bh2PmNyV5qLWli6jsYQnZX PjVTDmvcjJF/ue1g1/4UzHBuZZRvSlFCmwTDzZSBh3JWtzNcON+X1+vKJF4ZguoOa44k=; Received: from hsi-kbw-109-193-150-175.hsi7.kabel-badenwuerttemberg.de ([109.193.150.175] helo=t470p.stackframe.org) by smtp.eurescom.eu with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1gtGBu-0007Z5-Dr; Mon, 11 Feb 2019 19:20:26 +0100 From: Sven Schnelle To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 19:19:07 +0100 Message-Id: <20190211181907.2219-6-svens@stackframe.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211181907.2219-2-svens@stackframe.org> References: <20190211181907.2219-2-svens@stackframe.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:470:70c5:1111::170 Subject: [Qemu-devel] [PATCH 5/5] target/hppa: fix dcor instruction X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: deller@gmx.de, Sven Schnelle , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP It looks like the operands where exchanged. HP bootrom tests the following sequence: 0x00000000f0004064: ldil L%-66666800,r7 0x00000000f0004068: addi 19f,r7,r7 0x00000000f000406c: addi -1,r0,rp 0x00000000f0004070: addi f,r0,r4 0x00000000f0004074: addi 1,r4,r5 0x00000000f0004078: dcor rp,r6 0x00000000f000407c: cmpb,<>,n r6,r7,0xf000411 This returned 0x66666661 instead of the expected 0x9999999f in QEMU. Signed-off-by: Sven Schnelle --- target/hppa/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/hppa/translate.c b/target/hppa/translate.c index d858fabd3a..69c5a558fc 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2797,7 +2797,7 @@ static DisasJumpType trans_dcor(DisasContext *ctx, uint32_t insn, } tcg_gen_andi_reg(tmp, tmp, 0x11111111); tcg_gen_muli_reg(tmp, tmp, 6); - ret = do_unit(ctx, rt, tmp, load_gpr(ctx, r2), cf, false, + ret = do_unit(ctx, rt, load_gpr(ctx, r2), tmp, cf, false, is_i ? tcg_gen_add_reg : tcg_gen_sub_reg); return nullify_end(ctx, ret);