From nobody Tue Feb 10 21:41:33 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1668474691; cv=none; d=zohomail.com; s=zohoarc; b=iZUircJ4hSwTJVWXX5PLiO4aGjNYRHPcGUiaL6PduZIL7JjsXHaQhJKdP/0FH2T1olVs/EpYQpAoR7gxDhVMVImvtqVagmLMIMKS5ouBUguLS3AJK0WxR2+cmJwyaUWK6vYR4dNkoa7wl8J4uYnkNZ44mCZippgep/W461d+vR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668474691; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HIjPHkRH18chkLBXKE8P4bOXjlUnO+BcLL5w7iG1TVY=; b=CuAgeRdWUxoueh/RlEyjZn+C+cAh/2tNao9m2dnDUreaZvd0wnKlYsRkhfW6qQY3zB2qY2DV1vsw7UaEZUNkz5ytGCRfWM3J30HIlOSw9qurNcEToEdrKzHS96nu/e1tZSDWsx03ryS3e4cXXPhMbTYxIEEwdrJHlkpFSNmm1lg= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668474691268964.7291159546762; Mon, 14 Nov 2022 17:11:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouj2T-0005Xh-Oj; Mon, 14 Nov 2022 18:38:53 -0500 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 1ouj2R-0005UX-AE for qemu-devel@nongnu.org; Mon, 14 Nov 2022 18:38:52 -0500 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ouj2I-0006p3-PA for qemu-devel@nongnu.org; Mon, 14 Nov 2022 18:38:44 -0500 Received: by mail-pf1-x436.google.com with SMTP id y13so12535592pfp.7 for ; Mon, 14 Nov 2022 15:38:42 -0800 (PST) Received: from stoup.. (119-18-35-77.771223.bne.static.aussiebb.net. [119.18.35.77]) by smtp.gmail.com with ESMTPSA id cp16-20020a170902e79000b00176dc67df44sm8120268plb.132.2022.11.14.15.38.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 15:38:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HIjPHkRH18chkLBXKE8P4bOXjlUnO+BcLL5w7iG1TVY=; b=iegvts+xVMEC1hcdFzPmaJRW9bQpiZkOjY/BEWmhnitmkYayykjw7bFH9O7OAgrHmT 720w+MWOSBi/iaMwHAs11jEqOENW0gi2No3WUPP/aGo5/wBuI8cbarkDjDqxD9YM2+qg U2nobYU0Whc1tRHTuWYBrgtlhjNBTqHOVf1GLRAiO1JRr1gelSSh0GQzWSvuZYxpSaF1 inX3GD/7mLmoyFq1afqZekznL4xLwqkkiM9hVXmQOFAUzw/4y4DY9w2Dp1b6YsfVx8aB RICOM8hRJEr1d3JeCZMQnldGmC/9aVapDSLOVABNJsNLWe/Ax4Ma6XQRjj9/NxvZGzk+ HpzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HIjPHkRH18chkLBXKE8P4bOXjlUnO+BcLL5w7iG1TVY=; b=e9C9ZiTrdEdLDGVUG9/sK43LnE5YkEjekirLhFY/fx6bcAA07QiSM8zu7EPuOPAsPf Y0CR+3jKgPjZNTOVeaIVRByx+t1lUMOCFmGLal0DO0XtVD7UM/wpADBQpyDJb3C/7pfM u6c20W/FtjutnOKNG8ZcwfhrBfGRAnmYoRJl9XE2JaJOBPWPYJt/TgsfCXx4ghZIB4oZ ax3VQc2dJuaS67HZZDbs113rdPAHXCzHf1i1wABC7mAisQxQBJaaprMg0L7DwuH3/rYo 1qIYiYU43JtrIZT6+OePWv53MjKMmsD4lEpHXLRZyIB7NNekIBtT1ZtKvabtExslBIjY j3PA== X-Gm-Message-State: ANoB5pkfMNqw8xWfqtKaJBqNr9eGdwwTk7eAOTokY4yg3b2D+WKUCq7n T1gyk2o7GYZs+mqWINbVYvAQy5fPkW7olAI4 X-Google-Smtp-Source: AA0mqf4HWCdsdCm4t6Y57hs6gvZqtT2tPeLNqs3sg6Je3Pn/w3G75QgGYc9pm970QwrUbDde0dL/rA== X-Received: by 2002:a63:c009:0:b0:46e:bcc1:28df with SMTP id h9-20020a63c009000000b0046ebcc128dfmr13406824pgg.187.1668469121254; Mon, 14 Nov 2022 15:38:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Paolo Bonzini Subject: [PULL 2/2] target/i386: hardcode R_EAX as destination register for LAHF/SAHF Date: Tue, 15 Nov 2022 09:38:29 +1000 Message-Id: <20221114233829.3329805-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221114233829.3329805-1-richard.henderson@linaro.org> References: <20221114233829.3329805-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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: 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 @linaro.org) X-ZM-MESSAGEID: 1668474693288100003 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini When translating code that is using LAHF and SAHF in combination with the REX prefix, the instructions should not use any other register than AH; however, QEMU selects SPL (SP being register 4, just like AH) if the REX prefix is present. To fix this, use deposit directly without going through gen_op_mov_v_reg and gen_op_mov_reg_v. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/130 Signed-off-by: Paolo Bonzini Signed-off-by: Richard Henderson --- target/i386/tcg/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index dbd6492778..7e0b2a709a 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -5230,7 +5230,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) case 0x9e: /* sahf */ if (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM)) goto illegal_op; - gen_op_mov_v_reg(s, MO_8, s->T0, R_AH); + tcg_gen_shri_tl(s->T0, cpu_regs[R_EAX], 8); gen_compute_eflags(s); tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, CC_O); tcg_gen_andi_tl(s->T0, s->T0, CC_S | CC_Z | CC_A | CC_P | CC_C); @@ -5242,7 +5242,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_compute_eflags(s); /* Note: gen_compute_eflags() only gives the condition codes */ tcg_gen_ori_tl(s->T0, cpu_cc_src, 0x02); - gen_op_mov_reg_v(s, MO_8, R_AH, s->T0); + tcg_gen_deposit_tl(cpu_regs[R_EAX], cpu_regs[R_EAX], s->T0, 8, 8); break; case 0xf5: /* cmc */ gen_compute_eflags(s); --=20 2.34.1