From nobody Tue Oct 28 14:38:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513164031574369.85118125483655; Wed, 13 Dec 2017 03:20:31 -0800 (PST) Received: from localhost ([::1]:34898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eP55P-0002JQ-S1 for importer@patchew.org; Wed, 13 Dec 2017 06:20:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eP54W-00020Q-Uo for qemu-devel@nongnu.org; Wed, 13 Dec 2017 06:19:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eP54V-0006SW-MX for qemu-devel@nongnu.org; Wed, 13 Dec 2017 06:19:32 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:39042) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eP54V-0006PG-Et for qemu-devel@nongnu.org; Wed, 13 Dec 2017 06:19:31 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1eP54L-0006xS-CV; Wed, 13 Dec 2017 11:19:21 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Wed, 13 Dec 2017 11:19:19 +0000 Message-Id: <1513163959-17545-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH] target/i386: Fix handling of VEX prefixes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Richard Henderson , Alexandro Sanchez Bach , Eduardo Habkost , patches@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In commit e3af7c788b73a6495eb9d94992ef11f6ad6f3c56 we replaced direct calls to to cpu_ld*_code() with calls to the x86_ld*_code() wrappers which incorporate an advance of s->pc. Unfortunately we didn't notice that in one place the old code was deliberately not incrementing s->pc: @@ -4501,7 +4528,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) static const int pp_prefix[4] =3D { 0, PREFIX_DATA, PREFIX_REPZ, PREFIX_REPNZ }; - int vex3, vex2 =3D cpu_ldub_code(env, s->pc); + int vex3, vex2 =3D x86_ldub_code(env, s); if (!CODE64(s) && (vex2 & 0xc0) !=3D 0xc0) { /* 4.1.4.6: In 32-bit mode, bits [7:6] must be 11b, This meant we were mishandling this set of instructions. Remove the manual advance of s->pc for the "is VEX" case (which is now done by x86_ldub_code()) and instead rewind PC in the case where we decide that this isn't really VEX. Signed-off-by: Peter Maydell Cc: qemu-stable@nongnu.org Reported-by: Alexandro Sanchez Bach --- I checked the rest of the changes in e3af7c788b73a and I don't think we made this mistake anywhere else. --- target/i386/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/translate.c b/target/i386/translate.c index 088a9d9..ed5b69d 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -4547,9 +4547,9 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) if (!CODE64(s) && (vex2 & 0xc0) !=3D 0xc0) { /* 4.1.4.6: In 32-bit mode, bits [7:6] must be 11b, otherwise the instruction is LES or LDS. */ + s->pc--; /* rewind the advance_pc() x86_ldub_code() did */ break; } - s->pc++; =20 /* 4.1.1-4.1.3: No preceding lock, 66, f2, f3, or rex prefixes= . */ if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ --=20 2.7.4