From nobody Sat Sep 26 19:14:48 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=ilande.co.uk Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790407764086245.62930197451533; Sat, 26 Sep 2026 00:29:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xAMps-0000gW-MJ; Sat, 26 Sep 2026 03:28:40 -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 1xAMpr-0000gH-1M for qemu-devel@nongnu.org; Sat, 26 Sep 2026 03:28:39 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xAMpp-0002iM-8e for qemu-devel@nongnu.org; Sat, 26 Sep 2026 03:28:38 -0400 Received: from [2a02:8012:2f01:0:fe49:60b9:9856:b8ef] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1xAMpE-00FrBj-3w; Sat, 26 Sep 2026 08:28:00 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: Message-ID:Date:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=VJ0XLLBhNPX5F+C5c0Ntyg9f05vw99PVwdMPVYXd2B8=; b=DVzKw7deNO9JNkCT4I716K+6zj 8KFo4h/qOS50qzyMCyGftouqCb+5ZtYmHmWyyt/EHkSZfdpKg08mKMxlAgbiSRBSbTxx+Bfq8Zgn1 9AwfZSmcOGFU+/ucDNwlkGfKsBiqNZEx2NKV4Bxdy8Dyn/BuTZvQpvHpBWIBqfm748vI954XJJbWK q24Xju+1Ik80mqPjmKA8G/XBU55VvOfXJEmw8hffS3wXNivgHrP8Du0g+MhY74N7+uagd5WDM+IAp yqYdGW+We4k5OdC2GIgaaAxCYNqWP+C1sv8tWUXX77LlxJ0LRbGRHy8CNXNSguRSkEgvEEUwRT/VE ADMhufzXyEK6AzpNfzfN6ieLIIf6b9fTBCTkQQaYhrq0RtOxSL6mSpgD0XApzF3B4vFERPyppqJPt Ccz+ydmBdz0+25ZeaCyPk1p4s8hvb0KyXu+1054Xb1WQWZoSVKRPlC6/E+634gknmLC4OXCdqVDO8 z9unPW1A1xFkkxgB2VjyiDzvMZTfJOOTir1jVVWyij9zFwvE7YXFLQ8WwNRs/dDpbos2WkRlzGQwZ TF1cWvpVZjuFtqhtEVtZ4sBG2Vx2axfL0q4nySHqXX0pDX6rrg3BT4KYNk6/w5oE+wAdrK7/gqSUT RHG75vKICOAKVtW2WX2notoEkMMaKumOPAZpPlm7s=; From: Mark Cave-Ayland To: pbonzini@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Date: Sat, 26 Sep 2026 08:27:47 +0100 Message-ID: <20260926072815.467722-1-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a02:8012:2f01:0:fe49:60b9:9856:b8ef X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH] target/i386/tcg: fix lea address for instructions with an override prefix X-SA-Exim-Version: 4.2.1 (built Sat, 13 Feb 2021 17:57:42 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 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: fail (Header signature does not verify) X-ZM-MESSAGEID: 1790407767566158500 Content-Type: text/plain; charset="utf-8" Always add the segment base when an override prefix is specified in segment= ed mode. Otherwise the generated address is calculated incorrectly when an ove= rride prefix is specified and HF_ADDSEG_MASK is not set. Fixes: 55a15eb3504 ("target/i386/tcg: simplify effective address calculatio= n") Signed-off-by: Mark Cave-Ayland --- target/i386/tcg/translate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) Paolo/Richard: I'm not sure if this patch is exactly correct, however it fi= xes a regression when launching the OpenWatcom installer under MS-DOS. Current git master aborts the installer with a GPF error in the guest caused by this instruction: 0x0041e0b5: 66 2e 8e 1d 0c 00 00 00 movw %cs:0xc, %ds where def_seg =3D=3D 3, ovr_seg =3D=3D 1 and ADDSEG(s) is 0. Without this f= ix the target address is calculated as 0xc instead of 0x41e00c. =20 =20 diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 192cf43215e..323beec656b 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -600,12 +600,15 @@ static void gen_lea_v_seg_dest(DisasContext *s, MemOp= aflag, TCGv dest, TCGv a0, { int easize; bool has_base; + bool addseg =3D ADDSEG(s); =20 if (ovr_seg < 0) { ovr_seg =3D def_seg; + } else if (!CODE64(s)) { + addseg =3D true; } =20 - has_base =3D ovr_seg >=3D R_FS || (ovr_seg >=3D 0 && ADDSEG(s)); + has_base =3D ovr_seg >=3D R_FS || (ovr_seg >=3D 0 && addseg); easize =3D CODE64(s) ? MO_64 : MO_32; =20 if (has_base) { --=20 2.47.3