From nobody Tue Nov 26 22:35:57 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1704012407; cv=none; d=zohomail.com; s=zohoarc; b=KnpWJa36D4zp9KKwYX41koA+Er0hXtto8Bo61fFgsc5Qw2xn0PfNn6/dUNMfyavR7bJ9pSwdY6H15pZSv03F1qwxNFReCZpZ2RHcGrXctZXOB4Ph9hooq2B9Eb+EVzu0wzlXN/j4SGlS7W1yY6pPU2XIhmndWDkjtvASwb8b3v4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704012407; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=p+eGaivxgxxuwgRxyPAihwfI4xNVtda+8GH8RU0PMw0=; b=Df9K/hkfDtiMiu/x0qGThNo2RpQ8UkurmmsQWzFzxDXIJ7YoOaaVf93WWjMUbQLzxjUuLYAcZVU9z99oyGagURY4Z7Bjwy+icL91qYQ47sv9c6JBz3mRD8lANP+3Qjcv6MY8a1NTHmSYsNOutYxt/UUU8sX8Z6VVYR/H2Tq3PU8= 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 170401240704555.87163937452203; Sun, 31 Dec 2023 00:46:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rJrSI-0004Mg-Tn; Sun, 31 Dec 2023 03:45:58 -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 1rJrSG-0004Fw-UV for qemu-devel@nongnu.org; Sun, 31 Dec 2023 03:45:56 -0500 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 1rJrSF-0000ki-3F for qemu-devel@nongnu.org; Sun, 31 Dec 2023 03:45:56 -0500 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-Cj-K5j8_OLi11MgeIPn8iA-1; Sun, 31 Dec 2023 03:45:47 -0500 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-55641f6437fso15924a12.2 for ; Sun, 31 Dec 2023 00:45:47 -0800 (PST) Received: from [192.168.10.118] ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id z2-20020a05640240c200b005527c02c1d6sm13143688edb.50.2023.12.31.00.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 00:45:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704012354; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p+eGaivxgxxuwgRxyPAihwfI4xNVtda+8GH8RU0PMw0=; b=ABxWjtuvLB/zGuwt120raDsDV9Kq5Kx51nz6puE7GVJijBTnrO9yjdKvGC2cJme3yOY7TV 9kpWhoeXFTx/q7UQJItW47hC3hBgDbeR7PR3BIfI7zonXweUiwL/9rETvtcA5OmeOItSXs B5NRsQyD/KhmvIs1rL46TvBRK0V1tkI= X-MC-Unique: Cj-K5j8_OLi11MgeIPn8iA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704012346; x=1704617146; 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=p+eGaivxgxxuwgRxyPAihwfI4xNVtda+8GH8RU0PMw0=; b=dvdxej/cBoY1TKV6D1XjKh7rndQ6VuOv7rCJVTq1/F4hD6xlfsU9AKz1F9ijmhkXu8 aNv89qHwFMTeXpPKjQxGypjhg/93Sfo/hykrXnTeR5qJQTB41mMw2gSL+Kk+GA4OHVlc NhyWtly/VHj2qQMRHb37iL4YcfwBB1CM0+WpOjm8ZUyqhWS3kl2uEeu9Gxut2rffx78W PaFv179qIAKUx8OFkYpUvanGmDdqKGwWoXHR7mTjTkM0tSS7SmxHLZBArn6knTzeFAL9 v4nnEr77GOQRi0u6B043jUxVOwiYod7RASzu1nT7jU5g++7/doNfyvT1Skd/hMtoTQ0E hDHQ== X-Gm-Message-State: AOJu0Yy41qOG5FVmBAtNtos9y5lFtdXMyICC5pRL42h9U+i022iEdBcK K1OvtVIDxnWfnRAv5xkHD9QpmXTvw0eup5TcxBQbH+7P1507RZT1KmGIi3NrQFbOfFQndiqP3kM Gc6mfRBUf/fPL7YIW21vivjWbIKL6pNeFjO6HvnzjOhQZQ0OG+WukH1Sb7KbNpLJrXd1gi1pPsx RJV86WzRQ= X-Received: by 2002:a50:ab5d:0:b0:554:1af:fe11 with SMTP id t29-20020a50ab5d000000b0055401affe11mr8927826edc.12.1704012345893; Sun, 31 Dec 2023 00:45:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAxzV7A6FRgymOn6hxm1CR8F1iCFVnmEgS98/JWpAbHUxtKZL5ECvHceqVWCkwEbXvt0HZjw== X-Received: by 2002:a50:ab5d:0:b0:554:1af:fe11 with SMTP id t29-20020a50ab5d000000b0055401affe11mr8927818edc.12.1704012345531; Sun, 31 Dec 2023 00:45:45 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 15/46] target/i386: split eflags computation out of gen_compute_eflags Date: Sun, 31 Dec 2023 09:44:31 +0100 Message-ID: <20231231084502.235366-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231231084502.235366-1-pbonzini@redhat.com> References: <20231231084502.235366-1-pbonzini@redhat.com> 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -47 X-Spam_score: -4.8 X-Spam_bar: ---- X-Spam_report: (-4.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.667, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1704012409216100001 Content-Type: text/plain; charset="utf-8" The new x86 decoder wants the gen_* functions to compute EFLAGS before writeback, which can be an issue for instructions with a memory destination such as ARPL or shifts. Extract code to compute the EFLAGS without clobbering CC_SRC, in case the memory write causes a fault. The flags writeback mechanism will take care of copying the result to CC_SRC. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 00ed0cc9a31..b79c312465b 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -862,22 +862,22 @@ static void gen_op_update_neg_cc(DisasContext *s) tcg_gen_movi_tl(s->cc_srcT, 0); } =20 -/* compute all eflags to cc_src */ -static void gen_compute_eflags(DisasContext *s) +/* compute all eflags to reg */ +static void gen_mov_eflags(DisasContext *s, TCGv reg) { - TCGv zero, dst, src1, src2; + TCGv dst, src1, src2; + TCGv_i32 cc_op; int live, dead; =20 if (s->cc_op =3D=3D CC_OP_EFLAGS) { + tcg_gen_mov_tl(reg, cpu_cc_src); return; } if (s->cc_op =3D=3D CC_OP_CLR) { - tcg_gen_movi_tl(cpu_cc_src, CC_Z | CC_P); - set_cc_op(s, CC_OP_EFLAGS); + tcg_gen_movi_tl(reg, CC_Z | CC_P); return; } =20 - zero =3D NULL; dst =3D cpu_cc_dst; src1 =3D cpu_cc_src; src2 =3D cpu_cc_src2; @@ -886,7 +886,7 @@ static void gen_compute_eflags(DisasContext *s) live =3D cc_op_live[s->cc_op] & ~USES_CC_SRCT; dead =3D live ^ (USES_CC_DST | USES_CC_SRC | USES_CC_SRC2); if (dead) { - zero =3D tcg_constant_tl(0); + TCGv zero =3D tcg_constant_tl(0); if (dead & USES_CC_DST) { dst =3D zero; } @@ -898,8 +898,18 @@ static void gen_compute_eflags(DisasContext *s) } } =20 - gen_update_cc_op(s); - gen_helper_cc_compute_all(cpu_cc_src, dst, src1, src2, cpu_cc_op); + if (s->cc_op !=3D CC_OP_DYNAMIC) { + cc_op =3D tcg_constant_i32(s->cc_op); + } else { + cc_op =3D cpu_cc_op; + } + gen_helper_cc_compute_all(reg, dst, src1, src2, cc_op); +} + +/* compute all eflags to cc_src */ +static void gen_compute_eflags(DisasContext *s) +{ + gen_mov_eflags(s, cpu_cc_src); set_cc_op(s, CC_OP_EFLAGS); } =20 --=20 2.43.0