From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KFr6g-0002lb-C0 for qemu-devel@nongnu.org; Mon, 07 Jul 2008 09:50:18 -0400 Received: from [199.232.76.173] (port=41729 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KFr6e-0002lT-W7 for qemu-devel@nongnu.org; Mon, 07 Jul 2008 09:50:17 -0400 Received: from mx1.polytechnique.org ([129.104.30.34]:36278) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KFr6e-0000t0-OS for qemu-devel@nongnu.org; Mon, 07 Jul 2008 09:50:16 -0400 Received: from fbe1.dev.netgem.com (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 826C433171 for ; Mon, 7 Jul 2008 15:49:35 +0200 (CEST) Message-ID: <48721EEE.2060903@bellard.org> Date: Mon, 07 Jul 2008 15:49:34 +0200 From: Fabrice Bellard MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] x86-64: Fix 64-bit lgs/lfs/lss References: <48721086.2010506@siemens.com> In-Reply-To: <48721086.2010506@siemens.com> Content-Type: text/plain; charset=ISO-8859-15; 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 Hi, OK, at least for Intel CPUs. From the AMD & Intel specs, the behavior seems to differ between the two. If it is really the case, a CPU specific config bit is needed. Unfortunately there may be other corner cases where AMD and Intel differ in 64 bit mode. Fabrice. Jan Kiszka wrote: > Reading the code while porting my segment limit and type checks to > latest SVN made me stumble over this bug in the translator: 64-bit > lgs/lfs/lss was incorrectly reading only 32-bit offsets. > > Signed-off-by: Jan Kiszka > --- > target-i386/translate.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > Index: b/target-i386/translate.c > =================================================================== > --- a/target-i386/translate.c > +++ b/target-i386/translate.c > @@ -4864,7 +4864,7 @@ static target_ulong disas_insn(DisasCont > case 0x1b5: /* lgs Gv */ > op = R_GS; > do_lxx: > - ot = dflag ? OT_LONG : OT_WORD; > + ot = dflag + OT_WORD; > modrm = ldub_code(s->pc++); > reg = ((modrm >> 3) & 7) | rex_r; > mod = (modrm >> 6) & 3; > @@ -4872,7 +4872,7 @@ static target_ulong disas_insn(DisasCont > goto illegal_op; > gen_lea_modrm(s, modrm, ®_addr, &offset_addr); > gen_op_ld_T1_A0(ot + s->mem_index); > - gen_add_A0_im(s, 1 << (ot - OT_WORD + 1)); > + gen_add_A0_im(s, 1 << ot); > /* load the segment first to handle exceptions properly */ > gen_op_ldu_T0_A0(OT_WORD + s->mem_index); > gen_movl_seg_T0(s, op, pc_start - s->cs_base); > > > >