From nobody Mon Nov 23 04:28:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793435901; cv=none; d=zohomail.com; s=zohoarc; b=TNzEeMIvTYqQvPwfNTETtHyj0YJDDJ3NGiOgY4OhHrZHBNTwNq6g71J1E0JFcZ4LxDHxFoxidUs6n+p2HqeRpq9meikFQf85/mbEwa155QEO+rSidzI8KGFZPshfdDADQuzmueJ5qr2LYiYSW5/Qy62esDV6lHhiod51ERZaPSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793435901; h=Content-Transfer-Encoding:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=508H+wevQzYWcrN+tKieru00O500hG5L+P4mNRTA9aA=; b=gigBK1uLWvsMVKY6li6c7h8tjpAqNZxV4xAwQaBQARgpWXz6364AqD/QYFqxmAfvyye36ywKQR6pqEQckyi1hUQZtFP8S4saKFD3wqxF52IqND66J5l6mWgz+w4x5++KPA6+inMu1rE7wOO1rlp6xBjPjEt+A9Wy5mcsOUK46g8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793435901426965.1492905845894; Sat, 31 Oct 2026 01:38:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xN4bF-0007qa-SW; Sat, 31 Oct 2026 04:38:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xN4bD-0007q6-6K for qemu-devel@nongnu.org; Sat, 31 Oct 2026 04:38:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xN4bB-0002be-MY for qemu-devel@nongnu.org; Sat, 31 Oct 2026 04:38:02 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-354-s5RfPr99NhCdxa902SJzig-1; Sat, 31 Oct 2026 04:37:58 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E62FA1955DC0 for ; Sat, 31 Oct 2026 08:37:57 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 43ECF1800765 for ; Sat, 31 Oct 2026 08:37:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793435881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=508H+wevQzYWcrN+tKieru00O500hG5L+P4mNRTA9aA=; b=JSKQLytPC7omKmGq6Ri43Mh656vCvolPyP9P5+vcNpKn01rOpudLdHgnz4pm0NpDLOg9Yv 02R3i0X0GL+n5ErjY4IUMESoPlvisQhG2PgRmg8MGWzIGT+sRwuv+cElpGe0n7vkzC/hBG qimVYtDwq1ZAY9tR91cRqiUEtGieKf0= X-MC-Unique: s5RfPr99NhCdxa902SJzig-1 X-Mimecast-MFC-AGG-ID: s5RfPr99NhCdxa902SJzig_1793435878 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH] target/i386/tcg: change popl_esp_hack to an X86InsnSpecial Date: Sat, 31 Oct 2026 09:37:55 +0100 Message-ID: <20261031083755.1311968-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793435903809158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 6 ++++++ target/i386/tcg/translate.c | 1 - target/i386/tcg/decode-new.c.inc | 8 +++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h index 5f76b0c1b7a..a823143bbdf 100644 --- a/target/i386/tcg/decode-new.h +++ b/target/i386/tcg/decode-new.h @@ -242,6 +242,12 @@ typedef enum X86InsnSpecial { =20 /* Memory operand size of MOV from segment register is MO_16 */ X86_SPECIAL_Op0_Mw, + + /* + * If the address uses ESP as the base register, use the value + * of ESP after the pop. + */ + X86_SPECIAL_PopESP, } X86InsnSpecial; =20 /* diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index dd417cb5341..bfc370cc995 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -108,7 +108,6 @@ typedef struct DisasContext { uint8_t vex_v; /* vex vvvv register, without 1's complement. */ bool vex_ndd; /* is this a 3-operand instruction? */ bool vex_w; /* used by AVX even on 32-bit processors */ - uint8_t popl_esp_hack; /* for correct popl with esp base handling */ uint8_t rip_offset; /* only used in x86_64, but left for simplicity */ =20 uint8_t rex_r; /* 0 for i386, but left for simplicity */ diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 3845fab5c85..2756953c744 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -1615,8 +1615,7 @@ static void decode_group1A(DisasContext *s, CPUX86Sta= te *env, X86OpEntry *entry, *entry =3D UNKNOWN_OPCODE; } else { entry->gen =3D gen_POP; - /* The address must use the value of ESP after the pop. */ - s->popl_esp_hack =3D 1 << mo_pushpop(s, s->dflag); + entry->special =3D X86_SPECIAL_PopESP; } } =20 @@ -2360,8 +2359,8 @@ static void decode_modrm(DisasContext *s, CPUX86State= *env, } =20 /* For correct popl handling with esp. */ - if (base =3D=3D R_ESP && s->popl_esp_hack) { - disp +=3D s->popl_esp_hack; + if (base =3D=3D R_ESP && decode->e.special =3D=3D X86_SPECIAL_PopE= SP) { + disp +=3D 1 << mo_pushpop(s, s->dflag); } if (base =3D=3D R_EBP || base =3D=3D R_ESP) { def_seg =3D R_SS; @@ -3287,7 +3286,6 @@ static void disas_insn(DisasContext *s, CPUState *cpu) =20 s->pc =3D s->base.pc_next; s->override =3D -1; - s->popl_esp_hack =3D 0; #ifdef TARGET_X86_64 s->rex_r =3D 0; s->rex_x =3D 0; --=20 2.56.0