From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IaTVM-0007pc-Tw for qemu-devel@nongnu.org; Wed, 26 Sep 2007 05:48:28 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IaTVM-0007p7-8w for qemu-devel@nongnu.org; Wed, 26 Sep 2007 05:48:28 -0400 Received: from mx1.polytechnique.org ([129.104.30.34]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IaTVL-0000BD-Ql for qemu-devel@nongnu.org; Wed, 26 Sep 2007 05:48:28 -0400 Received: from [172.17.17.9] (gw.netgem.com [195.68.2.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTP id EB6E133176 for ; Wed, 26 Sep 2007 11:47:11 +0200 (CEST) Message-ID: <46FA2A9E.7050105@bellard.org> Date: Wed, 26 Sep 2007 11:47:10 +0200 From: Fabrice Bellard MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH][MIPS] Fix [ls][wd][lr] instructions References: <20070926092330.GA29659@hall.aurel32.net> In-Reply-To: <20070926092330.GA29659@hall.aurel32.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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 Aurelien Jarno wrote: > Hi, > > As written in the MIPS TODO file, the lwl, lwr, ldl, ldr, swl, swr, > sdl and sdr instructions are not correctly implemented. In case of > exception the BadVAddr register gets the aligned address instead of the > unaligned original address. > > In addition to that, the store instructions are generating the wrong > exception, AdEl instead of AdEs, because the current implementation > first do a load. > > The patch below fixes that by accessing the bytes one by one, starting > by the unaligned original address. > > Bye, > Aurelien [...] BTW, you could simplify a lot the implementation : switch (GET_LMASK(T0)) { case 0: T0 = (int32_t)tmp; break; case 1: T0 = (int32_t)((tmp << 8) | (T1 & 0x000000FF)); break; case 2: T0 = (int32_t)((tmp << 16) | (T1 & 0x0000FFFF)); break; case 3: T0 = (int32_t)((tmp << 24) | (T1 & 0x00FFFFFF)); break; } -> v = GET_LMASK(T0); if (v == 0) { T0 = tmp; } else { TO = (int32_t)((tmp << (8 * v)) | (T1 & ((1 << (v * 8)) - 1))); } Fabrice.