From mboxrd@z Thu Jan 1 00:00:00 1970 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 AF65EC4345F for ; Wed, 1 May 2024 12:56:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s29Ui-0007f2-Ja; Wed, 01 May 2024 08:55:32 -0400 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 1s29Ub-0007ef-VW; Wed, 01 May 2024 08:55:26 -0400 Received: from ik1-413-38519.vs.sakura.ne.jp ([153.127.30.23] helo=sakura.ysato.name) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s29UV-0003oL-M8; Wed, 01 May 2024 08:55:25 -0400 Received: from SIOS1075.ysato.ml (ZM005235.ppp.dion.ne.jp [222.8.5.235]) by sakura.ysato.name (Postfix) with ESMTPSA id 9947B1C0109; Wed, 1 May 2024 21:55:10 +0900 (JST) Date: Wed, 01 May 2024 21:55:07 +0900 Message-ID: <87ttjhadzo.wl-ysato@users.sourceforge.jp> From: Yoshinori Sato To: Philippe =?ISO-8859-1?Q?Mathieu-Daud=E9?= Cc: qemu-devel@nongnu.org, John Paul Adrian Glaubitz , Paul Cercueil , qemu-stable@nongnu.org, Richard Henderson Subject: Re: [PATCH v4 1/4] target/sh4: Fix ADDV opcode In-Reply-To: <20240430163125.77430-2-philmd@linaro.org> References: <20240430163125.77430-1-philmd@linaro.org> <20240430163125.77430-2-philmd@linaro.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Received-SPF: softfail client-ip=153.127.30.23; envelope-from=ysato@users.sourceforge.jp; helo=sakura.ysato.name X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, KHOP_HELO_FCRDNS=0.001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no 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 On Wed, 01 May 2024 01:31:22 +0900, Philippe Mathieu-Daud=E9 wrote: >=20 > The documentation says: >=20 > ADDV Rm, Rn Rn + Rm -> Rn, overflow -> T >=20 > But QEMU implementation was: >=20 > ADDV Rm, Rn Rn + Rm -> Rm, overflow -> T >=20 > Fix by filling the correct Rm register. >=20 > Add tests provided by Paul Cercueil. >=20 > Cc: qemu-stable@nongnu.org > Fixes: ad8d25a11f ("target-sh4: implement addv and subv using TCG") > Reported-by: Paul Cercueil > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2317 > Reviewed-by: Richard Henderson > Signed-off-by: Philippe Mathieu-Daud=E9 > --- > target/sh4/translate.c | 2 +- > tests/tcg/sh4/test-addv.c | 27 +++++++++++++++++++++++++++ > tests/tcg/sh4/Makefile.target | 3 +++ > 3 files changed, 31 insertions(+), 1 deletion(-) > create mode 100644 tests/tcg/sh4/test-addv.c >=20 > diff --git a/target/sh4/translate.c b/target/sh4/translate.c > index ebb6c901bf..4a1dd0d1f4 100644 > --- a/target/sh4/translate.c > +++ b/target/sh4/translate.c > @@ -714,7 +714,7 @@ static void _decode_opc(DisasContext * ctx) > tcg_gen_xor_i32(t2, REG(B7_4), REG(B11_8)); > tcg_gen_andc_i32(cpu_sr_t, t1, t2); > tcg_gen_shri_i32(cpu_sr_t, cpu_sr_t, 31); > - tcg_gen_mov_i32(REG(B7_4), t0); > + tcg_gen_mov_i32(REG(B11_8), t0); > } > return; > case 0x2009: /* and Rm,Rn */ > diff --git a/tests/tcg/sh4/test-addv.c b/tests/tcg/sh4/test-addv.c > new file mode 100644 > index 0000000000..64f709161f > --- /dev/null > +++ b/tests/tcg/sh4/test-addv.c > @@ -0,0 +1,27 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > + > +#include > +#include > +#include > + > +static void addv(const int a, const int b, const int res, const int carr= y) > +{ > + int o =3D a, c; > + > + asm volatile("addv %2,%0\n" > + "movt %1\n" > + : "+r"(o), "=3Dr"(c) : "r"(b) :); > + > + if (c !=3D carry || aw !=3D res) { > + printf("ADDV %d, %d =3D %d/%d [T =3D %d/%d]\n", a, b, o, res, c,= carry); > + abort(); > + } > +} > + > +int main(void) > +{ > + addv(INT_MAX, 1, INT_MIN, 1); > + addv(INT_MAX - 1, 1, INT_MAX, 0); > + > + return 0; > +} > diff --git a/tests/tcg/sh4/Makefile.target b/tests/tcg/sh4/Makefile.target > index 4d09291c0c..521b8b0a76 100644 > --- a/tests/tcg/sh4/Makefile.target > +++ b/tests/tcg/sh4/Makefile.target > @@ -17,3 +17,6 @@ TESTS +=3D test-macl > =20 > test-macw: CFLAGS +=3D -O -g > TESTS +=3D test-macw > + > +test-addv: CFLAGS +=3D -O -g > +TESTS +=3D test-addv > --=20 > 2.41.0 >=20 Reviewed-by: Yoshinori Sato --=20 Yosinori Sato