From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azA7z-0004Eu-Sz for qemu-devel@nongnu.org; Sat, 07 May 2016 17:51:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azA7y-0006Fq-Aw for qemu-devel@nongnu.org; Sat, 07 May 2016 17:51:11 -0400 Received: from mail-vk0-x230.google.com ([2607:f8b0:400c:c05::230]:36853) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azA7y-0006Ff-04 for qemu-devel@nongnu.org; Sat, 07 May 2016 17:51:10 -0400 Received: by mail-vk0-x230.google.com with SMTP id s184so28110012vkb.3 for ; Sat, 07 May 2016 14:51:08 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1462392752-17703-1-git-send-email-laurent@vivier.eu> <1462396869-22424-1-git-send-email-laurent@vivier.eu> <1462396869-22424-12-git-send-email-laurent@vivier.eu> <6ffba40e-10ae-0b52-15f2-20e300385cd0@twiddle.net> From: Peter Maydell Date: Sat, 7 May 2016 22:50:48 +0100 Message-ID: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 51/52] target-m68k: add cmpm List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier Cc: Richard Henderson , QEMU Developers , Andreas Schwab , Alexander Graf , Greg Ungerer On 7 May 2016 at 20:01, Laurent Vivier wrote: > > > Le 07/05/2016 =C3=A0 00:00, Richard Henderson a =C3=A9crit : >> On 05/04/2016 11:21 AM, Laurent Vivier wrote: >>> + reg =3D AREG(insn, 0); >>> + src =3D gen_load(s, opsize, reg, 1); >>> + tcg_gen_addi_i32(reg, reg, opsize_bytes(opsize)); >>> + >>> + reg =3D AREG(insn, 9); >>> + dest =3D gen_load(s, opsize, reg, 1); >>> + tcg_gen_addi_i32(reg, reg, opsize_bytes(opsize)); >> >> Delay the writeback to the first areg until after the second load. > > We can't delay because we can have "cmpm (%a0)+,(%a0)+" that is used to > compare two consecutive memory contents. If you write back to the first areg before the second load, don't you get the wrong value as seen by the exception handler if the second load faults? Usually you want to use the updated value for the purposes of calculating the address to use in the second load, but you don't want to actually update the guest CPU register until after the load has happened, in case it faults. (Disclaimer: I'm just assuming that on a fault no registers are updated, but if that wasn't the case the OS wouldn't be able to cleanly restart the instruction after fixing up a page fault, so it seems like a good guess.) thanks -- PMM