From nobody Mon Nov 25 04:54:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717322797809604.4322287290274; Sun, 2 Jun 2024 03:06:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sDi65-0004LB-LB; Sun, 02 Jun 2024 06:05:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sDi61-0004K5-Ry for qemu-devel@nongnu.org; Sun, 02 Jun 2024 06:05:50 -0400 Received: from smtp84.cstnet.cn ([159.226.251.84] helo=cstnet.cn) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1sDi5z-0001Ns-3S for qemu-devel@nongnu.org; Sun, 02 Jun 2024 06:05:49 -0400 Received: from lxy-MS-7D25.loongson.cn (unknown [114.242.206.180]) by APP-05 (Coremail) with SMTP id zQCowACnNBLoQ1xmCG3sDg--.50475S2; Sun, 02 Jun 2024 18:05:28 +0800 (CST) From: lixinyu20s@ict.ac.cn To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, richard.henderson@linaro.org, eduardo@habkost.net, Xinyu Li , Xinyu Li Subject: [PATCH] target/i386: fix memory opsize for Mov to/from Seg Date: Sun, 2 Jun 2024 18:05:28 +0800 Message-Id: <20240602100528.2135717-1-lixinyu20s@ict.ac.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: zQCowACnNBLoQ1xmCG3sDg--.50475S2 X-Coremail-Ant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2g6lf3hldfou0/ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=159.226.251.84; envelope-from=lixinyu20s@ict.ac.cn; helo=cstnet.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1717322802652100001 Content-Type: text/plain; charset="utf-8" From: Xinyu Li This commit fixes an issue with MOV instructions (0x8C and 0x8E) involving segment registers by explicitly setting the memory operand size to 16 bits. It introduces a new flag X86_SPECIAL_MovSeg to handle this specification correctly. Signed-off-by: Xinyu Li --- target/i386/tcg/decode-new.c.inc | 12 ++++++++++-- target/i386/tcg/decode-new.h | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 0ec849b003..ab7dbb45f9 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -202,6 +202,7 @@ #define avx_movx .special =3D X86_SPECIAL_AVXExtMov, #define sextT0 .special =3D X86_SPECIAL_SExtT0, #define zextT0 .special =3D X86_SPECIAL_ZExtT0, +#define movseg .special =3D X86_SPECIAL_MovSeg, =20 #define vex1 .vex_class =3D 1, #define vex1_rep3 .vex_class =3D 1, .vex_special =3D X86_VEX_REPScalar, @@ -1576,9 +1577,9 @@ static const X86OpEntry opcodes_root[256] =3D { [0x89] =3D X86_OP_ENTRY3(MOV, E,v, G,v, None, None), [0x8A] =3D X86_OP_ENTRY3(MOV, G,b, E,b, None, None), [0x8B] =3D X86_OP_ENTRY3(MOV, G,v, E,v, None, None), - [0x8C] =3D X86_OP_ENTRY3(MOV, E,v, S,w, None, None), + [0x8C] =3D X86_OP_ENTRY3(MOV, E,v, S,w, None, None, movseg), [0x8D] =3D X86_OP_ENTRY3(LEA, G,v, M,v, None, None, noseg), - [0x8E] =3D X86_OP_ENTRY3(MOV, S,w, E,v, None, None), + [0x8E] =3D X86_OP_ENTRY3(MOV, S,w, E,v, None, None, movseg), [0x8F] =3D X86_OP_GROUPw(group1A, E,v), =20 [0x98] =3D X86_OP_ENTRY1(CBW, 0,v), /* rAX */ @@ -2514,6 +2515,13 @@ static void disas_insn(DisasContext *s, CPUState *cp= u) s->override =3D -1; break; =20 + case X86_SPECIAL_MovSeg: + if (decode.op[0].unit =3D=3D X86_OP_INT && decode.op[0].has_ea) { + decode.op[0].ot =3D MO_16; + } else if (decode.op[1].unit =3D=3D X86_OP_INT && decode.op[1].has= _ea) { + decode.op[1].ot =3D MO_16; + } + default: break; } diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h index 51ef0e621b..f29f5de7d1 100644 --- a/target/i386/tcg/decode-new.h +++ b/target/i386/tcg/decode-new.h @@ -203,6 +203,8 @@ typedef enum X86InsnSpecial { /* When loaded into s->T0, register operand 1 is zero/sign extended. = */ X86_SPECIAL_SExtT0, X86_SPECIAL_ZExtT0, + /* Memory operand size of Mov to/from Seg is MO_16 */ + X86_SPECIAL_MovSeg, } X86InsnSpecial; =20 /* --=20 2.34.1