From nobody Mon Nov 25 10:17:14 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=1716637111; cv=none; d=zohomail.com; s=zohoarc; b=aaQwuo0W3oP0tv7XQwHVpa+C4DgISSZOJBszHEibk7VSfmRYRNKZIsCveXz4EuUKNOTPaDUQp7wgO2mmKLMewoJ+02dkN2yByo9CfXxIVfw78AbQ0StUQbZPwLVo4qp9ENEYbZHZbEcHwjndSSzsC/oksxjPVEz346SL/39ZaMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716637111; 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=6AzBA78pbflNThNfuRdbt+YMVvZA2AmBw1wMegaaFwc=; b=YzJtO5WgOgF/KMy7xImfxrBUCePR1/B0v+/1K95t8sXhXEvt2Rrc6YyAp1dz/1P/J/xyqL/RVdR3D3HB8ylsDyj1BOSFOlTLkk3OHQsk8Nak3OLeJPAPBLrZC3jGU5JC1P2xZ1AsvDNfkRZF9mTBI2tCO2YZMv8UFGtjGLpAhCY= 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 1716637111012595.9969616582787; Sat, 25 May 2024 04:38:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sApf2-0002MI-7p; Sat, 25 May 2024 07:34:04 -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 1sApf0-0002Lb-A1 for qemu-devel@nongnu.org; Sat, 25 May 2024 07:34:02 -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 1sApey-00042y-8b for qemu-devel@nongnu.org; Sat, 25 May 2024 07:34:02 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-602-6SAIdBPFPkKycWEMrolMZg-1; Sat, 25 May 2024 07:33:58 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a6267bcfb5fso32435066b.2 for ; Sat, 25 May 2024 04:33:58 -0700 (PDT) Received: from [192.168.10.116] ([151.95.155.52]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-579c004108esm348864a12.23.2024.05.25.04.33.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 May 2024 04:33:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716636839; 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=6AzBA78pbflNThNfuRdbt+YMVvZA2AmBw1wMegaaFwc=; b=Cct9YdkX2GUSxbQp/Nr8/L3o8EhlejrGj6eCLlYf+ndNxJii9JMK1OglrUKq2mb1uM1Hvg HVyVGC7RZq6+6xyzUhRsHuIJoR287nNrJ1qcJY78Ob0SDruPeiVEn/Fq8a2c6s0ZKsyw53 4/ZNd68EggB+EZSCCYwqAabjfhlZDKU= X-MC-Unique: 6SAIdBPFPkKycWEMrolMZg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716636836; x=1717241636; 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=6AzBA78pbflNThNfuRdbt+YMVvZA2AmBw1wMegaaFwc=; b=B8Ayz9+0b5IcYPeLXjacF7MqROcKe7ZFCBEONIrRzS1Jp/J1hq1tp7PzEYl5A+xJgF Pq+BfdDT6Pu7G9CVL0xph2s8RgBzr0KZQPebQs9oBlil7HtazY2M0VtwoyjG1cSoj5Tw 4025Qyy2mrg7YGRZ4HlGH3h+XC337aIR77licMIKR+OUlQ60GwsHGKt7ikmPn6THXsNF vDzkpTr9jnlh0jkWdr4oIkDKQO7JqeGSLJctISvMF+n4lfAWIhCPH/rT8ulI1woekrZK IJ234aANFP4zNiiqm+qbXSWmeypYgmQ/gcv2be4CaUukZP/+DpOBq7OJJrBtG/4YL2/7 RDmw== X-Gm-Message-State: AOJu0YwEXpNqLJEwNKs5J3bQTP+KNFL8ikx14HXAQ0hU68Lyrv46VCMX zTEeX89/r9RdLOU83CC2I9A2Q6gt9vTHFD9HGKZZ0JiVDcOaTLktM8S+6kfVQIzoZ2dsgqOko+6 Ou3ZoSZIBaBb3r4wteL4on7rtlliggrFWGGIXftWb3yLTVwZEkEwWLZNuI5k5qbMGEoY39BSbOz HDxFXwl2vKQ5v2lLgw44fdWQLU7u9HXOKcB2Oc X-Received: by 2002:a50:cd5d:0:b0:578:881e:7b77 with SMTP id 4fb4d7f45d1cf-578884c43e8mr1093196a12.34.1716636836081; Sat, 25 May 2024 04:33:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEckXUv7UbucwIzjAjV+uRTkRUTm3bavUmfopiYM+TacbJFz5QQ7IBC007pcLbANOM8tN7tjA== X-Received: by 2002:a50:cd5d:0:b0:578:881e:7b77 with SMTP id 4fb4d7f45d1cf-578884c43e8mr1093175a12.34.1716636835566; Sat, 25 May 2024 04:33:55 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 06/24] target/i386: cpu_load_eflags already sets cc_op Date: Sat, 25 May 2024 13:33:14 +0200 Message-ID: <20240525113332.1404158-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240525113332.1404158-1-pbonzini@redhat.com> References: <20240525113332.1404158-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1716637112404100001 Content-Type: text/plain; charset="utf-8" No need to set it again at the end of the translation block, cc_op_dirty can be set to false. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 37 ++++++++++++++++++++++++------------- target/i386/tcg/emit.c.inc | 2 +- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 920d854c2b5..25c973e20c6 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -309,7 +309,7 @@ static const uint8_t cc_op_live[CC_OP_NB] =3D { [CC_OP_POPCNT] =3D USES_CC_SRC, }; =20 -static void set_cc_op(DisasContext *s, CCOp op) +static void set_cc_op_1(DisasContext *s, CCOp op, bool dirty) { int dead; =20 @@ -332,20 +332,27 @@ static void set_cc_op(DisasContext *s, CCOp op) tcg_gen_discard_tl(s->cc_srcT); } =20 - if (op =3D=3D CC_OP_DYNAMIC) { - /* The DYNAMIC setting is translator only, and should never be - stored. Thus we always consider it clean. */ - s->cc_op_dirty =3D false; - } else { - /* Discard any computed CC_OP value (see shifts). */ - if (s->cc_op =3D=3D CC_OP_DYNAMIC) { - tcg_gen_discard_i32(cpu_cc_op); - } - s->cc_op_dirty =3D true; + if (dirty && s->cc_op =3D=3D CC_OP_DYNAMIC) { + tcg_gen_discard_i32(cpu_cc_op); } + s->cc_op_dirty =3D dirty; s->cc_op =3D op; } =20 +static void set_cc_op(DisasContext *s, CCOp op) +{ + /* + * The DYNAMIC setting is translator only, everything else + * will be spilled later. + */ + set_cc_op_1(s, op, op !=3D CC_OP_DYNAMIC); +} + +static void assume_cc_op(DisasContext *s, CCOp op) +{ + set_cc_op_1(s, op, false); +} + static void gen_update_cc_op(DisasContext *s) { if (s->cc_op_dirty) { @@ -3554,6 +3561,10 @@ static void disas_insn_old(DisasContext *s, CPUState= *cpu, int b) gen_update_cc_op(s); gen_update_eip_cur(s); gen_helper_syscall(tcg_env, cur_insn_len_i32(s)); + /* condition codes are modified only in long mode */ + if (LMA(s)) { + assume_cc_op(s, CC_OP_EFLAGS); + } /* TF handling for the syscall insn is different. The TF bit is c= hecked after the syscall insn completes. This allows #DB to not be generated after one has entered CPL0 if TF is set in FMASK. */ @@ -3570,7 +3581,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) gen_helper_sysret(tcg_env, tcg_constant_i32(dflag - 1)); /* condition codes are modified only in long mode */ if (LMA(s)) { - set_cc_op(s, CC_OP_EFLAGS); + assume_cc_op(s, CC_OP_EFLAGS); } /* TF handling for the sysret insn is different. The TF bit is checked after the sysret insn completes. This allows #DB to= be @@ -4489,7 +4500,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) g_assert_not_reached(); #else gen_helper_rsm(tcg_env); - set_cc_op(s, CC_OP_EFLAGS); + assume_cc_op(s, CC_OP_EFLAGS); #endif /* CONFIG_USER_ONLY */ s->base.is_jmp =3D DISAS_EOB_ONLY; break; diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index c78e35b1e28..3f2ae0aa7e7 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1883,7 +1883,7 @@ static void gen_IRET(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) gen_helper_iret_protected(tcg_env, tcg_constant_i32(s->dflag - 1), eip_next_i32(s)); } - set_cc_op(s, CC_OP_EFLAGS); + assume_cc_op(s, CC_OP_EFLAGS); s->base.is_jmp =3D DISAS_EOB_ONLY; } =20 --=20 2.45.1