From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kp2ko-0002vL-Px for qemu-devel@nongnu.org; Sun, 12 Oct 2008 11:21:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kp2ko-0002u7-1P for qemu-devel@nongnu.org; Sun, 12 Oct 2008 11:21:10 -0400 Received: from [199.232.76.173] (port=50172 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kp2kn-0002tx-QD for qemu-devel@nongnu.org; Sun, 12 Oct 2008 11:21:09 -0400 Received: from mail.codesourcery.com ([65.74.133.4]:52438) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kp2kn-0002G8-DO for qemu-devel@nongnu.org; Sun, 12 Oct 2008 11:21:09 -0400 From: Vladimir Prus Date: Sun, 12 Oct 2008 19:21:05 +0400 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200810121921.05267.vladimir@codesourcery.com> Subject: [Qemu-devel] [SH4] Fix swap.b Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org The SH4 manual documents the swap.b instruction as follows: SWAP.B Rm,Rn Rm =E2=86=92 swap lower 2 bytes =E2=86=92 Rn Current QEMU code, in addition to the above, also clears the high 16 bits. The immediate breakage I saw is that htonl function applied=20 to netmask of 255.255.255.0 gives 0, which breaks all networking. Attached patch fixes the problem. =2D Volodya =2D-- target-sh4/translate.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/target-sh4/translate.c b/target-sh4/translate.c index 365936f..2ef8c00 100644 =2D-- a/target-sh4/translate.c +++ b/target-sh4/translate.c @@ -686,7 +686,9 @@ void _decode_opc(DisasContext * ctx) return; case 0x6008: /* swap.b Rm,Rn */ { =2D TCGv high, low; + TCGv highw, high, low; + highw =3D tcg_temp_new(TCG_TYPE_I32); + tcg_gen_andi_i32(highw, REG(B7_4), 0xffff0000); high =3D tcg_temp_new(TCG_TYPE_I32); tcg_gen_ext8u_i32(high, REG(B7_4)); tcg_gen_shli_i32(high, high, 8); @@ -694,6 +696,7 @@ void _decode_opc(DisasContext * ctx) tcg_gen_shri_i32(low, REG(B7_4), 8); tcg_gen_ext8u_i32(low, low); tcg_gen_or_i32(REG(B11_8), high, low); + tcg_gen_or_i32(REG(B11_8), REG(B11_8), highw); tcg_temp_free(low); tcg_temp_free(high); } =2D-=20 1.5.3.5