From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NKevB-0005t1-EF for qemu-devel@nongnu.org; Tue, 15 Dec 2009 16:27:05 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NKev6-0005qb-Cr for qemu-devel@nongnu.org; Tue, 15 Dec 2009 16:27:04 -0500 Received: from [199.232.76.173] (port=48116 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKev6-0005qH-3J for qemu-devel@nongnu.org; Tue, 15 Dec 2009 16:27:00 -0500 Received: from mail2.shareable.org ([80.68.89.115]:57556) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NKev5-00035a-8R for qemu-devel@nongnu.org; Tue, 15 Dec 2009 16:26:59 -0500 Date: Tue, 15 Dec 2009 21:26:57 +0000 From: Jamie Lokier Subject: Re: [Qemu-devel] i386 emulation bug: mov reg, [addr] Message-ID: <20091215212657.GC26319@shareable.org> References: <200912151948.53307.ck@iseclab.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200912151948.53307.ck@iseclab.org> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Clemens Kolbitsch Cc: qemu-devel@nongnu.org Clemens Kolbitsch wrote: > /* XXX: index == 4 is always invalid */ > if (havesib && (index != 4 || scale != 0)) { > #ifdef TARGET_X86_64 > if (s->aflag == 2) { > gen_op_addq_A0_reg_sN(scale, index); > } else > #endif > { > /// !!!!!!!!!! this does the evil !!!!!!!!!!!!!! > gen_op_addl_A0_reg_sN(scale, index); > } > } This is indeed a bug. Avi's explained why it doesn't trigger in normal code. When the index register is 4, which normally means %esp, in the SIB encoding it means "no index". Independent of the shift (scale). So it should say: /* index == 4 means no index. */ if (havesib && index != 4) { But that said, I'm not sure if this line from earlier breaks the test: index = ((code >> 3) & 7) | REX_X(s); When is REX_X(s) not zero, and does it break the index != 4 test? -- Jamie